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 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)); }