Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kinetis RTC HAL: Allow writing 0 to the seconds register #5152

Merged
merged 1 commit into from Sep 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 2 additions & 7 deletions targets/TARGET_Freescale/TARGET_K20XX/rtc_api.c
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
7 changes: 1 addition & 6 deletions targets/TARGET_Freescale/TARGET_KLXX/rtc_api.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 0 additions & 3 deletions targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api/rtc_api.c
Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/api/rtc_api.c
Expand Up @@ -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);
Expand Down