Hi, I am sending (0x1A00) to the IMU in order to read the temperature value (which I expect it to be encoded as 207), but somehow I got sometimes 1 value, 2 values and sometimes nothing !!
Here is the output:
Here is the code:
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using GTI = Gadgeteer.Interfaces;
using Gadgeteer.Modules.GHIElectronics;
using System.IO;
using Microsoft.SPOT.IO;
using GHI.OSHW.Hardware;
using Microsoft.SPOT.Hardware;
namespace GadgeteerApp7
{
public partial class Program
{
//SPI
static GT.Socket _socket;
static GTI.SPI.Configuration _config;
static GTI.SPI _spi;
// This method is run when the mainboard is powered up or reset.
public void ProgramStarted()
{
// SPI Config
_socket = GT.Socket.GetSocket(1, true, null, null);
_config = new GTI.SPI.Configuration(true, 0, 0, true, true, 1000);
_spi = new GTI.SPI(_socket, _config, GTI.SPI.Sharing.Exclusive, _socket, GT.Socket.Pin.Five, null);
while (true)
{
// SPI Reading
byte[] BytesWrite = new byte[] { 0x1A , 0x00 };
byte[] SPIBuffer = new byte[2];
_spi.WriteRead(BytesWrite, SPIBuffer);
// SPI writing to SD
Debug.Print("IMU Message: ");
Debug.Print(SPIBuffer[0].ToString());
Debug.Print(SPIBuffer[1].ToString());
Thread.Sleep(1000);
}
}
}
}