Hello, I am using external interrupt from an ADXL345 . Can you tell me how to detect that external interrupt with the nRF51 ?
Hello, I am using external interrupt from an ADXL345 . Can you tell me how to detect that external interrupt with the nRF51 ?
The following code will detect a Low-to-High transition on a given Interrupt Pin( needs to be defined by you).
GPIOTE Event Handler:
void gpiote_evt_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
switch(action)
{
case NRF_GPIOTE_POLARITY_LOTOHI:
//do something
break;
default:
//do nothing
break;
}
}
Main Function:
int main(void)
{
ret_code_t ret_code;
ret_code = nrf_drv_gpiote_init();
APP_ERROR_CHECK(ret_code);
nrf_drv_gpiote_in_config_t config =
{
.sense = NRF_GPIOTE_POLARITY_LOTOHI,
.pull = NRF_GPIO_PIN_NOPULL ,
.is_watcher = false,
.hi_accuracy = false
};
ret_code = nrf_drv_gpiote_in_init(INTERRUPT_PIN, &config, gpiote_evt_handler);
APP_ERROR_CHECK(ret_code);
nrf_drv_gpiote_in_event_enable(INTERRUPT_PIN,true);
}
Project files for an example that toogles a led when a button is pressed
It should compile just fine, regardless if it says that there is something in the include chain that is missing.
It should compile just fine, regardless if it says that there is something in the include chain that is missing.