Intel® Makers
Intel® Edison, Intel® Joule™, Intel® Curie™, Intel® Galileo
Announcements
Welcome - This is a Peer-to-Peer Forum only. Intel has discontinued these products but you may find support from other customers on this Forum
9868 Discussions

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

ABigl1
Beginner
1,861 Views

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
CK_Intel
Moderator
193 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

Shah_Intel
Moderator
193 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

ABigl1
Beginner
193 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!

Shah_Intel
Moderator
193 Views
ABigl1
Beginner
193 Views

Thank you very much, my friend mohamedshaharris_intel!!!

This post was a lot of help for me!

Reply