SRD Standelone programmation box: rtc.c File Reference

| SRD Standelone programmation box 2.0 (16/11/15 10:00:00) Documentation of the SRD standelone programmation box

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Enumerations Enumerator Macros Pages
Functions | Variables
rtc.c File Reference

Source file for RTC Driver. More...

`#include "rtc.h"`
Include dependency graph for rtc.c:

Go to the source code of this file.

## Functions

void | RtcInit (void)
| Function used to initialized the RTC module. More...
unsigned long | RtcGetTime (void)
| return the current time in the RTC. More...
void | RtcSetTime (unsigned long nbrSec)
| set the current time. More...
unsigned char | RtcUpdatedSinceLastReset (void)
| Indicate if the RTC have been initialized or not. More...

## Variables

unsigned char | RtcUpdated = 0

## Detailed Description

Source file for RTC Driver.

Author
  Thibaut LALUQUE 3D-Ouest

Date
  26/09/2014

Version
  1.0

All Right Reserved.

Definition in file rtc.c.

## Function Documentation

unsigned long RtcGetTime | ( | void |  | ) |

return the current time in the RTC.

Returns
  (unsigned long) : time ellapsed from th 1st january 2010.

Definition at line 98 of file rtc.c.

Referenced by ButtonManagerDealer(), and UsbManagerCmdDealer().

98 {
99 unsigned long r1 = RTC->TSR;
100 unsigned long r2 = RTC->TSR;
101
102 while(r1 != r2) {
103 r1 = RTC->TSR;
104 r2 = RTC->TSR;
105 }
106
107 return r1;
108 }

Here is the caller graph for this function:

void RtcInit | ( | void |  | ) |

Function used to initialized the RTC module.

Definition at line 78 of file rtc.c.

References RtcAllowAccess, and RtcUpdated.

Referenced by CriticalInit().

78 {
79
80 RtcAllowAccess();
81
82 RTC->SR = 0x00U; //Reset all flag and turn off RTC
83
84 //RTC->TCR = 0; //No correction
85 RTC->TPR = 0; //Reset 32k prescaler
86 RTC->TSR = 0; //Reset counter sec register
87
88 RTC->SR |= RTC_SR_TCE_MASK; //Enable RTC
89
90 RTC_IER &= 0; //Rtc flag reset
91
92 RtcUpdated = 0;
93 //RtcUpdated = 1;
94
95 //RtcForbiddenAccess();
96 }
RtcAllowAccess
#define RtcAllowAccess()
Macro used to allow or forbidden the access to the RTC module.
Definition: rtc.h:64
RtcUpdated
unsigned char RtcUpdated
Definition: rtc.c:60

Here is the caller graph for this function:

void RtcSetTime | ( | unsigned long | nbrSec | ) |

set the current time.

Parameters

  [in] | nbrSec | (unsigned long) : number of second ellapsed from the 1st january 2010.

Definition at line 110 of file rtc.c.

References RtcUpdated.

Referenced by UsbManagerCmdDealer().

110 {
111
112 RTC->SR &= ~RTC_SR_TCE_MASK; //Stop RTC
113
114 RTC->TPR = 0; //Reset 32k prescaler
115 RTC->TSR = nbrSec; //set time counter sec register
116
117 RTC->SR |=RTC_SR_TCE_MASK; //Restart RTC
118
119 RtcUpdated = 1;
120 }
RtcUpdated
unsigned char RtcUpdated
Definition: rtc.c:60

Here is the caller graph for this function:

unsigned char RtcUpdatedSinceLastReset | ( | void |  | ) |

Indicate if the RTC have been initialized or not.

Returns
  (unsigned char) : 1 if the RTC have been initialized, else 0.

Definition at line 122 of file rtc.c.

References RtcUpdated.

Referenced by ButtonManager().

122 {
123 return RtcUpdated;
124 }
RtcUpdated
unsigned char RtcUpdated
Definition: rtc.c:60

Here is the caller graph for this function:

## Variable Documentation

unsigned char RtcUpdated = 0

Definition at line 60 of file rtc.c.

Referenced by RtcInit(), RtcSetTime(), and RtcUpdatedSinceLastReset().