Skip to content

Commit a0bb91b

Browse files
committed
Add gd32 rcu component
1 parent 3732dea commit a0bb91b

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

qiling/hw/misc/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
STM32F4xxRccV3,
1111
STM32F446Rcc, STM32F412Rcc,
1212
)
13-
from .stm32f4xx_syscfg import STM32F4xxSyscfg
13+
from .stm32f4xx_syscfg import STM32F4xxSyscfg
14+
from .gd32vf1xx_rcu import GD32VF1xxRcu

qiling/hw/misc/gd32vf1xx_rcu.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import ctypes
2+
3+
from qiling.hw.peripheral import QlPeripheral
4+
5+
6+
class GD32VF1xxRcu(QlPeripheral):
7+
class Type(ctypes.Structure):
8+
""" Reset and clock unit
9+
"""
10+
11+
_fields_ = [
12+
("CTL" , ctypes.c_uint32), # Address offset: 0x0, Control register
13+
("CFG0" , ctypes.c_uint32), # Address offset: 0x04, Clock configuration register 0 (RCU_CFG0)
14+
("INT" , ctypes.c_uint32), # Address offset: 0x08, Clock interrupt register (RCU_INT)
15+
("APB2RST", ctypes.c_uint32), # Address offset: 0x0C, APB2 reset register (RCU_APB2RST)
16+
("APB1RST", ctypes.c_uint32), # Address offset: 0x10, APB1 reset register (RCU_APB1RST)
17+
("AHBEN" , ctypes.c_uint32), # Address offset: 0x14, AHB enable register
18+
("APB2EN" , ctypes.c_uint32), # Address offset: 0x18, APB2 clock enable register (RCU_APB2EN)
19+
("APB1EN" , ctypes.c_uint32), # Address offset: 0x1C, APB1 clock enable register (RCU_APB1EN)
20+
("BDCTL" , ctypes.c_uint32), # Address offset: 0x20, Backup domain control register (RCU_BDCTL)
21+
("RSTSCK" , ctypes.c_uint32), # Address offset: 0x24, Reset source /clock register (RCU_RSTSCK)
22+
("AHBRST" , ctypes.c_uint32), # Address offset: 0x28, AHB reset register
23+
("CFG1" , ctypes.c_uint32), # Address offset: 0x2C, Clock Configuration register 1
24+
("DSV" , ctypes.c_uint32), # Address offset: 0x34, Deep sleep mode Voltage register
25+
]
26+
27+
def __init__(self, ql, label):
28+
super().__init__(ql, label)
29+
30+
self.rcu = self.struct(
31+
CTL = 0x00000083,
32+
CFG0 = 0x00000000,
33+
INT = 0x00000000,
34+
APB2RST = 0x00000000,
35+
APB1RST = 0x00000000,
36+
AHBEN = 0x00000014,
37+
APB2EN = 0x00000000,
38+
APB1EN = 0x00000000,
39+
BDCTL = 0x00000018,
40+
RSTSCK = 0x0c000000,
41+
AHBRST = 0x00000000,
42+
CFG1 = 0x00000000,
43+
DSV = 0x00000000,
44+
)
45+

0 commit comments

Comments
 (0)