|
ChibiOS 21.11.4
|
Generic RTC Driver. More...
Generic RTC Driver.
This module defines an abstract interface for a Real Time Clock Peripheral.
HAL_USE_RTC option must be enabled in halconf.h.
Date/Time bit masks for FAT format | |
| #define | RTC_FAT_TIME_SECONDS_MASK 0x0000001FU |
| #define | RTC_FAT_TIME_MINUTES_MASK 0x000007E0U |
| #define | RTC_FAT_TIME_HOURS_MASK 0x0000F800U |
| #define | RTC_FAT_DATE_DAYS_MASK 0x001F0000U |
| #define | RTC_FAT_DATE_MONTHS_MASK 0x01E00000U |
| #define | RTC_FAT_DATE_YEARS_MASK 0xFE000000U |
Day of week encoding | |
| #define | RTC_DAY_CATURDAY 0U |
| #define | RTC_DAY_MONDAY 1U |
| #define | RTC_DAY_TUESDAY 2U |
| #define | RTC_DAY_WEDNESDAY 3U |
| #define | RTC_DAY_THURSDAY 4U |
| #define | RTC_DAY_FRIDAY 5U |
| #define | RTC_DAY_SATURDAY 6U |
| #define | RTC_DAY_SUNDAY 7U |
Implementation capabilities | |
| #define | RTC_SUPPORTS_CALLBACKS TRUE |
| Callback support int the driver. | |
| #define | RTC_ALARMS 2 |
| Number of alarms available. | |
| #define | RTC_HAS_STORAGE FALSE |
| Presence of a local persistent storage. | |
PLATFORM configuration options | |
| #define | PLATFORM_RTC_USE_RTC1 FALSE |
| RTCD1 driver enable switch. | |
Data Structures | |
| struct | RTCDateTime |
| Type of a structure representing an RTC date/time stamp. More... | |
| struct | RTCDriverVMT |
RTCDriver virtual methods table. More... | |
| struct | RTCDriver |
| Structure representing an RTC driver. More... | |
| struct | RTCAlarm |
| Type of a structure representing an RTC alarm time stamp. More... | |
Macros | |
| #define | RTC_BASE_YEAR 1980U |
| Base year of the calendar. | |
| #define | _rtc_driver_methods _base_pers_storage_methods |
| BasePersistentStorage specific methods. | |
| #define | rtc_lld_driver_fields uint32_t dummy; |
Implementation-specific RTCDriver fields. | |
Typedefs | |
| typedef struct RTCDriver | RTCDriver |
| Type of a structure representing an RTC driver. | |
| typedef unsigned int | rtcalarm_t |
| Type of an RTC alarm number. | |
| typedef void(* | rtccb_t) (RTCDriver *rtcp, rtcevent_t event) |
| Type of a generic RTC callback. | |
Enumerations | |
| enum | rtcevent_t { RTC_EVENT_SECOND = 0 } |
| Type of an RTC event. More... | |
Functions | |
| void | rtcInit (void) |
| RTC Driver initialization. | |
| void | rtcObjectInit (RTCDriver *rtcp) |
| Initializes a generic RTC driver object. | |
| void | rtcSetTime (RTCDriver *rtcp, const RTCDateTime *timespec) |
| Set current time. | |
| void | rtcGetTime (RTCDriver *rtcp, RTCDateTime *timespec) |
| Get current time. | |
| void | rtcSetAlarm (RTCDriver *rtcp, rtcalarm_t alarm, const RTCAlarm *alarmspec) |
| Set alarm time. | |
| void | rtcGetAlarm (RTCDriver *rtcp, rtcalarm_t alarm, RTCAlarm *alarmspec) |
| Get current alarm. | |
| void | rtcSetCallback (RTCDriver *rtcp, rtccb_t callback) |
| Enables or disables RTC callbacks. | |
| void | rtcConvertDateTimeToStructTm (const RTCDateTime *timespec, struct tm *timp, uint32_t *tv_msec) |
Convert RTCDateTime to broken-down time structure. | |
| void | rtcConvertStructTmToDateTime (const struct tm *timp, uint32_t tv_msec, RTCDateTime *timespec) |
Convert broken-down time structure to RTCDateTime. | |
| uint32_t | rtcConvertDateTimeToFAT (const RTCDateTime *timespec) |
| Get current time in format suitable for usage in FAT file system. | |
| void | rtc_lld_init (void) |
| RTC driver identifier. | |
| void | rtc_lld_set_time (RTCDriver *rtcp, const RTCDateTime *timespec) |
| Set current time. | |
| void | rtc_lld_get_time (RTCDriver *rtcp, RTCDateTime *timespec) |
| Get current time. | |
| void | rtc_lld_set_alarm (RTCDriver *rtcp, rtcalarm_t alarm, const RTCAlarm *alarmspec) |
| Set alarm time. | |
| void | rtc_lld_get_alarm (RTCDriver *rtcp, rtcalarm_t alarm, RTCAlarm *alarmspec) |
| Get alarm time. | |
| void | rtc_lld_set_callback (RTCDriver *rtcp, rtccb_t callback) |
Variables | |
| static const uint8_t | month_len [12] |
| static const uint16_t | accu_month_len [12] |
| #define RTC_BASE_YEAR 1980U |
Base year of the calendar.
Definition at line 45 of file hal_rtc.h.
Referenced by rtcConvertDateTimeToStructTm(), and rtcConvertStructTmToDateTime().
| #define _rtc_driver_methods _base_pers_storage_methods |
BasePersistentStorage specific methods.
| #define RTC_SUPPORTS_CALLBACKS TRUE |
Callback support int the driver.
Definition at line 45 of file hal_rtc_lld.h.
| #define RTC_ALARMS 2 |
Number of alarms available.
Definition at line 50 of file hal_rtc_lld.h.
Referenced by rtcGetAlarm(), and rtcSetAlarm().
| #define RTC_HAS_STORAGE FALSE |
Presence of a local persistent storage.
Definition at line 55 of file hal_rtc_lld.h.
| #define PLATFORM_RTC_USE_RTC1 FALSE |
RTCD1 driver enable switch.
If set to TRUE the support for RTC1 is included.
FALSE. Definition at line 72 of file hal_rtc_lld.h.
| #define rtc_lld_driver_fields uint32_t dummy; |
Implementation-specific RTCDriver fields.
Definition at line 109 of file hal_rtc_lld.h.
| typedef struct RTCDriver RTCDriver |
| typedef unsigned int rtcalarm_t |
| typedef void(* rtccb_t) (RTCDriver *rtcp, rtcevent_t event) |
Type of a generic RTC callback.
Definition at line 95 of file hal_rtc_lld.h.
| enum rtcevent_t |
| void rtcInit | ( | void | ) |
RTC Driver initialization.
halInit(), there is no need to explicitly initialize the driver.Definition at line 71 of file hal_rtc.c.
References rtc_lld_init().
Referenced by halInit().

