Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-src by
Diff: targets/hal/TARGET_NXP/TARGET_LPC43XX/rtc_api.c
- Revision:
- 441:d2c15dda23c1
- Parent:
- 20:4263a77256ae
diff -r 8a0b45cd594f -r d2c15dda23c1 targets/hal/TARGET_NXP/TARGET_LPC43XX/rtc_api.c
--- a/targets/hal/TARGET_NXP/TARGET_LPC43XX/rtc_api.c Tue Dec 16 08:15:08 2014 +0000
+++ b/targets/hal/TARGET_NXP/TARGET_LPC43XX/rtc_api.c Tue Jan 06 16:15:36 2015 +0000
@@ -35,10 +35,20 @@
* 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;
+ // Return, if already enabled
+ if (LPC_RTC->CCR & 1)
+ return;
- LPC_RTC->CCR |= 1 << 0; // Ensure the RTC is enabled
+ // 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) {
