关于多interrup的配置t pin

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
4 posts / 0 new
Last post
Aron
Offline
Last seen:3 years 1 month ago
加入:2017-08-28 07:01
关于多interrup的配置t pin

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

Device:
MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi 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

Aron
Offline
Last seen:3 years 1 month ago
加入:2017-08-28 07:01
Hi Diaglog,

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

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi 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:

  • The default state of one of the pins to be low, in that case the device "sees" that one of the other pins are in state that trigger's the interrupt so any attempt to trigger the interrupt fails on an additional pin fails.
  • You are using ports 3 and 4 so i suppose that you have a AQFN package and not a WLCSP.

Thanks MT_dialog