RZV Flexible Software Package Documentation
Release v3.0.0
|
|
Driver for the RTC peripheral on RZ MPUs. This module implements the RTC Interface.
The RTC HAL module configures the RTC module and controls clock, calendar and alarm functions. A callback can be used to respond to the alarm and periodic interrupt.
The RTC HAL module supports three different interrupt types:
"Parameter Checking" needs to be enabled if date and time validation is required for calendarTimeSet and calendarAlarmSet APIs. If "Parameter Checking" is enabled, the 'day of the week' field is automatically calculated and updated by the driver for the provided date. When using the calendarAlarmSet API, only the fields which have their corresponding match flag set are written to the registers. Other register fields are reset to default value.
The time error adjustment function is used to correct errors, running fast or slow, in the time caused by variation in the precision of oscillation by the clock oscillator. Because 32,768 cycles of the clock oscillator constitute 1 second of operation when the clock oscillator is selected, the clock runs fast if the clock frequency is high and slow if the clock frequency is low. The time error adjustment functions include:
The error adjustment is reset every time RTC is reconfigured or time is set.
This MPU supports bypassing the RTC's oscillator circuit, which typically requires an AC clock signal from a crystal oscillator. However, a DC clock signal can be directly input via the RTXIN pin. Therefore the clock mode for the RTC can be changed as the follows:
Configuration | Options | Default | Description |
---|---|---|---|
Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
Configuration | Options | Default | Description |
---|---|---|---|
Name | Name must be a valid C symbol | g_rtc0 | Module name. |
External Clock Bypass Mode |
| Crystal Oscillator | Receive the clock from either a crystal oscillator or directly from a clock source by inputting it to the RTXIN pin only. |
Automatic Adjustment Mode |
| Enabled | Enable/ Disable the Error Adjustment mode |
Automatic Adjustment Period |
| 10 Seconds | Select the Error Adjustment Period for Automatic Adjustment |
Adjustment Type (Plus-Minus) |
| NONE | Select the Error Adjustment type |
Error Adjustment Value | Value must be a positive integer less than equal to 63 | 0 | Specify the Adjustment Value (the number of sub-clock cycles) from the prescaler |
Callback | Name must be a valid C symbol | NULL | A user callback function can be provided. If this callback function is provided, it will be called from the interrupt service routine (ISR). |
Alarm Interrupt | MCU Specific Options | Enable the Alarm interrupt. | |
Alarm Interrupt Priority | Value must be a non-negative integer | 12 | Select the alarm interrupt priority. |
Period Interrupt | MCU Specific Options | Enable the Periodic interrupt. | |
Period Interrupt Priority | Value must be a non-negative integer | 12 | Select the period interrupt priority. |
Carry Interrupt | MCU Specific Options | Enable the Carry interrupt. | |
Carry Interrupt Priority | Value must be a non-negative integer | 12 | Select the carry interrupt priority. |
To activate interrupts for the RTC module, the desired interrupts must be enabled, The underlying implementation will be expected to handle any interrupts it can support and notify higher layers via callback.
This module does not use I/O pins.
Developers should be aware of the following limitations when using the RTC:
This is a basic example of minimal use of the RTC in an application.
This is an example of periodic interrupt in RTC.
This is an example of alarm interrupt in RTC.
This is an example of modifying error adjustment in RTC.
Data Structures | |
struct | rtc_extended_cfg_t |
struct | rtc_instance_ctrl_t |
Enumerations | |
enum | rtc_clock_bypass_mode_t |
struct rtc_extended_cfg_t |
RTC extend configuration
Data Fields | ||
---|---|---|
uint8_t | alarm1_ipl | Alarm 1 interrupt priority. |
IRQn_Type | alarm1_irq | Alarm 1 interrupt vector. |
rtc_clock_bypass_mode_t | clock_bypass_mode | Clock Bypass Mode. |
struct rtc_instance_ctrl_t |
Channel control block. DO NOT INITIALIZE. Initialization occurs when rtc_api_t::open is called
Data Fields | |
uint32_t | open |
Whether or not driver is open. | |
const rtc_cfg_t * | p_cfg |
Pointer to initial configurations. | |
volatile bool | carry_isr_triggered |
Was the carry isr triggered. | |
RTC Clock Bypass Mode
fsp_err_t R_RTC_Open | ( | rtc_ctrl_t *const | p_ctrl, |
rtc_cfg_t const *const | p_cfg | ||
) |
Opens and configures the RTC driver module. Implements rtc_api_t::open. Configuration includes clock source, and interrupt callback function.
Example:
FSP_SUCCESS | Initialization was successful and RTC has started. |
FSP_ERR_ASSERTION | Invalid p_ctrl or p_cfg pointer. |
FSP_ERR_ALREADY_OPEN | Module is already open. |
FSP_ERR_INVALID_ARGUMENT | Invalid time parameter field. |
fsp_err_t R_RTC_Close | ( | rtc_ctrl_t *const | p_ctrl | ) |
Close the RTC driver. Implements rtc_api_t::close
FSP_SUCCESS | De-Initialization was successful and RTC driver closed. |
FSP_ERR_ASSERTION | Invalid p_ctrl. |
FSP_ERR_NOT_OPEN | Driver not open already for close. |
fsp_err_t R_RTC_ClockSourceSet | ( | rtc_ctrl_t *const | p_ctrl | ) |
Implements rtc_api_t::clockSourceSet. Unsupported.
FSP_SUCCESS | Initialization was successful and RTC has started. |
FSP_ERR_ASSERTION | Invalid p_ctrl or p_cfg pointer. |
FSP_ERR_NOT_OPEN | Driver is not opened. |
FSP_ERR_INVALID_ARGUMENT | Invalid clock source. |
FSP_ERR_UNSUPPORTED | Function not supported in this implementation. |
fsp_err_t R_RTC_CalendarTimeSet | ( | rtc_ctrl_t *const | p_ctrl, |
rtc_time_t *const | p_time | ||
) |
Set the calendar time.
Implements rtc_api_t::calendarTimeSet.
FSP_SUCCESS | Calendar time set operation was successful. |
FSP_ERR_ASSERTION | Invalid input argument. |
FSP_ERR_NOT_OPEN | Driver not open already for operation. |
FSP_ERR_INVALID_ARGUMENT | Invalid time parameter field. |
fsp_err_t R_RTC_CalendarTimeGet | ( | rtc_ctrl_t *const | p_ctrl, |
rtc_time_t *const | p_time | ||
) |
Get the calendar time.
Implements rtc_api_t::calendarTimeGet
FSP_SUCCESS | Calendar time get operation was successful. |
FSP_ERR_ASSERTION | Invalid input argument. |
FSP_ERR_NOT_OPEN | Driver not open already for operation. |
FSP_ERR_IRQ_BSP_DISABLED | User IRQ parameter not valid |
fsp_err_t R_RTC_CalendarAlarmSet | ( | rtc_ctrl_t *const | p_ctrl, |
rtc_alarm_time_t *const | p_alarm | ||
) |
Set the calendar alarm time.
Implements rtc_api_t::calendarAlarmSet.
FSP_SUCCESS | Calendar alarm time set operation was successful. |
FSP_ERR_INVALID_ARGUMENT | Invalid time parameter field. |
FSP_ERR_ASSERTION | Invalid input argument. |
FSP_ERR_NOT_OPEN | Driver not open already for operation. |
FSP_ERR_IRQ_BSP_DISABLED | User IRQ parameter not valid |
fsp_err_t R_RTC_CalendarAlarmGet | ( | rtc_ctrl_t *const | p_ctrl, |
rtc_alarm_time_t *const | p_alarm | ||
) |
Get the calendar alarm time.
Implements rtc_api_t::calendarAlarmGet
FSP_SUCCESS | Calendar alarm time get operation was successful. |
FSP_ERR_ASSERTION | Invalid input argument. |
FSP_ERR_NOT_OPEN | Driver not open already for operation. |
fsp_err_t R_RTC_PeriodicIrqRateSet | ( | rtc_ctrl_t *const | p_ctrl, |
rtc_periodic_irq_select_t const | rate | ||
) |
Set the periodic interrupt rate and enable periodic interrupt.
Implements rtc_api_t::periodicIrqRateSet
Example:
FSP_SUCCESS | The periodic interrupt rate was successfully set. |
FSP_ERR_ASSERTION | Invalid input argument. |
FSP_ERR_NOT_OPEN | Driver not open already for operation. |
FSP_ERR_IRQ_BSP_DISABLED | User IRQ parameter not valid |
fsp_err_t R_RTC_ErrorAdjustmentSet | ( | rtc_ctrl_t *const | p_ctrl, |
rtc_error_adjustment_cfg_t const *const | err_adj_cfg | ||
) |
This function sets time error adjustment
Implements rtc_api_t::errorAdjustmentSet
FSP_SUCCESS | Time error adjustment successful. |
FSP_ERR_ASSERTION | Invalid input argument. |
FSP_ERR_NOT_OPEN | Driver not open for operation. |
FSP_ERR_UNSUPPORTED | The clock source is not sub-clock. |
FSP_ERR_INVALID_ARGUMENT | Invalid error adjustment value. |
fsp_err_t R_RTC_InfoGet | ( | rtc_ctrl_t *const | p_ctrl, |
rtc_info_t *const | p_rtc_info | ||
) |
Set RTC clock source and running status information ad store it in provided pointer p_rtc_info
Implements rtc_api_t::infoGet
FSP_SUCCESS | Get information Successful. |
FSP_ERR_ASSERTION | Invalid input argument. |
FSP_ERR_NOT_OPEN | Driver not open already for operation. |
fsp_err_t R_RTC_CallbackSet | ( | rtc_ctrl_t *const | p_ctrl, |
void(*)(rtc_callback_args_t *) | p_callback, | ||
void const *const | p_context, | ||
rtc_callback_args_t *const | p_callback_memory | ||
) |
Updates the user callback and has option of providing memory for callback structure. Implements rtc_api_t::callbackSet
FSP_SUCCESS | Baud rate was successfully changed. |
FSP_ERR_ASSERTION | Pointer to RTC control block is NULL or the RTC is not configured to use the internal clock. |
FSP_ERR_NOT_OPEN | The control block has not been opened |
FSP_ERR_NO_CALLBACK_MEMORY | p_callback is non-secure and p_callback_memory is either secure or NULL. |
fsp_err_t R_RTC_TimeCaptureSet | ( | rtc_ctrl_t *const | p_ctrl, |
rtc_time_capture_t *const | p_time_capture | ||
) |
Set time capture configuration for the provided channel.
Implements rtc_api_t::timeCaptureSet
FSP_SUCCESS | Setting for Time capture was successful. |
FSP_ERR_ASSERTION | Invalid input argument. |
FSP_ERR_NOT_OPEN | Driver not open already for operation. |
FSP_ERR_INVALID_CHANNEL | Invalid input channel set. |
FSP_ERR_UNSUPPORTED | Hardware not support this feature. |
fsp_err_t R_RTC_TimeCaptureGet | ( | rtc_ctrl_t *const | p_ctrl, |
rtc_time_capture_t *const | p_time_capture | ||
) |
Get time capture value of the provided channel.
Implements rtc_api_t::timeCaptureGet
FSP_SUCCESS | Get time capture successful. |
FSP_ERR_ASSERTION | Invalid input argument. |
FSP_ERR_NOT_OPEN | Driver not open already for operation. |
FSP_ERR_INVALID_CHANNEL | Invalid input channel get. |
FSP_ERR_INVALID_STATE | Invalid operation state. |
FSP_ERR_UNSUPPORTED | Hardware not support this feature. |