aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-11-27 15:07:26 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-11-27 15:07:26 +0000
commite40082e1d66e963a16ef36ad2231dd40b56bdf7c (patch)
treedf6ff561cedc5c66ffaf6416f6ac9bd65b2b7d28 /os/hal/ports
parent5e580ea5724dda947be738bf22f1f47adfb6feee (diff)
downloadChibiOS-e40082e1d66e963a16ef36ad2231dd40b56bdf7c.tar.gz
ChibiOS-e40082e1d66e963a16ef36ad2231dd40b56bdf7c.tar.bz2
ChibiOS-e40082e1d66e963a16ef36ad2231dd40b56bdf7c.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7543 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/ports')
-rw-r--r--os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c3
-rw-r--r--os/hal/ports/STM32/LLD/RTCv1/rtc_lld.h51
-rw-r--r--os/hal/ports/STM32/LLD/RTCv2/rtc_lld.c81
-rw-r--r--os/hal/ports/STM32/LLD/RTCv2/rtc_lld.h36
4 files changed, 155 insertions, 16 deletions
diff --git a/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c b/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c
index 87fc6b763..1d02c353b 100644
--- a/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c
+++ b/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.c
@@ -204,6 +204,9 @@ void rtc_lld_set_prescaler(void) {
*/
void rtc_lld_init(void) {
+ /* RTC object initialization.*/
+ rtcObjectInit(&RTCD1);
+
/* RTC pointer initialization.*/
RTCD1.rtc = RTC;
diff --git a/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.h b/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.h
index 0685ef6bc..7a3ec6eec 100644
--- a/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.h
+++ b/os/hal/ports/STM32/LLD/RTCv1/rtc_lld.h
@@ -36,6 +36,9 @@
/*===========================================================================*/
/**
+ * @name Implementation capabilities
+ */
+/**
* @brief This RTC implementation supports callbacks.
*/
#define RTC_SUPPORTS_CALLBACKS TRUE
@@ -45,6 +48,12 @@
*/
#define RTC_ALARMS 1
+/**
+ * @brief Presence of a local persistent storage.
+ */
+#define RTC_HAS_STORAGE FALSE
+/** @} */
+
/*===========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
@@ -76,14 +85,15 @@
/*===========================================================================*/
/**
- * @brief Type of a structure representing an RTC alarm time stamp.
+ * @brief FileStream specific methods.
*/
-typedef struct RTCAlarm RTCAlarm;
+#define _rtc_driver_methods \
+ _file_stream_methods
/**
- * @brief Type of a structure representing an RTC callbacks config.
+ * @brief Type of a structure representing an RTC alarm time stamp.
*/
-typedef struct RTCCallbackConfig RTCCallbackConfig;
+typedef struct RTCAlarm RTCAlarm;
/**
* @brief Type of an RTC alarm.
@@ -106,16 +116,6 @@ typedef enum {
typedef void (*rtccb_t)(RTCDriver *rtcp, rtcevent_t event);
/**
- * @brief Structure representing an RTC callbacks config.
- */
-struct RTCCallbackConfig{
- /**
- * @brief Generic RTC callback pointer.
- */
- rtccb_t callback;
-};
-
-/**
* @brief Structure representing an RTC alarm time stamp.
*/
struct RTCAlarm {
@@ -125,17 +125,33 @@ 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.
*/
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.
+ * @brief Callback pointer.
*/
rtccb_t callback;
};
@@ -150,6 +166,9 @@ struct RTCDriver{
#if !defined(__DOXYGEN__)
extern RTCDriver RTCD1;
+#if RTC_HAS_STORAGE
+extern struct RTCDriverVMT _rtc_lld_vmt;
+#endif
#endif
#ifdef __cplusplus
diff --git a/os/hal/ports/STM32/LLD/RTCv2/rtc_lld.c b/os/hal/ports/STM32/LLD/RTCv2/rtc_lld.c
index 6e706e3c8..563e5ecc6 100644
--- a/os/hal/ports/STM32/LLD/RTCv2/rtc_lld.c
+++ b/os/hal/ports/STM32/LLD/RTCv2/rtc_lld.c
@@ -197,6 +197,84 @@ static uint32_t rtc_encode_date(const RTCDateTime *timespec) {
return dr;
}
+static size_t _write(void *instance, const uint8_t *bp, size_t n) {
+
+ (void)instance;
+ (void)bp;
+ (void)n;
+
+ return 0;
+}
+
+static size_t _read(void *instance, uint8_t *bp, size_t n) {
+
+ (void)instance;
+ (void)bp;
+ (void)n;
+
+ 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
+};
+
/*===========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
@@ -212,6 +290,9 @@ static uint32_t rtc_encode_date(const RTCDateTime *timespec) {
*/
void rtc_lld_init(void) {
+ /* RTC object initialization.*/
+ rtcObjectInit(&RTCD1);
+
/* RTC pointer initialization.*/
RTCD1.rtc = RTC;
diff --git a/os/hal/ports/STM32/LLD/RTCv2/rtc_lld.h b/os/hal/ports/STM32/LLD/RTCv2/rtc_lld.h
index 2c6c5509b..6d86f68a5 100644
--- a/os/hal/ports/STM32/LLD/RTCv2/rtc_lld.h
+++ b/os/hal/ports/STM32/LLD/RTCv2/rtc_lld.h
@@ -36,6 +36,9 @@
/*===========================================================================*/
/**
+ * @name Implementation capabilities
+ */
+/**
* @brief Callback support int the driver.
*/
#define RTC_SUPPORTS_CALLBACKS STM32_RTC_HAS_INTERRUPTS
@@ -46,6 +49,12 @@
#define RTC_ALARMS STM32_RTC_NUM_ALARMS
/**
+ * @brief Presence of a local persistent storage.
+ */
+#define RTC_HAS_STORAGE TRUE
+/** @} */
+
+/**
* @brief RTC PRER register initializer.
*/
#define RTC_PRER(a, s) ((((a) - 1) << 16) | ((s) - 1))
@@ -123,6 +132,12 @@
/*===========================================================================*/
/**
+ * @brief FileStream specific methods.
+ */
+#define _rtc_driver_methods \
+ _file_stream_methods
+
+/**
* @brief Type of an RTC alarm number.
*/
typedef uint32_t rtcalarm_t;
@@ -150,10 +165,28 @@ typedef struct {
} RTCWakeup;
#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
+ /* End of the mandatory fields.*/
/**
* @brief Pointer to the RTC registers block.
*/
@@ -170,6 +203,9 @@ struct RTCDriver {
#if !defined(__DOXYGEN__)
extern RTCDriver RTCD1;
+#if RTC_HAS_STORAGE
+extern struct RTCDriverVMT _rtc_lld_vmt;
+#endif
#endif
#ifdef __cplusplus