19 #include "gpio_level_handler.h" 23 #include "isr_manager.h" 26 #define GPIO_BUFFER_SIZE 4 35 NRF_GPIOTE->EVENTS_PORT = 0;
37 NRF_GPIOTE->INTENCLR = GPIOTE_INTENCLR_PORT_Enabled << GPIOTE_INTENCLR_PORT_Pos;
39 NVIC_ClearPendingIRQ(GPIOTE_IRQn);
40 NVIC_DisableIRQ(GPIOTE_IRQn);
48 for(i = 0; i<cfg_num; i++)
50 cfg_buffer[i] = *(cfg + i);
52 hal_gpio_cfg((cfg + i)->pin_num,
53 GPIO_PIN_CNF_DIR_Input,
54 GPIO_PIN_CNF_INPUT_Connect,
56 GPIO_PIN_CNF_DRIVE_S0S1,
57 ((cfg + i)->trigger_on_high)
58 ?GPIO_PIN_CNF_SENSE_High:GPIO_PIN_CNF_SENSE_Low );
62 NRF_GPIO->DETECTMODE = GPIO_DETECTMODE_DETECTMODE_LDETECT << GPIO_DETECTMODE_DETECTMODE_Pos;
63 NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_PORT_Enabled << GPIOTE_INTENSET_PORT_Pos;
65 NVIC_ClearPendingIRQ(GPIOTE_IRQn);
66 NVIC_SetPriority(GPIOTE_IRQn, irq_priority);
67 NVIC_EnableIRQ(GPIOTE_IRQn);
71 void gpio_level_handler_gpiote_Handler ()
76 NRF_GPIOTE->EVENTS_PORT = 0;
77 (void) NRF_GPIOTE->EVENTS_PORT;
80 for(i = 0; i<gpio_len; i++)
82 uint32_t pin_num = cfg_buffer[i].
pin_num;
83 if(NRF_GPIO->LATCH & (1 << pin_num))
85 uint32_t pin_val = hal_gpio_pin_read(pin_num);
88 NRF_GPIO->LATCH = (1 << pin_num);
89 cfg_buffer[i].handler((pin_val == level_checked));
The configuration parameter for each of the GPIO pin that is being configured in the GPIO level handl...
bool trigger_on_high
the nrf bitfields header file
uint32_t pin_num
this pin is at the specified level
void gpio_level_init(gpio_level_cfg *cfg, uint32_t cfg_num, uint32_t irq_priority)
Initializes the GPIO level handler module by taking in the the configurations of all the GPIOs that n...