High level interface for interacting with the real-time clock (RTC).
The real time clock provides tracking of the current time and date, as well as the ability to trigger a callback at a specific time in the future.
Initialise the RTC using the PDL. Set the current time and date using mtb_hal_rtc_write.
See Snippet 1: Initialize RTC, write and read current time and date to initialize RTC, read and write current date and time to the RTC peripheral.
The following code sets the current date and time using mtb_hal_rtc_write. The current date and time is read from the RTC using mtb_hal_rtc_read. The time structure tm , contains the calendar date and time which are broken down into its components. This structure is declared in standard C library time.h which is included by HAL.
API Reference | |
RTC HAL Results | |
RTC specific return codes. | |
Functions | |
cy_rslt_t | mtb_hal_rtc_read (mtb_hal_rtc_t *obj, struct tm *time) |
Get the current time and date from the RTC peripheral. More... | |
cy_rslt_t | mtb_hal_rtc_write (mtb_hal_rtc_t *obj, const struct tm *time) |
Write the specified time and date to the RTC peripheral. More... | |
cy_rslt_t mtb_hal_rtc_read | ( | mtb_hal_rtc_t * | obj, |
struct tm * | time | ||
) |
Get the current time and date from the RTC peripheral.
[in] | obj | RTC object |
[out] | time | The current time (see: https://en.cppreference.com/w/cpp/chrono/c/tm) |
cy_rslt_t mtb_hal_rtc_write | ( | mtb_hal_rtc_t * | obj, |
const struct tm * | time | ||
) |
Write the specified time and date to the RTC peripheral.
[in] | obj | RTC object |
[in] | time | The time to be set (see: https://en.cppreference.com/w/cpp/chrono/c/tm). Specify the local time to set to the RTC. |