Community
cancel
Showing results for 
Search instead for 
Did you mean: 
PPati4
Novice
944 Views

Intel Quark D2000 wake-up using RTC and Hardware interrupt.

Jump to solution

# include "qm_common.h"

# include "qm_power.h"

# include "qm_rtc.h"

# include "qm_interrupt.h"

# include "qm_soc_regs.h"

# include "qm_gpio.h"

# include "qm_scss.h"

# define LED_BIT 24 /*LED*/

# define PIN_INTR 2 /*Switch on D2000 Dev Board*/

# define DELAY 300000UL

static void rtc_example_callback();

static void gpio_example_callback();

static qm_gpio_port_config_t cfg1;

volatile unsigned char flag = 0;

int main(void)

{

qm_rtc_config_t rtc_cfg;

cfg1.direction = BIT(LED_BIT);

cfg1.int_en = BIT(PIN_INTR); /* Interrupt enabled */

cfg1.int_type = BIT(PIN_INTR); /* Edge sensitive interrupt */

cfg1.int_polarity = BIT(PIN_INTR); /* Rising edge */

cfg1.int_debounce = 0; /* Debounce disabled */

cfg1.int_bothedge = 0x0; /* Both edge disabled */

cfg1.callback = gpio_example_callback;

qm_irq_request(QM_IRQ_GPIO_0, qm_gpio_isr_0);

qm_gpio_set_config(QM_GPIO_0, &cfg1);

clk_periph_enable(CLK_PERIPH_RTC_REGISTER | CLK_PERIPH_CLK);

/* Initialize RTC configuration. */

rtc_cfg.init_val = 0;

rtc_cfg.alarm_en = 1;

rtc_cfg.alarm_val = QM_RTC_ALARM_MINUTE/2;

rtc_cfg.callback = rtc_example_callback;

qm_gpio_set_pin(QM_GPIO_0, LED_BIT);

clk_sys_udelay(DELAY);

clk_sys_udelay(DELAY);

clk_sys_udelay(DELAY);

qm_gpio_clear_pin(QM_GPIO_0, LED_BIT);

clk_sys_udelay(DELAY);

clk_sys_udelay(DELAY);

clk_sys_udelay(DELAY);

/* Set alarm for 30sec from now. */

qm_rtc_set_alarm(QM_RTC_0,QM_RTC_ALARM_MINUTE/2);

qm_gpio_set_pin(QM_GPIO_0, LED_BIT);

qm_irq_request(QM_IRQ_RTC_0, qm_rtc_isr_0);

qm_rtc_set_config(QM_RTC_0, &rtc_cfg);

soc_sleep();

while(1)

{

if(flag == 1)

{

qm_gpio_clear_pin(QM_GPIO_0, LED_BIT);

clk_sys_udelay(DELAY);

clk_sys_udelay(DELAY);

clk_sys_udelay(DELAY);

qm_gpio_set_pin(QM_GPIO_0, LED_BIT);

clk_sys_udelay(DELAY);

clk_sys_udelay(DELAY);

clk_sys_udelay(DELAY);

flag = 0;

}

}

return 0;

}

void rtc_example_callback()

{

}

void gpio_example_callback()

{

flag = 1;

}

0 Kudos
1 Solution
Diego_V_Intel
Employee
71 Views

Hi Pratik_PP,

You have another thread for this same question: . Let's continue there.

Regards,

Diego

View solution in original post

1 Reply
Diego_V_Intel
Employee
72 Views

Hi Pratik_PP,

You have another thread for this same question: . Let's continue there.

Regards,

Diego

View solution in original post

Reply