If the softdevice is not used, As follows:
static void gpio_init(void) {
nrf_gpio_cfg_input(Record, NRF_GPIO_PIN_PULLUP);
nrf_gpio_cfg_input(Play, NRF_GPIO_PIN_PULLUP);
nrf_gpio_cfg_input(Menu_Dw, NRF_GPIO_PIN_PULLUP);
NVIC_DisableIRQ(GPIOTE_IRQn);
NVIC_ClearPendingIRQ(GPIOTE_IRQn);
NRF_GPIOTE->CONFIG[0] = (GPIOTE_CONFIG_POLARITY_HiToLo << GPIOTE_CONFIG_POLARITY_Pos)
| (0x1E << GPIOTE_CONFIG_PSEL_Pos)
| (GPIOTE_CONFIG_MODE_Event << GPIOTE_CONFIG_MODE_Pos);
NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_IN0_Set << GPIOTE_INTENSET_IN0_Pos;
NRF_GPIOTE->CONFIG[1] = (GPIOTE_CONFIG_POLARITY_HiToLo << GPIOTE_CONFIG_POLARITY_Pos)
| (0x1C << GPIOTE_CONFIG_PSEL_Pos)
| (GPIOTE_CONFIG_MODE_Event << GPIOTE_CONFIG_MODE_Pos);
NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_IN1_Set << GPIOTE_INTENSET_IN1_Pos;
__NOP();
__NOP();
__NOP();
/* Clear the event that appears in some cases */
NRF_GPIOTE->EVENTS_IN[0] = 0;
NRF_GPIOTE->EVENTS_IN[1] = 0;
NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_IN0_Enabled << GPIOTE_INTENSET_IN0_Pos;
NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_IN1_Enabled << GPIOTE_INTENSET_IN1_Pos;
NVIC_EnableIRQ(GPIOTE_IRQn);
}
void GPIOTE_IRQHandler(void) {
if ((NRF_GPIOTE->EVENTS_IN[0] != 0))
{
menu_count++;
NRF_GPIOTE->EVENTS_IN[0] = 0;
}
if ((NRF_GPIOTE->EVENTS_IN[1] != 0))
{
Record_Start = (!Record_Start) ;
NRF_GPIOTE->EVENTS_IN[1] = 0;
}
}
In this case operates.
But not getting the behavior when I try to put a pin input for use with S110.
I would like to run when the button receives the input of the ad or when the Bluetooth connection to each other.
If I read a few comments, Recommend the use of app_gpiote library and app_button library together.
And the ble_app_bps example of the examples were recommended.
The following sources are part of the sample.
static void button_event_handler(uint8_t pin_no, uint8_t button_action) {
if (button_action == APP_BUTTON_PUSH)
{
switch (pin_no)
{
case SEND_MEAS_BUTTON_PIN_NO:
blood_pressure_measurement_send();
break;
default:
APP_ERROR_HANDLER(pin_no);
break;
}
}
}
static void gpiote_init(void) {
APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS);
}
static void buttons_init(void) {
static app_button_cfg_t buttons[] =
{
{SEND_MEAS_BUTTON_PIN_NO, false, BUTTON_PULL, button_event_handler},
{BOND_DELETE_ALL_BUTTON_ID, false, BUTTON_PULL, NULL}
};
APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, false);
}
If the SEND_MEAS_BUTTON_PIN_NO button is pressed, the operation will be button_event_handler.
However, if you press the BOND_DELETE_ALL_BUTTON_ID button, I don't know what to work.
And I don't know how the interrupt occurs.
I don't understand function: APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS);
Not find an association between button and interrupt.
I will wait for the reply.
Help please~