添加gpio测试,软件没有运行

This commit is contained in:
RuigeLee
2024-11-05 11:09:40 +08:00
parent b1c71b67a0
commit f89f48f951
4 changed files with 39 additions and 2 deletions

24
tb/sw/bin_to_hex.py Normal file
View File

@@ -0,0 +1,24 @@
def bin_to_hex_file(bin_file, hex_file, address_depth=1024, data_width=32):
# 打开二进制文件和输出的Hex文件
with open(bin_file, 'rb') as bf, open(hex_file, 'w') as hf:
# 写入文件头
hf.write("#File_format=Hex\n")
hf.write(f"#Address_depth={address_depth}\n")
hf.write(f"#Data_width={data_width}\n")
# 读取二进制文件内容
data = bf.read()
# 将二进制内容按每4字节分割并转换为十六进制字符串
for i in range(address_depth):
if i * 4 < len(data):
# 提取4字节数据并转为32位的十六进制字符串
value = int.from_bytes(data[i*4:(i+1)*4], byteorder='little')
hf.write(f"{value:08X}\n")
else:
# 如果数据不够填充0
hf.write("00000000\n")
# 运行脚本
bin_to_hex_file("./tb/sw/build/slvTest.bin", "./tb/sw/build/slvTest.mi")
bin_to_hex_file("./tb/sw/build/mstTest.bin", "./tb/sw/build/mstTest.mi")

View File

@@ -44,6 +44,8 @@ void main()
uint32_t isLast;
uint32_t led = 0;
while(1){
*cdr_softReset = 1; //复位脉冲
@@ -53,11 +55,19 @@ void main()
"1:\n"
"rdcycle ra\n"
"srli ra, ra, 12\n"
//"srli ra, ra, 26\n"
// "srli ra, ra, 26\n"
"andi ra, ra, 0x1\n"
"beqz ra, 1b\n"
);
if( led ){
*WriteGpio = 0xFFFFFFFF;
led = 0;
} else{
*WriteGpio = 0x0;
led = 1;
}
//发送下行包头
*cdr_txLen = 520; //总长520

View File

@@ -48,6 +48,7 @@ void main()
*cdr_softReset = 1; //复位脉冲
isLast = *ReadIsLast;
*cdr_direct = 0;
*WriteGpio = 0xaaaa;
asm volatile (
"1:\n"