Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ADXL362 mbed MPL3115A2
main.cpp
- Committer:
- htdoughe
- Date:
- 2018-02-20
- Revision:
- 1:b8716571ecac
- Parent:
- 0:0f663d16e8a2
- Child:
- 2:496a662be854
File content as of revision 1:b8716571ecac:
#include "mbed.h" #include "mbed.h" #include "ADXL362.h" // Interface pulled from ADXL362.cpp // ADXL362::ADXL362(PinName CS, PinName MOSI, PinName MISO, PinName SCK) : ADXL362 adxl362(PA_0,PA_7,PA_6,PA_1); int main() { adxl362.reset(); wait_ms(600); // we need to wait at least 500ms after ADXL362 reset adxl362.set_mode(ADXL362::MEASUREMENT); int8_t x,y,z; adxl362_reg_print(start, length); while(1) { x=adxl362.scanx_u8(); y=adxl362.scany_u8(); z=adxl362.scanz_u8(); printf("x = %d y = %d z = %d\r\n",x,y,z); wait_ms(100); } } int adxl362_reg_print(int s, int l){ //check s is 0x00 and 0x2E if(s > 0x2E || s < 0x00){ printf("adx: requires start between 0x00 and 0x2E; given %d (0x%01x)\n", s,s); return 1; }else if(l < 0){ //check length >0 printf("adx: requires length >= 0, given %d\n", l); return 1; }else{ // start sending stuff //first check DEVID_AD == 0xAD if(DEVID_AD != 0xAD){ printf("error: DEVID_AD is not 0xAD\n"); return 1; }else{ //now do stuff //if length == 0, send everything from s to end of registers if(l == 0){ } } } }