public static uint ReadDoubleWordUsingWordBigEndian(this IWordPeripheral peripheral, long address) { unchecked { return((uint)((peripheral.ReadWord(address) << 16) | peripheral.ReadWord(address + 2))); } }
public static void WriteDoubleWordUsingWordBigEndian(this IWordPeripheral peripheral, long address, uint value) { unchecked { peripheral.WriteWord(address, (ushort)(value >> 16)); peripheral.WriteWord(address + 2, (ushort)(value)); } }
public static byte ReadByteUsingWord(this IWordPeripheral peripheral, long address) { unchecked { var readAddress = address & (~1); var offset = (int)(address & 1); return((byte)(peripheral.ReadWord(readAddress) >> 8 * offset)); } }
public static void WriteByteUsingWordBigEndian(this IWordPeripheral peripheral, long address, byte value) { unchecked { var writeAddress = address & (~1); var offset = 1 - (int)(address & 1); var oldValue = peripheral.ReadWord(writeAddress) & (0xFF << (1 - offset) * 8); peripheral.WriteWord(writeAddress, (ushort)(oldValue | (value << 8 * offset))); } }
public static void WriteWordBigEndian(this IWordPeripheral peripheral, long address, ushort value) { peripheral.WriteWord(address, Misc.SwapBytesUShort(value)); }
public static ushort ReadWordBigEndian(this IWordPeripheral peripheral, long address) { return(Misc.SwapBytesUShort(peripheral.ReadWord(address))); }