Beta
Dependencies: ST_INTERFACES X_NUCLEO_COMMON
Fork of X_NUCLEO_IKS01A2 by
Diff: Components/LSM303AGRSensor/LSM303AGRAccSensor.cpp
- Revision:
- 9:038121268b07
- Parent:
- 6:671fd10a51b7
--- a/Components/LSM303AGRSensor/LSM303AGRAccSensor.cpp Tue Mar 14 13:56:20 2017 +0100 +++ b/Components/LSM303AGRSensor/LSM303AGRAccSensor.cpp Tue Mar 14 13:30:55 2017 +0000 @@ -49,16 +49,16 @@ * @param i2c object of an helper class which handles the I2C peripheral * @param address the address of the component's instance */ -LSM303AGRAccSensor::LSM303AGRAccSensor(DevI2C &i2c) : dev_i2c(i2c) +LSM303AGRAccSensor::LSM303AGRAccSensor(DevI2C &i2c) : _dev_i2c(i2c) { - address = LSM303AGR_ACC_I2C_ADDRESS; + _address = LSM303AGR_ACC_I2C_ADDRESS; }; /** Constructor * @param i2c object of an helper class which handles the I2C peripheral * @param address the address of the component's instance */ -LSM303AGRAccSensor::LSM303AGRAccSensor(DevI2C &i2c, uint8_t address) : dev_i2c(i2c), address(address) +LSM303AGRAccSensor::LSM303AGRAccSensor(DevI2C &i2c, uint8_t address) : _dev_i2c(i2c), _address(address) { }; @@ -111,9 +111,9 @@ } /* Select default output data rate. */ - Last_ODR = 100.0f; + _last_odr = 100.0f; - isEnabled = 0; + _is_enabled = 0; return 0; } @@ -122,21 +122,21 @@ * @brief Enable LSM303AGR Accelerator * @retval 0 in case of success, an error code otherwise */ -int LSM303AGRAccSensor::Enable(void) +int LSM303AGRAccSensor::enable(void) { /* Check if the component is already enabled */ - if ( isEnabled == 1 ) + if ( _is_enabled == 1 ) { return 0; } /* Output data rate selection. */ - if ( set_x_odr_when_enabled( Last_ODR ) == 1 ) + if ( set_x_odr_when_enabled( _last_odr ) == 1 ) { return 1; } - isEnabled = 1; + _is_enabled = 1; return 0; } @@ -145,16 +145,16 @@ * @brief Disable LSM303AGR Accelerator * @retval 0 in case of success, an error code otherwise */ -int LSM303AGRAccSensor::Disable(void) +int LSM303AGRAccSensor::disable(void) { /* Check if the component is already disabled */ - if ( isEnabled == 0 ) + if ( _is_enabled == 0 ) { return 0; } /* Store actual output data rate. */ - if ( get_x_odr( &Last_ODR ) == 1 ) + if ( get_x_odr( &_last_odr ) == 1 ) { return 1; } @@ -165,7 +165,7 @@ return 1; } - isEnabled = 0; + _is_enabled = 0; return 0; } @@ -239,15 +239,15 @@ if( lp_value == LSM303AGR_ACC_LPEN_DISABLED && hr_value == LSM303AGR_ACC_HR_DISABLED ) { /* Normal Mode */ - return get_x_sensitivity_Normal_Mode( pfData ); + return get_x_sensitivity_normal_mode( pfData ); } else if ( lp_value == LSM303AGR_ACC_LPEN_ENABLED && hr_value == LSM303AGR_ACC_HR_DISABLED ) { /* Low Power Mode */ - return get_x_sensitivity_LP_Mode( pfData ); + return get_x_sensitivity_lp_mode( pfData ); } else if ( lp_value == LSM303AGR_ACC_LPEN_DISABLED && hr_value == LSM303AGR_ACC_HR_ENABLED ) { /* High Resolution Mode */ - return get_x_sensitivity_HR_Mode( pfData ); + return get_x_sensitivity_hr_mode( pfData ); } else { /* Not allowed */ @@ -260,7 +260,7 @@ * @param sensitivity the pointer where the accelerometer sensitivity is stored * @retval 0 in case of success, an error code otherwise */ -int LSM303AGRAccSensor::get_x_sensitivity_Normal_Mode( float *sensitivity ) +int LSM303AGRAccSensor::get_x_sensitivity_normal_mode( float *sensitivity ) { LSM303AGR_ACC_FS_t fullScale; @@ -298,7 +298,7 @@ * @param sensitivity the pointer where the accelerometer sensitivity is stored * @retval 0 in case of success, an error code otherwise */ -int LSM303AGRAccSensor::get_x_sensitivity_LP_Mode( float *sensitivity ) +int LSM303AGRAccSensor::get_x_sensitivity_lp_mode( float *sensitivity ) { LSM303AGR_ACC_FS_t fullScale; @@ -336,7 +336,7 @@ * @param sensitivity the pointer where the accelerometer sensitivity is stored * @retval 0 in case of success, an error code otherwise */ -int LSM303AGRAccSensor::get_x_sensitivity_HR_Mode( float *sensitivity ) +int LSM303AGRAccSensor::get_x_sensitivity_hr_mode( float *sensitivity ) { LSM303AGR_ACC_FS_t fullScale; @@ -374,7 +374,7 @@ * @param pData the pointer where the accelerometer raw data are stored * @retval 0 in case of success, an error code otherwise */ -int LSM303AGRAccSensor::get_x_axesRaw(int16_t *pData) +int LSM303AGRAccSensor::get_x_axes_raw(int16_t *pData) { uint8_t regValue[6] = {0, 0, 0, 0, 0, 0}; u8_t shift = 0; @@ -472,7 +472,7 @@ */ int LSM303AGRAccSensor::set_x_odr(float odr) { - if(isEnabled == 1) + if(_is_enabled == 1) { if(set_x_odr_when_enabled(odr) == 1) { @@ -522,7 +522,7 @@ */ int LSM303AGRAccSensor::set_x_odr_when_disabled(float odr) { - Last_ODR = ( odr <= 1.0f ) ? 1.0f + _last_odr = ( odr <= 1.0f ) ? 1.0f : ( odr <= 10.0f ) ? 10.0f : ( odr <= 25.0f ) ? 25.0f : ( odr <= 50.0f ) ? 50.0f