ADXL basic test
Dependencies: mbed
Fork of BLE_UARTConsole by
main.cpp
- Committer:
- smigielski
- Date:
- 2015-01-30
- Revision:
- 10:4e3a56a61c3b
- Parent:
- 9:17b6ab281627
File content as of revision 10:4e3a56a61c3b:
#include "mbed.h" SPI spi(P0_28, P0_24, P0_29); // mosi, miso, sclk DigitalOut cs(P0_23); // ACC Registers #define ADXL362_DEVID_AD 0x00 #define ADXL362_DEVID_MST 0x01 #define ADXL362_PART_ID 0x02 #define ADXL362_REV_ID 0x03 #define ADXL362_DATA 0x08 #define ADXL362_READ_REGISTER 0x0b void readRegister(uint8_t reg){ cs = 0; spi.write(ADXL362_READ_REGISTER); spi.write(reg); uint8_t val = spi.write(0x00); cs = 1; } //Test that spi is working with adxl362 int main() { cs=1; while(1) { readRegister(ADXL362_DEVID_AD); wait(0.5); readRegister(ADXL362_DEVID_MST); wait(0.5); readRegister(ADXL362_PART_ID); wait(0.5); readRegister(ADXL362_REV_ID); wait(0.5); readRegister(ADXL362_DATA); wait(0.5); } }