Skip to content

Commit 6cb1540

Browse files
committed
optimize i2c/adc api and example
1 parent 97c72fb commit 6cb1540

9 files changed

Lines changed: 201 additions & 213 deletions

File tree

src/fw/board/boards/board_em_lb525.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,9 @@ extern PwmConfig pwm2_ch1;
7070

7171
extern ADCInputConfig adc1_ch7;
7272
extern ADCInputConfig adc1_ch0;
73-
extern I2CBus i2c1;
7473
extern struct I2CSlavePort i2c1_device;
7574

7675

77-
78-
7976
static const BoardConfig BOARD_CONFIG = {
8077
.ambient_light_dark_threshold = 150,
8178
.ambient_k_delta_threshold = 50,

src/fw/drivers/i2c.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -618,15 +618,11 @@ void command_power_2v5(char *arg) {
618618
#endif
619619

620620
#ifdef MICRO_FAMILY_SF32LB
621-
void i2c_repear()
621+
void example_i2c()
622622
{
623-
i2c_hal_repare();
624-
}
625-
void example_i2c(struct I2CSlavePort * i2c)
626-
{
627-
i2c_init(i2c->bus);
628-
i2c_use(i2c);
629-
i2c_release(i2c);
623+
i2c_init(i2c1_device.bus);
624+
i2c_use(&i2c1_device);
625+
i2c_release(&i2c1_device);
630626
}
631627
#endif
632628

src/fw/drivers/i2c.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ bool i2c_write_register_block(I2CSlavePort *slave, uint8_t register_address_star
9797
bool i2c_write_block(I2CSlavePort *slave, uint32_t write_size, const uint8_t* buffer);
9898

9999
#ifdef MICRO_FAMILY_SF32LB
100-
extern void example_i2c(struct I2CSlavePort * i2c);
101-
extern void i2c_repear();
100+
extern void example_i2c();
102101
#endif
103102

src/fw/drivers/i2c_hal.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,4 @@ void i2c_hal_start_transfer(I2CBus *bus);
3838
void i2c_hal_pins_set_gpio(I2CBus *bus);
3939
void i2c_hal_pins_set_i2c(I2CBus *bus);
4040
#endif
41-
#ifdef MICRO_FAMILY_SF32LB
42-
void i2c_hal_repare();
43-
#endif
41+

0 commit comments

Comments
 (0)