Merge pull request #5152 from NXPmicro/Update_RTC_HAL_driver

Kinetis RTC HAL: Allow writing 0 to the seconds register
pull/5008/merge
Jimmy Brisson 2017-09-29 10:12:22 -05:00 committed by GitHub
commit f5bb15f773
4 changed files with 3 additions and 19 deletions

View File

@ -29,14 +29,14 @@ static void init(void) {
void rtc_init(void) {
init();
// Enable the oscillator
#if defined (TARGET_K20D50M)
RTC->CR |= RTC_CR_OSCE_MASK;
#else
// Teensy3.1 requires 20pF MCU loading capacitors for 32KHz RTC oscillator
/* RTC->CR: SC2P=0,SC4P=1,SC8P=0,SC16P=1,CLKO=0,OSCE=1,UM=0,SUP=0,SPE=0,SWR=0 */
RTC->CR |= RTC_CR_OSCE_MASK |RTC_CR_SC16P_MASK | RTC_CR_SC4P_MASK;
RTC->CR |= RTC_CR_OSCE_MASK |RTC_CR_SC16P_MASK | RTC_CR_SC4P_MASK;
#endif
//Configure the TSR. default value: 1
@ -78,11 +78,6 @@ void rtc_write(time_t t) {
// disable counter
RTC->SR &= ~RTC_SR_TCE_MASK;
// we do not write 0 into TSR
// to avoid invalid time
if (t == 0)
t = 1;
// write seconds
RTC->TSR = t;

View File

@ -26,7 +26,7 @@ static void init(void) {
// select RTC clock source
SIM->SOPT1 &= ~SIM_SOPT1_OSC32KSEL_MASK;
// Enable external crystal source if clock source is 32KHz
if (extosc_frequency()==32768) {
SIM->SOPT1 |= SIM_SOPT1_OSC32KSEL(OSC32KCLK);
@ -104,11 +104,6 @@ void rtc_write(time_t t) {
// disable counter
RTC->SR &= ~RTC_SR_TCE_MASK;
// we do not write 0 into TSR
// to avoid invalid time
if (t == 0)
t = 1;
// write seconds
RTC->TSR = t;

View File

@ -57,9 +57,6 @@ time_t rtc_read(void)
void rtc_write(time_t t)
{
if (t == 0) {
t = 1;
}
RTC_StopTimer(RTC);
RTC->TSR = t;
RTC_StartTimer(RTC);

View File

@ -54,9 +54,6 @@ time_t rtc_read(void)
void rtc_write(time_t t)
{
if (t == 0) {
t = 1;
}
RTC_StopTimer(RTC);
RTC->COUNT = t;
RTC_StartTimer(RTC);