mikroSDK Reference Manual

RTC Driver API Reference. More...

Functions list

void rtc_init ()
 Initialize the RTC module. More...
 
err_t rtc_start ()
 Start the RTC module. More...
 
err_t rtc_stop ()
 Stop the RTC module. More...
 
err_t rtc_reset ()
 Reset the RTC module. More...
 
err_t rtc_set_time (rtc_time_t *time)
 Configure time of RTC module. More...
 
err_t rtc_get_time (rtc_time_t *time)
 Get time from RTC module. More...
 
void rtc_system_reset ()
 Preforms system reset. More...
 

Detailed Description

The RTC driver provides standard RTC functionality including start, reset and stop of RTC counter, it also allows setting custom values.

Function Documentation

◆ rtc_init()

void rtc_init ( )

Initialize the RTC module.

Parameters
None.Example
// Initialize RTC.

◆ rtc_start()

err_t rtc_start ( )

Continue the RTC module count from the stored value in the counter register.

Parameters
None.
Returns
The function can return one of the values defined by rtc_err_t structure, which is size dependant on the architecture.
Note
It is recommended to configure RTC module using rtc_set_time( rtc_time_t *time ) before the first start and to check return value for error.

Example

// RTC time structure.
static rtc_time_t time;
// Initalize the RTC module.
// Start the RTC module.
if ( RTC_ERROR == rtc_start() ) {
// Error handling strategy.
}

◆ rtc_stop()

err_t rtc_stop ( )

Stop the RTC module count.

Parameters
None.
Returns
The function can return one of the values defined by rtc_err_t structure, which is size dependant on the architecture.
Note
It is recommended to check return value for error.

Example

// RTC time structure.
static rtc_time_t time;
// Initalize the RTC module.
// Stop the RTC module.
if ( RTC_ERROR == rtc_stop() ) {
// Error handling strategy.
}

◆ rtc_reset()

err_t rtc_reset ( )

Reset the RTC counter to the default values of 0h:0m:0s.

Parameters
None.
Returns
The function can return one of the values defined by rtc_err_t structure, which is size dependant on the architecture.
Note
It is recommended to check return value for error.

Example

// RTC time structure.
static rtc_time_t time;
// Initalize the RTC module.
// Reset the RTC module.
if ( RTC_ERROR == rtc_reset() ) {
// Error handling strategy.
}

◆ rtc_set_time()

err_t rtc_set_time ( rtc_time_t time)

Configure time registers with the values from rtc_time_t structure.

Parameters
timertc_time_t structure.
Returns
The function can return one of the values defined by rtc_err_t structure, which is size dependant on the architecture.
Note
It is recommended to check return value for error.

Example

// Time structure.
static rtc_time_t time;
// Initialize RTC.
// Modify time.
time.second = 0;
time.minute = 5;
time.hour = 3;
// Set time.
if ( RTC_SUCCESS != rtc_set_time( &time ) ) {
// Error handling strategy.
}

◆ rtc_get_time()

err_t rtc_get_time ( rtc_time_t time)

Configure rtc_time_t structure with the values from time registers.

Parameters
timertc_time_t structure.
Returns
The function can return one of the values defined by rtc_err_t structure, which is size dependant on the architecture.
Note
It is recommended to check return value for error.

Example

// Time structure.
static rtc_time_t time;
// Initialize RTC.
if ( RTC_SUCCESS != rtc_get_time( &time ) ) {
// Error handling strategy.
}

◆ rtc_system_reset()

void rtc_system_reset ( )

Resets the core and all on-chip peripherals except the Debug interface.

Parameters
None.
Warning
System reset affects core and periferals, depending on the architecture you will need to reconfigure opened modules.

Example

// Time structure.
static rtc_time_t time;
// Initialize RTC.
// Reset.
rtc_reset
err_t rtc_reset()
Reset the RTC module.
rtc_system_reset
void rtc_system_reset()
Preforms system reset.
rtc_time_t
Structure representing the RTC time.
Definition: drv_rtc.h:79
rtc_start
err_t rtc_start()
Start the RTC module.
rtc_time_t::second
uint8_t second
Definition: drv_rtc.h:83
RTC_SUCCESS
Definition: drv_rtc.h:57
RTC_ERROR
Definition: drv_rtc.h:58
rtc_get_time
err_t rtc_get_time(rtc_time_t *time)
Get time from RTC module.
rtc_set_time
err_t rtc_set_time(rtc_time_t *time)
Configure time of RTC module.
rtc_time_t::minute
uint8_t minute
Definition: drv_rtc.h:82
rtc_init
void rtc_init()
Initialize the RTC module.
rtc_time_t::hour
uint8_t hour
Definition: drv_rtc.h:81
rtc_stop
err_t rtc_stop()
Stop the RTC module.