[LPC4337] Fix RTC clock setting issue

- Fixed missing RTC clock intialization code
- Confirm to pass RTC test case (MBED_16)
pull/815/head
Toyomasa Watarai 2014-12-24 18:09:47 +09:00
parent 869fd19e63
commit 44c66b1062
1 changed files with 15 additions and 3 deletions

View File

@ -35,10 +35,22 @@
* The RTC may already be running, so we should set it up
* without impacting if it is the case
*/
void rtc_init(void) {
LPC_RTC->CCR = 0x00;
LPC_RTC->CCR |= 1 << 0; // Ensure the RTC is enabled
static int rtc_inited = 0;
void rtc_init(void) {
if (rtc_inited)
return;
rtc_inited = 1;
// Enable 1kHz output of 32kHz oscillator
LPC_CREG->CREG0 &= ~((1 << 3) | (1 << 2));
LPC_CREG->CREG0 |= (0x03 << 6) | (1 << 1) | (1 << 0);
// Enable RTC
do {
LPC_RTC->CCR |= 1 << 0;
} while ((LPC_RTC->CCR & 1) == 0);
}
void rtc_free(void) {