-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
105 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "task_led.h" | ||
#include "ruuvi_driver_error.h" | ||
#include "ruuvi_interface_gpio.h" | ||
#include <stddef.h> | ||
|
||
ruuvi_driver_status_t task_led_init(void) | ||
{ | ||
ruuvi_driver_status_t err_code = RUUVI_DRIVER_SUCCESS; | ||
err_code |= ruuvi_platform_gpio_init(); | ||
uint8_t leds[] = RUUVI_BOARD_LEDS_LIST; | ||
for(size_t ii = 0; ii < RUUVI_BOARD_LEDS_NUMBER; ii++) | ||
{ | ||
ruuvi_platform_gpio_configure(leds[ii], RUUVI_INTERFACE_GPIO_MODE_OUTPUT_HIGHDRIVE); | ||
ruuvi_platform_gpio_write(leds[ii], !RUUVI_BOARD_LEDS_ACTIVE_STATE); | ||
} | ||
|
||
return err_code; | ||
} | ||
|
||
ruuvi_driver_status_t task_led_write(uint8_t led, task_led_state_t state) | ||
{ | ||
ruuvi_driver_status_t err_code = RUUVI_DRIVER_SUCCESS; | ||
err_code |= ruuvi_platform_gpio_write(led, state); | ||
return err_code; | ||
} | ||
|
||
ruuvi_driver_status_t task_led_cycle(void) | ||
{ | ||
ruuvi_driver_status_t err_code = RUUVI_DRIVER_SUCCESS; | ||
static uint8_t phase = 0; | ||
uint8_t leds[] = RUUVI_BOARD_LEDS_LIST; | ||
err_code |= ruuvi_platform_gpio_toggle(leds[phase++]); | ||
if(RUUVI_BOARD_LEDS_NUMBER <= phase) { phase = 0; } | ||
return err_code; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Ruuvi Firmware 3.x LED tasks. | ||
* | ||
* License: BSD-3 | ||
* Author: Otso Jousimaa <otso@ojousima.net> | ||
**/ | ||
|
||
#ifndef TASK_LED_H | ||
#define TASK_LED_H | ||
|
||
#include "ruuvi_boards.h" | ||
#include "ruuvi_driver_error.h" | ||
|
||
typedef enum{ | ||
TASK_LED_ON = RUUVI_BOARD_LEDS_ACTIVE_STATE, | ||
TASK_LED_OFF = !RUUVI_BOARD_LEDS_ACTIVE_STATE | ||
}task_led_state_t; | ||
|
||
/** | ||
* LED initialization function. Configures GPIOs as high-drive output and sets LEDs as inactive. | ||
* | ||
* return: Status code from the stack. RUUVI_DRIVER_SUCCESS if no errors occured. | ||
**/ | ||
ruuvi_driver_status_t task_led_init(void); | ||
|
||
/** | ||
* LED write function. Set given LED ON or OFF. | ||
* | ||
* parameter led: LED to change, use constant from RUUVI_BOARDS | ||
* parameter state: New state of given led | ||
* | ||
* return: Status code from the stack. RUUVI_DRIVER_SUCCESS if no errors occured. | ||
**/ | ||
ruuvi_driver_status_t task_led_write(uint8_t led, task_led_state_t state); | ||
|
||
/** | ||
* Task demonstrator, cycles LEDs ON and OFF in sequence. | ||
* | ||
* return: Status code from the stack. RUUVI_DRIVER_SUCCESS if no errors occured. | ||
*/ | ||
ruuvi_driver_status_t task_led_cycle(void); | ||
|
||
#endif |