RTEMS  5.0.0
Functions
rtc.c File Reference
#include "chip.h"
#include <stdint.h>
#include <assert.h>

Functions

void RTC_SetHourMode (Rtc *pRtc, uint32_t dwMode)
 Sets the RTC in either 12 or 24 hour mode. More...
 
uint32_t RTC_GetHourMode (Rtc *pRtc)
 Gets the RTC mode. More...
 
void RTC_EnableIt (Rtc *pRtc, uint32_t dwSources)
 Enables the selected interrupt sources of the RTC. More...
 
void RTC_DisableIt (Rtc *pRtc, uint32_t dwSources)
 Disables the selected interrupt sources of the RTC. More...
 
int RTC_SetTime (Rtc *pRtc, uint8_t ucHour, uint8_t ucMinute, uint8_t ucSecond)
 Sets the current time in the RTC. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
void RTC_ClearSCCR (Rtc *pRtc, uint32_t dwMask)
 Clear flag bits of status clear command register in the RTC. More...
 
uint32_t RTC_GetSR (Rtc *pRtc, uint32_t dwMask)
 Get flag bits of status register in the RTC. More...
 

Detailed Description

Implementation of Real Time Clock (RTC) controller.

Function Documentation

◆ RTC_ClearSCCR()

void RTC_ClearSCCR ( Rtc pRtc,
uint32_t  dwMask 
)

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

Parameters
maskBits mask of cleared events

◆ RTC_DisableIt()

void RTC_DisableIt ( Rtc pRtc,
uint32_t  dwSources 
)

Disables the selected interrupt sources of the RTC.

Parameters
sourcesInterrupt sources to disable.

◆ RTC_EnableIt()

void RTC_EnableIt ( Rtc pRtc,
uint32_t  dwSources 
)

Enables the selected interrupt sources of the RTC.

Parameters
sourcesInterrupt sources to enable.

◆ RTC_GetDate()

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
pYwearCurrent year (optional).
pucMonthCurrent month (optional).
pucDayCurrent day (optional).
pucWeekCurrent day in current week (optional).

◆ RTC_GetHourMode()

uint32_t RTC_GetHourMode ( Rtc pRtc)

Gets the RTC mode.

Returns
Hour mode.

◆ RTC_GetSR()

uint32_t RTC_GetSR ( Rtc pRtc,
uint32_t  dwMask 
)

Get flag bits of status register in the RTC.

Parameters
maskBits mask of Status Register
Returns
Status register & mask

◆ RTC_GetTime()

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
pucHourIf not null, current hour is stored in this variable.
pucMinuteIf not null, current minute is stored in this variable.
pucSecondIf not null, current second is stored in this variable.

◆ RTC_SetDate()

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
wYearCurrent year.
ucMonthCurrent month.
ucDayCurrent day.
ucWeekDay number in current week.
Returns
0 success, 1 fail to set

◆ RTC_SetDateAlarm()

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
pucMonthIf not null, the RTC alarm will month-match this value.
pucDayIf not null, the RTC alarm will day-match this value.
Returns
0 success, 1 fail to set

◆ RTC_SetHourMode()

void RTC_SetHourMode ( Rtc pRtc,
uint32_t  dwMode 
)

Sets the RTC in either 12 or 24 hour mode.

Parameters
modeHour mode.

◆ RTC_SetTime()

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
ucHourCurrent hour in 12 or 24 hour mode.
ucMinuteCurrent minute.
ucSecondCurrent second.
Returns
0 success, 1 fail to set

◆ RTC_SetTimeAlarm()

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
pucHourIf not null, the time alarm will hour-match this value.
pucMinuteIf not null, the time alarm will minute-match this value.
pucSecondIf not null, the time alarm will second-match this value.
Returns
0 success, 1 fail to set