Пример #1
0
            public InteropI2CBus(GT.Socket socket, GT.Socket.Pin sdaPin, GT.Socket.Pin sclPin, ushort address, int clockRateKHz, GTM.Module module)
            {
                this.Address      = address;
                this.ClockRateKHz = clockRateKHz;

                this.softwareBus = new SoftwareI2CBus(socket.CpuPins[(int)sclPin], socket.CpuPins[(int)sdaPin]);
            }
Пример #2
0
 static public void Disable()
 {
     if (i2cbus != null && i2cdev != null)
     {
         WriteToRegister(0x2A, 0);//bit 0 is 0 - standby
         isActived = false;
         i2cdev    = null;
         i2cbus.Dispose();
         i2cbus = null;
     }
 }
Пример #3
0
        /// <summary>
        /// Disables the accelerometer to save power.
        /// </summary>
        public static void Disable()
        {
            if (!Accelerometer.IsEnabled)
            {
                return;
            }

            Accelerometer.WriteToRegister(0x2A, 0);

            Accelerometer.I2CDevice = null;
            Accelerometer.I2CBus.Dispose();
            Accelerometer.I2CBus = null;

            Accelerometer.Enabled = false;
        }
Пример #4
0
        /// <summary>
        /// Enables the accelerometer functionality if it was disabled.
        /// </summary>
        public static void Enable()
        {
            if (Accelerometer.IsEnabled)
            {
                return;
            }

            Accelerometer.I2CBus    = new SoftwareI2CBus(Accelerometer.I2C_CLK, Accelerometer.I2C_DATA);
            Accelerometer.I2CDevice = Accelerometer.I2CBus.CreateI2CDevice(Accelerometer.I2C_ADDRESS, 400);

            //bit 0 is 1 - active
            //bit 0 is 0 - standby
            //bit 1 = 1: 8 bit accurate - fast mode read
            //bit 1 = 0: 10 bit accurate - normal mode read

            WriteToRegister(0x2A, 1);

            Accelerometer.Enabled = true;
        }
Пример #5
0
        //const String TEXT_EXCEPTION_00 = "Accelerometer needs to be enable by calling Enable() function";
        static public void Enable()
        {
            if (i2cbus == null)
            {
                i2cbus = new SoftwareI2CBus(i2c_clk, i2c_dat);
            }
            if (i2cdev == null)
            {
                i2cdev = i2cbus.CreateI2CDevice(0x1C, 400);
            }



            //bit 0 is 1 - active
            //bit 0 is 0 - standby
            //bit 1 = 1: 8 bit accurate - fast mode read
            //bit 1 = 0: 10 bit accurate - normal mode read

            isActived = true;
            WriteToRegister(0x2A, 1); //bit 0 is 1 - active
        }
Пример #6
0
 bool NativeI2CWriteRead(GT.Socket socket, GT.Socket.Pin sda, GT.Socket.Pin scl, byte address, byte[] write, int writeOffset, int writeLen, byte[] read, int readOffset, int readLen, out int numWritten, out int numRead)
 {
     // implement this method if you support NativeI2CWriteRead for faster DaisyLink performance
     // otherwise, the DaisyLink I2C interface will be supported in Gadgeteer.dll in managed code.
     return(SoftwareI2CBus.DirectI2CWriteRead(socket.CpuPins[(int)scl], socket.CpuPins[(int)sda], 100, address, write, writeOffset, writeLen, read, readOffset, readLen, out numWritten, out numRead));
 }
Пример #7
0
 bool NativeI2CWriteRead(GT.Socket socket, GT.Socket.Pin sda, GT.Socket.Pin scl, byte address, byte[] write, int writeOffset, int writeLen, byte[] read, int readOffset, int readLen, out int numWritten, out int numRead)
 {
     return(SoftwareI2CBus.DirectI2CWriteRead(socket.CpuPins[(int)scl], socket.CpuPins[(int)sda], 100, address, write, writeOffset, writeLen, read, readOffset, readLen, out numWritten, out numRead));
 }