public static uint ReadDoubleWordUsingWordBigEndian(this IWordPeripheral peripheral, long address) { unchecked { return((uint)((peripheral.ReadWord(address) << 16) | peripheral.ReadWord(address + 2))); } }
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 ushort ReadWordBigEndian(this IWordPeripheral peripheral, long address) { return(Misc.SwapBytesUShort(peripheral.ReadWord(address))); }