nRF5 SDK for Mesh v3.2.0
Macros | Typedefs | Functions
Simple Hardware Abstraction Layer

Simple hardware abstraction layer for the example applications. More...

Macros

#define HAL_BUTTON_PRESS_FREQUENCY   HAL_MS_TO_RTC_TICKS(400)
 Acceptable button press frequency in RTC ticks. 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 BUTTON_BOARD   (defined(BOARD_PCA10040) || defined(BOARD_PCA10028) || defined(BOARD_PCA10056))
 Boards with user buttons.
 

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.

Macro Definition Documentation

◆ HAL_BUTTON_PRESS_FREQUENCY

#define HAL_BUTTON_PRESS_FREQUENCY   HAL_MS_TO_RTC_TICKS(400)

Acceptable button press frequency in RTC ticks.

Definition at line 53 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 56 of file simple_hal.h.

◆ LED_MASK_STATE_OFF

#define LED_MASK_STATE_OFF   (false)

Set LED Mask state to Off.

Definition at line 59 of file simple_hal.h.

◆ LED_MASK_STATE_ON

#define LED_MASK_STATE_ON   (true)

Set LED Mask state to On.

Definition at line 61 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_numberButton number (0-3).

Definition at line 71 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.

Parameters
[in]cbButton event callback.
Return values
NRF_SUCCESSSuccessfully initialized buttons.
NRF_ERROR_NULLCallback was NULL.
NRF_ERROR_NOT_SUPPORTEDButtons 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]pinLED pin number.
[in]valuetrue for on, false for 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_maskMask of LED pins to set/clear.
[in]valuetrue for on, false for 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]pinPin to get state of.
Returns
true if the LED is on, false otherwise.

◆ 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_ms is less than HAL_LED_BLINK_PERIOD_MIN_MS or blink_count is zero, the call will be ignored.
If the APP_TIMER queue is full, this call may fail silently.
Parameters
[in]pin_maskMask of LED pins.
[in]delay_msDelay in milliseconds between each state change.
[in]blink_countNumber 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.

Documentation feedback | Developer Zone | Subscribe | Updated