123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- #ifndef LED_SOFTBLINK_H__
- #define LED_SOFTBLINK_H__
- #include <stdbool.h>
- #include <stdint.h>
- #include "sdk_errors.h"
- #include "nrf_gpio.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- typedef struct
- {
- bool active_high;
- uint8_t duty_cycle_max;
- uint8_t duty_cycle_min;
- uint8_t duty_cycle_step;
- uint32_t off_time_ticks;
- uint32_t on_time_ticks;
- uint32_t leds_pin_bm;
- NRF_GPIO_Type * p_leds_port;
- }led_sb_init_params_t;
- #define LED_SB_INIT_PARAMS_ACTIVE_HIGH false
- #define LED_SB_INIT_PARAMS_DUTY_CYCLE_MAX 220
- #define LED_SB_INIT_PARAMS_DUTY_CYCLE_MIN 0
- #define LED_SB_INIT_PARAMS_DUTY_CYCLE_STEP 5
- #define LED_SB_INIT_PARAMS_OFF_TIME_TICKS 65536
- #define LED_SB_INIT_PARAMS_ON_TIME_TICKS 0
- #define LED_SB_INIT_PARAMS_LEDS_PIN_BM(mask) (mask)
- #define LED_SB_INIT_PARAMS_LEDS_PORT NRF_GPIO
- #define LED_SB_INIT_DEFAULT_PARAMS(mask) \
- { \
- .active_high = LED_SB_INIT_PARAMS_ACTIVE_HIGH, \
- .duty_cycle_max = LED_SB_INIT_PARAMS_DUTY_CYCLE_MAX, \
- .duty_cycle_min = LED_SB_INIT_PARAMS_DUTY_CYCLE_MIN, \
- .duty_cycle_step = LED_SB_INIT_PARAMS_DUTY_CYCLE_STEP, \
- .off_time_ticks = LED_SB_INIT_PARAMS_OFF_TIME_TICKS, \
- .on_time_ticks = LED_SB_INIT_PARAMS_ON_TIME_TICKS, \
- .leds_pin_bm = LED_SB_INIT_PARAMS_LEDS_PIN_BM(mask), \
- .p_leds_port = LED_SB_INIT_PARAMS_LEDS_PORT \
- }
- ret_code_t led_softblink_init(led_sb_init_params_t const * p_init_params);
- ret_code_t led_softblink_start(uint32_t leds_pin_bit_mask);
- ret_code_t led_softblink_stop(void);
- void led_softblink_off_time_set(uint32_t off_time_ticks);
- void led_softblink_on_time_set(uint32_t on_time_ticks);
- ret_code_t led_softblink_uninit(void);
- #ifdef __cplusplus
- }
- #endif
- #endif
|