Ejemplo n.º 1
0
        /// <summary>
        /// Executes the specified transaction.
        /// </summary>
        /// <param name="deviceAddress">The address of the device.</param>
        /// <param name="transaction">The transaction.</param>
        internal void Execute(int deviceAddress, I2CTransaction transaction)
        {
            lock (this.driverLock)
            {
                var control = this.bscAddress + (int)Interop.Bcm2835BscC;

                foreach (I2CAction action in transaction.Actions)
                {
                    if (action is I2CWriteAction)
                    {
                        this.Write(deviceAddress, action.Buffer);
                    }
                    else if (action is I2CReadAction)
                    {
                        this.Read(deviceAddress, action.Buffer);
                    }
                    else
                    {
                        throw new InvalidOperationException("Only read and write transactions are allowed.");
                    }
                }

                WriteUInt32Mask(control, Interop.Bcm2835BscSDone, Interop.Bcm2835BscSDone);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Executes the specified transaction.
        /// </summary>
        /// <param name="transaction">The transaction.</param>
        public void Execute(I2CTransaction transaction)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException(nameof(transaction));
            }

            this.driver.Execute(this.deviceAddress, transaction);
        }