RTC: Methods

Real Time Clock

RTC
Methods
DAVE_APP_VERSION_t RTC_GetAppVersion (void)
 Get RTC APP version.
RTC_STATUS_t RTC_Init (RTC_t *const handle)
 Initializes RTC module.
RTC_STATUS_t RTC_Time (time_t *time_value)
 Returns the time in seconds since the epoch time(01/01/1970).
__STATIC_INLINE void RTC_Start (void)
 Starts the RTC running.
__STATIC_INLINE void RTC_Stop (void)
 Stops the RTC running.
RTC_STATUS_t RTC_SetTime (XMC_RTC_TIME_t *time)
 Sets the time.
RTC_STATUS_t RTC_SetAlarmTime (XMC_RTC_ALARM_t *alarm)
 Sets the alarm time.
void RTC_GetTime (XMC_RTC_TIME_t *time)
 Gets the time.
void RTC_GetAlarmTime (XMC_RTC_ALARM_t *alarm)
 Gets the alarm time.
uint32_t RTC_GetFlagStatus (void)
 Gets the flag status.

Methods


Function Documentation

void RTC_GetAlarmTime ( XMC_RTC_ALARM_t *  alarm)

Gets the alarm time.

Parameters:
timePointer to structure of type XMC_RTC_ALARM_t
Returns:
None

Example: Pre-requisite: Instantiate RTC APP and generate code before copying below code snippet.

 #include <DAVE.h>
 XMC_RTC_ALARM_t alarm =
 {
   .seconds = 0U,
   .minutes = 1U,
   .hours = 0U,
   .days = 1U,
   .month = 1,
   .year = 1970U
 };
 int main(void)
 {
  RTC_STATUS_t status = RTC_STATUS_FAILURE;
  DAVE_Init();
  RTC_Stop();
  status = RTC_SetAlarmTime(&alarm);
  if(status == RTC_STATUS_SUCCESS)
  {
    RTC_GetAlarmTime(&alarm);
  }
   // ... infinite loop ...
   while(1)
   {}
 }


Definition at line 354 of file RTC.c.

DAVE_APP_VERSION_t RTC_GetAppVersion ( void  )

Get RTC APP version.

Returns:
DAVE_APP_VERSION_t APP version information (major, minor and patch number)
Description:
The function can be used to check application software compatibility with a specific version of the APP.
  #include <DAVE.h>
  #include <DAVE_common.h>
  int main(void)
  {
    DAVE_APP_VERSION_t version;
    DAVE_Init();
    version = RTC_GetAppVersion();
    if(version.major != 4U)
    {
    }
    return 0;
  }


Definition at line 110 of file RTC.c.

uint32_t RTC_GetFlagStatus ( void  )

Gets the flag status.

Parameters:
None
Returns:
uint32_t flag status

Example: Pre-requisite: Instantiate RTC APP and generate code before copying below code snippet.

 #include <DAVE.h>
 int main(void)
 {
   DAVE_Init(); // RTC_Init(&RTC_0); is called inside DAVE_Init()
   if(RTC_GetFlagStatus()& RTC_STSSR_SPSE_Msk) // check if the periodic seconds event has occurred.
   {
   }
   while(1)
   {}
 }


Definition at line 367 of file RTC.c.

void RTC_GetTime ( XMC_RTC_TIME_t *  time)

Gets the time.

Parameters:
timePointer to structure of type XMC_RTC_TIME_t
Returns:
None

Example: Pre-requisite: Instantiate RTC APP and generate code before copying below code snippet.

 #include <DAVE.h>
 XMC_RTC_TIME_t timeval =
 {
   .seconds = 0U,
   .minutes = 0U,
   .hours = 0U,
   .days = 1U,
   .month = 1,
   .year = 1970U
 };
 int main(void)
 {
  RTC_STATUS_t status = RTC_STATUS_FAILURE;
  DAVE_Init();
  RTC_Stop();
  status = RTC_SetTime(&timeval);
  if(status == RTC_STATUS_SUCCESS)
  {
    RTC_GetTime(&timeval);
  }
  // ... infinite loop ...
  while(1)
  {}
 }


Definition at line 307 of file RTC.c.

RTC_STATUS_t RTC_Init ( RTC_t *const  handle)

Initializes RTC module.

Parameters:
handleConstant pointer to RTC structure of type RTC_t
Returns:
RTC_STATUS_t
Description:
Configures the RTC module registers as per settings updated in UI and enables the RTC module.

Example: Pre-requisite: Instantiate RTC APP and generate code before copying below code snippet.

  #include <DAVE.h>
  int main(void)
  {
    DAVE_Init(); // RTC_Init(&RTC_0) will be called within DAVE_Init()
    // ... infinite loop ...
    while(1)
    {}
  }


