Skip to content

Commit 34d0700

Browse files
committed
Add GD32 usart component
1 parent 873544c commit 34d0700

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

qiling/hw/char/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
44
#
55

6-
from .stm32f4xx_usart import STM32F4xxUsart
6+
from .stm32f4xx_usart import STM32F4xxUsart
7+
from .gd32vf1xx_usart import GD32VF1xxUsart

qiling/hw/char/gd32vf1xx_usart.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import ctypes
2+
3+
from qiling.hw.connectivity import QlConnectivityPeripheral
4+
5+
6+
class GD32VF1xxUsart(QlConnectivityPeripheral):
7+
class Type(ctypes.Structure):
8+
""" Universal synchronous asynchronous receiver
9+
transmitter
10+
"""
11+
12+
_fields_ = [
13+
("STAT", ctypes.c_uint32), # Address offset: 0x00, Status register
14+
("DATA", ctypes.c_uint32), # Address offset: 0x04, Data register
15+
("BAUD", ctypes.c_uint32), # Address offset: 0x08, Baud rate register
16+
("CTL0", ctypes.c_uint32), # Address offset: 0x0C, Control register 0
17+
("CTL1", ctypes.c_uint32), # Address offset: 0x10, Control register 1
18+
("CTL2", ctypes.c_uint32), # Address offset: 0x14, Control register 2
19+
("GP" , ctypes.c_uint32), # Address offset: 0x18, Guard time and prescaler register
20+
]
21+
22+
def __init__(self, ql, label):
23+
super().__init__(ql, label)
24+
25+
self.usart = self.struct(
26+
STAT = 0x000000c0,
27+
DATA = 0x00000000,
28+
BAUD = 0x00000000,
29+
CTL0 = 0x00000000,
30+
CTL1 = 0x00000000,
31+
CTL2 = 0x00000000,
32+
GP = 0x00000000,
33+
)
34+
35+
@QlConnectivityPeripheral.device_handler
36+
def step(self):
37+
pass

0 commit comments

Comments
 (0)