⚠️
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.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
3 posts / 0 new
Last post
dx3gerst
Offline
Last seen:3 years 9 months ago
Joined:2017-03-29 13:35
Button GPIO interrupt

Hi Dialog,

I'm using the peripherals_demo to communicate with an UART-device. Now I would like to use button K1 (P1_6) on the Development-Board (Basic) as GPIO-Interrupt which switches the orange LED on the board (P1_5). I think the hw_wkup_interrupt will be the proper one. Does this Interrupt work in all modes (active, sleep, Extended sleep)?
I can't find any documentation about how to implement an ISR, so can you please help me with it?
If I get it right, the Pin configuration and the Interrupt initialisation should be inserted into the periph_setup() function.

void periph_setup(void)
{
...
//Pin config
hw_gpio_set_pin_function(HW_GPIO_PORT_1, HW_GPIO_PIN_6, HW_GPIO_MODE_INPUT_PULLUP, HW_GPIO_FUNC_GPIO); //button K1
hw_gpio_set_pin_function(HW_GPIO_PORT_1, HW_GPIO_PIN_5, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_GPIO); // LED D2

//Interrupt init
hw_wkup_init(NULL);
hw_wkup_register_interrupt(wkup_ISR, 1);
hw_wkup_configure_pin(HW_GPIO_PORT_1, HW_GPIO_PIN_6, true, HW_WKUP_PIN_STATE_LOW);
...
}

Where should the ISR be implemented? In the first step I just want to activate and deactivate the LED so I can ensure that the Interrupt is working.

static void wkup_ISR(void)
{
hw_wkup_reset_interrupt();
hw_gpio_set_active(HW_GPIO_PORT_1, HW_GPIO_PIN_5); //Switch on LED to screen the functionality
...
hw_gpio_set_inactive (HW_GPIO_PORT_1 HW_GPIO_PIN_5); //Switch off LED
}

Thank you!

Device:
MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi dx3gerst,

Hi dx3gerst,

What do you mean "where the ISR should be implemented", in which file ? You can have the code implementation at the main.c file if you would like to. Also dont place the wakeup interrupt setup in the periph_init() (this function is getting invoked in every wake up in order to setup your pins after exiting sleep), you can have a look at the hrp_sensor example in the SDK, the example places in the periph_init() only the configuration for the pins and the setup of the wakeup interrupt is implemented in the prvSetupHardware() function, just after the pm_system_init() which invokes the periph_init().

Thanks MT_dialog

dx3gerst
Offline
Last seen:3 years 9 months ago
Joined:2017-03-29 13:35
Thank you!

Thank you!