acceleration_sensor.hpp
Go to the documentation of this file.
1 /*
2  * SocialLedge.com - Copyright (C) 2013
3  *
4  * This file is part of free software framework for embedded processors.
5  * You can use it and/or distribute it as long as this copyright header
6  * remains unmodified. The code is free for personal use and requires
7  * permission to use in a commercial product.
8  *
9  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
10  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
12  * I SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
13  * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
14  *
15  * You can reach the author of this software at :
16  * p r e e t . w i k i @ g m a i l . c o m
17  */
18 
24 #ifndef ACCELERATION_SENSOR_HPP_
25 #define ACCELERATION_SENSOR_HPP_
26 #include <stdint.h>
27 #include "i2c2_device.hpp" // I2C Device Base Class
28 
29 
30 
38 class Acceleration_Sensor : private i2c2_device, public SingletonTemplate<Acceleration_Sensor>
39 {
40  public:
41  bool init();
42 
43  int16_t getX();
44  int16_t getY();
45  int16_t getZ();
46 
47  private:
50  {
51  }
53 
54 
55 
57  static const unsigned char mWhoAmIExpectedValue = 0x2A;
58  typedef enum {
59  status=0,
60  X_MSB=1, X_LSB=2,
61  Y_MSB=3, Y_LSB=4,
62  Z_MSB=5, Z_LSB=6,
63 
64  SysMod=0xb, IntSource=0xc,WhoAmI=0xd,
65  XYZDataCfg=0xe,HPFilterCutoff=0xf,
66 
67  PL_Status=0x10, PL_Cfg=0x11, PL_Count=0x12, PL_BF_ZComp=0x13, PL_THS_Reg=0x14,
68  FF_MT_Cfg=0x15, FF_MT_Src=0x16, FF_MT_THS=0x17, FF_MT_Count=0x18,
69 
70  Transient_Cfg=0x1d, Transient_Src=0x1e, Transient_THS=0x1f, Transient_Count=0x20,
71  Pulse_Cfg=0x21, Pulse_Src=0x22, Pulse_THSX=0x23, Pulse_THSY=0x24, Pulse_THSZ=0x25,
72  Pulse_TMLT=0x26, Pulse_LTCY=0x27, Pulse_Wind=0x28,
73 
74  ASLP_Count=0x29,
75  Ctrl_Reg1=0x2A, Ctrl_Reg2=0x2B, Ctrl_Reg3=0x2C, Ctrl_Reg4=0x2D, Ctrl_Reg5=0x2E,
76  OffsetX=0x2F, OffsetY=0x30, OffsetZ=0x31
77 
78  } __attribute__ ((packed)) RegisterMap;
79 
80 };
81 
82 
83 #endif /* ACCELERATION_SENSOR_HPP_ */
Definition: i2c2_device.hpp:39
Definition: i2c2.hpp:56
int16_t getY()
Definition: io_source.cpp:131
__attribute__
Definition: rtc.h:56
int16_t getX()
Definition: io_source.cpp:127
Definition: acceleration_sensor.hpp:38
int16_t getZ()
Definition: io_source.cpp:135
bool init()
Initializes the sensor.
Definition: io_source.cpp:118
Definition: singleton_template.hpp:55