Microchip® Advanced Software Framework

rtc_calendar.c File Reference

SAM RTC Driver (Calendar Mode)

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

#include "rtc_calendar.h"
#include <gclk.h>

Functions

static void _rtc_calendar_set_config (struct rtc_module *const module, const struct rtc_calendar_config *const config)
 
void rtc_calendar_disable (struct rtc_module *const module)
 Disables the RTC module. More...
 
void rtc_calendar_enable (struct rtc_module *const module)
 Enables the RTC module. More...
 
enum status_code rtc_calendar_frequency_correction (struct rtc_module *const module, const int8_t value)
 Calibrate for too-slow or too-fast oscillator. More...
 
enum status_code rtc_calendar_get_alarm (struct rtc_module *const module, struct rtc_calendar_alarm_time *const alarm, const enum rtc_calendar_alarm alarm_index)
 Get the current alarm time of specified alarm. More...
 
void rtc_calendar_get_time (struct rtc_module *const module, struct rtc_calendar_time *const time)
 Get the current calendar value. More...
 
void rtc_calendar_init (struct rtc_module *const module, Rtc *const hw, const struct rtc_calendar_config *const config)
 Initializes the RTC module with given configurations. More...
 
static bool rtc_calendar_is_syncing (struct rtc_module *const module)
 Determines if the hardware module(s) are currently synchronizing to the bus. More...
 
void rtc_calendar_register_value_to_time (struct rtc_module *const module, const uint32_t register_value, struct rtc_calendar_time *const time)
 Convert register_value to time structure. More...
 
void rtc_calendar_reset (struct rtc_module *const module)
 Resets the RTC module. More...
 
enum status_code rtc_calendar_set_alarm (struct rtc_module *const module, const struct rtc_calendar_alarm_time *const alarm, const enum rtc_calendar_alarm alarm_index)
 Set the alarm time for the specified alarm. More...
 
void rtc_calendar_set_time (struct rtc_module *const module, const struct rtc_calendar_time *const time)
 Set the current calendar time to desired time. More...
 
void rtc_calendar_swap_time_mode (struct rtc_module *const module)
 Swaps between 12h and 24h clock mode. More...
 
uint32_t rtc_calendar_time_to_register_value (struct rtc_module *const module, const struct rtc_calendar_time *const time)
 Convert time structure to register_value. More...
 

static void _rtc_calendar_set_config ( struct rtc_module *const  module,
const struct rtc_calendar_config *const  config 
)
static

Applies the given configuration.

Set the configurations given from the configuration structure to the hardware module.

Parameters
[in,out]modulePointer to the software instance struct
[in]configPointer to the configuration structure.

References rtc_calendar_config::alarm, Assert, rtc_calendar_config::clear_on_match, rtc_calendar_config::clock_24h, rtc_calendar_config::continuously_update, rtc_calendar_config::prescaler, and rtc_calendar_set_alarm().

Referenced by rtc_calendar_init().

static bool rtc_calendar_is_syncing ( struct rtc_module *const  module)
inlinestatic

Determines if the hardware module(s) are currently synchronizing to the bus.

Checks to see if the underlying hardware peripheral module(s) are currently synchronizing across multiple clock domains to the hardware bus, This function can be used to delay further operations on a module until such time that it is ready, to prevent blocking delays for synchronization in the user application.

Parameters
[in]moduleRTC hardware module
Returns
Synchronization status of the underlying hardware module(s).
Return values
falseIf the module has completed synchronization
trueIf the module synchronization is ongoing

References Assert.

Referenced by rtc_calendar_disable(), rtc_calendar_enable(), rtc_calendar_frequency_correction(), rtc_calendar_get_time(), rtc_calendar_reset(), rtc_calendar_set_alarm(), and rtc_calendar_set_time().