diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2019-06-12 12:51:20 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2019-06-12 13:50:19 +0200 |
commit | 5d4a81f50106e2ab856d3237243806526fb8f1d9 (patch) | |
tree | 78e6ce61241c61ddad0800461f0c4c3d8c2a0472 /bsps/arm/atsam/contrib/libraries/libchip/source/rtc.c | |
parent | libdl/rap: fix RAP file load error. (diff) | |
download | rtems-5d4a81f50106e2ab856d3237243806526fb8f1d9.tar.bz2 |
bsp/atsam: Fix RTC_SetTimeAlarm()
Set the alarm time according to the note in the datasheet.
Diffstat (limited to 'bsps/arm/atsam/contrib/libraries/libchip/source/rtc.c')
-rw-r--r-- | bsps/arm/atsam/contrib/libraries/libchip/source/rtc.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/bsps/arm/atsam/contrib/libraries/libchip/source/rtc.c b/bsps/arm/atsam/contrib/libraries/libchip/source/rtc.c index 9527585217..77e3236365 100644 --- a/bsps/arm/atsam/contrib/libraries/libchip/source/rtc.c +++ b/bsps/arm/atsam/contrib/libraries/libchip/source/rtc.c @@ -261,25 +261,31 @@ extern int RTC_SetTimeAlarm(Rtc *pRtc, uint8_t *pucHour, uint8_t *pucMinute, uint8_t *pucSecond) { uint32_t dwAlarm = 0; + uint32_t dwAlarmEnable = 0; TRACE_DEBUG("RTC_SetTimeAlarm()\n\r"); /* Hour */ - if (pucHour) - dwAlarm |= RTC_TIMALR_HOUREN | ((*pucHour / 10) << 20) | (( - *pucHour % 10) << 16); + if (pucHour) { + dwAlarm |= ((*pucHour / 10) << 20) | (( *pucHour % 10) << 16); + dwAlarmEnable |= RTC_TIMALR_HOUREN; + } /* Minute */ if (pucMinute) { - dwAlarm |= RTC_TIMALR_MINEN | ((*pucMinute / 10) << 12) - | ((*pucMinute % 10) << 8); + dwAlarm |= ((*pucMinute / 10) << 12) | ((*pucMinute % 10) << 8); + dwAlarmEnable |= RTC_TIMALR_MINEN; } /* Second */ - if (pucSecond) - dwAlarm |= RTC_TIMALR_SECEN | ((*pucSecond / 10) << 4) | (*pucSecond % 10); + if (pucSecond) { + dwAlarm |= ((*pucSecond / 10) << 4) | (*pucSecond % 10); + dwAlarmEnable |= RTC_TIMALR_SECEN; + } + pRtc->RTC_TIMALR = 0; pRtc->RTC_TIMALR = dwAlarm; + pRtc->RTC_TIMALR = dwAlarm | dwAlarmEnable; return (int)(pRtc->RTC_VER & RTC_VER_NVTIMALR); } |