Creating a project for TT_Mxx

Committer:
ThunderSoft
Date:
Fri Apr 26 09:46:22 2019 +0000
Revision:
1:05a211e75d38
Parent:
0:53c9fac03371
"update the mbed-os code to support TT_M4G9"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ThunderSoft 0:53c9fac03371 1 #ifndef MPU6050_H
ThunderSoft 0:53c9fac03371 2 #define MPU6050_H
ThunderSoft 0:53c9fac03371 3
ThunderSoft 0:53c9fac03371 4 #include "mbed.h"
ThunderSoft 0:53c9fac03371 5
ThunderSoft 0:53c9fac03371 6 class MPU6050 : public I2C {
ThunderSoft 0:53c9fac03371 7
ThunderSoft 0:53c9fac03371 8
ThunderSoft 0:53c9fac03371 9 public:
ThunderSoft 0:53c9fac03371 10 MPU6050();
ThunderSoft 0:53c9fac03371 11 MPU6050(PinName sda,PinName scl);
ThunderSoft 0:53c9fac03371 12 /**
ThunderSoft 0:53c9fac03371 13 * @brief Get MPU6050 device's ID for test the device wheter connect.
ThunderSoft 0:53c9fac03371 14 * @return [0x68] [0xFF] fail.
ThunderSoft 0:53c9fac03371 15 */
ThunderSoft 0:53c9fac03371 16 uint8_t getDeviceID();
ThunderSoft 0:53c9fac03371 17
ThunderSoft 0:53c9fac03371 18 uint16_t getX();
ThunderSoft 0:53c9fac03371 19
ThunderSoft 0:53c9fac03371 20 uint16_t getY();
ThunderSoft 0:53c9fac03371 21
ThunderSoft 0:53c9fac03371 22 uint16_t getZ();
ThunderSoft 0:53c9fac03371 23
ThunderSoft 0:53c9fac03371 24 uint16_t getGX();
ThunderSoft 0:53c9fac03371 25
ThunderSoft 0:53c9fac03371 26 uint16_t getGY();
ThunderSoft 0:53c9fac03371 27
ThunderSoft 0:53c9fac03371 28 uint16_t getGZ();
ThunderSoft 0:53c9fac03371 29 private:
ThunderSoft 0:53c9fac03371 30 /**
ThunderSoft 0:53c9fac03371 31 * @brief Read value from MPU6050 register address
ThunderSoft 0:53c9fac03371 32 * @param register_address
ThunderSoft 0:53c9fac03371 33 * @return [description]
ThunderSoft 0:53c9fac03371 34 */
ThunderSoft 0:53c9fac03371 35 uint8_t readByte(uint8_t register_address);
ThunderSoft 0:53c9fac03371 36
ThunderSoft 0:53c9fac03371 37 /**
ThunderSoft 0:53c9fac03371 38 * @brief Write value to MPU6050's register address.
ThunderSoft 0:53c9fac03371 39 * @param register_address [description]
ThunderSoft 0:53c9fac03371 40 * @param value [description]
ThunderSoft 0:53c9fac03371 41 * @return [0] success.
ThunderSoft 0:53c9fac03371 42 */
ThunderSoft 0:53c9fac03371 43 uint8_t writeByte(uint8_t register_address,uint8_t value);
ThunderSoft 0:53c9fac03371 44
ThunderSoft 0:53c9fac03371 45
ThunderSoft 0:53c9fac03371 46 /**
ThunderSoft 0:53c9fac03371 47 * @brief Init MPU6050 sensor.
ThunderSoft 0:53c9fac03371 48 */
ThunderSoft 0:53c9fac03371 49 void init_sensor();
ThunderSoft 0:53c9fac03371 50
ThunderSoft 0:53c9fac03371 51 /**
ThunderSoft 0:53c9fac03371 52 * @brief Set clock source.
ThunderSoft 0:53c9fac03371 53 * @param value [description]
ThunderSoft 0:53c9fac03371 54 */
ThunderSoft 0:53c9fac03371 55 void setClockSource(uint8_t value);
ThunderSoft 0:53c9fac03371 56
ThunderSoft 0:53c9fac03371 57 /**
ThunderSoft 0:53c9fac03371 58 * @brief Set gyroscopes’ full scale range.
ThunderSoft 0:53c9fac03371 59 * @param value
ThunderSoft 0:53c9fac03371 60 */
ThunderSoft 0:53c9fac03371 61 void setFullScaleGyroRange(uint8_t value);
ThunderSoft 0:53c9fac03371 62
ThunderSoft 0:53c9fac03371 63 /**
ThunderSoft 0:53c9fac03371 64 * @brief Set configure the accelerometer full scale range.
ThunderSoft 0:53c9fac03371 65 * @param value [description]
ThunderSoft 0:53c9fac03371 66 */
ThunderSoft 0:53c9fac03371 67 void setFullScaleAccelRange(uint8_t value);
ThunderSoft 0:53c9fac03371 68
ThunderSoft 0:53c9fac03371 69 };
ThunderSoft 0:53c9fac03371 70
ThunderSoft 0:53c9fac03371 71
ThunderSoft 0:53c9fac03371 72 #endif