Skip to content

Commit b19c313

Browse files
committed
Add gd32 spi component
1 parent d517e94 commit b19c313

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

qiling/hw/spi/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
#
55

66
from .stm32f4xx_spi import STM32F4xxSpi
7+
from .gd32vf1xx_spi import GD32VF1xxSpi

qiling/hw/spi/gd32vf1xx_spi.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 GD32VF1xxSpi(QlConnectivityPeripheral):
7+
class Type(ctypes.Structure):
8+
""" Serial peripheral interface
9+
"""
10+
11+
_fields_ = [
12+
("CTL0" , ctypes.c_uint16), # Address offset: 0x0, control register 0
13+
("CTL1" , ctypes.c_uint16), # Address offset: 0x04, control register 1
14+
("STAT" , ctypes.c_uint16), # Address offset: 0x08, status register
15+
("DATA" , ctypes.c_uint16), # Address offset: 0x0C, data register
16+
("CRCPOLY", ctypes.c_uint16), # Address offset: 0x10, CRC polynomial register
17+
("RCRC" , ctypes.c_uint16), # Address offset: 0x14, RX CRC register
18+
("TCRC" , ctypes.c_uint16), # Address offset: 0x18, TX CRC register
19+
("I2SCTL" , ctypes.c_uint16), # Address offset: 0x1C, I2S control register
20+
("I2SPSC" , ctypes.c_uint16), # Address offset: 0x20, I2S prescaler register
21+
]
22+
23+
def __init__(self, ql, label):
24+
super().__init__(ql, label)
25+
26+
self.spi = self.struct(
27+
CTL0 = 0x00000000,
28+
CTL1 = 0x00000000,
29+
STAT = 0x00000002,
30+
DATA = 0x00000000,
31+
CRCPOLY = 0x00000007,
32+
RCRC = 0x00000000,
33+
TCRC = 0x00000000,
34+
I2SCTL = 0x00000000,
35+
I2SPSC = 0x00000002,
36+
)
37+

0 commit comments

Comments
 (0)