Dear Dialog,
I'm using DA14680 and I need to handle multi interrupt as below.
(1) P3_4 : key interrupt
(2) P3_5 : sw reset interrupt by key
(3) P4_7 : sensor interrupt
I added the code for them in main.c.
static void key_interrupt_cb(void)
{
int port, pin, count = 0;
int interrupt_port=0, interrupt_pin=0;
for (port = 0; port < HW_GPIO_NUM_PORTS; port++) {
uint8_t state, trigger;
state = hw_wkup_get_port_state(port);
trigger = hw_wkup_get_port_trigger(port);
for (pin = 0 ; pin < hw_gpio_port_num_pins[port]; pin++) {
/* n-th pin state in port is simply value of n-th bit in bitmask */
if (!(state & (1 << pin))) {
continue;
}
printf(NEWLINE " P%d.%d trigger on %s state", port, pin,
(trigger & (1 << pin)) ? "high" : "low");
interrupt_port = port;
interrupt_pin = pin;
count++;
}
}
if (count == 0) {
printf(NEWLINE " (none)");
}
if((interrupt_port == 3) && (interrupt_pin == 4))
{
printf(NEWLINE "SOS key interrupt happened.\r\n");
}
if((interrupt_port == 3) && (interrupt_pin == 5))
{
printf(NEWLINE "SW reset key interrupt happened.\r\n");
}
if((interrupt_port == 4) && (interrupt_pin == 7))
{
printf(NEWLINE "Sensor interrupt happened.\r\n");
}
hw_wkup_reset_interrupt();
}
void key_interrupt_init(void)
{
hw_wkup_init(NULL);
hw_wkup_configure_pin(HW_GPIO_PORT_3, HW_GPIO_PIN_4, 1, HW_WKUP_PIN_STATE_LOW);
hw_wkup_configure_pin(HW_GPIO_PORT_3, HW_GPIO_PIN_5, 1, HW_WKUP_PIN_STATE_LOW);
hw_wkup_configure_pin(HW_GPIO_PORT_4, HW_GPIO_PIN_7, 1, HW_WKUP_PIN_STATE_LOW);
hw_wkup_set_counter_threshold(1);
hw_wkup_set_debounce_time(10);
hw_wkup_register_interrupt(key_interrupt_cb, 1);
}
static void prvSetupHardware( void )
{
...
// Interrupt init
key_interrupt_init();
...
}
But, the operation has not worked when I tested with this code.
I think the problem is from wkup pin configuration, but, now I don't have any idea for solving the problem.
Could you please advice to me about the problem?
Thanks,
Aron
Hi Aron,
Sorry, i am not sure i understand the question, you would like to use the wakeup timer using three different pins instead of one ?
In that case the configuration in the key_interrupt_init() is proper, what i dont understand is the sos_key_interrupt_cb, as far as i can understand the function of the callback is the key_interrupt_cb(), but you have registered another callback for the interrupt of the wakeup timer module.
Thanks MT_dialog
Hi Diaglog,
I'm sorry for my typo in previous my comment.
I modified the code in my comment for removing confusion, but I think I have a mistake.
Actually, I used key_interrupt_cb and I could see the operation is no problem when I set just one GPIO interrupt pin.
====================
hw_wkup_configure_pin(HW_GPIO_PORT_3, HW_GPIO_PIN_4, 1, HW_WKUP_PIN_STATE_LOW);
====================
But, It doesn't work when I checked P3_4 after I set three pin in key_interrupt_init function
====================
hw_wkup_configure_pin(HW_GPIO_PORT_3, HW_GPIO_PIN_4, 1, HW_WKUP_PIN_STATE_LOW);
hw_wkup_configure_pin(HW_GPIO_PORT_3, HW_GPIO_PIN_5, 1, HW_WKUP_PIN_STATE_LOW);
hw_wkup_configure_pin(HW_GPIO_PORT_4, HW_GPIO_PIN_7, 1, HW_WKUP_PIN_STATE_LOW);
====================
So, I thought my three pin configuration has some problem and I need your advice about that.
Thanks,
Aron
Hi Aron,
I dont see any issue, i tested waking up from three different pins using the hrp_sensor and configuring the device as you illustrated, if you dont see the device waking up and the callback function to execute, there are two possible options:
Thanks MT_dialog