feat: add jtag boundary scan

This commit is contained in:
SikongJueluo 2025-05-12 21:56:17 +08:00
parent 9eb3acb94c
commit 8699a568d1
No known key found for this signature in database
2 changed files with 26 additions and 18 deletions

View File

@ -41,7 +41,7 @@ namespace Common
0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
}; };
/// <summary> /// <summary>
/// 整数转成二进制字节数组 /// 整数转成二进制字节数组
/// </summary> /// </summary>
@ -167,6 +167,26 @@ namespace Common
} }
/// <summary>
/// [TODO:description]
/// </summary>
/// <param name="uintArray">[TODO:parameter]</param>
/// <returns>[TODO:return]</returns>
public static Result<byte[]> UInt32ArrayToBytes(UInt32[] uintArray)
{
byte[] byteArray = new byte[uintArray.Length * 4];
try
{
Buffer.BlockCopy(uintArray, 0, byteArray, 0, uintArray.Length * 4);
return byteArray;
}
catch (Exception error)
{
return new(error);
}
}
/// <summary> /// <summary>
/// 比特合并成二进制字节 /// 比特合并成二进制字节

View File

@ -1,3 +1,4 @@
using System.Collections;
using System.Net; using System.Net;
using DotNext; using DotNext;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -368,21 +369,6 @@ public class JtagStatusReg
} }
} }
/// <summary>
/// [TODO:description]
/// </summary>
public class JtagBoundaryRegister
{
/// <summary>
/// [TODO:description]
/// </summary>
public int PortNum { get; set; }
/// <summary>
/// [TODO:description]
/// </summary>
public UInt32[] PortStatus { get; set; } = new UInt32[] { };
}
/// <summary> /// <summary>
/// Jtag控制器 /// Jtag控制器
/// </summary> /// </summary>
@ -945,7 +931,7 @@ public class Jtag
/// </summary> /// </summary>
/// <param name="portNum">[TODO:parameter]</param> /// <param name="portNum">[TODO:parameter]</param>
/// <returns>[TODO:return]</returns> /// <returns>[TODO:return]</returns>
public async ValueTask<Result<JtagBoundaryRegister>> BoundaryScan(int portNum) public async ValueTask<Result<BitArray>> BoundaryScan(int portNum)
{ {
if (portNum <= 0) if (portNum <= 0)
return new(new ArgumentException("The number of port couldn't be negative", nameof(portNum))); return new(new ArgumentException("The number of port couldn't be negative", nameof(portNum)));
@ -979,6 +965,8 @@ public class Jtag
if (!ret.IsSuccessful) return new(ret.Error); if (!ret.IsSuccessful) return new(ret.Error);
else if (!ret.Value) return new(new Exception("Jtag Close Test Failed")); else if (!ret.Value) return new(new Exception("Jtag Close Test Failed"));
return new JtagBoundaryRegister() { PortNum = portNum, PortStatus = retData.Value }; var byteArray = Common.Number.UInt32ArrayToBytes(retData.Value);
if (!byteArray.IsSuccessful) return new(byteArray.Error);
return new BitArray(byteArray.Value);
} }
} }