MCUXpresso: Enable RTC on LPC54114 and LPC546XX

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
pull/7009/head
Mahesh Mahadevan 2018-03-26 14:55:55 -05:00 committed by Bartek Szatkowski
parent a17cf07a35
commit f7c6e555f3
2 changed files with 23 additions and 5 deletions

View File

@ -15,7 +15,7 @@
*/
#include "rtc_api.h"
#if DEVICE_RTC
#if DEVICE_RTC || DEVICE_LOWPOWERTIMER
#include "pinmap.h"
#include "fsl_rtc.h"
@ -23,6 +23,8 @@
extern void rtc_setup_oscillator(void);
static bool rtc_time_set = false;
void rtc_init(void)
{
rtc_setup_oscillator();
@ -34,7 +36,10 @@ void rtc_init(void)
void rtc_free(void)
{
RTC_Deinit(RTC);
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
/* Gate the module clock */
CLOCK_DisableClock(kCLOCK_Rtc);
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
}
/*
@ -43,8 +48,19 @@ void rtc_free(void)
*/
int rtc_isenabled(void)
{
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
/* Enable the RTC peripheral clock */
CLOCK_EnableClock(kCLOCK_Rtc);
return (int)((RTC->CTRL & RTC_CTRL_RTC_EN_MASK) >> RTC_CTRL_RTC_EN_SHIFT);
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
const bool rtc_init_done = ((RTC->CTRL & RTC_CTRL_RTC_EN_MASK) >> RTC_CTRL_RTC_EN_SHIFT);
/* If RTC is not initialized, then disable the clock gate on exit. */
if(!rtc_init_done) {
rtc_free();
}
return (rtc_init_done & rtc_time_set);
}
time_t rtc_read(void)
@ -57,6 +73,8 @@ void rtc_write(time_t t)
RTC_StopTimer(RTC);
RTC->COUNT = t;
RTC_StartTimer(RTC);
rtc_time_set = true;
}
#endif

View File

@ -766,7 +766,7 @@
"macros": ["CPU_LPC54114J256BD64_cm4", "FSL_RTOS_MBED"],
"inherits": ["Target"],
"detect_code": ["1054"],
"device_has": ["USTICKER", "ANALOGIN", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "SERIAL", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES", "FLASH"],
"device_has": ["USTICKER", "RTC", "ANALOGIN", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "SERIAL", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES", "FLASH"],
"release_versions": ["2", "5"],
"device_name" : "LPC54114J256BD64"
},
@ -777,7 +777,7 @@
"is_disk_virtual": true,
"macros": ["CPU_LPC54628J512ET180", "FSL_RTOS_MBED"],
"inherits": ["Target"],
"device_has": ["USTICKER", "ANALOGIN", "EMAC", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "SERIAL", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES", "FLASH", "TRNG"],
"device_has": ["USTICKER", "RTC", "ANALOGIN", "EMAC", "I2C", "I2CSLAVE", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "SERIAL", "SLEEP", "SPI", "SPISLAVE", "STDIO_MESSAGES", "FLASH", "TRNG"],
"features": ["LWIP"],
"device_name" : "LPC54628J512ET180",
"overrides": {