Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit a155366

Browse files
BST-Github-Adminkegov
authored andcommitted
Fixed some Macro typos. Updated the bmi160_get_power_mode API. Fixed a bug which configured the pre-filter in the power mode API.
1 parent 3ac7bb6 commit a155366

7 files changed

Lines changed: 56 additions & 112 deletions

File tree

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved.
1+
Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved.
22

33
BSD-3-Clause
44

bmi160.c

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved.
2+
* Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved.
33
*
44
* BSD-3-Clause
55
*
@@ -31,8 +31,8 @@
3131
* POSSIBILITY OF SUCH DAMAGE.
3232
*
3333
* @file bmi160.c
34-
* @date 2021-03-12
35-
* @version v3.9.1
34+
* @date 2021-10-05
35+
* @version v3.9.2
3636
*
3737
*/
3838

@@ -1383,7 +1383,7 @@ int8_t bmi160_get_regs(uint8_t reg_addr, uint8_t *data, uint16_t len, const stru
13831383
}
13841384
else if (len == 0)
13851385
{
1386-
rslt = BMI160_READ_WRITE_LENGHT_INVALID;
1386+
rslt = BMI160_E_READ_WRITE_LENGTH_INVALID;
13871387
}
13881388
else
13891389
{
@@ -1415,7 +1415,7 @@ int8_t bmi160_set_regs(uint8_t reg_addr, uint8_t *data, uint16_t len, const stru
14151415
}
14161416
else if (len == 0)
14171417
{
1418-
rslt = BMI160_READ_WRITE_LENGHT_INVALID;
1418+
rslt = BMI160_E_READ_WRITE_LENGTH_INVALID;
14191419
}
14201420
else
14211421
{
@@ -1627,7 +1627,7 @@ int8_t bmi160_set_power_mode(struct bmi160_dev *dev)
16271627
/*!
16281628
* @brief This API gets the power mode of the sensor.
16291629
*/
1630-
int8_t bmi160_get_power_mode(struct bmi160_pmu_status *pmu_status, const struct bmi160_dev *dev)
1630+
int8_t bmi160_get_power_mode(struct bmi160_dev *dev)
16311631
{
16321632
int8_t rslt = 0;
16331633
uint8_t power_mode = 0;
@@ -1642,10 +1642,9 @@ int8_t bmi160_get_power_mode(struct bmi160_pmu_status *pmu_status, const struct
16421642
rslt = bmi160_get_regs(BMI160_PMU_STATUS_ADDR, &power_mode, 1, dev);
16431643
if (rslt == BMI160_OK)
16441644
{
1645-
/* Power mode of the accel,gyro,aux sensor is obtained */
1646-
pmu_status->aux_pmu_status = BMI160_GET_BITS_POS_0(power_mode, BMI160_MAG_POWER_MODE);
1647-
pmu_status->gyro_pmu_status = BMI160_GET_BITS(power_mode, BMI160_GYRO_POWER_MODE);
1648-
pmu_status->accel_pmu_status = BMI160_GET_BITS(power_mode, BMI160_ACCEL_POWER_MODE);
1645+
/* Power mode of the accel, gyro sensor is obtained */
1646+
dev->gyro_cfg.power = BMI160_GET_BITS(power_mode, BMI160_GYRO_POWER_MODE);
1647+
dev->accel_cfg.power = BMI160_GET_BITS(power_mode, BMI160_ACCEL_POWER_MODE);
16491648
}
16501649
}
16511650

@@ -3523,7 +3522,7 @@ static int8_t set_accel_pwr(struct bmi160_dev *dev)
35233522
}
35243523
else
35253524
{
3526-
rslt = BMI160_E_OUT_OF_RANGE;
3525+
rslt = BMI160_E_INVALID_CONFIG;
35273526
}
35283527

35293528
return rslt;
@@ -3536,7 +3535,7 @@ static int8_t process_under_sampling(uint8_t *data, const struct bmi160_dev *dev
35363535
{
35373536
int8_t rslt;
35383537
uint8_t temp = 0;
3539-
uint8_t pre_filter = 0;
3538+
uint8_t pre_filter[2] = { 0 };
35403539

35413540
rslt = bmi160_get_regs(BMI160_ACCEL_CONFIG_ADDR, data, 1, dev);
35423541
if (rslt == BMI160_OK)
@@ -3551,20 +3550,18 @@ static int8_t process_under_sampling(uint8_t *data, const struct bmi160_dev *dev
35513550
/* Write data */
35523551
rslt = bmi160_set_regs(BMI160_ACCEL_CONFIG_ADDR, data, 1, dev);
35533552

3554-
/* disable the pre-filter data in
3555-
* low power mode */
3553+
/* Disable the pre-filter data in low power mode */
35563554
if (rslt == BMI160_OK)
35573555
{
35583556
/* Disable the Pre-filter data*/
3559-
rslt = bmi160_set_regs(BMI160_INT_DATA_0_ADDR, &pre_filter, 2, dev);
3557+
rslt = bmi160_set_regs(BMI160_INT_DATA_0_ADDR, pre_filter, 2, dev);
35603558
}
35613559
}
35623560
else if (*data & BMI160_ACCEL_UNDERSAMPLING_MASK)
35633561
{
35643562
temp = *data & ~BMI160_ACCEL_UNDERSAMPLING_MASK;
35653563

3566-
/* disable under-sampling parameter
3567-
* if already enabled */
3564+
/* Disable under-sampling parameter if already enabled */
35683565
*data = temp;
35693566

35703567
/* Write data */
@@ -3611,7 +3608,7 @@ static int8_t set_gyro_pwr(struct bmi160_dev *dev)
36113608
}
36123609
else
36133610
{
3614-
rslt = BMI160_E_OUT_OF_RANGE;
3611+
rslt = BMI160_E_INVALID_CONFIG;
36153612
}
36163613

36173614
return rslt;
@@ -6379,6 +6376,7 @@ static int8_t configure_offset_enable(const struct bmi160_foc_conf *foc_conf, st
63796376

63806377
return rslt;
63816378
}
6379+
63826380
static int8_t trigger_foc(struct bmi160_offsets *offset, struct bmi160_dev const *dev)
63836381
{
63846382
int8_t rslt;
@@ -6415,7 +6413,7 @@ static int8_t trigger_foc(struct bmi160_offsets *offset, struct bmi160_dev const
64156413
else
64166414
{
64176415
/* FOC failure case */
6418-
rslt = BMI160_FOC_FAILURE;
6416+
rslt = BMI160_E_FOC_FAILURE;
64196417
}
64206418
}
64216419

bmi160.h

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2020 Bosch Sensortec GmbH. All rights reserved.
2+
* Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved.
33
*
44
* BSD-3-Clause
55
*
@@ -31,8 +31,8 @@
3131
* POSSIBILITY OF SUCH DAMAGE.
3232
*
3333
* @file bmi160.h
34-
* @date 2021-03-12
35-
* @version v3.9.1
34+
* @date 2021-10-05
35+
* @version v3.9.2
3636
*
3737
*/
3838

@@ -224,33 +224,17 @@ int8_t bmi160_set_power_mode(struct bmi160_dev *dev);
224224
* \ingroup bmi160ApiPowermode
225225
* \page bmi160_api_bmi160_get_power_mode bmi160_get_power_mode
226226
* \code
227-
* int8_t bmi160_get_power_mode(struct bmi160_pmu_status *pmu_status, const struct bmi160_dev *dev);
227+
* int8_t bmi160_get_power_mode(struct bmi160_dev *dev);
228228
* \endcode
229229
* @details This API gets the power mode of the sensor.
230230
*
231-
* @param[in] power_mode : Power mode of the sensor
232231
* @param[in] dev : Structure instance of bmi160_dev
233232
*
234-
* power_mode Macros possible values for pmu_status->aux_pmu_status :
235-
* - BMI160_AUX_PMU_SUSPEND
236-
* - BMI160_AUX_PMU_NORMAL
237-
* - BMI160_AUX_PMU_LOW_POWER
238-
*
239-
* power_mode Macros possible values for pmu_status->gyro_pmu_status :
240-
* - BMI160_GYRO_PMU_SUSPEND
241-
* - BMI160_GYRO_PMU_NORMAL
242-
* - BMI160_GYRO_PMU_FSU
243-
*
244-
* power_mode Macros possible values for pmu_status->accel_pmu_status :
245-
* - BMI160_ACCEL_PMU_SUSPEND
246-
* - BMI160_ACCEL_PMU_NORMAL
247-
* - BMI160_ACCEL_PMU_LOW_POWER
248-
*
249233
* @return Result of API execution status
250234
* @retval Zero Success
251235
* @retval Negative Error
252236
*/
253-
int8_t bmi160_get_power_mode(struct bmi160_pmu_status *pmu_status, const struct bmi160_dev *dev);
237+
int8_t bmi160_get_power_mode(struct bmi160_dev *dev);
254238

255239
/**
256240
* \ingroup bmi160

0 commit comments

Comments
 (0)