public override bool ReadU32(UInt32 Addr, UInt32 Count, ref UInt32[] data) { GCHandle addr_hndl = GCHandle.Alloc(data, GCHandleType.Pinned); IntPtr addr_data = addr_hndl.AddrOfPinnedObject(); bool status = (JLinkARM.JLINKARM_ReadMemU32(Addr, Count, addr_data, IntPtr.Zero) >= 0) ? true : false; addr_hndl.Free(); return(status); }
public override bool ReadU32(UInt32 Addr, ref UInt32 data) { /* * byte[] data_b = new byte[4]; * GCHandle addr_hndl = GCHandle.Alloc(data_b, GCHandleType.Pinned); * IntPtr addr_data = addr_hndl.AddrOfPinnedObject(); * bool status = (JLinkARM.JLINKARM_ReadMem(Addr, 4, addr_data) == 0) ? true : false; * data = (UInt32)(data_b[0] | (data_b[1] << 8) | (data_b[2] << 16) | (data_b[3] << 24)); * addr_hndl.Free(); */ UInt32[] data_r = new UInt32[2]; // TODO: Костыль, иначе по IntPtr всегда возвращается 0х0 ... GCHandle addr_hndl = GCHandle.Alloc(data_r, GCHandleType.Pinned); IntPtr addr_data = addr_hndl.AddrOfPinnedObject(); bool status = (JLinkARM.JLINKARM_ReadMemU32(Addr, 1, addr_data, IntPtr.Zero) >= 0); addr_hndl.Free(); data = data_r[0]; return(status); }
public override bool ReadU32(UInt32 Addr, ref UInt32 data) { UInt32[] data_r = new UInt32[2]; // TODO: Костыль, иначе по IntPtr всегда возвращается 0х0 ... GCHandle addr_hndl = GCHandle.Alloc(data_r, GCHandleType.Pinned); IntPtr addr_data = addr_hndl.AddrOfPinnedObject(); bool status = (JLinkARM.JLINKARM_ReadMemU32(Addr, 1, addr_data, IntPtr.Zero) >= 0); addr_hndl.Free(); data = data_r[0]; /* * byte[] data_b = new byte[8]; * GCHandle addr_hndl = GCHandle.Alloc(data_b, GCHandleType.Pinned); * IntPtr addr_data = addr_hndl.AddrOfPinnedObject(); * bool status = (JLinkARM.JLINKARM_ReadMemHW(Addr, 8, addr_data) == 0); * //data = (UInt32)(data_b[7] | data_b[6] << 4 | data_b[5] << 8 | data_b[4] << 12 | data_b[3] << 16 | data_b[2] << 20 | data_b[1] << 24 | data_b[0] << 28); * data = (UInt32)(data_b[0] | data_b[1] << 4 | data_b[2] << 8 | data_b[3] << 12 | data_b[4] << 16 | data_b[5] << 20 | data_b[6] << 24 | data_b[7] << 28); * addr_hndl.Free(); */ return(status); }