- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
This example is based on the 'GPIO' example provided in ISSM - Create a project using the gpio template from 'Create New QMSI/BSP Project'. Then just paste the above into the main.c .
# include "qm_gpio.h"
# include "qm_interrupt.h"
/* QMSI GPIO app example
*
* PIN_OUT will be configured as an output pin and PIN_INTR will be
* configured as an input pin with interrupts
* enabled.
*
* On the Intel(R) Quark(TM) Microcontroller D2000 Development Platform PIN_OUT
* and PIN_INTR are marked "SSO 10" and "A0".
*/
/* Connect LED to PIN_OUT */
# define PIN_OUT 0
/*Connect Button to PIN_INTR */
# define PIN_INTR 3
/* Example callback function */
static void gpio_example_callback(uint32_t);
int main(void)
{
qm_gpio_port_config_t cfg;
/* Request IRQ and write GPIO port config */
cfg.direction = BIT(PIN_OUT);
cfg.int_en = BIT(PIN_INTR); /* Interrupt enabled */
cfg.int_type = BIT(PIN_INTR); /* Edge sensitive interrupt */
cfg.int_polarity = BIT(PIN_INTR); /* Rising edge */
cfg.int_debounce = BIT(PIN_INTR); /* Debounce enabled */
cfg.int_bothedge = 0x0; /* Both edge disabled */
cfg.callback = gpio_example_callback;
qm_irq_request(QM_IRQ_GPIO_0, qm_gpio_isr_0);
qm_gpio_set_config(QM_GPIO_0, &cfg);
/* Set PIN_OUT to trigger PIN_INTR interrupt*/
qm_gpio_clear_pin(QM_GPIO_0, PIN_OUT);
qm_gpio_set_pin(QM_GPIO_0, PIN_OUT);
while(1)
{
/* Your code goes here */
}
return 0;
}
void gpio_example_callback(uint32_t status)
{
/* toggle LED state - ON/OFF */
if(false == qm_gpio_read_pin(QM_GPIO_0, PIN_OUT))
{
qm_gpio_set_pin(QM_GPIO_0, PIN_OUT);
}
else{
qm_gpio_clear_pin(QM_GPIO_0, PIN_OUT);
}
}
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi Michellec,
I want to use two GPIO interrupt in the same code. Can you please share the information for the same.
Regards,
Dilip Shankar

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page