diff options
author | edolomb <edolomb@110e8d01-0319-4d1e-a829-52ad28d1bb01> | 2018-04-11 16:50:54 +0000 |
---|---|---|
committer | edolomb <edolomb@110e8d01-0319-4d1e-a829-52ad28d1bb01> | 2018-04-11 16:50:54 +0000 |
commit | c53c5b7e022f73056dc3d7c6284f6988c4f83d5d (patch) | |
tree | b1a8254b2e0cf770565f18d4b4e33ed0d6e6e4b7 | |
parent | 8bd7edf5f571a97ab1cc69072993a65321bcfc22 (diff) | |
download | ChibiOS-c53c5b7e022f73056dc3d7c6284f6988c4f83d5d.tar.gz ChibiOS-c53c5b7e022f73056dc3d7c6284f6988c4f83d5d.tar.bz2 ChibiOS-c53c5b7e022f73056dc3d7c6284f6988c4f83d5d.zip |
Updated demo and chconf.h
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11899 110e8d01-0319-4d1e-a829-52ad28d1bb01
-rw-r--r-- | testhal/ATSAMA5D2/RTC/chconf.h | 9 | ||||
-rw-r--r-- | testhal/ATSAMA5D2/RTC/main.c | 40 |
2 files changed, 42 insertions, 7 deletions
diff --git a/testhal/ATSAMA5D2/RTC/chconf.h b/testhal/ATSAMA5D2/RTC/chconf.h index b1e3841a8..4dbf9c6d8 100644 --- a/testhal/ATSAMA5D2/RTC/chconf.h +++ b/testhal/ATSAMA5D2/RTC/chconf.h @@ -49,7 +49,8 @@ * @details Frequency of the system timer that drives the system ticks. This
* setting also defines the system tick time unit.
*/
-#define CH_CFG_ST_FREQUENCY 1000
+#define CH_CFG_ST_FREQUENCY 1000 /* periodic tick. */
+//#define CH_CFG_ST_FREQUENCY (83000000 / 32) /* tick-less. */
/**
* @brief Time intervals data size.
@@ -400,7 +401,7 @@ *
* @note The default is @p FALSE.
*/
-#define CH_DBG_SYSTEM_STATE_CHECK FALSE
+#define CH_DBG_SYSTEM_STATE_CHECK TRUE
/**
* @brief Debug option, parameters checks.
@@ -409,7 +410,7 @@ *
* @note The default is @p FALSE.
*/
-#define CH_DBG_ENABLE_CHECKS FALSE
+#define CH_DBG_ENABLE_CHECKS TRUE
/**
* @brief Debug option, consistency checks.
@@ -419,7 +420,7 @@ *
* @note The default is @p FALSE.
*/
-#define CH_DBG_ENABLE_ASSERTS FALSE
+#define CH_DBG_ENABLE_ASSERTS TRUE
/**
* @brief Debug option, trace buffer.
diff --git a/testhal/ATSAMA5D2/RTC/main.c b/testhal/ATSAMA5D2/RTC/main.c index 49865e6d3..d75ed1caa 100644 --- a/testhal/ATSAMA5D2/RTC/main.c +++ b/testhal/ATSAMA5D2/RTC/main.c @@ -20,15 +20,18 @@ #include "string.h"
#include <time.h>
+/* This macro converts from decimal to BCD */
+#define decimal2BCD(nt, nu) ((nt << 4) | (nu))
+
#define SIZE 30
RTCDateTime cfg_time = {
38,
- 2,
+ 4,
0,
1,
- 26,
- 46824000
+ 9,
+ 66840000
};
RTCDateTime now_DateTime;
@@ -36,6 +39,35 @@ struct tm now_tm; char buffer[SIZE];
+/*
+ * Alarm configuration.
+ * Fields are in BCD format
+ */
+RTCAlarm alarmspec = {
+ RTC_TIMALR_HOUREN | RTC_TIMALR_HOUR(decimal2BCD(1,8)) |
+ RTC_TIMALR_MINEN | RTC_TIMALR_MIN(decimal2BCD(3,5)) , /* timalarm */
+ 0 /* calalarm */
+};
+
+/*
+ * Alarm callback.
+ */
+static void alarm_cb(RTCDriver *rtcp, rtcevent_t event) {
+
+ (void)rtcp;
+
+ switch (event) {
+ case RTC_EVENT_SECOND:
+ /* Toggle Led green very second */
+ palToggleLine(LINE_LED_GREEN);
+ break;
+ case RTC_EVENT_ALARM:
+ /* Led red on alarm */
+ palClearLine(LINE_LED_RED);
+ break;
+ }
+}
+
static const SerialConfig sdcfg = {
115200,
0,
@@ -83,6 +115,8 @@ int main(void) { * Configures date
*/
rtcSetTime(&RTCD0, &cfg_time);
+ rtcSetAlarm(&RTCD0, 0, &alarmspec);
+ rtcSetCallback(&RTCD0, alarm_cb);
while (true) {
if(!palReadPad(PIOB, PIOB_USER_PB)) {
|