AEM
adxl345.h
Go to the documentation of this file.
1 #ifndef YADLX345_H
2 #define YADLX345_H
3 
4 #include <Arduino.h>
5 #include <SparkFun_ADXL345.h>
6 
7 #include "yspi.h"
8 #include "yADC.h"
9 
10 // SPARFUN define !!
11 #define ADXL345_TO_READ (6) // Number of Bytes Read - Two Bytes Per Axis
12 
13 
14 #define YADXL345_NB_CHANNELS (3)
15 #define YADXL345_T_DELAY (15)
16 #define YADXL345_T_QUIET (15)
21 class YADXL345 : public YADC {
22  protected:
23  byte _buff[ADXL345_TO_READ]; // 6 Byte Buffer
24  float gains[3]; // used to convert output to g's
25 
26  void powerOn() const;
27  void writeToSPI(byte __reg_address, byte __val) const;
28  void readFromSPI(byte __reg_address, int num, byte _buff[]) const;
29  void setRegisterBit(byte regAdress, int bitPos, bool state) const;
30  void setSpiBit(bool spiBit) const;
31  void setRangeSetting(int val) const;
32  void readAccel(int* x, int* y, int* z);
33 
34  public:
35  YADXL345(const YSPI *const y);
36  float acquireChannel(uint8_t channel);
37  bool selftest(void);
38 };
39 #endif
40 
41 
#define ADXL345_TO_READ
Definition: adxl345.h:11
Definition: yspi.h:34
Definition: adxl345.h:21