Microchip® Advanced Software Framework

rtc_example.c File Reference

Real-Time Clock (RTC) example for SAM.

Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.

#include "asf.h"
#include "stdio_serial.h"
#include "conf_clock.h"
#include "conf_board.h"

Macros

#define char_to_digit(c)   ((c) - '0')
 
#define MAX_EDIT_SIZE   10
 
#define STATE_MENU   0
 
#define STATE_SET_DATE   2
 
#define STATE_SET_DATE_ALARM   4
 
#define STATE_SET_TIME   1
 
#define STATE_SET_TIME_ALARM   3
 
#define STATE_WAVEFORM   5
 
#define STRING_EOL   "\r"
 
#define STRING_HEADER
 

Functions

static uint32_t calculate_week (uint32_t ul_year, uint32_t ul_month, uint32_t ul_day)
 Calculate week from year, month, day. More...
 
static void configure_console (void)
 Configure UART console. More...
 
static uint32_t get_new_date (void)
 Get new time. More...
 
static uint32_t get_new_time (void)
 Get new time. More...
 
int main (void)
 Application entry point for RTC example. More...
 
static void refresh_display (void)
 Display the user interface on the terminal. More...
 
void RTC_Handler (void)
 Interrupt handler for the RTC. More...
 

Variables

static uint8_t gs_uc_date [10+1]
 
static uint8_t gs_uc_day_names [7][4]
 
static uint8_t gs_uc_rtc_time [8+1]
 
static uint32_t gs_ul_alarm_triggered = 0
 
static uint32_t gs_ul_menu_shown = 0
 
static uint32_t gs_ul_new_day
 
static uint32_t gs_ul_new_hour
 
static uint32_t gs_ul_new_minute
 
static uint32_t gs_ul_new_month
 
static uint32_t gs_ul_new_second
 
static uint32_t gs_ul_new_week
 
static uint32_t gs_ul_new_year
 
static uint32_t gs_ul_state = STATE_MENU
 

#define char_to_digit (   c)    ((c) - '0')

Referenced by get_new_date(), get_new_time(), and main().

#define MAX_EDIT_SIZE   10
#define STATE_MENU   0

Referenced by main(), and refresh_display().

#define STATE_SET_DATE   2

Referenced by main().

#define STATE_SET_DATE_ALARM   4

Referenced by main().

#define STATE_SET_TIME   1

Referenced by main().

#define STATE_SET_TIME_ALARM   3

Referenced by main().

#define STATE_WAVEFORM   5

Referenced by main().

#define STRING_EOL   "\r"
#define STRING_HEADER
Value:
"-- RTC Example --\r\n" \
"-- "BOARD_NAME" --\r\n" \
"-- Compiled: "__DATE__" "__TIME__" --"STRING_EOL
#define STRING_EOL
Definition: rtc_example.c:160
#define BOARD_NAME
Definition: fatfs_access_example.c:112

Referenced by main().

static uint32_t calculate_week ( uint32_t  ul_year,
uint32_t  ul_month,
uint32_t  ul_day 
)
static

Calculate week from year, month, day.

Referenced by get_new_date().

static void configure_console ( void  )
static

Configure UART console.

References uart_rs232_options::baudrate, stdio_serial_init(), and sysclk_enable_peripheral_clock().

Referenced by main().

static uint32_t get_new_date ( void  )
static

Get new time.

Successful value is put in gs_ul_new_year, gs_ul_new_month, gs_ul_new_day, gs_ul_new_week.

References calculate_week(), and char_to_digit.

Referenced by main().

static uint32_t get_new_time ( void  )
static

Get new time.

Successful value is put in gs_ul_new_hour, gs_ul_new_minute, gs_ul_new_second.

References char_to_digit.

Referenced by main().

static void refresh_display ( void  )
static

Display the user interface on the terminal.

References rtc_get_date(), rtc_get_time(), and STATE_MENU.

Referenced by main(), and RTC_Handler().

void RTC_Handler ( void  )

Interrupt handler for the RTC.

Refresh the display.

References refresh_display(), rtc_clear_status(), rtc_disable_interrupt(), rtc_enable_interrupt(), and rtc_get_status().

uint8_t gs_uc_date[10+1]
static
Initial value:
=
{ '0', '0', '/', '0', '0', '/', '0', '0', '0', '0', '\0' }
uint8_t gs_uc_day_names[7][4]
static
Initial value:
=
{ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }
uint8_t gs_uc_rtc_time[8+1]
static
Initial value:
=
{ '0', '0', ':', '0', '0', ':', '0', '0', '\0' }
uint32_t gs_ul_alarm_triggered = 0
static
uint32_t gs_ul_menu_shown = 0
static
uint32_t gs_ul_new_day
static
uint32_t gs_ul_new_hour
static
uint32_t gs_ul_new_minute
static
uint32_t gs_ul_new_month
static
uint32_t gs_ul_new_second
static
uint32_t gs_ul_new_week
static
uint32_t gs_ul_new_year
static
uint32_t gs_ul_state = STATE_MENU
static