SAMV71 Xplained Ultra Software Package 1.4

rtc.c File Reference

#include "chip.h"
#include <stdint.h>
#include <assert.h>

Go to the source code of this file.

Functions

void RTC_SetHourMode (Rtc *pRtc, uint32_t dwMode)
 Sets the RTC in either 12 or 24 hour mode.
uint32_t RTC_GetHourMode (Rtc *pRtc)
 Gets the RTC mode.
void RTC_EnableIt (Rtc *pRtc, uint32_t dwSources)
 Enables the selected interrupt sources of the RTC.
void RTC_DisableIt (Rtc *pRtc, uint32_t dwSources)
 Disables the selected interrupt sources of the RTC.
int RTC_SetTime (Rtc *pRtc, uint8_t ucHour, uint8_t ucMinute, uint8_t ucSecond)
 Sets the current time in the RTC.
void RTC_GetTime (Rtc *pRtc, uint8_t *pucHour, uint8_t *pucMinute, uint8_t *pucSecond)
 Retrieves the current time as stored in the RTC in several variables.
int RTC_SetTimeAlarm (Rtc *pRtc, uint8_t *pucHour, uint8_t *pucMinute, uint8_t *pucSecond)
 Sets a time alarm on the RTC. The match is performed only on the provided variables; Setting all pointers to 0 disables the time alarm.
void RTC_GetDate (Rtc *pRtc, uint16_t *pwYear, uint8_t *pucMonth, uint8_t *pucDay, uint8_t *pucWeek)
 Retrieves the current year, month and day from the RTC. Month, day and week values are numbered starting at 1.
int RTC_SetDate (Rtc *pRtc, uint16_t wYear, uint8_t ucMonth, uint8_t ucDay, uint8_t ucWeek)
 Sets the current year, month and day in the RTC. Month, day and week values must be numbered starting from 1.
int RTC_SetDateAlarm (Rtc *pRtc, uint8_t *pucMonth, uint8_t *pucDay)
 Sets a date alarm in the RTC. The alarm will match only the provided values; Passing a null-pointer disables the corresponding field match.
void RTC_ClearSCCR (Rtc *pRtc, uint32_t dwMask)
 Clear flag bits of status clear command register in the RTC.
uint32_t RTC_GetSR (Rtc *pRtc, uint32_t dwMask)
 Get flag bits of status register in the RTC.

Detailed Description

Implementation of Real Time Clock (RTC) controller.

Definition in file rtc.c.


Function Documentation

void RTC_ClearSCCR ( Rtc pRtc,
uint32_t  dwMask 
)

Clear flag bits of status clear command register in the RTC.

Parameters:
mask Bits mask of cleared events

Definition at line 431 of file rtc.c.

void RTC_DisableIt ( Rtc pRtc,
uint32_t  dwSources 
)

Disables the selected interrupt sources of the RTC.

Parameters:
sources Interrupt sources to disable.

Definition at line 140 of file rtc.c.

void RTC_EnableIt ( Rtc pRtc,
uint32_t  dwSources 
)

Enables the selected interrupt sources of the RTC.

Parameters:
sources Interrupt sources to enable.

Definition at line 126 of file rtc.c.

void RTC_GetDate ( Rtc pRtc,
uint16_t *  pwYear,
uint8_t *  pucMonth,
uint8_t *  pucDay,
uint8_t *  pucWeek 
)

Retrieves the current year, month and day from the RTC. Month, day and week values are numbered starting at 1.

Parameters:
pYwear Current year (optional).
pucMonth Current month (optional).
pucDay Current day (optional).
pucWeek Current day in current week (optional).

Definition at line 295 of file rtc.c.

uint32_t RTC_GetHourMode ( Rtc pRtc  ) 

Gets the RTC mode.

Returns:
Hour mode.

Definition at line 109 of file rtc.c.

uint32_t RTC_GetSR ( Rtc pRtc,
uint32_t  dwMask 
)

Get flag bits of status register in the RTC.

Parameters:
mask Bits mask of Status Register
Returns:
Status register & mask

Definition at line 447 of file rtc.c.

void RTC_GetTime ( Rtc pRtc,
uint8_t *  pucHour,
uint8_t *  pucMinute,
uint8_t *  pucSecond 
)

Retrieves the current time as stored in the RTC in several variables.

Parameters:
pucHour If not null, current hour is stored in this variable.
pucMinute If not null, current minute is stored in this variable.
pucSecond If not null, current second is stored in this variable.

Definition at line 208 of file rtc.c.

int RTC_SetDate ( Rtc pRtc,
uint16_t  wYear,
uint8_t  ucMonth,
uint8_t  ucDay,
uint8_t  ucWeek 
)

Sets the current year, month and day in the RTC. Month, day and week values must be numbered starting from 1.

Note:
In successive update operations, the user must wait at least one second after resetting the UPDTIM/UPDCAL bit in the RTC_CR before setting these bits again. Please look at the RTC section of the datasheet for detail.
Parameters:
wYear Current year.
ucMonth Current month.
ucDay Current day.
ucWeek Day number in current week.
Returns:
0 success, 1 fail to set

Definition at line 345 of file rtc.c.

int RTC_SetDateAlarm ( Rtc pRtc,
uint8_t *  pucMonth,
uint8_t *  pucDay 
)

Sets a date alarm in the RTC. The alarm will match only the provided values; Passing a null-pointer disables the corresponding field match.

Parameters:
pucMonth If not null, the RTC alarm will month-match this value.
pucDay If not null, the RTC alarm will day-match this value.
Returns:
0 success, 1 fail to set

Definition at line 401 of file rtc.c.

void RTC_SetHourMode ( Rtc pRtc,
uint32_t  dwMode 
)

Sets the RTC in either 12 or 24 hour mode.

Parameters:
mode Hour mode.

Definition at line 97 of file rtc.c.

int RTC_SetTime ( Rtc pRtc,
uint8_t  ucHour,
uint8_t  ucMinute,
uint8_t  ucSecond 
)

Sets the current time in the RTC.

Note:
In successive update operations, the user must wait at least one second after resetting the UPDTIM/UPDCAL bit in the RTC_CR before setting these bits again. Please look at the RTC section of the datasheet for detail.
Parameters:
ucHour Current hour in 12 or 24 hour mode.
ucMinute Current minute.
ucSecond Current second.
Returns:
0 success, 1 fail to set

Definition at line 162 of file rtc.c.

int RTC_SetTimeAlarm ( Rtc pRtc,
uint8_t *  pucHour,
uint8_t *  pucMinute,
uint8_t *  pucSecond 
)

Sets a time alarm on the RTC. The match is performed only on the provided variables; Setting all pointers to 0 disables the time alarm.

Note:
In AM/PM mode, the hour value must have bit #7 set for PM, cleared for AM (as expected in the time registers).
Parameters:
pucHour If not null, the time alarm will hour-match this value.
pucMinute If not null, the time alarm will minute-match this value.
pucSecond If not null, the time alarm will second-match this value.
Returns:
0 success, 1 fail to set

Definition at line 258 of file rtc.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines