From 48f47e74b9a4a45918a13f281e2490a341c64b51 Mon Sep 17 00:00:00 2001 From: Rahix <rahix@rahix.de> Date: Mon, 29 Jul 2019 21:44:58 +0200 Subject: [PATCH] fix(libcard10): Properly wait for RTC init Signed-off-by: Rahix <rahix@rahix.de> --- lib/card10/card10.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/card10/card10.c b/lib/card10/card10.c index 0056aef00..519c97fed 100644 --- a/lib/card10/card10.c +++ b/lib/card10/card10.c @@ -57,11 +57,18 @@ void card10_init(void) pmic_set_led(2, 0); TMR_Delay(MXC_TMR0, MSEC(1000), 0); - RTC_EnableRTCE(MXC_RTC); + while (RTC_EnableRTCE(MXC_RTC) == E_BUSY) + ; + // Enable 32 kHz output - RTC_SquareWave( - MXC_RTC, SQUARE_WAVE_ENABLED, F_32KHZ, NOISE_IMMUNE_MODE, NULL - ); + while (RTC_SquareWave( + MXC_RTC, + SQUARE_WAVE_ENABLED, + F_32KHZ, + NOISE_IMMUNE_MODE, + NULL) == E_BUSY + ) + ; if (RTC_GetSecond() < 1546300800UL) { while (RTC_Init(MXC_RTC, 1546300800UL, 0, NULL) == E_BUSY) -- GitLab