180622 HJM : 10 Count sensing data RF send
Fork of ADXL362 by
Diff: ADXL362.h
- Revision:
- 1:bf56b783747e
- Parent:
- 0:d9853774f233
--- a/ADXL362.h Thu Mar 03 13:49:03 2016 +0000 +++ b/ADXL362.h Fri Jun 22 03:41:47 2018 +0000 @@ -22,64 +22,66 @@ #define UP 1 #define SAMPLE_SET 128 -/* Class ADXL362: configure and connect to ADXL362 3-axis accelerometer. - * Richard McWilliam +/* Class ADXL362: configure and connect to ADXL362 3-axis accelerometer. + * Richard McWilliam * - * Example: + * Example: * - * #include "mbed.h" - * #include "ADXL362.h" + * #include "mbed.h" + * #include "ADXL362.h" * - * ADXL362 adxl362(p11, p12, p13, p10); // Accelerometer (mosi, miso, sclk, cs) + * ADXL362 adxl362(p11, p12, p13, p10); // Accelerometer (mosi, miso, sclk, cs) * - * int main() - * { - * // local variables - * int8_t x8 = 0; - * int8_t y8 = 0; - * int8_t z8 = 0; - * uint8_t reg; + * int main() + * { + * // local variables + * int8_t x8 = 0; + * int8_t y8 = 0; + * int8_t z8 = 0; + * uint8_t reg; * - * // set up SPI interface - * adxl362.init_spi(); - * // Set up accelerometer - * adxl362.init_adxl362(); + * // set up SPI interface + * adxl362.init_spi(); + * // Set up accelerometer + * adxl362.init_adxl362(); * - * // Check settings - * reg = adxl362.ACC_ReadReg(FILTER_CTL); - * printf("FILTER_CTL = 0x%X\r\n", reg); + * // Check settings + * reg = adxl362.ACC_ReadReg(FILTER_CTL); + * printf("FILTER_CTL = 0x%X\r\n", reg); * - * adxl362.ACC_GetXYZ8(&x8, &y8, &z8); // Fetch sample from ADXL362 - * wait(0.1); // Wait is required in this mode - * - * } + * adxl362.ACC_GetXYZ8(&x8, &y8, &z8); // Fetch sample from ADXL362 + * wait(0.1); // Wait is required in this mode + * + * } */ class ADXL362 { - - public: - // Set up object for communcation with ADXL362. Pins are mosi, miso, sclk, cs - ADXL362(PinName mosi, PinName miso, PinName sclk, PinName cbs); - //~ADXL362() {}; - - // Initialise the SPI interface for ADXL362 - void init_spi(); - - // Initialise ADXL362 in basic capture mode, 8 bit pcakets. - void init_adxl362(); - - // Fetch a single set of x,y,z packets indicating acceleration - void ACC_GetXYZ8(int8_t* x, int8_t* y, int8_t* z); - - // Read specified register of ADXL362 - uint8_t ACC_ReadReg( uint8_t reg ); - - // Write to register of ADXL362 - void ACC_WriteReg( uint8_t reg, uint8_t cmd ); - - private: - SPI SPI_m; - DigitalOut CBS_m; + + public: + // Set up object for communcation with ADXL362. Pins are mosi, miso, sclk, cs + ADXL362(PinName mosi, PinName miso, PinName sclk, PinName cbs); + //~ADXL362() {}; + + // Initialise the SPI interface for ADXL362 + void init_spi(); + + // Initialise ADXL362 in basic capture mode, 8 bit pcakets. + void init_adxl362(); + + // Fetch a single set of x,y,z packets indicating acceleration + void ACC_GetXYZ8(int8_t* x8, int8_t* y8, int8_t* z8); + // Fetch a single set of x,y,z packets indicating acceleration + void ACC_GetXYZ16(int16_t* x, int16_t* y, int16_t* z); + + // Read specified register of ADXL362 + uint8_t ACC_ReadReg( uint8_t reg ); + + // Write to register of ADXL362 + void ACC_WriteReg( uint8_t reg, uint8_t cmd ); + + private: + SPI SPI_m; + DigitalOut CBS_m; }; #endif \ No newline at end of file