aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2018-10-14 12:31:41 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2018-10-14 12:31:41 +0000
commitdbf616f8b33d53419b03d95197c5ceec0c3f0351 (patch)
tree0a0afb5db7681f7eac89026fc0770ddb80a6e62f /os/hal/ports/STM32
parent8ec0f1a75387fadd2b0179a02b9f7f81e37b2fe1 (diff)
downloadChibiOS-dbf616f8b33d53419b03d95197c5ceec0c3f0351.tar.gz
ChibiOS-dbf616f8b33d53419b03d95197c5ceec0c3f0351.tar.bz2
ChibiOS-dbf616f8b33d53419b03d95197c5ceec0c3f0351.zip
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
Diffstat (limited to 'os/hal/ports/STM32')
-rw-r--r--os/hal/ports/STM32/LLD/RTCv1/hal_rtc_lld.h51
-rw-r--r--os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.c71
-rw-r--r--os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.h45
3 files changed, 19 insertions, 148 deletions
diff --git a/os/hal/ports/STM32/LLD/RTCv1/hal_rtc_lld.h b/os/hal/ports/STM32/LLD/RTCv1/hal_rtc_lld.h
index 98f750dc7..1903af378 100644
--- a/os/hal/ports/STM32/LLD/RTCv1/hal_rtc_lld.h
+++ b/os/hal/ports/STM32/LLD/RTCv1/hal_rtc_lld.h
@@ -85,23 +85,11 @@
/*===========================================================================*/
/**
- * @brief FileStream specific methods.
- */
-#define _rtc_driver_methods \
- _file_stream_methods
-
-/**
* @brief Type of a structure representing an RTC alarm time stamp.
*/
typedef struct RTCAlarm RTCAlarm;
/**
- * @brief Type of an RTC alarm.
- * @details Meaningful on platforms with more than 1 alarm comparator.
- */
-typedef uint32_t rtcalarm_t;
-
-/**
* @brief Type of an RTC event.
*/
typedef enum {
@@ -125,36 +113,14 @@ struct RTCAlarm {
uint32_t tv_sec;
};
-#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.
+ * @brief Implementation-specific @p RTCDriver fields.
*/
-struct RTCDriver{
-#if RTC_HAS_STORAGE || defined(__DOXYGEN__)
- /**
- * @brief Virtual Methods Table.
- */
- const struct RTCDriverVMT *vmt;
-#endif
- /**
- * @brief Pointer to the RTC registers block.
- */
- RTC_TypeDef *rtc;
- /**
- * @brief Callback pointer.
- */
+#define _rtc_lld_driver_fields \
+ /* Pointer to the RTC registers block.*/ \
+ RTC_TypeDef *rtc; \
+ /* Callback pointer.*/ \
rtccb_t callback;
-};
/*===========================================================================*/
/* Driver macros. */
@@ -164,13 +130,6 @@ struct RTCDriver{
/* External declarations. */
/*===========================================================================*/
-#if !defined(__DOXYGEN__)
-extern RTCDriver RTCD1;
-#if RTC_HAS_STORAGE
-extern struct RTCDriverVMT _rtc_lld_vmt;
-#endif
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.c b/os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.c
index 547b9e98c..19ed93e14 100644
--- a/os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.c
+++ b/os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.c
@@ -199,86 +199,37 @@ static uint32_t rtc_encode_date(const RTCDateTime *timespec) {
return dr;
}
-#if RTC_HAS_STORAGE
+#if RTC_HAS_STORAGE == TRUE
/* TODO: Map on the backup SRAM on devices that have it.*/
-static size_t _write(void *instance, const uint8_t *bp, size_t n) {
+static size_t _read(void *instance, ps_offset_t offset,
+ size_t n, uint8_t *rp) {
(void)instance;
- (void)bp;
+ (void)offset;
(void)n;
+ (void)rp;
return 0;
}
-static size_t _read(void *instance, uint8_t *bp, size_t n) {
+static ps_error_t _write(void *instance, ps_offset_t offset,
+ size_t n, const uint8_t *wp) {
(void)instance;
- (void)bp;
+ (void)offset;
(void)n;
+ (void)wp;
return 0;
}
-static msg_t _put(void *instance, uint8_t b) {
-
- (void)instance;
- (void)b;
-
- return FILE_OK;
-}
-
-static msg_t _get(void *instance) {
-
- (void)instance;
-
- return FILE_OK;
-}
-
-static msg_t _close(void *instance) {
-
- /* Close is not supported.*/
- (void)instance;
-
- return FILE_OK;
-}
-
-static msg_t _geterror(void *instance) {
-
- (void)instance;
-
- return (msg_t)0;
-}
-
-static msg_t _getsize(void *instance) {
-
- (void)instance;
-
- return 0;
-}
-
-static msg_t _getposition(void *instance) {
-
- (void)instance;
-
- return 0;
-}
-
-static msg_t _lseek(void *instance, fileoffset_t offset) {
-
- (void)instance;
- (void)offset;
-
- return FILE_OK;
-}
-
/**
* @brief VMT for the RTC storage file interface.
*/
struct RTCDriverVMT _rtc_lld_vmt = {
- _write, _read, _put, _get,
- _close, _geterror, _getsize, _getposition, _lseek
+ _getsize, _read, _write
};
-#endif /* RTC_HAS_STORAGE */
+#endif /* RTC_HAS_STORAGE == TRUE */
/*===========================================================================*/
/* Driver interrupt handlers. */
diff --git a/os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.h b/os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.h
index 51b3244d5..e6dbcbefd 100644
--- a/os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.h
+++ b/os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.h
@@ -134,17 +134,6 @@
/*===========================================================================*/
/**
- * @brief FileStream specific methods.
- */
-#define _rtc_driver_methods \
- _file_stream_methods
-
-/**
- * @brief Type of an RTC alarm number.
- */
-typedef uint32_t rtcalarm_t;
-
-/**
* @brief Type of a structure representing an RTC alarm time stamp.
*/
typedef struct {
@@ -168,33 +157,12 @@ typedef struct {
} RTCWakeup;
#endif
-#if RTC_HAS_STORAGE || defined(__DOXYGEN__)
/**
- * @extends FileStream
- *
- * @brief @p RTCDriver virtual methods table.
+ * @brief Implementation-specific @p RTCDriver fields.
*/
-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
- /* End of the mandatory fields.*/
- /**
- * @brief Pointer to the RTC registers block.
- */
+#define _rtc_lld_driver_fields \
+ /* Pointer to the RTC registers block.*/ \
RTC_TypeDef *rtc;
-};
/*===========================================================================*/
/* Driver macros. */
@@ -204,13 +172,6 @@ struct RTCDriver {
/* External declarations. */
/*===========================================================================*/
-#if !defined(__DOXYGEN__)
-extern RTCDriver RTCD1;
-#if RTC_HAS_STORAGE
-extern struct RTCDriverVMT _rtc_lld_vmt;
-#endif
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif