修正QSPI/SPI,但没有通过测试,增加包生成工具,尚未完成

This commit is contained in:
2025-05-19 14:43:00 +08:00
4 changed files with 140 additions and 42 deletions

49
tb/shinTest/gen_pkt.py Executable file
View File

@@ -0,0 +1,49 @@
#!/usr/bin/env python
#encoding=utf-8
from ctypes import *
class TPkt(BigEndianStructure):
pass
TPkt._pack_ = 1
TPkt._fields_=[
('len', c_uint, 12),
('rsv1', c_uint, 2),
('type', c_uint, 2),
('rsv2', c_uint16),
('data', c_uint8 * 2040),
]
class TSubPkt(BigEndianStructure):
pass
TSubPkt._pack_ = 1
TSubPkt._fields_=[
('dev', c_uint, 14),
('mode', c_uint, 2),
('addr', c_uint16),
('cmd', c_uint, 4),
('slen', c_uint, 12),
('wkr', c_uint16)
]
if __name__ == '__main__':
packet = b'\0' * 2048
pkt = cast (packet, POINTER(TPkt)).contents
pkt.len = 512
pkt.rsv1 = 0
pkt.type = 0
pkt.rsv2 = 0
pkt.data[0] = 1
pkt.data[1] = 2
pkt.data[2] = 3
pkt.data[3] = 4
for i in range(10):
print(hex(packet[i]), ' ')