Skip to content

Commit 3b8cffa

Browse files
authored
Merge pull request #190 from Pan-Chenliang/bmi055_driver_fix
Fix bmi055 driver accel spi device name
2 parents 551023e + 1268281 commit 3b8cffa

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

src/driver/imu/bmi055.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "hal/spi/spi.h"
2323

2424
#define DRV_DBG(...)
25+
// #define DRV_DBG(...) console_printf(__VA_ARGS__)
2526

2627
#define BIT(_idx) (1 << _idx)
2728
#define REG_VAL(_setbits, _clearbits) \
@@ -297,7 +298,7 @@ static rt_err_t gyro_read_rad(gyro_dev_t gyro_dev, float gyr[3])
297298

298299
// change to NED coordinate
299300
bmi055_rotate_to_frd(gyr, (uint32_t)gyro_dev->parent.user_data & 0x7F);
300-
301+
301302
return RT_EOK;
302303
}
303304

@@ -532,18 +533,18 @@ const static struct accel_ops __accel_ops = {
532533
accel_read,
533534
};
534535

535-
#define GYRO_CONFIG \
536-
{ \
537-
1000, /* 1K sample rate */ \
538-
92, /* 256Hz bandwidth */ \
539-
GYRO_RANGE_2000DPS, /* +-2000 deg/s */ \
536+
#define GYRO_CONFIG \
537+
{ \
538+
1000, /* 1K sample rate */ \
539+
92, /* 256Hz bandwidth */ \
540+
GYRO_RANGE_2000DPS, /* +-2000 deg/s */ \
540541
}
541542

542-
#define ACCEL_CONFIG \
543-
{ \
544-
1000, /* 1K sample rate */ \
545-
125, /* 125Hz bandwidth */ \
546-
ACCEL_RANGE_16G, /* +-16g */ \
543+
#define ACCEL_CONFIG \
544+
{ \
545+
1000, /* 1K sample rate */ \
546+
125, /* 125Hz bandwidth */ \
547+
ACCEL_RANGE_16G, /* +-16g */ \
547548
}
548549

549550
static struct gyro_device gyro_dev = {
@@ -558,11 +559,11 @@ static struct accel_device accel_dev = {
558559
.bus_type = GYRO_SPI_BUS_TYPE
559560
};
560561

561-
rt_err_t drv_bmi055_init(const char* spi_device_name, const char* gyro_device_name, const char* accel_device_name, uint32_t dev_flags)
562+
rt_err_t drv_bmi055_init(const char* gyro_spi_device_name, const char* accel_spi_device_name, const char* gyro_device_name, const char* accel_device_name, uint32_t dev_flags)
562563
{
563564
/* Initialize gyroscope */
564565

565-
gyro_spi_dev = rt_device_find(spi_device_name);
566+
gyro_spi_dev = rt_device_find(gyro_spi_device_name);
566567
RT_ASSERT(gyro_spi_dev != NULL);
567568
/* config spi */
568569
{
@@ -585,7 +586,7 @@ rt_err_t drv_bmi055_init(const char* spi_device_name, const char* gyro_device_na
585586

586587
/* Initialize accelerometer */
587588

588-
accel_spi_dev = rt_device_find("spi1_dev4");
589+
accel_spi_dev = rt_device_find(accel_spi_device_name);
589590
RT_ASSERT(accel_spi_dev != NULL);
590591
/* config spi */
591592
{

src/driver/imu/bmi055.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
extern "C" {
2323
#endif
2424

25-
rt_err_t drv_bmi055_init(const char* spi_device_name, const char* gyro_device_name, const char* accel_device_name, uint32_t dev_flags);
25+
rt_err_t drv_bmi055_init(const char* gyro_spi_device_name, const char* accel_spi_device_name, const char* gyro_device_name, const char* accel_device_name, uint32_t dev_flags);
2626

2727
#ifdef __cplusplus
2828
}

target/cuav/v5_nano/board/board.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ void bsp_initialize(void)
438438
#else
439439
/* init onboard sensors */
440440
RT_CHECK(drv_icm20689_init("spi1_dev1", "gyro0", "accel0", 0));
441-
RT_CHECK(drv_bmi055_init("spi1_dev3", "gyro1", "accel1", 0));
441+
RT_CHECK(drv_bmi055_init("spi1_dev3", "spi1_dev4", "gyro1", "accel1", 0));
442442
RT_CHECK(drv_ms5611_init("spi4_dev1", "barometer"));
443443
/* if no gps mag then use onboard mag */
444444
// if (drv_ist8310_init("i2c1_dev1", "mag0", EXTERNAL_DEV | 0) != RT_EOK) {

target/cuav/v5_plus/board/board.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ void bsp_initialize(void)
434434
#else
435435
/* init onboard sensors */
436436
RT_CHECK(drv_icm20689_init("spi1_dev1", "gyro0", "accel0", 0));
437-
RT_CHECK(drv_bmi055_init("spi1_dev3", "gyro1", "accel1", 0));
437+
RT_CHECK(drv_bmi055_init("spi1_dev3", "spi1_dev4", "gyro1", "accel1", 0));
438438
RT_CHECK(drv_ms5611_init("spi4_dev1", "barometer"));
439439
/* if no gps mag then use onboard mag */
440440
if (drv_ist8310_init("i2c1_dev1", "mag0", EXTERNAL_DEV | 0) != RT_EOK) {

target/pixhawk/fmu-v5/board/board.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ void bsp_initialize(void)
421421
#else
422422
/* init onboard sensors */
423423
RT_CHECK(drv_icm20689_init("spi1_dev1", "gyro0", "accel0", 0));
424-
RT_CHECK(drv_bmi055_init("spi1_dev3", "gyro1", "accel1", 0));
424+
RT_CHECK(drv_bmi055_init("spi1_dev3", "spi1_dev4", "gyro1", "accel1", 0));
425425
RT_CHECK(drv_ms5611_init("spi4_dev1", "barometer"));
426426
/* if no gps mag then use onboard mag */
427427
// if (drv_ist8310_init("i2c1_dev1", "mag0", EXTERNAL_DEV | 0) != FMT_EOK) {

0 commit comments

Comments
 (0)