Skip to content

Commit f5bb15f

Browse files
Merge pull request #5152 from NXPmicro/Update_RTC_HAL_driver
Kinetis RTC HAL: Allow writing 0 to the seconds register
2 parents 3b22425 + 1dadb05 commit f5bb15f

File tree

4 files changed

+3
-19
lines changed

4 files changed

+3
-19
lines changed

targets/TARGET_Freescale/TARGET_K20XX/rtc_api.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ static void init(void) {
2929

3030
void rtc_init(void) {
3131
init();
32-
32+
3333
// Enable the oscillator
3434
#if defined (TARGET_K20D50M)
3535
RTC->CR |= RTC_CR_OSCE_MASK;
3636
#else
3737
// Teensy3.1 requires 20pF MCU loading capacitors for 32KHz RTC oscillator
3838
/* RTC->CR: SC2P=0,SC4P=1,SC8P=0,SC16P=1,CLKO=0,OSCE=1,UM=0,SUP=0,SPE=0,SWR=0 */
39-
RTC->CR |= RTC_CR_OSCE_MASK |RTC_CR_SC16P_MASK | RTC_CR_SC4P_MASK;
39+
RTC->CR |= RTC_CR_OSCE_MASK |RTC_CR_SC16P_MASK | RTC_CR_SC4P_MASK;
4040
#endif
4141

4242
//Configure the TSR. default value: 1
@@ -78,11 +78,6 @@ void rtc_write(time_t t) {
7878
// disable counter
7979
RTC->SR &= ~RTC_SR_TCE_MASK;
8080

81-
// we do not write 0 into TSR
82-
// to avoid invalid time
83-
if (t == 0)
84-
t = 1;
85-
8681
// write seconds
8782
RTC->TSR = t;
8883

targets/TARGET_Freescale/TARGET_KLXX/rtc_api.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static void init(void) {
2626

2727
// select RTC clock source
2828
SIM->SOPT1 &= ~SIM_SOPT1_OSC32KSEL_MASK;
29-
29+
3030
// Enable external crystal source if clock source is 32KHz
3131
if (extosc_frequency()==32768) {
3232
SIM->SOPT1 |= SIM_SOPT1_OSC32KSEL(OSC32KCLK);
@@ -104,11 +104,6 @@ void rtc_write(time_t t) {
104104
// disable counter
105105
RTC->SR &= ~RTC_SR_TCE_MASK;
106106

107-
// we do not write 0 into TSR
108-
// to avoid invalid time
109-
if (t == 0)
110-
t = 1;
111-
112107
// write seconds
113108
RTC->TSR = t;
114109

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api/rtc_api.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ time_t rtc_read(void)
5757

5858
void rtc_write(time_t t)
5959
{
60-
if (t == 0) {
61-
t = 1;
62-
}
6360
RTC_StopTimer(RTC);
6461
RTC->TSR = t;
6562
RTC_StartTimer(RTC);

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/api/rtc_api.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ time_t rtc_read(void)
5454

5555
void rtc_write(time_t t)
5656
{
57-
if (t == 0) {
58-
t = 1;
59-
}
6057
RTC_StopTimer(RTC);
6158
RTC->COUNT = t;
6259
RTC_StartTimer(RTC);

0 commit comments

Comments
 (0)