MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rtc_test

Function rtc_test

examples/test/rtc_test.c:14–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12#include <rtdevice.h>
13
14int rtc_test(void)
15{
16 uint8_t i;
17 time_t now;
18
19 rt_err_t ret = RT_EOK;
20
21 rt_kprintf("[RTC Test]RTC Test Start...\n");
22 rt_thread_delay(RT_TICK_PER_SECOND);
23 rt_kprintf("[RTC Test]Set RTC 2017-04-01 12:30:46\n");
24 rt_thread_delay(RT_TICK_PER_SECOND);
25
26 ret = set_date(2017, 4, 1);
27 if(ret != RT_EOK)
28 {
29 rt_kprintf("[RTC Test]Set RTC Date failed\n");
30 return -RT_ERROR;
31 }
32
33 rt_thread_delay(RT_TICK_PER_SECOND);
34
35 ret = set_time(12, 30, 46);
36 if(ret != RT_EOK)
37 {
38 rt_kprintf("[RTC Test]Set RTC Time failed\n");
39 return -RT_ERROR;
40 }
41
42 rt_thread_delay(RT_TICK_PER_SECOND);
43
44 for(i = 0; i < 10; i++)
45 {
46 rt_kprintf("[RTC Test]Read RTC Date and Time: ");
47 now = time(RT_NULL);
48 rt_kprintf("%s\n", ctime(&now));
49
50 rt_thread_delay(RT_TICK_PER_SECOND);
51 }
52
53 rt_kprintf("\n");
54
55 return RT_EOK;
56}
57#ifdef RT_USING_FINSH
58#include <finsh.h>
59FINSH_FUNCTION_EXPORT(rtc_test, rtc driver test. e.g: rtc_test());

Callers 1

rtc_test.cFile · 0.85

Calls 6

rt_kprintfFunction · 0.85
rt_thread_delayFunction · 0.85
set_dateFunction · 0.85
set_timeFunction · 0.85
timeFunction · 0.85
ctimeFunction · 0.85

Tested by

no test coverage detected