File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed
targets/TARGET_Samsung/TARGET_SIDK_S1SBP6A Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,35 @@ uint32_t bp6a_rtc_bin2bcd(uint8_t bin)
40
40
return ((bin / 10u ) << 4u ) + (bin % 10 );
41
41
}
42
42
43
+ void bp6a_rtc_offset_write (uint32_t offset , uint32_t flag )
44
+ {
45
+ uint8_t i ;
46
+
47
+ bp6a_rtc_unlock (true);
48
+ for (i = 0 ; i < 4 ; i ++ )
49
+ putreg32 (0x40019000 + 0xB8 + i * 4 , ((offset >> (i * 8 )) & 0xFF ));
50
+
51
+ putreg32 (0x40019000 + 0x90 , flag );
52
+ bp6a_rtc_unlock (false);
53
+ }
54
+
55
+ uint32_t bp6a_rtc_read_offset (uint32_t * flag )
56
+ {
57
+ uint8_t i ;
58
+ uint32_t offset = 0 ;
59
+
60
+ bp6a_rtc_unlock (true);
61
+
62
+ for (i = 0 ; i < 4 ; i ++ )
63
+ offset |= getreg32 (0x40019000 + 0xB8 + i * 4 ) << (i * 8 );
64
+
65
+ * flag = getreg32 (0x40019000 + 0x90 );
66
+
67
+ bp6a_rtc_unlock (false);
68
+
69
+ return offset ;
70
+ }
71
+
43
72
void bp6a_rtc_getdatetime (struct rtc_bcd_s * rtc )
44
73
{
45
74
bp6a_rtc_unlock (true);
Original file line number Diff line number Diff line change @@ -36,5 +36,6 @@ void bp6a_rtc_getdatetime(struct rtc_bcd_s *rtc);
36
36
void bp6a_rtc_setdatetime (struct rtc_bcd_s * rtc );
37
37
void bp6a_rtc_init (void );
38
38
void bp6a_set_rtc_delay (uint32_t delay );
39
-
39
+ uint32_t bp6a_rtc_read_offset (uint32_t * flag );
40
+ void bp6a_rtc_offset_write (uint32_t offset , uint32_t flag );
40
41
#endif /*__S1SBP6A_RTC_H */
Original file line number Diff line number Diff line change 30
30
#include "mbed_debug.h"
31
31
32
32
#define BP6A_RTC_START_TIME 946684800
33
+ #define BP6A_MAX_REG 0x0FFFFFFF
33
34
static bool rtc_initialized = false;
34
35
static bool g_before2000 = false;
36
+ static time_t g_rtc_offset = 0 ;
35
37
36
38
void rtc_init (void )
37
39
{
@@ -40,6 +42,7 @@ void rtc_init(void)
40
42
41
43
bp6a_set_rtc_delay ((uint32_t )((float )sys_clk * 2 / 32789 ));
42
44
bp6a_rtc_init ();
45
+ g_rtc_offset = bp6a_rtc_read_offset (& g_before2000 );
43
46
rtc_initialized = true;
44
47
}
45
48
}
@@ -73,6 +76,8 @@ time_t rtc_read(void)
73
76
return 0 ;
74
77
}
75
78
79
+ t += g_rtc_offset ;
80
+
76
81
if (g_before2000 ) {
77
82
t -= BP6A_RTC_START_TIME ;
78
83
}
@@ -84,6 +89,12 @@ void rtc_write(time_t t)
84
89
struct rtc_bcd_s rtc_val ;
85
90
struct tm timeinfo ;
86
91
92
+ if (t > BP6A_MAX_REG ) {
93
+ g_rtc_offset = t ;
94
+ t = 0 ;
95
+ } else
96
+ g_rtc_offset = 0 ;
97
+
87
98
/*BP6A : The implicit number of thousands place is 20.*/
88
99
if (t < BP6A_RTC_START_TIME ) {
89
100
g_before2000 = true;
@@ -92,6 +103,7 @@ void rtc_write(time_t t)
92
103
g_before2000 = false;
93
104
}
94
105
106
+ bp6a_rtc_offset_write (g_rtc_offset , (uint32_t )g_before2000 );
95
107
96
108
if (_rtc_localtime (t , & timeinfo , RTC_4_YEAR_LEAP_YEAR_SUPPORT ) == false) {
97
109
return ;
You can’t perform that action at this time.
0 commit comments