internal void Execute(int deviceAddress, I2cTransaction transaction)
{
lock (driverLock)
{
var control = bscAddress + (int)Interop.BCM2835_BSC_C;
foreach (I2cAction action in transaction.Actions)
{
if (action is I2cWriteAction)
{
Write(deviceAddress, action.Buffer);
}
else if (action is I2cReadAction)
{
Read(deviceAddress, action.Buffer);
}
else
{
throw new InvalidOperationException("Only read and write transactions are allowed.");
}
}
WriteUInt32Mask(control, Interop.BCM2835_BSC_S_DONE, Interop.BCM2835_BSC_S_DONE);
}
}