Skip to content

Commit a4522ec

Browse files
committed
The RTC pass the initlization stage
1 parent dfcdf62 commit a4522ec

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

qiling/hw/timer/stm32f4xx_rtc.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
#
55

66
import ctypes
7+
78
from qiling.hw.peripheral import QlPeripheral
9+
from qiling.hw.const.stm32f4xx_rtc import RTC_TR, RTC_ISR
810

911

1012
class STM32F4xxRtc(QlPeripheral):
@@ -99,5 +101,27 @@ def read(self, offset: int, size: int) -> int:
99101

100102
@QlPeripheral.debug_info()
101103
def write(self, offset: int, size: int, value: int):
104+
if offset == self.struct.ISR.offset:
105+
for bitmask in [
106+
RTC_ISR.TAMP1F,
107+
RTC_ISR.TSOVF,
108+
RTC_ISR.TSF,
109+
RTC_ISR.WUTF,
110+
RTC_ISR.ALRBF,
111+
RTC_ISR.ALRAF,
112+
RTC_ISR.RSF
113+
]:
114+
if value & bitmask == 0:
115+
self.rtc.ISR &= ~bitmask
116+
117+
self.rtc.ISR = (self.rtc.ISR & ~RTC_ISR.INIT) | (value & RTC_ISR.INIT)
118+
return
119+
102120
data = (value).to_bytes(size, 'little')
103-
ctypes.memmove(ctypes.addressof(self.rtc) + offset, data, size)
121+
ctypes.memmove(ctypes.addressof(self.rtc) + offset, data, size)
122+
123+
def step(self):
124+
if self.rtc.ISR & RTC_ISR.INIT:
125+
self.rtc.ISR |= RTC_ISR.INITF
126+
127+
self.rtc.ISR |= RTC_ISR.RSF

0 commit comments

Comments
 (0)