Advertisement
blackswords

IMU3000 header

May 28th, 2012
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.04 KB | None | 0 0
  1. /*
  2.  * IMU3000.h
  3.  *
  4.  *  Created on: 27 mai 2012
  5.  *      Author: blackswords
  6.  *
  7.  *  Update time : 493ยตs
  8.  */
  9.  
  10. #ifndef IMU3000_H_
  11. #define IMU3000_H_
  12.  
  13. #include "WProgram.h"
  14. #include "MyLib.h"
  15. #include <HardWire.h>
  16.  
  17. class IMU3000 {
  18. public:
  19.     IMU3000();
  20.     virtual ~IMU3000();
  21.  
  22.     void Init(uint8 I2CPort, uint8 flags = 0);
  23.  
  24.     void Update();
  25.     void GetGyro();
  26.     void GetAcc();
  27.     void SetFullScaleRange(fullScale new_fs);
  28.     void SetLowPassFilter(LPFilter new_lp);
  29.     void Calibration();
  30.  
  31.     axes gyro, acc, calib;
  32.  
  33. private:
  34.  
  35.     fullScale   FS;
  36.     LPFilter    LP;
  37.  
  38.     void    WriteReg(uint8_t address, uint8_t reg, uint8_t value);
  39.     uint8_t ReadReg(uint8_t address, uint8_t reg);
  40.     void    BurstWrite(uint8_t address, uint8_t first_reg, uint8_t nbytes, uint8_t *buff);
  41.     void    BurstRead(uint8_t address, uint8_t first_reg, uint8_t nbytes, uint8_t *buff);
  42. };
  43.  
  44. //#define AUTO_CALIB
  45.  
  46. /***        I2C Address and port        ***/
  47. #define IMU3000_ADDR        0b1101000
  48. #define ADXL345_ADDR        0x53
  49.  
  50. /***        Values      ***/
  51. #define FS_RANGE 2000.0
  52.  
  53. /***        Registers       ***/
  54. // IMU3000
  55. #define WHO_AM_I                0x00
  56. #define X_OFFS_USRH             0x0C
  57. #define X_OFFS_USRL             0x0D
  58. #define Y_OFFS_USRH             0x0E
  59. #define Y_OFFS_USRL             0x0F
  60. #define Z_OFFS_USRH             0x10
  61. #define Z_OFFS_USRL             0x11
  62. #define FIFO_EN                 0x12
  63. #define AUX_VDDIO               0x13
  64. #define AUX_SLV_ADDR            0x14
  65. #define SMPLRT_DIV              0x15
  66. #define DLPF_FS                 0x16
  67. #define INT_CFG                 0x17
  68. #define AUX_BURST_AD            0x18
  69. #define INT_STATUS R            0x1A
  70. #define TEMP_OUT_H              0x1B
  71. #define TEMP_OUT_L              0x1C
  72. #define GYRO_XOUT_H             0x1D
  73. #define GYRO_XOUT_L             0x1E
  74. #define GYRO_YOUT_H             0x1F
  75. #define GYRO_YOUT_L             0x20
  76. #define GYRO_ZOUT_H             0x21
  77. #define GYRO_ZOUT_L             0x22
  78. #define AUX_XOUT_H              0x23
  79. #define AUX_XOUT_L              0x24
  80. #define AUX_YOUT_H              0x25
  81. #define AUX_YOUT_L              0x26
  82. #define AUX_ZOUT_H              0x27
  83. #define AUX_ZOUT_L              0x28
  84. #define DMP_REG1                0x35
  85. #define DMP_REG2                0x36
  86. #define DMP_REG3                0x37
  87. #define DMP_REG4                0x38
  88. #define DMP_REG5                0x39
  89. #define FIFO_COUNT_H            0x3A
  90. #define FIFO_COUNT_L            0x3B
  91. #define FIFO_R                  0x3C
  92. #define USER_CTRL               0x3D
  93. #define PWR_MGM                 0x3E
  94.  
  95. #define IMU3000_BURST_R_ADDR    GYRO_XOUT_H
  96.  
  97. // ADXL345
  98. #define DEVID                   0x00
  99. #define THRESH_TAP              0x1D
  100. #define OFSX                    0x1E
  101. #define OFSY                    0x1F
  102. #define OFSZ                    0x20
  103. #define DUR                     0x21
  104. #define Latent                  0x22
  105. #define Window                  0x23
  106. #define THRESH_ACT              0x24
  107. #define THRESH_INACT            0x25
  108. #define TIME_INACT              0x26
  109. #define ACT_INACT_CTL           0x27
  110. #define THRESH_FF               0x28
  111. #define TIME_FF                 0x29
  112. #define TAP_AXES                0x2A
  113. #define ACT_TAP_STATUS          0x2B
  114. #define BW_RATE                 0x2C
  115. #define POWER_CTL               0x2D
  116. #define INT_ENABLE              0x2E
  117. #define INT_MAP                 0x2F
  118. #define INT_SOURCE              0x30
  119. #define DATA_FORMAT             0x31
  120. #define DATAX0                  0x32
  121. #define DATAX1                  0x33
  122. #define DATAY0                  0x34
  123. #define DATAY1                  0x35
  124. #define DATAZ0                  0x36
  125. #define DATAZ1                  0x37
  126. #define FIFO_CTL                0x38
  127. #define FIFO_STATUS             0x39
  128.  
  129. #define ADXL345_BURST_R_ADDR    DATAX0
  130.  
  131. extern IMU3000 IMU;
  132.  
  133. #endif /* IMU3000_H_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement