RTC
These APIs allow you to perform operations such as reading or writing system time, reading or writing alarm time, setting alarm interrupts, registering alarm callbacks, setting the external frequency, resetting the RTC driver, and customizing RTC configurations. The RTC driver provides precise real time for the operating system (OS). If the OS is powered off, the RTC driver continues to keep track of the system time using an external battery.
Since:
1.0
Summary
Files
Data Structures
Typedefs
RtcAlarmCallback) (enum ) |
Defines a callback that will be invoked when an alarm is generated at the specified time. |
Enumerations
RtcAlarmIndex { = 0, RTC_ALARM_INDEX_B = 1 } |
Functions
struct DevHandle |
|
(struct DevHandle handle) |
|
RtcWriteAlarm (struct handle, enum RtcAlarmIndex alarmIndex, const struct time) |
|
(struct DevHandle handle, enum alarmIndex, RtcAlarmCallback cb) |
Registers that will be invoked when an alarm is generated at the specified time. |
RtcAlarmInterruptEnable (struct handle, enum RtcAlarmIndex alarmIndex, uint8_t enable) |
|
(struct DevHandle handle, uint32_t freq) |
|
(struct DevHandle handle, uint32_t freq) |
Sets the frequency of the external crystal oscillator connected to the RTC driver. |
(struct DevHandle handle) |
|
Reads the configuration of a custom RTC register based on the register index. |
|
(struct DevHandle *handle, uint8_t usrDefIndex, uint8_t value) |
Writes the configuration of a custom RTC register based on the register index. |
Details
RtcAlarmCallback
Description:
Defines a callback that will be invoked when an alarm is generated at the specified time.
Enumeration Type Documentation
RtcAlarmIndex
Description:
Enumerates alarm indexes.
The alarm indexes will be used when you perform operations related to alarms.
RTC_ALARM_INDEX_A | |
RTC_ALARM_INDEX_B |
Function Documentation
RtcAlarmInterruptEnable()
int32_t RtcAlarmInterruptEnable (struct [DevHandle]($api-api-SmartVision-Devices-DevHandle.md) * handle, enum [RtcAlarmIndex]($api-api-SmartVision-Devices-RTC.md#gad7b3a575c848e2669db5e5b6f7e74330) alarmIndex, uint8_t enable )
Description:
Enables or disables alarm interrupts.
Before performing alarm operations, you need to call this function to enable alarm interrupts, so that the RtcRegisterAlarmCallback will be called when the alarm is not generated upon a timeout.
Parameters:
Returns:
Returns 0 if the operation is successful; returns a negative value if the operation fails. For details, see HDF_STATUS.
RtcClose()
void RtcClose (struct [DevHandle]($api-api-SmartVision-Devices-DevHandle.md) * handle)
Description:
Releases a specified handle of the RTC device.
Parameters:
handle | Indicates the pointer to the RTC device handle to release, which is created via RtcGetHandle. |
RtcGetFreq()
int32_t RtcGetFreq (struct [DevHandle]($api-api-SmartVision-Devices-DevHandle.md) * handle, uint32_t * freq )
Description:
Reads the RTC external frequency.
This function reads the frequency of the external crystal oscillator connected to the RTC driver.
Parameters:
handle | Indicates the pointer to the RTC device handle, which is obtained via RtcGetHandle. |
freq | Indicates the pointer to the frequency of the external crystal oscillator, in Hz. |
Returns:
Returns 0 if the operation is successful; returns a negative value if the operation fails. For details, see .
Description:
Opens the RTC device to obtain its handle.
The OS supports only one RTC device.
Returns:
Returns DevHandle if the operation is successful; returns NULL if the operation fails.
RtcReadAlarm()
Description:
Reads the RTC alarm time that was set last time.
Parameters:
handle | Indicates the pointer to the RTC device handle, which is obtained via RtcGetHandle. |
alarmIndex | Indicates the RTC alarm index. For details, see . |
time | Indicates the pointer to the RTC alarm time information. For details, see RtcTime. |
Returns:
Returns 0 if the operation is successful; returns a negative value if the operation fails. For details, see .
RtcReadReg()
int32_t RtcReadReg (struct [DevHandle]($api-api-SmartVision-Devices-DevHandle.md) * handle, uint8_t usrDefIndex, uint8_t * value )
Description:
Reads the configuration of a custom RTC register based on the register index.
One index corresponds to one byte of the configuration value.
Parameters:
Returns:
RtcReadTime()
int32_t RtcReadTime (struct [DevHandle]($api-api-SmartVision-Devices-DevHandle.md) * handle, struct [RtcTime]($api-api-SmartVision-Devices-RtcTime.md) * time )
Description:
Reads time from the RTC driver.
The time information includes the year, month, day, day of the week, hour, minute, second, and millisecond.
Parameters:
handle | Indicates the pointer to the RTC device handle, which is obtained via RtcGetHandle. |
time | Indicates the pointer to the time information read from the RTC driver. For details, see RtcTime. |
Returns:
Returns 0 if the operation is successful; returns a negative value if the operation fails. For details, see .
RtcRegisterAlarmCallback()
int32_t RtcRegisterAlarmCallback (struct [DevHandle]($api-api-SmartVision-Devices-DevHandle.md) * handle, enum [RtcAlarmIndex]($api-api-SmartVision-Devices-RTC.md#gad7b3a575c848e2669db5e5b6f7e74330) alarmIndex, [RtcAlarmCallback]($api-api-SmartVision-Devices-RTC.md#gaf9932b7e647bce0503f1314bbe5eef8d) cb )
Description:
Registers that will be invoked when an alarm is generated at the specified time.
Parameters:
Returns:
Returns 0 if the operation is successful; returns a negative value if the operation fails. For details, see .
RtcReset()
Description:
Resets the RTC driver.
After the reset, the configuration registers are restored to the default values.
Parameters:
handle | Indicates the pointer to the RTC device handle, which is obtained via RtcGetHandle. |
Returns:
Returns 0 if the operation is successful; returns a negative value if the operation fails. For details, see HDF_STATUS.
RtcSetFreq()
Description:
Sets the frequency of the external crystal oscillator connected to the RTC driver.
Note that the frequency must be configured in accordance with the requirements specified in the product manual of the in-use component.
Parameters:
handle | Indicates the pointer to the RTC device handle, which is obtained via RtcGetHandle. |
freq | Indicates the frequency to set for the external crystal oscillator, in Hz. |
Returns:
Returns 0 if the operation is successful; returns a negative value if the operation fails. For details, see .
RtcWriteAlarm()
int32_t RtcWriteAlarm (struct [DevHandle]($api-api-SmartVision-Devices-DevHandle.md) * handle, enum [RtcAlarmIndex]($api-api-SmartVision-Devices-RTC.md#gad7b3a575c848e2669db5e5b6f7e74330) alarmIndex, const struct [RtcTime]($api-api-SmartVision-Devices-RtcTime.md) * time )
Description:
Writes the RTC alarm time based on the alarm index.
Note that the RTC start time is 1970/01/01 Thursday 00:00:00 (UTC). Set the maximum value of year based on the requirements specified in the product manual of the in-use component.
Parameters:
handle | Indicates the pointer to the RTC device handle, which is obtained via RtcGetHandle. |
alarmIndex | Indicates the RTC alarm index. For details, see RtcAlarmIndex. |
tm | Indicates the pointer to the RTC alarm time information. For details, see . |
Returns:
Returns 0 if the operation is successful; returns a negative value if the operation fails. For details, see HDF_STATUS.
int32_t RtcWriteReg (struct [DevHandle]($api-api-SmartVision-Devices-DevHandle.md) * handle, uint8_t usrDefIndex, uint8_t value )
Description:
Writes the configuration of a custom RTC register based on the register index.
One index corresponds to one byte of the configuration value.
Parameters:
Returns:
Returns 0 if the operation is successful; returns a negative value if the operation fails. For details, see HDF_STATUS.
RtcWriteTime()
int32_t RtcWriteTime (struct [DevHandle]($api-api-SmartVision-Devices-DevHandle.md) * handle, const struct [RtcTime]($api-api-SmartVision-Devices-RtcTime.md) * time )
Description:
Writes format-compliant time to the RTC driver.
Note that the RTC start time is 1970/01/01 Thursday 00:00:00 (UTC). Set the maximum value of year based on the requirements specified in the product manual of the in-use component.
Parameters:
handle | Indicates the pointer to the RTC device handle, which is obtained via RtcGetHandle. |
time | Indicates the pointer to the time information to write. For details, see . |
Returns 0 if the operation is successful; returns a negative value if the operation fails. For details, see HDF_STATUS.