Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
1,703 Views

How to configure two leds and an interrupt in gpio pins?

Hello friends!

I started recently with the Intel Quark D2000 Dev Board, I'm doing tests with interrupt in GPIOS, I have configured two leds and a button. The idea is to detect the interruption and to switch the LEDs, but I can not make it work. Would they help me?

This is my code ...

# include "qm_interrupt.h"

# include "qm_isr.h"

# include "qm_gpio.h"

# include "qm_pinmux.h"

# define LED_0_OUT 9

# define LED_1_OUT 10

# define BTN_0_IN 12

static void btn_isr();

volatile int t_status = 0;

int main(void) {

static qm_gpio_port_config_t cfg;

qm_pmux_select(LED_0_OUT, QM_PMUX_FN_0);

qm_pmux_select(LED_1_OUT, QM_PMUX_FN_0);

qm_pmux_select(BTN_0_IN, QM_PMUX_FN_0);

qm_pmux_input_en(BTN_0_IN, true);

cfg.direction = BIT(LED_0_OUT) | BIT(LED_1_OUT);

cfg.int_en = BIT(BTN_0_IN);

cfg.int_type = BIT(BTN_0_IN);

cfg.int_polarity = BIT(BTN_0_IN);

cfg.int_debounce = BIT(BTN_0_IN);

cfg.int_bothedge = 0x0;

cfg.callback = btn_isr;

qm_irq_request(QM_IRQ_GPIO_0, qm_gpio_isr_0);

qm_gpio_set_config(QM_GPIO_0, &cfg);

while (1) {

}

return 0;

}

void btn_isr () {

t_status = !t_status;

if (t_status == 1) {

qm_gpio_clear_pin(QM_GPIO_0, LED_1_OUT);

qm_gpio_set_pin(QM_GPIO_0, LED_0_OUT);

} else if (t_status == 0) {

qm_gpio_clear_pin(QM_GPIO_0, LED_0_OUT);

qm_gpio_set_pin(QM_GPIO_0, LED_1_OUT);

}

}

Regards!

0 Kudos
5 Replies
Highlighted
Moderator
35 Views

Hello,

Thank you for reaching out to Intel® Quark™ Microcontrollers Community.

We will look into this issue and get back to you shortly.

Regards

Intel Customer Support

0 Kudos
Highlighted
Moderator
35 Views

Hi Alan,

Have you try with single LED? Do you able to make it work with your code?

Or you still have issue with single LED?

Regards,

Intel Customer Support

0 Kudos
Highlighted
Beginner
35 Views

Hi Friends, thanks for your answers!

I just tested with a single LED, but I still do not have successful results...

Is my source code correct?

Regards!

0 Kudos
Highlighted
Moderator
35 Views

Hi Alan,

You can refer to this documentation for Button and LED.

https://software.intel.com/en-us/articles/d2000-button-and-led https://software.intel.com/en-us/articles/d2000-button-and-led

Regards

Intel Customer Support

Highlighted
Beginner
35 Views

Thank you very much, my friend mohamedshaharris_intel!!!

This post was a lot of help for me!

0 Kudos