PicoWAN SDK Documentation
Macros | Enumerations | Functions
led.h File Reference

LED driver. More...

#include <stdint.h>

Go to the source code of this file.

Macros

#define MAX_LEDS   4
 
#define MAX_SLOTS   16
 
#define SLOT_0   (1 << 0)
 
#define SLOT_1   (1 << 1)
 
#define SLOT_2   (1 << 2)
 
#define SLOT_3   (1 << 3)
 
#define SLOT_4   (1 << 4)
 
#define SLOT_5   (1 << 5)
 
#define SLOT_6   (1 << 6)
 
#define SLOT_7   (1 << 7)
 
#define SLOT_8   (1 << 8)
 
#define SLOT_9   (1 << 9)
 
#define SLOT_10   (1 << 10)
 
#define SLOT_11   (1 << 11)
 
#define SLOT_12   (1 << 12)
 
#define SLOT_13   (1 << 13)
 
#define SLOT_14   (1 << 14)
 
#define SLOT_15   (1 << 15)
 
#define ON_OFF_SLOTS_PERIOD_2_DUTY_50   (SLOT_0 | SLOT_2 | SLOT_4 | SLOT_6 | SLOT_8 | SLOT_10 | SLOT_12 | SLOT_14)
 
#define ON_OFF_SLOTS_PERIOD_4_DUTY_50   (SLOT_0 | SLOT_1 | SLOT_4 | SLOT_5 | SLOT_8 | SLOT_9 | SLOT_12 | SLOT_13)
 
#define ON_OFF_SLOTS_PERIOD_8_DUTY_50   (SLOT_0 | SLOT_1 | SLOT_2 | SLOT_3 | SLOT_8 | SLOT_9 | SLOT_10 | SLOT_11)
 
#define ON_OFF_SLOTS_PERIOD_16_DUTY_50   (SLOT_0 | SLOT_1 | SLOT_2 | SLOT_3 | SLOT_4 | SLOT_5 | SLOT_6 | SLOT_7)
 

Enumerations

enum  led_state { LED_OFF = 0, LED_ON = 1, LED_BLINK = 2 }
 
enum  led_mode { LED_ACTIVE_LOW = 0, LED_ACTIVE_HIGH = 1 }
 

Functions

void led_init (void)
 Initializes the LED driver.
 
void led_set (uint8_t num, enum led_state state)
 Enables or disable an LED. More...
 
void led_blink (uint8_t num, uint16_t led_on_mask, uint8_t repeat)
 Makes an LED blink. More...
 
enum led_state led_get (uint8_t num)
 Gets the current state of an LED. More...
 
void led_toggle (uint8_t num)
 Toggles an LED. More...
 

Detailed Description

LED driver.

Copyright (c) 2018, Archos S.A. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND AND EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARCHOS S.A. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

void led_blink ( uint8_t  num,
uint16_t  led_on_mask,
uint8_t  repeat 
)

Makes an LED blink.

This function makes an LED blink. A timer will wake up 16 times in 1.2s, giving 16 slots where the LED can be on or off. Slots are numbered from 0 to 15 and last for 75 ms each.

Parameters
numThe number of the LED.
led_on_maskA mask of all 16 slots. Set only the slots where the LED will be on.
repeatNumber of repeats. 0 forever.
enum led_state led_get ( uint8_t  num)

Gets the current state of an LED.

Parameters
numThe number of the LED.
Return values
led_stateThe current state of the LED.
void led_set ( uint8_t  num,
enum led_state  state 
)

Enables or disable an LED.

Parameters
numThe number of the LED.
stateThe new state of the LED. This can be LED_OFF, LED_ON, or LED_BLINK.
void led_toggle ( uint8_t  num)

Toggles an LED.

This function toggles an LED. A blinking LED will be toggled OFF.

Parameters
numThe number of the LED.