hello there i want to generate external interrupt from adxl345.can you help me? can we do same like we are using with button??
hello there i want to generate external interrupt from adxl345.can you help me? can we do same like we are using with button??
...
static void button_event_handler(uint8_t pin_no, uint8_t button_action)
{
uint32_t err_code;
switch (pin_no)
{
case LEDBUTTON_BUTTON_PIN:
err_code = ble_lbs_on_button_change(&m_lbs, button_action);
if (err_code != NRF_SUCCESS &&
err_code != BLE_ERROR_INVALID_CONN_HANDLE &&
err_code != NRF_ERROR_INVALID_STATE)
{
APP_ERROR_CHECK(err_code);
}
break;
default:
APP_ERROR_HANDLER(pin_no);
break;
}
}
/**@brief Function for initializing the button handler module.
*/
static void buttons_init(void)
{
uint32_t err_code;
//The array must be static because a pointer to it will be saved in the button handler module.
static app_button_cfg_t buttons[] =
{
{LEDBUTTON_BUTTON_PIN, false, BUTTON_PULL, button_event_handler}
};
err_code = app_button_init(buttons, sizeof(buttons) / sizeof(buttons[0]),
BUTTON_DETECTION_DELAY);
APP_ERROR_CHECK(err_code);
}
i think this code is useful for me.but i can't understand it. can anyone explain me how button_event_handler is used in buttons init function??
here they don't use two arguments like uint8_t pin_no, uint8_t button_action. can anyone explain me??
i can't solve my this doubt. can anyone help me??
Hi rushin
Would this button press solution be useful to you, or do you want to use app_button directly?
By the way, what nRF51 SDK version are you using?
All that a button does is to change the voltage level on a GPIO pin to generate an interrupt. If an external circuit also changes the voltage level in the same way as a button does, you can use the same button code to detect an interrupt from an external circuit, as e.g. the adxl345.
Update 8.1.2016 To use app_button, you need to initialize app_timer and app_gpiote, because app_button uses those libraries internally. A good app_button code example is available on Github. The example is for nRF51 SDK 8.0.0 but it should also work for nRF51 SDK 10.0.0
i am using nrf51 SDK10