Exemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="port">The SPI port the accelerometer is attached to</param>
 /// <param name="range">The range (+ or -) that the accelerometer will measure.</param>
 public ADXL345_SPI(SPI.Port port, AccelerometerRange range)
 {
     m_spi = new SPI(port);
     m_spi.SetClockRate(500000);
     m_spi.SetSampleDataOnFalling();
     m_spi.SetClockActiveLow();
     m_spi.SetChipSelectActiveHigh();
     byte[] commands = new byte[2];
     commands[0] = PowerCtlRegister;
     commands[1] = (byte)PowerCtl.Measure;
     m_spi.Write(commands, 2);
     AccelerometerRange = range;
     HAL.Report(ResourceType.kResourceType_ADXL345, Instances.kADXL345_SPI);
     LiveWindow.AddSensor("ADXL345_SPI", (byte)port, this);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="port">The SPI port the accelerometer is attached to</param>
 /// <param name="range">The range (+ or -) that the accelerometer will measure.</param>
 public ADXL345_SPI(SPI.Port port, AccelerometerRange range)
 {
     m_spi = new SPI(port);
     m_spi.SetClockRate(500000);
     m_spi.SetSampleDataOnFalling();
     m_spi.SetClockActiveLow();
     m_spi.SetChipSelectActiveHigh();
     byte[] commands = new byte[2];
     commands[0] = PowerCtlRegister;
     commands[1] = (byte)PowerCtl.Measure;
     m_spi.Write(commands, 2);
     AccelerometerRange = range;
     HAL.Base.HAL.Report(ResourceType.kResourceType_ADXL345, Instances.kADXL345_SPI);
     LiveWindow.LiveWindow.AddSensor("ADXL345_SPI", (byte)port, this);
 }