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 (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);
            }
        }
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("transaction");
            }

            driver.Execute(deviceAddress, transaction);
        }
        /// <summary>
        /// Executes the specified transaction.
        /// </summary>
        /// <param name="transaction">The transaction.</param>
        public void Execute(I2cTransaction transaction)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }

            driver.Execute(deviceAddress, transaction);
        }
Ejemplo n.º 4
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 (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);
            }
        }