An I2C bus implementation for the Raspberry Pi. Derived from the RPi.I2C.Net library by mshmelev at https://github.com/mshmelev/RPi.I2C.Net. As such, this class (and the required methods in UnsafeNativeMethods) is dependent on the underlying LibNativeI2C native library which must be compiled and included with this library.
Inheritance: II2CBus
Ejemplo n.º 1
0
        /// <summary>
        /// Gets an open I2C connection instance.
        /// </summary>
        /// <param name="boardRev">
        /// Specifies the revision of the RPi board in use. This
        /// used to determine the path to the system file associated
        /// with the i2c bus.
        /// </param>
        /// <returns>
        /// An open I2C connection instance.
        /// </returns>
        /// <exception cref="ObjectDisposedException">
        /// This instance has been disposed.
        /// </exception>
        /// <exception cref="IOException">
        /// Unable to open the bus connection.
        /// </exception>
        public static I2CBus Open(BoardRevision boardRev)
        {
            I2CBus bus = new I2CBus(boardRev);

            bus.Open();
            return(bus);
        }
Ejemplo n.º 2
0
		/// <summary>
		/// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/>
		/// class with the I2C device that represents the physical connection
		/// to the gyro.
		/// </summary>
		/// <param name="device">
		/// The I2C device that represents the physical connection to the gyro.
		/// If null, then it is assumed that the host is a revision 2 or higher
		/// board and a default <see cref="CyrusBuilt.MonoPi.IO.I2C.I2CBus"/>
		/// using the rev 2 I2C bus path will be used instead.
		/// </param>
		/// <exception cref="IOException">
		/// Unable to open the specified I2C bus device.
		/// </exception>
		/// <exception cref="ObjectDisposedException">
		/// The specified device instance has been disposed.
		/// </exception>
		public ADXL345(II2CBus device)
			: base() {
			if (device == null) {
				device = new I2CBus(BoardRevision.Rev2);
			}

			this._device = device;
			if (!this._device.IsOpen) {
				this._device.Open();
			}

			this._x = new AxisGyroscope(this, 20f);
			this._y = new AxisGyroscope(this, 20f);
			this._z = new AxisGyroscope(this, 20f);

			this._aX = (AxisGyroscope)this._x;
			this._aY = (AxisGyroscope)this._y;
			this._aZ = (AxisGyroscope)this._z;
		}
Ejemplo n.º 3
0
		/// <summary>
		/// Gets an open I2C connection instance.
		/// </summary>
		/// <param name="boardRev">
		/// Specifies the revision of the RPi board in use. This
		/// used to determine the path to the system file associated
		/// with the i2c bus.
		/// </param>
		/// <returns>
		/// An open I2C connection instance.
		/// </returns>
		/// <exception cref="ObjectDisposedException">
		/// This instance has been disposed.
		/// </exception>
		/// <exception cref="IOException">
		/// Unable to open the bus connection.
		/// </exception>
		public static I2CBus Open(BoardRevision boardRev) {
			I2CBus bus = new I2CBus(boardRev);
			bus.Open();
			return bus;
		}