Skip to content

Commit e420957

Browse files
committed
SIDK_S1SBP6A: fix to support rtc range from 0 to 0xEFFFFFFF
BP6A do not support from 0 to 0xEFFFFFFF in SOC. This patch fixes it in s/w manner. Signed-off-by: Heuisam Kwag <[email protected]>
1 parent f661c23 commit e420957

File tree

1 file changed

+10
-1
lines changed
  • targets/TARGET_Samsung/TARGET_SIDK_S1SBP6A

1 file changed

+10
-1
lines changed

targets/TARGET_Samsung/TARGET_SIDK_S1SBP6A/rtc_api.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@
3030
#include "mbed_debug.h"
3131

3232
#define BP6A_RTC_START_TIME 946684800
33+
#define BP6A_MAX_REG 0x0FFFFFFF
3334
static bool rtc_initialized = false;
3435
static bool g_before2000 = false;
35-
36+
static time_t g_rtc_offset = 0;
3637
void rtc_init(void)
3738
{
3839
if (!rtc_initialized) {
@@ -73,6 +74,8 @@ time_t rtc_read(void)
7374
return 0;
7475
}
7576

77+
t += g_rtc_offset;
78+
7679
if (g_before2000) {
7780
t -= BP6A_RTC_START_TIME;
7881
}
@@ -84,6 +87,12 @@ void rtc_write(time_t t)
8487
struct rtc_bcd_s rtc_val;
8588
struct tm timeinfo;
8689

90+
if (t > BP6A_MAX_REG) {
91+
g_rtc_offset = t;
92+
t = 0;
93+
} else
94+
g_rtc_offset = 0;
95+
8796
/*BP6A : The implicit number of thousands place is 20.*/
8897
if (t < BP6A_RTC_START_TIME) {
8998
g_before2000 = true;

0 commit comments

Comments
 (0)