| void rtcObjectInit | ( | RTCDriver * | rtcp | ) |
Initializes a generic RTC driver object.
The HW dependent part of the initialization has to be performed outside, usually in the hardware initialization code.
| [out] | rtcp | pointer to RTC driver structure |
Definition at line 85 of file hal_rtc.c.
References RTCDriver::vmt.
Referenced by rtc_lld_init().
| void rtcSetTime | ( | RTCDriver * | rtcp, |
| const RTCDateTime * | timespec ) |
Set current time.
| [in] | rtcp | pointer to RTC driver structure |
| [in] | timespec | pointer to a RTCDateTime structure |
Definition at line 108 of file hal_rtc.c.
References osalDbgCheck, and rtc_lld_set_time().

| void rtcGetTime | ( | RTCDriver * | rtcp, |
| RTCDateTime * | timespec ) |
Get current time.
| [in] | rtcp | pointer to RTC driver structure |
| [out] | timespec | pointer to a RTCDateTime structure |
Definition at line 129 of file hal_rtc.c.
References osalDbgCheck, and rtc_lld_get_time().

| void rtcSetAlarm | ( | RTCDriver * | rtcp, |
| rtcalarm_t | alarm, | ||
| const RTCAlarm * | alarmspec ) |
Set alarm time.
| [in] | rtcp | pointer to RTC driver structure |
| [in] | alarm | alarm identifier |
| [in] | alarmspec | pointer to a RTCAlarm structure or NULL |
Definition at line 152 of file hal_rtc.c.
References osalDbgCheck, RTC_ALARMS, and rtc_lld_set_alarm().

| void rtcGetAlarm | ( | RTCDriver * | rtcp, |
| rtcalarm_t | alarm, | ||
| RTCAlarm * | alarmspec ) |
Get current alarm.
| [in] | rtcp | pointer to RTC driver structure |
| [in] | alarm | alarm identifier |
| [out] | alarmspec | pointer to a RTCAlarm structure |
Definition at line 178 of file hal_rtc.c.
References osalDbgCheck, RTC_ALARMS, and rtc_lld_get_alarm().

