Skip to content

Commit c7e00cf

Browse files
committed
[S1 BSP] Change i2c device
1 parent 74a0490 commit c7e00cf

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

target/sieon/s1/board/board.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ void bsp_initialize(void)
458458
RT_CHECK(drv_bmi088_init("spi4_dev1", "spi4_dev2", "gyro0", "accel0", 0));
459459
RT_CHECK(drv_icm42688_init("spi4_dev3", "gyro1", "accel1", 0));
460460
RT_CHECK(drv_bmm150_init("spi4_dev4", "mag0"));
461-
// RT_CHECK(drv_qmc5883l_init("i2c3_dev1", "mag0"));
461+
// RT_CHECK(drv_qmc5883l_init("i2c1_dev2", "mag0"));
462462
RT_CHECK(drv_spl06_init("spi1_dev1", "barometer"));
463463
RT_CHECK(gps_ubx_init("serial3", "gps"));
464464
// RT_CHECK(drv_tofsense_init("serial5"));

target/sieon/s1/drivers/drv_i2c.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,14 @@ static struct stm32_i2c_bus stm32_i2c4 = { .parent.ops = &i2c_bus_ops, .I2C = I2
353353
/* i2c device instances */
354354
static struct rt_i2c_device i2c1_dev1 = { .slave_addr = IST8310_ADDRESS, /* 7 bit address */
355355
.flags = 0 };
356-
static struct rt_i2c_device i2c2_dev1 = { .slave_addr = IST8310_ADDRESS, /* 7 bit address */
356+
static struct rt_i2c_device i2c1_dev2 = { .slave_addr = QMC5883L_ADDRESS, /* 7 bit address */
357357
.flags = 0 };
358-
static struct rt_i2c_device i2c1_dev2 = { .slave_addr = 0x0D, /* 7 bit address */
358+
static struct rt_i2c_device i2c2_dev1 = { .slave_addr = IST8310_ADDRESS, /* 7 bit address */
359359
.flags = 0 };
360-
static struct rt_i2c_device i2c2_dev2 = { .slave_addr = 0x0D, /* 7 bit address */
361-
.flags = 0 };
362-
static struct rt_i2c_device i2c3_dev1 = { .slave_addr = 0x0D, /* 7 bit address */
363-
.flags = 0 };
364-
static struct rt_i2c_device i2c4_dev1 = { .slave_addr = 0x0D, /* 7 bit address */
365-
.flags = 0 };
360+
static struct rt_i2c_device i2c2_dev2 = { .slave_addr = QMC5883L_ADDRESS, /* 7 bit address */
361+
.flags = 0 };
362+
static struct rt_i2c_device i2c3_dev1 = { .slave_addr = QMC5883L_ADDRESS, /* 7 bit address */
363+
.flags = 0 };
366364

367365
rt_err_t drv_i2c_init(void)
368366
{
@@ -376,16 +374,16 @@ rt_err_t drv_i2c_init(void)
376374
RT_TRY(rt_i2c_bus_device_register(&stm32_i2c1.parent, "i2c1"));
377375
RT_TRY(rt_i2c_bus_device_register(&stm32_i2c2.parent, "i2c2"));
378376
RT_TRY(rt_i2c_bus_device_register(&stm32_i2c3.parent, "i2c3"));
379-
RT_TRY(rt_i2c_bus_device_register(&stm32_i2c4.parent, "i2c4"));
377+
RT_TRY(rt_i2c_bus_device_register(&stm32_i2c4.parent, "i2c4")); // I2C4 is exported
380378

381379
/* attach i2c devices */
382380
RT_TRY(rt_i2c_bus_attach_device(&i2c1_dev1, "i2c1_dev1", "i2c1", RT_NULL));
383-
RT_TRY(rt_i2c_bus_attach_device(&i2c2_dev1, "i2c2_dev1", "i2c2", RT_NULL));
384-
385381
RT_TRY(rt_i2c_bus_attach_device(&i2c1_dev2, "i2c1_dev2", "i2c1", RT_NULL));
382+
383+
RT_TRY(rt_i2c_bus_attach_device(&i2c2_dev1, "i2c2_dev1", "i2c2", RT_NULL));
386384
RT_TRY(rt_i2c_bus_attach_device(&i2c2_dev2, "i2c2_dev2", "i2c2", RT_NULL));
385+
387386
RT_TRY(rt_i2c_bus_attach_device(&i2c3_dev1, "i2c3_dev1", "i2c3", RT_NULL));
388-
RT_TRY(rt_i2c_bus_attach_device(&i2c4_dev1, "i2c4_dev1", "i2c4", RT_NULL));
389387

390388
return RT_EOK;
391389
}

target/sieon/s1/drivers/drv_i2c.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ extern "C" {
2424

2525
/* i2c slave device addresses */
2626
#define IST8310_ADDRESS 0x0E
27+
#define QMC5883L_ADDRESS 0x0D
2728
#define NCP5623C_ADDRESS 0x39
2829

2930
rt_err_t drv_i2c_init(void);

0 commit comments

Comments
 (0)