nRF51 SDK - S120 SoftDevice
|
BSP module. More...
Macros | |
#define | BUTTON_ERASE_BONDING BSP_BUTTON_0_MASK |
#define | BUTTON_ERASE_ALL BSP_BUTTON_1_MASK |
#define | BUTTON_ADVERTISE BSP_BUTTON_0_MASK |
#define | BUTTON_CLEAR_EVT BSP_BUTTON_1_MASK |
#define | BUTTON_CAPSLOCK BSP_BUTTON_2_MASK |
#define | BSP_BUTTONS_ALL 0xFFFFFFFF |
#define | BSP_BUTTONS_NONE 0 |
#define | BSP_INIT_NONE 0 |
Types of BSP initialization. More... | |
#define | BSP_INIT_LED (1 << 0) |
#define | BSP_INIT_BUTTONS (1 << 1) |
#define | BSP_INIT_UART (1 << 2) |
#define | BSP_INDICATIONS_LIST |
Typedefs | |
typedef void(* | bsp_event_callback_t )(bsp_event_t) |
BSP module event callback function type. More... | |
Functions | |
uint32_t | bsp_init (uint32_t type, uint32_t ticks_per_100ms, bsp_event_callback_t callback) |
Function for initializing BSP. More... | |
uint32_t | bsp_buttons_state_get (uint32_t *p_buttons_state) |
Function for getting buttons states. More... | |
uint32_t | bsp_button_is_pressed (uint32_t button, bool *p_state) |
Function for checking buttons states. More... | |
uint32_t | bsp_event_to_button_assign (uint32_t button, bsp_event_t event) |
Function for assigning specific event to button. More... | |
uint32_t | bsp_indication_set (bsp_indication_t indicate) |
Function for configuring indicators to required state. More... | |
uint32_t | bsp_indication_text_set (bsp_indication_t indicate, const char *p_text) |
Function for configuring indicators to required state. More... | |
uint32_t | bsp_buttons_enable (uint32_t buttons) |
Function for enabling specified buttons (others are disabled). More... | |
BSP module.
This module provides a layer of abstraction from the board. It allows the user to indicate certain states on LEDs in a simple way. Module functionality can be modified by additional defines:
#define BSP_INDICATIONS_LIST |
See BSP indication states for a list of how these states are indicated for the PCA10028 board and the PCA10031 dongle.
#define BSP_INIT_BUTTONS (1 << 1) |
This bit enables buttons during initialization (bsp_init).
#define BSP_INIT_LED (1 << 0) |
This bit enables LEDs during initialization (bsp_init).
#define BSP_INIT_NONE 0 |
Types of BSP initialization.
This define specifies the type of initialization without support for LEDs and buttons (bsp_init).
#define BSP_INIT_UART (1 << 2) |
This bit enables UART during initialization (bsp_init).
typedef void(* bsp_event_callback_t)(bsp_event_t) |
BSP module event callback function type.
Upon an event in the BSP module, this callback function will be called to notify the application about the event.
[in] | bsp_event_t | BSP event type. |
enum bsp_event_t |
BSP events.
enum bsp_indication_t |
BSP indication states.
See BSP indication states for a list of how these states are indicated for the PCA10028 board and the PCA10031 dongle.
Enumerator | |
---|---|
BSP_INDICATE_IDLE |
See BSP_INDICATE_IDLE. |
BSP_INDICATE_SCANNING | |
BSP_INDICATE_ADVERTISING | |
BSP_INDICATE_ADVERTISING_WHITELIST | |
BSP_INDICATE_ADVERTISING_SLOW | |
BSP_INDICATE_ADVERTISING_DIRECTED | |
BSP_INDICATE_BONDING |
See BSP_INDICATE_BONDING. |
BSP_INDICATE_CONNECTED | |
BSP_INDICATE_SENT_OK |
See BSP_INDICATE_SENT_OK. |
BSP_INDICATE_SEND_ERROR | |
BSP_INDICATE_RCV_OK |
See BSP_INDICATE_RCV_OK. |
BSP_INDICATE_RCV_ERROR | |
BSP_INDICATE_FATAL_ERROR | |
BSP_INDICATE_ALERT_0 |
See BSP_INDICATE_ALERT_0. |
BSP_INDICATE_ALERT_1 |
See BSP_INDICATE_ALERT_1. |
BSP_INDICATE_ALERT_2 |
See BSP_INDICATE_ALERT_2. |
BSP_INDICATE_ALERT_3 |
See BSP_INDICATE_ALERT_3. |
BSP_INDICATE_ALERT_OFF | |
BSP_INDICATE_USER_STATE_OFF | |
BSP_INDICATE_USER_STATE_0 | |
BSP_INDICATE_USER_STATE_1 | |
BSP_INDICATE_USER_STATE_2 | |
BSP_INDICATE_USER_STATE_3 | |
BSP_INDICATE_USER_STATE_ON |
uint32_t bsp_button_is_pressed | ( | uint32_t | button, |
bool * | p_state | ||
) |
Function for checking buttons states.
This function checks if the button is pressed. If the button ID iss out of range, the function returns false.
[in] | button | Button ID to check. |
[in] | p_state | This variable will store the information whether the specified button is pressed (true) or not. |
NRF_SUCCESS | If the button state was successfully read. |
uint32_t bsp_buttons_enable | ( | uint32_t | buttons | ) |
Function for enabling specified buttons (others are disabled).
This function enables the specified buttons and configures them to be scanned. All other buttons are disabled (inactive).
[in] | buttons | Buttons to be enabled, encoded as bits (bit 0 = button 0, bit 1 = button 1, etc). |
NRF_SUCCESS | If the buttons were successfully enabled. |
uint32_t bsp_buttons_state_get | ( | uint32_t * | p_buttons_state | ) |
Function for getting buttons states.
This function allows to get the state of all buttons.
[in] | p_buttons_state | This variable will store buttons state. Button 0 state is represented by bit 0 (1=pressed), Button 1 state by bit 1, and so on. |
NRF_SUCCESS | If buttons state was successfully read. |
uint32_t bsp_event_to_button_assign | ( | uint32_t | button, |
bsp_event_t | event | ||
) |
Function for assigning specific event to button.
This function allows redefinition of standard events assigned to buttons. To unassign events, provide the event @ ref BSP_EVENT_NOTHING.
[in] | button | Button ID to be redefined. |
[in] | event | Event to be assigned to button. |
NRF_SUCCESS | If the event was successfully assigned to button. |
NRF_ERROR_INVALID_PARAM | If the button ID was invalid. |
uint32_t bsp_indication_set | ( | bsp_indication_t | indicate | ) |
Function for configuring indicators to required state.
This function indicates the required state by means of LEDs (if enabled).
[in] | indicate | State to be indicated. |
NRF_SUCCESS | If the state was successfully indicated. |
NRF_ERROR_NO_MEM | If the internal timer operations queue was full. |
NRF_ERROR_INVALID_STATE | If the application timer module has not been initialized, or internal timer has not been created. |
uint32_t bsp_indication_text_set | ( | bsp_indication_t | indicate, |
const char * | p_text | ||
) |
Function for configuring indicators to required state.
This function indicates the required state by means of LEDs (if enabled) and UART (if enabled).
[in] | indicate | State to be indicated. |
[in] | p_text | Text to be output on UART. |
NRF_SUCCESS | If the state was successfully indicated. |
NRF_ERROR_NO_MEM | If the internal timer operations queue was full. |
NRF_ERROR_INVALID_STATE | If the application timer module has not been initialized, or timer has not been created. |
uint32_t bsp_init | ( | uint32_t | type, |
uint32_t | ticks_per_100ms, | ||
bsp_event_callback_t | callback | ||
) |
Function for initializing BSP.
The function initializes the board support package to allow state indication and button reaction. Default events are assigned to buttons.
[in] | type | Type of peripherals used. |
[in] | ticks_per_100ms | Number of RTC ticks for 100 ms. |
[in] | callback | Function to be called when button press/event is detected. |
NRF_SUCCESS | If the BSP module was successfully initialized. |
NRF_ERROR_INVALID_STATE | If the application timer module has not been initialized. |
NRF_ERROR_NO_MEM | If the maximum number of timers has already been reached. |
NRF_ERROR_INVALID_PARAM | If GPIOTE has too many users. |
NRF_ERROR_INVALID_STATE | If button or GPIOTE has not been initialized. |