Simple hardware abstraction layer for the example applications. More...
Macros | |
| #define | HAL_BUTTON_PRESS_DEBOUNCE_INTERVAL MS_TO_US(400) |
| Acceptable button press interval in microseconds. More... | |
| #define | HAL_LED_BLINK_PERIOD_MIN_MS (20) |
| Lowest possible blinking period in milliseconds. More... | |
| #define | LED_MASK_STATE_OFF (false) |
| Set LED Mask state to Off. More... | |
| #define | LED_MASK_STATE_ON (true) |
| Set LED Mask state to On. More... | |
| #define | HAL_LED_MASK ((1 << LEDS_NUMBER) - 1) |
| LEDs mask full. | |
| #define | HAL_LED_MASK_HALF ((1 << (LEDS_NUMBER/2)) - 1) |
| LEDs mask half. | |
| #define | HAL_LED_MASK_LOWER_HALF (HAL_LED_MASK_HALF) |
| #define | HAL_LED_MASK_UPPER_HALF (HAL_LED_MASK ^ HAL_LED_MASK_HALF) |
| #define | BUTTON_BOARD |
| Boards with user buttons. More... | |
Typedefs | |
| typedef void(* | hal_button_handler_cb_t) (uint32_t button_number) |
| Button event handler callback type. More... | |
Functions | |
| void | hal_leds_init (void) |
| Initializes the LEDs. More... | |
| uint32_t | hal_buttons_init (hal_button_handler_cb_t cb) |
| Initializes the buttons on a DK. More... | |
| void | hal_led_pin_set (uint32_t pin, bool value) |
| Sets the LED for the given PIN. More... | |
| void | hal_led_mask_set (uint32_t led_mask, bool value) |
| Sets the LEDs for the given mask. More... | |
| bool | hal_led_pin_get (uint32_t pin) |
| Gets the current state of a (LED) pin. More... | |
| void | hal_led_blink_ms (uint32_t pin_mask, uint32_t delay_ms, uint32_t blink_count) |
| Blinks (one toggle cycle) pin_mask a specified number of times. More... | |
| void | hal_led_blink_stop (void) |
| Stops blinking the LEDs (previously started by hal_led_blink_ms). More... | |
Detailed Description
Simple hardware abstraction layer for the example applications.
This module uses GPIOTE driver module. Therefore, GPIOTE_ENABLED must be set to 1 in the app_config.h file.
Macro Definition Documentation
◆ HAL_BUTTON_PRESS_DEBOUNCE_INTERVAL
| #define HAL_BUTTON_PRESS_DEBOUNCE_INTERVAL MS_TO_US(400) |
Acceptable button press interval in microseconds.
Definition at line 57 of file simple_hal.h.
◆ HAL_LED_BLINK_PERIOD_MIN_MS
| #define HAL_LED_BLINK_PERIOD_MIN_MS (20) |
Lowest possible blinking period in milliseconds.
Definition at line 60 of file simple_hal.h.
◆ LED_MASK_STATE_OFF
| #define LED_MASK_STATE_OFF (false) |
Set LED Mask state to Off.
Definition at line 63 of file simple_hal.h.
◆ LED_MASK_STATE_ON
| #define LED_MASK_STATE_ON (true) |
Set LED Mask state to On.
Definition at line 65 of file simple_hal.h.
◆ BUTTON_BOARD
| #define BUTTON_BOARD |
(defined(BOARD_PCA10040) || defined(BOARD_PCA10028) || defined(BOARD_PCA10056) \ || defined(BOARD_PCA10100) || defined(BOARD_PCA10059))
Boards with user buttons.
Definition at line 81 of file simple_hal.h.
Typedef Documentation
◆ hal_button_handler_cb_t
| typedef void(* hal_button_handler_cb_t) (uint32_t button_number) |
Button event handler callback type.
- Parameters
-
[in] button_number Button number (0-3).
Definition at line 88 of file simple_hal.h.
Function Documentation
◆ hal_leds_init()
| void hal_leds_init | ( | void | ) |
Initializes the LEDs.
◆ hal_buttons_init()
| uint32_t hal_buttons_init | ( | hal_button_handler_cb_t | cb | ) |
Initializes the buttons on a DK.
To use this API, GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS must be set to a value greater than or equal to BUTTONS_NUMBER in app_config.h file to support buttons on the DK board.
- Parameters
-
[in] cb Button event callback.
- Return values
-
NRF_SUCCESS Successfully initialized buttons. NRF_ERROR_NULL Callback was NULL. NRF_ERROR_NOT_SUPPORTED Buttons not supported for this board.
◆ hal_led_pin_set()
| void hal_led_pin_set | ( | uint32_t | pin, |
| bool | value | ||
| ) |
Sets the LED for the given PIN.
- Parameters
-
[in] pin LED pin number. [in] value truefor on,falsefor off.
◆ hal_led_mask_set()
| void hal_led_mask_set | ( | uint32_t | led_mask, |
| bool | value | ||
| ) |
Sets the LEDs for the given mask.
- Parameters
-
[in] led_mask Mask of LED pins to set/clear. [in] value truefor on,falsefor off.
◆ hal_led_pin_get()
| bool hal_led_pin_get | ( | uint32_t | pin | ) |
Gets the current state of a (LED) pin.
- Note
- The LEDs are active low, i.e., on when it's GPIO is set low.
- Parameters
-
[in] pin Pin to get state of.
- Returns
trueif the LED is on,falseotherwise.
◆ hal_led_blink_ms()
| void hal_led_blink_ms | ( | uint32_t | pin_mask, |
| uint32_t | delay_ms, | ||
| uint32_t | blink_count | ||
| ) |
Blinks (one toggle cycle) pin_mask a specified number of times.
- Note
- If the API is called twice, the blink sequence is reset.
-
If
delay_msis less than HAL_LED_BLINK_PERIOD_MIN_MS orblink_countis zero, the call will be ignored. - If the APP_TIMER queue is full, this call may fail silently.
- Parameters
-
[in] pin_mask Mask of LED pins. [in] delay_ms Delay in milliseconds between each state change. [in] blink_count Number of times to blink.
◆ hal_led_blink_stop()
| void hal_led_blink_stop | ( | void | ) |
Stops blinking the LEDs (previously started by hal_led_blink_ms).
- Note
- Sets the LED mask from the hal_led_blink_ms call to off.