Chip: nRF51422
Board: PCA10028
Firmware: S130_nRF51_2.0.1
void timer_accel_update_handler(void * p_context){
bool p_state;
bsp_button_is_pressed(BUTTON_3, &p_state);
printf("%d",p_state);
if (p_state == true){
start_accel_update_flag = true;
}
}
static void on_ble_evt(ble_evt_t * p_ble_evt){
uint32_t err_code;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
APP_ERROR_CHECK(err_code);
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
err_code = app_timer_start(m_timer_accel_update_id, TIMER_INTERVAL_ACCEL_UPDATE, NULL);
APP_ERROR_CHECK(err_code);
break;
case BLE_GAP_EVT_DISCONNECTED:
m_conn_handle = BLE_CONN_HANDLE_INVALID;
app_timer_stop(m_timer_accel_update_id);
break;
default:
// No implementation needed.
break;
}}
After connecting to the BlueTooth, no matter how hard I pressed the button 3, the p_state is aways false and it printed 0 on the UART console.
BUTTON_3 is defined as 19 by pca10028.h.
4/14 update:
static void timers_init(void){
// Initialize timer module.
APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
uint32_t err_code;
err_code = app_timer_create(&m_timer_accel_update_id, APP_TIMER_MODE_REPEATED, timer_accel_update_handler);
APP_ERROR_CHECK(err_code);
}