Skip to content

Commit 3732dea

Browse files
committed
Add GD32 GPIO component
1 parent 34d0700 commit 3732dea

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

qiling/hw/gpio/__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_gpio import STM32F4xxGpio
6+
from .stm32f4xx_gpio import STM32F4xxGpio
7+
from .gd32vf1xx_gpio import GD32VF1xxGpio

qiling/hw/gpio/gd32vf1xx_gpio.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import ctypes
2+
3+
from qiling.hw.peripheral import QlPeripheral
4+
5+
6+
class GD32VF1xxGpio(QlPeripheral):
7+
class Type(ctypes.Structure):
8+
""" General-purpose I/Os
9+
"""
10+
11+
_fields_ = [
12+
("CTL0" , ctypes.c_uint32), # Address offset: 0x0, port control register 0
13+
("CTL1" , ctypes.c_uint32), # Address offset: 0x04, port control register 1
14+
("ISTAT", ctypes.c_uint32), # Address offset: 0x08, Port input status register
15+
("OCTL" , ctypes.c_uint32), # Address offset: 0x0C, Port output control register
16+
("BOP" , ctypes.c_uint32), # Address offset: 0x10, Port bit operate register
17+
("BC" , ctypes.c_uint32), # Address offset: 0x14, Port bit clear register
18+
("LOCK" , ctypes.c_uint32), # Address offset: 0x18, GPIO port configuration lock register
19+
]
20+
21+
def __init__(self, ql, label):
22+
super().__init__(ql, label)
23+
24+
self.gpio = self.struct(
25+
CTL0 = 0x44444444,
26+
CTL1 = 0x44444444,
27+
ISTAT = 0x00000000,
28+
OCTL = 0x00000000,
29+
BOP = 0x00000000,
30+
BC = 0x00000000,
31+
LOCK = 0x00000000,
32+
)
33+

0 commit comments

Comments
 (0)