L3GD20 & L3G4200D / STMicroelectronics / MEMS motion sensor, three-axis gyroscope library
Dependents: GR-PEACH_test_wo_rtos GR-PEACH_test_on_rtos_works_well
Diff: L3GD20.h
- Revision:
- 6:451811697299
- Parent:
- 5:81fc00bd76fe
- Child:
- 7:f5c0fe6ed71a
--- a/L3GD20.h Tue Feb 24 12:21:41 2015 +0000 +++ b/L3GD20.h Tue Feb 24 12:24:29 2015 +0000 @@ -1,5 +1,5 @@ /* - * mbed library program + * mbed library program * L3GD20 MEMS motion sensor: 3-axis digital gyroscope, made by STMicroelectronics * http://www.st.com/web/catalog/sense_power/FM89/SC1288 * /PF252443?sc=internet/analog/product/252443.jsp @@ -10,7 +10,7 @@ * Copyright (c) 2014,'15 Kenji Arai / JH1PJL * http://www.page.sannet.ne.jp/kenjia/index.html * http://mbed.org/users/kenjiArai/ - * Created: July 13th, 2014 + * Created: July 13th, 2014 * Revised: Feburary 24th, 2015 * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, @@ -132,7 +132,8 @@ * @endcode */ -class L3GX_GYRO{ +class L3GX_GYRO +{ public: /** Configure data pin * @param data SDA and SCL pins @@ -143,7 +144,7 @@ * @param full scale selection, FS_250DPS, FS_500DPS, FS_2000DPS */ L3GX_GYRO(PinName p_sda, PinName p_scl, - uint8_t addr, uint8_t data_rate, uint8_t bandwidth, uint8_t fullscale); + uint8_t addr, uint8_t data_rate, uint8_t bandwidth, uint8_t fullscale); /** Configure data pin * @param data SDA and SCL pins @@ -154,13 +155,13 @@ * @default full scale selection = FS_250DPS */ L3GX_GYRO(PinName p_sda, PinName p_scl, uint8_t addr); - + /** Configure data pin (with other devices on I2C line) * @param I2C previous definition * @param other parameters -> please see L3GX_GYRO(PinName p_sda, PinName p_scl,...) */ L3GX_GYRO(I2C& p_i2c, - uint8_t addr, uint8_t data_rate, uint8_t bandwidth, uint8_t fullscale); + uint8_t addr, uint8_t data_rate, uint8_t bandwidth, uint8_t fullscale); /** Configure data pin (with other devices on I2C line) * @param I2C previous definition @@ -176,14 +177,14 @@ * @return temperature unit:degreeC(Celsius) */ int8_t read_temp(); - + /** Read a float type data from Gyro * @param float type of three arry's address, e.g. float dt_usr[3]; * @return Gyro motion data unit in param array:dps(degree per second) - * @return dt_usr[0]->x, dt_usr[1]->y, dt_usr[2]->z + * @return dt_usr[0]->x, dt_usr[1]->y, dt_usr[2]->z */ void read_data(float *dt_usr); - + /** Read a Gyro ID number * @param none * @return if STM MEMS Gyro, it should be I_AM_L3G4200D(0xd3) or I_AM_L3GD20(0xd4) @@ -219,13 +220,13 @@ void initialize(uint8_t, uint8_t, uint8_t, uint8_t); I2C _i2c; - + private: float fs_factor; // full scale factor char dt[2]; // working buffer uint8_t gyro_addr; // gyro sensor address uint8_t gyro_id; // gyro ID - uint8_t gyro_ready; // gyro is on I2C line = 1, not = 0 + uint8_t gyro_ready; // gyro is on I2C line = 1, not = 0 }; #endif // L3GD20_GYRO_H