Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using Microsoft.SPOT;
- using Microsoft.SPOT.Hardware;
- namespace Tester
- {
- class I2CManager
- {
- I2CDevice.Configuration accelConfig = new I2CDevice.Configuration(0x53, 100);
- byte[] data = new byte[6];
- I2CDevice.I2CTransaction[] ReadAccel;
- I2CDevice accel;
- public I2CManager()
- {
- ReadAccel = new I2CDevice.I2CTransaction[]
- {
- I2CDevice.CreateWriteTransaction(new byte[]{0x30}),
- I2CDevice.CreateReadTransaction(data)
- };
- accel = new I2CDevice(accelConfig);
- }
- public void Read()
- {
- int read1 = accel.Execute(new I2CDevice.I2CTransaction[] { ReadAccel[0] }, 1000);
- int read2 = accel.Execute(new I2CDevice.I2CTransaction[] { ReadAccel[1] }, 1000);
- byte[] temp = ReadAccel[1].Buffer;
- Debug.Print("Read: " + read1 + ", " + read2 + ", " + temp[0] + ", " + temp[1]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement