diff options
author | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-12-15 15:13:37 +0000 |
---|---|---|
committer | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-12-15 15:13:37 +0000 |
commit | 124a432b0ed05568381f2bf6930a86a767f85ea6 (patch) | |
tree | 48976d38ce75ea535ac1ce361973859836d43a3c | |
parent | 122eecfb5e3360a86695815a7cf59f1bcd6f933f (diff) | |
download | ChibiOS-124a432b0ed05568381f2bf6930a86a767f85ea6.tar.gz ChibiOS-124a432b0ed05568381f2bf6930a86a767f85ea6.tar.bz2 ChibiOS-124a432b0ed05568381f2bf6930a86a767f85ea6.zip |
RTC. Nop.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3614 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r-- | testhal/STM32F4xx/RTC/Makefile | 4 | ||||
-rw-r--r-- | testhal/STM32F4xx/RTC/main.c | 46 |
2 files changed, 31 insertions, 19 deletions
diff --git a/testhal/STM32F4xx/RTC/Makefile b/testhal/STM32F4xx/RTC/Makefile index 34c02d4ff..64c8e9767 100644 --- a/testhal/STM32F4xx/RTC/Makefile +++ b/testhal/STM32F4xx/RTC/Makefile @@ -12,7 +12,7 @@ ifeq ($(USE_OPT),) # If all calls to a given function are integrated, and the function is declared static, then the function is normally not output as assembler code in its own right.
# Enabled at level '-O3'.
- USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
+ USE_OPT = -O0 -ggdb -fomit-frame-pointer # -mhard-float #-falign-functions=16
#USE_OPT = -O1 -ggdb -fomit-frame-pointer -falign-functions=16 -fno-inline
#USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -fno-strict-aliasing
#USE_OPT = -O3 -ggdb -fomit-frame-pointer -falign-functions=16
@@ -41,7 +41,7 @@ endif # Enable this if you want to see the full log while compiling.
ifeq ($(USE_VERBOSE_COMPILE),)
- USE_VERBOSE_COMPILE = no
+ USE_VERBOSE_COMPILE = yes
endif
#
diff --git a/testhal/STM32F4xx/RTC/main.c b/testhal/STM32F4xx/RTC/main.c index 1532129c4..d6cf4f533 100644 --- a/testhal/STM32F4xx/RTC/main.c +++ b/testhal/STM32F4xx/RTC/main.c @@ -120,28 +120,28 @@ void bcd2tm(struct tm *timp, uint32_t tv_time, uint32_t tv_date){ * Convert from classical format to STM32 BCD
*/
void tm2bcd(struct tm *timp, RTCTime *timespec){
- uint32_t p = 0; // temporal variable
+ uint32_t v = 0; // temporal variable
timespec->tv_date = 0;
timespec->tv_time = 0;
- p = timp->tm_year - 100;
- timespec->tv_date |= (((p / 10) & 0xF) << 20) | ((p % 10) << 16);
+ v = timp->tm_year - 100;
+ timespec->tv_date |= (((v / 10) & 0xF) << 20) | ((v % 10) << 16);
if (timp->tm_wday == 0)
- p = 7;
+ v = 7;
else
- p = timp->tm_wday;
- timespec->tv_date |= (p & 7) << 13;
- p = timp->tm_mon + 1;
- timespec->tv_date |= (((p / 10) & 1) << 12) | ((p % 10) << 8);
- p = timp->tm_mday;
- timespec->tv_date |= (((p / 10) & 3) << 4) | (p % 10);
- p = timp->tm_hour;
- timespec->tv_time |= (((p / 10) & 3) << 20) | ((p % 10) << 16);
- p = timp->tm_min;
- timespec->tv_time |= (((p / 10) & 7) << 12) | ((p % 10) << 8);
- p = timp->tm_sec;
- timespec->tv_time |= (((p / 10) & 7) << 4) | (p % 10);
+ v = timp->tm_wday;
+ timespec->tv_date |= (v & 7) << 13;
+ v = timp->tm_mon + 1;
+ timespec->tv_date |= (((v / 10) & 1) << 12) | ((v % 10) << 8);
+ v = timp->tm_mday;
+ timespec->tv_date |= (((v / 10) & 3) << 4) | (v % 10);
+ v = timp->tm_hour;
+ timespec->tv_time |= (((v / 10) & 3) << 20) | ((v % 10) << 16);
+ v = timp->tm_min;
+ timespec->tv_time |= (((v / 10) & 7) << 12) | ((v % 10) << 8);
+ v = timp->tm_sec;
+ timespec->tv_time |= (((v / 10) & 7) << 4) | (v % 10);
}
@@ -162,11 +162,23 @@ int main(void){ bcd2tm(&timp, timespec.tv_time, timespec.tv_date);
unix_time = mktime(&timp);
+ if (unix_time == -1){// incorrect time in RTC cell
+ unix_time = 1000000000;
+ }
+ tm2bcd((localtime(&unix_time)), ×pec);
+ rtcSetTime(&RTCD1, ×pec);
while (TRUE){
- chThdSleepMilliseconds(500);
+ rtcGetTime(&RTCD1, ×pec);
+ bcd2tm(&timp, timespec.tv_time, timespec.tv_date);
+ unix_time = mktime(&timp);
+ chThdSleepMilliseconds(1500);
}
return 0;
}
+
+
+
+
|