Enables or disables RTC callbacks.
This function enables or disables the callback, use a NULL pointer in order to disable it.
| [in] | rtcp | pointer to RTC driver structure |
| [in] | callback | callback function pointer or NULL |
Definition at line 207 of file hal_rtc.c.
References osalDbgCheck, and rtc_lld_set_callback().

| void rtcConvertDateTimeToStructTm | ( | const RTCDateTime * | timespec, |
| struct tm * | timp, | ||
| uint32_t * | tv_msec ) |
Convert RTCDateTime to broken-down time structure.
| [in] | timespec | pointer to a RTCDateTime structure |
| [out] | timp | pointer to a broken-down time structure |
| [out] | tv_msec | pointer to milliseconds value or NULL |
Definition at line 224 of file hal_rtc.c.
References accu_month_len, RTCDateTime::day, RTCDateTime::dayofweek, RTCDateTime::dstflag, RTCDateTime::millisecond, RTCDateTime::month, RTC_BASE_YEAR, and RTCDateTime::year.
| void rtcConvertStructTmToDateTime | ( | const struct tm * | timp, |
| uint32_t | tv_msec, | ||
| RTCDateTime * | timespec ) |
Convert broken-down time structure to RTCDateTime.
| [in] | timp | pointer to a broken-down time structure |
| [in] | tv_msec | milliseconds value |
| [out] | timespec | pointer to a RTCDateTime structure |
Definition at line 265 of file hal_rtc.c.
References RTCDateTime::day, RTCDateTime::dayofweek, RTCDateTime::dstflag, RTCDateTime::millisecond, RTCDateTime::month, RTC_BASE_YEAR, and RTCDateTime::year.
| uint32_t rtcConvertDateTimeToFAT | ( | const RTCDateTime * | timespec | ) |
Get current time in format suitable for usage in FAT file system.
| [out] | timespec | pointer to a RTCDateTime structure |
Definition at line 299 of file hal_rtc.c.
References RTCDateTime::day, RTCDateTime::dstflag, RTCDateTime::millisecond, RTCDateTime::month, month_len, and RTCDateTime::year.
| void rtc_lld_init | ( | void | ) |
RTC driver identifier.
Enable access to registers.
Definition at line 69 of file hal_rtc_lld.c.
References rtcObjectInit().
Referenced by rtcInit().

| void rtc_lld_set_time | ( | RTCDriver * | rtcp, |
| const RTCDateTime * | timespec ) |
Set current time.
| [in] | rtcp | pointer to RTC driver structure |
| [in] | timespec | pointer to a RTCDateTime structure |
Definition at line 88 of file hal_rtc_lld.c.
Referenced by rtcSetTime().
| void rtc_lld_get_time | ( | RTCDriver * | rtcp, |
| RTCDateTime * | timespec ) |
Get current time.
| [in] | rtcp | pointer to RTC driver structure |
| [out] | timespec | pointer to a RTCDateTime structure |
Definition at line 103 of file hal_rtc_lld.c.
Referenced by rtcGetTime().
| void rtc_lld_set_alarm | ( | RTCDriver * | rtcp, |
| rtcalarm_t | alarm, | ||
| const RTCAlarm * | alarmspec ) |
Set alarm time.
| [in] | rtcp | pointer to RTC driver structure. |
| [in] | alarm | alarm identifier. Can be 1 or 2. |
| [in] | alarmspec | pointer to a RTCAlarm structure. |
Definition at line 122 of file hal_rtc_lld.c.
Referenced by rtcSetAlarm().
| void rtc_lld_get_alarm | ( | RTCDriver * | rtcp, |
| rtcalarm_t | alarm, | ||
| RTCAlarm * | alarmspec ) |
Get alarm time.
| [in] | rtcp | pointer to RTC driver structure |
| [in] | alarm | alarm identifier |
| [out] | alarmspec | pointer to a RTCAlarm structure |
Definition at line 141 of file hal_rtc_lld.c.
Referenced by rtcGetAlarm().
Referenced by rtcSetCallback().
|
static |
Definition at line 48 of file hal_rtc.c.
Referenced by rtcConvertDateTimeToFAT().
|
static |
Definition at line 52 of file hal_rtc.c.
Referenced by rtcConvertDateTimeToStructTm().