I'm trying to communicate with an onboard BMA222 accelerometer. This is my first time doing SPI communication, so could anyone tell me what my code is missing? I simply get no responses.
#include "SPI.h"
void setup()
{
pinMode(17, OUTPUT); //pin 17 is Chip select
digitalWrite(17,HIGH);
SPI.begin();
SerialUSB.begin(9600);
}
void loop()
{
byte c;
digitalWrite(17, LOW);
c = SPI.transfer(0x08); //0x08 is the temperature sensor
digitalWrite(17, HIGH);
SerialUSB.println("Temp:"+c);
}
Printing "c" results in no output. I realize I am missing SPI_MODE stuff, but I'm not sure which mode corresponds to the BMA222, and I have seen example code online that does not use it. Could that be my problem? Thanks!