zephyr/samples/drivers/rtc/src/main.c
Kumar Gala e547533435 samples: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I08c682bfc0b80dfa88de859e90a011bcd2db2762
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 09:53:53 -05:00

44 lines
718 B
C

/*
* Copyright (c) 2015 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include <device.h>
#include <rtc.h>
#include <misc/printk.h>
#define ALARM (RTC_ALARM_SECOND)
void test_rtc_interrupt_fn(struct device *rtc_dev)
{
u32_t now = rtc_read(rtc_dev);
printk("Alarm\n");
rtc_set_alarm(rtc_dev, now + ALARM);
}
void main(void)
{
struct rtc_config config;
struct device *rtc_dev;
printk("Test RTC driver\n");
rtc_dev = device_get_binding(CONFIG_RTC_0_NAME);
config.init_val = 0;
config.alarm_enable = 1;
config.alarm_val = ALARM;
config.cb_fn = test_rtc_interrupt_fn;
rtc_enable(rtc_dev);
rtc_set_config(rtc_dev, &config);
while (1) {
/* do nothing */
}
}