Definition at line 125 of file RTC.c.

References RealTimeClock::config, RealTimeClock::initialized, RTC_Start(), RTC_START_ENABLE, RTC_STATUS_FAILURE, RTC_STATUS_SUCCESS, and RTC_CONFIG::start.

RTC_STATUS_t RTC_SetAlarmTime ( XMC_RTC_ALARM_t *  alarm)

Sets the alarm time.

Parameters:
alarmPointer to structure of type XMC_RTC_ALARM_t
Returns:
RTC_STATUS_t

Example: Pre-requisite: Instantiate RTC APP and generate code before copying below code snippet.

 #include <DAVE.h>
 XMC_RTC_ALARM_t alarm =
 {
    .seconds = 0U,
    .minutes = 1U,
    .hours = 0U,
    .days = 1U,
    .month = 1,
    .year = 1970U
 };
 int main(void)
 {
   RTC_STATUS_t status = RTC_STATUS_FAILURE;
   DAVE_Init();
   RTC_Stop();
   status = RTC_SetAlarmTime(&alarm);
   if(status != RTC_STATUS_SUCCESS)
   {
           //error
   }
   // ... infinite loop ...
   while(1)
   {}
 }


Definition at line 320 of file RTC.c.

References RTC_STATUS_FAILURE, and RTC_STATUS_SUCCESS.

RTC_STATUS_t RTC_SetTime ( XMC_RTC_TIME_t *  time)

Sets the time.

Parameters:
timePointer to structure of type XMC_RTC_TIME_t
Returns:
RTC_STATUS_t

Example: Pre-requisite: Instantiate RTC APP and generate code before copying below code snippet.

 #include <DAVE.h>
 XMC_RTC_TIME_t timeval =
 {
    .seconds = 0U,
    .minutes = 0U,
    .hours = 0U,
    .days = 1U,
    .month = 1,
    .year = 1970U
 };
 int main(void)
 {
   RTC_STATUS_t status = RTC_STATUS_FAILURE;
   DAVE_Init();
   RTC_Stop();
   status = RTC_SetTime(&timeval);
   if(status != RTC_STATUS_SUCCESS)
   {
           //error
   }
   // ... infinite loop ...
   while(1)
   {}
 }


Definition at line 274 of file RTC.c.

References RTC_STATUS_FAILURE, and RTC_STATUS_SUCCESS.

__STATIC_INLINE void RTC_Start ( void  )

Starts the RTC running.

Returns:
None
Description:
Before verifying this API it is required to deselect "Start after initialization" checbox in UI. Thereby this API shall be used to start the RTC module.

Example: Pre-requisite: 1. Instantiate RTC APP
2. Unselect "Start after initialization checkbox in UI"
3. Generate code before copying below code snippet.

 #include <DAVE.h>
 int main(void)
 {
   DAVE_Init();// RTC_Init(&RTC_0) will be called within DAVE_Init()
   RTC_Stop();
   if (XMC_RTC_IsRunning() == false)
   {
     RTC_Start();
   }
   // ... infinite loop ...
   while(1)
   {}
 }


Definition at line 288 of file RTC.h.

Referenced by RTC_Init().

__STATIC_INLINE void RTC_Stop ( void  )

Stops the RTC running.

Returns:
None

Example: Pre-requisite: Instantiate RTC APP
Enable periodic seconds event in "Interrupt Settings" tab.
Generate code before copying below code snippet.

 #include <DAVE.h>

 void Time_Handler(void)
 {
    static uint32_t seconds = 0;
    seconds++;

    if(seconds == 30)
    {
      RTC_Stop();
    }
 }
 int main(void)
 {
   DAVE_Init(); // RTC_Init(&RTC_0) will be called within DAVE_Init()
   // ... infinite loop ...
   while(1)
   {}
 }


Definition at line 324 of file RTC.h.

RTC_STATUS_t RTC_Time ( time_t *  time_value)

Returns the time in seconds since the epoch time(01/01/1970).

Parameters:
time_valuePointer to structure of type time_t
Returns:
RTC_STATUS_t

Example: Pre-requisite: Instantiate RTC APP and generate code before copying below code snippet.

 #include <DAVE.h>
 int main(void)
 {
   RTC_STATUS_t status = RTC_STATUS_FAILURE;
   time_t Time_Sec;
   DAVE_Init();  // RTC_Init(&RTC_0) will be called within DAVE_Init()
   status = RTC_Time(&Time_Sec);
   if(status != RTC_STATUS_SUCCESS)
   {
           //error
   }
   // ... infinite loop ...
   while(1)
   {}
 }


Definition at line 380 of file RTC.c.

References RTC_STATUS_FAILURE, and RTC_STATUS_SUCCESS.