/**
******************************************************************************
* @file stm32f0xx_rtc.c
* @author MCD Application Team
* @version V1.0.0
* @date 23-March-2012
* @brief This file provides firmware functions to manage the following
* functionalities of the Real-Time Clock (RTC) peripheral:
* + Initialization
* + Calendar (Time and Date) configuration
* + Alarms (Alarm A) configuration
* + Daylight Saving configuration
* + Output pin Configuration
* + Digital Calibration configuration
* + TimeStamp configuration
* + Tampers configuration
* + Backup Data Registers configuration
* + Output Type Config configuration
* + Shift control synchronisation
* + Interrupts and flags management
*
@verbatim
===============================================================================
##### Backup Domain Operating Condition #####
===============================================================================
[..] The real-time clock (RTC) and the RTC backup registers can be powered
from the VBAT voltage when the main VDD supply is powered off.
To retain the content of the RTC backup registers and supply the RTC
when VDD is turned off, VBAT pin can be connected to an optional
standby voltage supplied by a battery or by another source.
[..] To allow the RTC to operate even when the main digital supply (VDD)
is turned off, the VBAT pin powers the following blocks:
(#) The RTC
(#) The LSE oscillator
(#) PC13 to PC15 I/Os I/Os (when available)
[..] When the backup domain is supplied by VDD (analog switch connected
to VDD), the following functions are available:
(#) PC14 and PC15 can be used as either GPIO or LSE pins
(#) PC13 can be used as a GPIO or as the RTC_AF1 pin
[..] When the backup domain is supplied by VBAT (analog switch connected
to VBAT because VDD is not present), the following functions are available:
(#) PC14 and PC15 can be used as LSE pins only
(#) PC13 can be used as the RTC_AF1 pin
##### Backup Domain Reset #####
===============================================================================
[..] The backup domain reset sets all RTC registers and the RCC_BDCR
register to their reset values.
A backup domain reset is generated when one of the following events
occurs:
(#) Software reset, triggered by setting the BDRST bit in the
RCC Backup domain control register (RCC_BDCR). You can use the
RCC_BackupResetCmd().
(#) VDD or VBAT power on, if both supplies have previously been
powered off.
##### Backup Domain Access #####
===============================================================================
[..] After reset, the backup domain (RTC registers and RTC backup data
registers) is protected against possible unwanted write accesses.
[..] To enable access to the Backup Domain and RTC registers, proceed as follows:
(#) Enable the Power Controller (PWR) APB1 interface clock using the
RCC_APB1PeriphClockCmd() function.
(#) Enable access to Backup domain using the PWR_BackupAccessCmd() function.
(#) Select the RTC clock source using the RCC_RTCCLKConfig() function.
(#) Enable RTC Clock using the RCC_RTCCLKCmd() function.
##### How to use this driver #####
===============================================================================
[..]
(+) Enable the backup domain access (see description in the section above)
(+) Configure the RTC Prescaler (Asynchronous and Synchronous) and
RTC hour format using the RTC_Init() function.
***Time and Date configuration ***
==================================
[..]
(+) To configure the RTC Calendar (Time and Date) use the RTC_SetTime()
and RTC_SetDate() functions.
(+) To read the RTC Calendar, use the RTC_GetTime() and RTC_GetDate()
functions.
(+) To read the RTC subsecond, use the RTC_GetSubSecond() function.
(+) Use the RTC_DayLightSavingConfig() function to add or sub one
hour to the RTC Calendar.
***Alarm configuration ***
==========================
[..]
(+) To configure the RTC Alarm use the RTC_SetAlarm() function.
(+) Enable the selected RTC Alarm using the RTC_AlarmCmd() function
(+) To read the RTC Alarm, use the RTC_GetAlarm() function.
(+) To read the RTC alarm SubSecond, use the RTC_GetAlarmSubSecond() function.
***Outputs configuration ***
============================
[..] The RTC has 2 different outputs:
(+) AFO_ALARM: this output is used to manage the RTC Alarm A.
To output the selected RTC signal on RTC_AF1 pin, use the
RTC_OutputConfig() function.
(+) AFO_CALIB: this output is 512Hz signal or 1Hz .
To output the RTC Clock on RTC_AF1 pin, use the RTC_CalibOutputCmd()
function.
***Original Digital Calibration configuration ***
=================================
[..] Configure the RTC Original Digital Calibration Value and the corresponding
calibration cycle period (32s,16s and 8s) using the RTC_SmoothCalibConfig()
function.
***TimeStamp configuration ***
==============================
[..]
(+) Configure the RTC_AF1 trigger and enables the RTC TimeStamp
using the RTC_TimeStampCmd() function.
(+) To read the RTC TimeStamp Time and Date register, use the
RTC_GetTimeStamp() function.
(+) To read the RTC TimeStamp SubSecond register, use the
RTC_GetTimeStampSubSecond() function.
***Tamper configuration ***
===========================
[..]
(+) Configure the Tamper filter count using RTC_TamperFilterConfig()
function.
(+) Configure the RTC Tamper trigger Edge or Level according to the Tamper
filter (if equal to 0 Edge else Level) value using the RTC_TamperConfig() function
(+) Configure the Tamper sampling frequency using RTC_TamperSamplingFreqConfig()
function.
(+) Configure the Tamper precharge or discharge duration using
RTC_TamperPinsPrechargeDuration() function.
(+) Enable the Tamper Pull-UP using RTC_TamperPullUpDisableCmd() function.
(+) Enable the RTC Tamper using the RTC_TamperCmd() function.
(+) Enable the Time stamp on Tamper detection event using
RTC_TSOnTamperDetecCmd() function.
***Backup Data Registers configuration ***
==========================================
[..]
(+) To write to the RTC Backup Data registers, use the RTC_WriteBackupRegister()
function.
(+) To read the RTC Backup Data registers, use the RTC_ReadBackupRegister()
function.
##### RTC and low power modes #####
===============================================================================
[..] The MCU can be woken up from a low power mode by an RTC alternate
function.
[..] The RTC alternate functions are the RTC alarm (Alarm A), RTC tamper
event detection and RTC time stamp event detection.
These RTC alternate functions can wake up the system from the Stop
评论0