We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ab46ea6 + 7b62e7d commit 2f63fa7Copy full SHA for 2f63fa7
libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/rtc_api.c
@@ -35,10 +35,20 @@
35
* The RTC may already be running, so we should set it up
36
* without impacting if it is the case
37
*/
38
+
39
void rtc_init(void) {
- LPC_RTC->CCR = 0x00;
40
+ // Return, if already enabled
41
+ if (LPC_RTC->CCR & 1)
42
+ return;
43
44
+ // Enable 1kHz output of 32kHz oscillator
45
+ LPC_CREG->CREG0 &= ~((1 << 3) | (1 << 2));
46
+ LPC_CREG->CREG0 |= (0x03 << 6) | (1 << 1) | (1 << 0);
47
- LPC_RTC->CCR |= 1 << 0; // Ensure the RTC is enabled
48
+ // Enable RTC
49
+ do {
50
+ LPC_RTC->CCR |= 1 << 0;
51
+ } while ((LPC_RTC->CCR & 1) == 0);
52
}
53
54
void rtc_free(void) {
0 commit comments