1 | /**
|
2 | * \brief Display the user interface on the terminal.
|
3 | */
|
4 | static void refresh_display(void)
|
5 | {
|
6 | // Zeigt nach jedem CPU-Reset 01.01.2007 00:00:00 an.
|
7 |
|
8 | uint32_t ul_hour, ul_minute, ul_second;
|
9 | uint32_t ul_year, ul_month, ul_day, ul_week;
|
10 |
|
11 | if (gs_ul_state != STATE_MENU) {
|
12 | /* Not in menu display mode, in set mode. */
|
13 | } else {
|
14 | /* Retrieve date and time */
|
15 | rtc_get_time(RTC, &ul_hour, &ul_minute, &ul_second);
|
16 | rtc_get_date(RTC, &ul_year, &ul_month, &ul_day, &ul_week);
|
17 |
|
18 | /* Display */
|
19 | if (!gs_ul_menu_shown) {
|
20 | puts("\n\rMenu:\n\r"
|
21 | " t - Set time\n\r"
|
22 | " d - Set date\n\r"
|
23 | " i - Set time alarm\n\r"
|
24 | " m - Set date alarm\r");
|
25 | #if ((SAM3S8) || (SAM3SD8) || (SAM4S) || (SAM4C) || (SAM4CP) || (SAM4CM))
|
26 | puts(" w - Generate Waveform\r");
|
27 | #endif
|
28 | if (gs_ul_alarm_triggered) {
|
29 | puts(" c - Clear alarm notification\r");
|
30 | }
|
31 |
|
32 | printf("\n\r");
|
33 |
|
34 | gs_ul_menu_shown = 1;
|
35 | }
|
36 |
|
37 | /* Update current date and time */
|
38 | puts("\r");
|
39 | printf(" [Time/Date: %02u:%02u:%02u, %02u/%02u/%04u %s ][Alarm status:%s]",
|
40 | (unsigned int)ul_hour,
|
41 | (unsigned int)ul_minute,
|
42 | (unsigned int)ul_second,
|
43 | (unsigned int)ul_month,
|
44 | (unsigned int)ul_day,
|
45 | (unsigned int)ul_year,
|
46 | gs_uc_day_names[ul_week-1],
|
47 | gs_ul_alarm_triggered ? "Triggered!" : "");
|
48 | }
|
49 | }
|
50 |
|
51 |
|
52 | /**
|
53 | * \brief Application entry point for RTC example.
|
54 | *
|
55 | * \return Unused (ANSI-C compatibility).
|
56 | */
|
57 | int main(void)
|
58 | {
|
59 | uint8_t uc_key;
|
60 |
|
61 | /* Initialize the SAM system */
|
62 | sysclk_init();
|
63 | board_init();
|
64 |
|
65 | /* Initialize the console uart */
|
66 | configure_console();
|
67 |
|
68 | /* Output example information */
|
69 | puts(STRING_HEADER); // "RTC example..."
|
70 |
|
71 | refresh_display();
|
72 | while (1); //DEBUG
|
73 | }
|