From dbf616f8b33d53419b03d95197c5ceec0c3f0351 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sun, 14 Oct 2018 12:31:41 +0000 Subject: Changes to the RTC driver to use the persistent storage interface, git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12366 110e8d01-0319-4d1e-a829-52ad28d1bb01 --- os/hal/include/hal_rtc.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'os/hal/include/hal_rtc.h') diff --git a/os/hal/include/hal_rtc.h b/os/hal/include/hal_rtc.h index 63a916b22..342d61815 100644 --- a/os/hal/include/hal_rtc.h +++ b/os/hal/include/hal_rtc.h @@ -87,6 +87,11 @@ */ typedef struct RTCDriver RTCDriver; +/** + * @brief Type of an RTC alarm number. + */ +typedef unsigned int rtcalarm_t; + /** * @brief Type of a structure representing an RTC date/time stamp. */ @@ -101,8 +106,56 @@ typedef struct { /*lint -restore*/ } RTCDateTime; +/** + * @brief BasePersistentStorage specific methods. + */ +#define _rtc_driver_methods \ + _base_persistent_storage_methods + #include "hal_rtc_lld.h" +/* Some more checks, must happen after inclusion of the LLD header, this is + why are placed here.*/ +#if !defined(RTC_SUPPORTS_CALLBACKS) +#error "RTC LLD does not define the required RTC_SUPPORTS_CALLBACKS macro" +#endif + +#if !defined(RTC_ALARMS) +#error "RTC LLD does not define the required RTC_ALARMS macro" +#endif + +#if !defined(RTC_HAS_STORAGE) +#error "RTC LLD does not define the required RTC_HAS_STORAGE macro" +#endif + +#if RTC_HAS_STORAGE || defined(__DOXYGEN__) +/** + * @extends FileStream + * + * @brief @p RTCDriver virtual methods table. + */ +struct RTCDriverVMT { + _rtc_driver_methods +}; +#endif + +/** + * @brief Structure representing an RTC driver. + */ +struct RTCDriver { +#if RTC_HAS_STORAGE || defined(__DOXYGEN__) + /** + * @brief Virtual Methods Table. + */ + const struct RTCDriverVMT *vmt; +#endif +#if defined(RTC_DRIVER_EXT_FIELDS) + RTC_DRIVER_EXT_FIELDS +#endif + /* End of the mandatory fields.*/ + _rtc_lld_driver_fields +}; + /*===========================================================================*/ /* Driver macros. */ /*===========================================================================*/ @@ -111,6 +164,13 @@ typedef struct { /* External declarations. */ /*===========================================================================*/ +#if !defined(__DOXYGEN__) +extern RTCDriver RTCD1; +#if RTC_HAS_STORAGE == TRUE +extern struct RTCDriverVMT _rtc_lld_vmt; +#endif +#endif + #ifdef __cplusplus extern "C" { #endif -- cgit v1.2.3