ChibiOS/HAL
6.1.0
|
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
. Macros | |
#define | RTC_BASE_YEAR 1980U |
Base year of the calendar. More... | |
#define | _rtc_driver_methods _file_stream_methods |
FileStream specific methods. More... | |
Implementation capabilities | |
#define | RTC_SUPPORTS_CALLBACKS TRUE |
Callback support int the driver. More... | |
#define | RTC_ALARMS 2 |
Number of alarms available. More... | |
#define | RTC_HAS_STORAGE FALSE |
Presence of a local persistent storage. More... | |
PLATFORM configuration options | |
#define | PLATFORM_RTC_USE_RTC1 FALSE |
RTCD1 driver enable switch. More... | |
Typedefs | |
typedef struct RTCDriver | RTCDriver |
Type of a structure representing an RTC driver. More... | |
typedef uint32_t | rtcalarm_t |
Type of an RTC alarm number. More... | |
typedef void(* | rtccb_t) (RTCDriver *rtcp, rtcevent_t event) |
Type of a generic RTC callback. More... | |
Data Structures | |
struct | RTCDateTime |
Type of a structure representing an RTC date/time stamp. More... | |
struct | RTCAlarm |
Type of a structure representing an RTC alarm time stamp. More... | |
struct | RTCDriverVMT |
RTCDriver virtual methods table. More... | |
struct | RTCDriver |
Structure representing an RTC driver. More... | |
Functions | |
void | rtcInit (void) |
RTC Driver initialization. More... | |
void | rtcObjectInit (RTCDriver *rtcp) |
Initializes a generic RTC driver object. More... | |
void | rtcSetTime (RTCDriver *rtcp, const RTCDateTime *timespec) |
Set current time. More... | |
void | rtcGetTime (RTCDriver *rtcp, RTCDateTime *timespec) |
Get current time. More... | |
void | rtcSetAlarm (RTCDriver *rtcp, rtcalarm_t alarm, const RTCAlarm *alarmspec) |
Set alarm time. More... | |
void | rtcGetAlarm (RTCDriver *rtcp, rtcalarm_t alarm, RTCAlarm *alarmspec) |
Get current alarm. More... | |
void | rtcSetCallback (RTCDriver *rtcp, rtccb_t callback) |
Enables or disables RTC callbacks. More... | |
void | rtcConvertDateTimeToStructTm (const RTCDateTime *timespec, struct tm *timp, uint32_t *tv_msec) |
Convert RTCDateTime to broken-down time structure. More... | |
void | rtcConvertStructTmToDateTime (const struct tm *timp, uint32_t tv_msec, RTCDateTime *timespec) |
Convert broken-down time structure to RTCDateTime . More... | |
uint32_t | rtcConvertDateTimeToFAT (const RTCDateTime *timespec) |
Get current time in format suitable for usage in FAT file system. More... | |
void | rtc_lld_init (void) |
RTC driver identifier. More... | |
void | rtc_lld_set_time (RTCDriver *rtcp, const RTCDateTime *timespec) |
Set current time. More... | |
void | rtc_lld_get_time (RTCDriver *rtcp, RTCDateTime *timespec) |
Get current time. More... | |
void | rtc_lld_set_alarm (RTCDriver *rtcp, rtcalarm_t alarm, const RTCAlarm *alarmspec) |
Set alarm time. More... | |
void | rtc_lld_get_alarm (RTCDriver *rtcp, rtcalarm_t alarm, RTCAlarm *alarmspec) |
Get alarm time. More... | |
Enumerations |
#define RTC_SUPPORTS_CALLBACKS TRUE |
Callback support int the driver.
Definition at line 44 of file hal_rtc_lld.h.
#define RTC_ALARMS 2 |
Number of alarms available.
Definition at line 49 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 54 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 71 of file hal_rtc_lld.h.
#define _rtc_driver_methods _file_stream_methods |
FileStream specific methods.
Definition at line 86 of file hal_rtc_lld.h.
typedef uint32_t rtcalarm_t |
Type of an RTC alarm number.
Definition at line 92 of file hal_rtc_lld.h.
typedef void(* rtccb_t) (RTCDriver *rtcp, rtcevent_t event) |
Type of a generic RTC callback.
Definition at line 105 of file hal_rtc_lld.h.
enum rtcevent_t |
Type of an RTC event.
Definition at line 98 of file hal_rtc_lld.h.
void rtcInit | ( | void | ) |
RTC Driver initialization.
halInit()
, there is no need to explicitly initialize the driver.Definition at line 67 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 81 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 104 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 125 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 148 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 174 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 203 of file hal_rtc.c.
References osalDbgCheck.
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 220 of file hal_rtc.c.
References RTCDateTime::day, RTCDateTime::dayofweek, RTCDateTime::dstflag, RTCDateTime::millisecond, RTCDateTime::month, 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 251 of file hal_rtc.c.
References RTCDateTime::day, RTCDateTime::dayofweek, RTCDateTime::dstflag, RTCDateTime::millisecond, RTCDateTime::month, 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 284 of file hal_rtc.c.
References RTCDateTime::day, RTCDateTime::dstflag, RTCDateTime::millisecond, RTCDateTime::month, 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().