Self test boot program for testing icarus sensors
Dependencies: BLE_API mbed nRF51822
Fork of BLE_UARTConsole by
MPU9250Sensor.cpp
- Committer:
- smigielski
- Date:
- 2015-01-29
- Revision:
- 11:70359785c2a7
- Parent:
- 10:3a24c970db40
- Child:
- 13:ef0ce8fa871f
File content as of revision 11:70359785c2a7:
#include "MPU9250Sensor.h" #include "mbed.h" #ifndef LOG #define LOG(...) do printf(__VA_ARGS__); while (0) #endif MPU9250Sensor::MPU9250Sensor(SPI* spi_,DigitalOut* cs_) : BaseSensor() { this->spi=spi_; this->cs=cs_; *cs = UP; //To prevent switching into I2C mode when using SPI, the I2C interface should be disabled by setting the I2C_IF_DIS //configuration bit. Setting this bit should be performed immediately after waiting for the time specified by the //“Start-Up Time for Register Read/Write” in Section 6.3. } char* MPU9250Sensor::getSimpleName() { return "MPU9250"; } uint32_t MPU9250Sensor::verifyIntegrity(uint32_t* errorResult) { LOG("Start verfication of MPU9250 Sensor"); uint32_t errors = 0; //who am I register value is 0x71 // uint8_t sensorId = readRegister(MPU9250_WHOAMI); // if (sensorId !=0x71){ // errorResult[errors++] = ERROR_WRONG_DEVICE_ID; // LOG("Wrong sensorId: %X",sensorId); // } //check status registry // uint8_t status = readRegister(STATUS); //indicate that SEU error was detetcted // if (status & (1 << 7)){ // errorResult[errors++] = ERROR_SEU_ERROR_DETECT; // LOG("SEU error detected: %X",status); // } //check that chip is in awaken state //if (!(status & (1 << 6))){ // errorResult[errors++] = ERROR_DEVICE_SLEEPING; // LOG("Chip not awaken: %X",status); // } //perform self test // errors+=selfTest(&errorResult[errors]); return errors; } void MPU9250Sensor::getSensorDetails(sensor_t* sensorDetails) { } //uint8_t MPU9250Sensor::readRegister( uint8_t reg){ // cs->write(DOWN); // spi->write(reg| MPU9250_READ_FLAG); // uint8_t val = spi->write(0x00); // cs->write(UP); // return (val); //} // //void MPU9250Sensor::writeRegister( uint8_t reg, uint8_t cmd ){ // cs->write(DOWN); // spi->write(reg); // spi->write(cmd); // cs->write(UP); //}