ret_code_t bsp_nfc_btn_deinit(uint32_t sleep_button) { uint32_t err_code = bsp_event_to_button_action_assign(sleep_button, BTN_ACTION_SLEEP, BSP_EVENT_DEFAULT); return err_code; }
/**@brief Function for configuring the buttons for connection. * * @retval NRF_SUCCESS Configured successfully. * @return A propagated error code. */ static uint32_t connection_buttons_configure() { uint32_t err_code; err_code = bsp_event_to_button_action_assign(BTN_ID_SLEEP, BTN_ACTION_SLEEP, BSP_EVENT_DEFAULT); RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code); err_code = bsp_event_to_button_action_assign(BTN_ID_WHITELIST_OFF, BTN_ACTION_WHITELIST_OFF, BSP_EVENT_WHITELIST_OFF); RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code); err_code = bsp_event_to_button_action_assign(BTN_ID_DISCONNECT, BTN_ACTION_DISCONNECT, BSP_EVENT_DISCONNECT); RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code); return NRF_SUCCESS; }
uint32_t bsp_init(uint32_t type, uint32_t ticks_per_100ms, bsp_event_callback_t callback) { uint32_t err_code = NRF_SUCCESS; #if LEDS_NUMBER > 0 && !(defined BSP_SIMPLE) m_app_ticks_per_100ms = ticks_per_100ms; m_indication_type = type; #else UNUSED_VARIABLE(ticks_per_100ms); #endif // LEDS_NUMBER > 0 && !(defined BSP_SIMPLE) #if (BUTTONS_NUMBER > 0) && !(defined BSP_SIMPLE) m_registered_callback = callback; // BSP will support buttons and generate events if (type & BSP_INIT_BUTTONS) { uint32_t num; for (num = 0; ((num < BUTTONS_NUMBER) && (err_code == NRF_SUCCESS)); num++) { err_code = bsp_event_to_button_action_assign(num, BSP_BUTTON_ACTION_PUSH, BSP_EVENT_DEFAULT); } if (err_code == NRF_SUCCESS) { err_code = app_button_init((app_button_cfg_t *)app_buttons, BUTTONS_NUMBER, ticks_per_100ms / 2); } if (err_code == NRF_SUCCESS) { err_code = app_button_enable(); } if (err_code == NRF_SUCCESS) { err_code = app_timer_create(&m_button_timer_id, APP_TIMER_MODE_SINGLE_SHOT, button_timer_handler); } } #elif (BUTTONS_NUMBER > 0) && (defined BSP_SIMPLE) if (type & BSP_INIT_BUTTONS) { uint32_t cnt; uint32_t buttons[] = BUTTONS_LIST; for (cnt = 0; cnt < BUTTONS_NUMBER; cnt++) { nrf_gpio_cfg_input(buttons[cnt], BUTTON_PULL); } } #endif // (BUTTONS_NUMBER > 0) && !(defined BSP_SIMPLE) #if LEDS_NUMBER > 0 && !(defined BSP_SIMPLE) if (type & BSP_INIT_LED) { LEDS_OFF(LEDS_MASK); NRF_GPIO->DIRSET = LEDS_MASK; } // timers module must be already initialized! if (err_code == NRF_SUCCESS) { err_code = app_timer_create(&m_leds_timer_id, APP_TIMER_MODE_SINGLE_SHOT, leds_timer_handler); } if (err_code == NRF_SUCCESS) { err_code = app_timer_create(&m_alert_timer_id, APP_TIMER_MODE_REPEATED, alert_timer_handler); } #endif // LEDS_NUMBER > 0 && !(defined BSP_SIMPLE) return err_code; }
uint32_t bsp_init(uint32_t type, bsp_event_callback_t callback) { uint32_t err_code = NRF_SUCCESS; #if LEDS_NUMBER > 0 && !(defined BSP_SIMPLE) m_indication_type = type; #endif // LEDS_NUMBER > 0 && !(defined BSP_SIMPLE) #if (BUTTONS_NUMBER > 0) && !(defined BSP_SIMPLE) m_registered_callback = callback; // BSP will support buttons and generate events if (type & BSP_INIT_BUTTONS) { uint32_t num; for (num = 0; ((num < BUTTONS_NUMBER) && (err_code == NRF_SUCCESS)); num++) { err_code = bsp_event_to_button_action_assign(num, BSP_BUTTON_ACTION_PUSH, BSP_EVENT_DEFAULT); } if (err_code == NRF_SUCCESS) { err_code = app_button_init((app_button_cfg_t *)app_buttons, BUTTONS_NUMBER, APP_TIMER_TICKS(50)); } if (err_code == NRF_SUCCESS) { err_code = app_button_enable(); } if (err_code == NRF_SUCCESS) { err_code = app_timer_create(&m_bsp_button_tmr, APP_TIMER_MODE_SINGLE_SHOT, button_timer_handler); } } #elif (BUTTONS_NUMBER > 0) && (defined BSP_SIMPLE) bsp_board_init(type); #endif // (BUTTONS_NUMBER > 0) && !(defined BSP_SIMPLE) #if LEDS_NUMBER > 0 && !(defined BSP_SIMPLE) if (type & BSP_INIT_LEDS) { //handle LEDs only. Buttons are already handled. bsp_board_init(BSP_INIT_LEDS); // timers module must be already initialized! if (err_code == NRF_SUCCESS) { err_code = app_timer_create(&m_bsp_leds_tmr, APP_TIMER_MODE_SINGLE_SHOT, leds_timer_handler); } if (err_code == NRF_SUCCESS) { err_code = app_timer_create(&m_bsp_alert_tmr, APP_TIMER_MODE_REPEATED, alert_timer_handler); } } #endif // LEDS_NUMBER > 0 && !(defined BSP_SIMPLE) return err_code; }
uint32_t bsp_init(uint32_t type, uint32_t ticks_per_100ms, bsp_event_callback_t callback) { uint32_t err_code = NRF_SUCCESS; #if LEDS_NUMBER > 0 && !(defined BSP_SIMPLE) m_app_ticks_per_100ms = ticks_per_100ms; m_indication_type = type; #else UNUSED_VARIABLE(ticks_per_100ms); #endif // LEDS_NUMBER > 0 && !(defined BSP_SIMPLE) #if (BUTTONS_NUMBER > 0) && !(defined BSP_SIMPLE) m_registered_callback = callback; NRF_LOG_INFO("START BUTTON INIT\r\n"); // BSP will support buttons and generate events if (type & BSP_INIT_BUTTONS) { uint32_t num; for (num = 0; ((num < BUTTONS_NUMBER) && (err_code == NRF_SUCCESS)); num++) { NRF_LOG_INFO("ASSIGN %d\r\n", num); err_code = bsp_event_to_button_action_assign(num, BSP_BUTTON_ACTION_PUSH, BSP_EVENT_DEFAULT); } if (err_code == NRF_SUCCESS) { NRF_LOG_INFO("INIT \r\n"); err_code = app_button_init((app_button_cfg_t *)app_buttons, BUTTONS_NUMBER, ticks_per_100ms / 2); } if (err_code == NRF_SUCCESS) { NRF_LOG_INFO("Enable \r\n"); err_code = app_button_enable(); } if (err_code == NRF_SUCCESS) { NRF_LOG_INFO("Create \r\n"); err_code = app_timer_create(&m_button_timer_id, APP_TIMER_MODE_SINGLE_SHOT, button_timer_handler); } } #elif (BUTTONS_NUMBER > 0) && (defined BSP_SIMPLE) if (type & BSP_INIT_BUTTONS) { bsp_board_buttons_init(); } #endif // (BUTTONS_NUMBER > 0) && !(defined BSP_SIMPLE) #if LEDS_NUMBER > 0 && !(defined BSP_SIMPLE) if (type & BSP_INIT_LED) { bsp_board_leds_init(); } // timers module must be already initialized! if (err_code == NRF_SUCCESS) { err_code = app_timer_create(&m_leds_timer_id, APP_TIMER_MODE_SINGLE_SHOT, leds_timer_handler); } if (err_code == NRF_SUCCESS) { err_code = app_timer_create(&m_alert_timer_id, APP_TIMER_MODE_REPEATED, alert_timer_handler); } #endif // LEDS_NUMBER > 0 && !(defined BSP_SIMPLE) return err_code; }