rename i2c_num_status
to peripherals_i2c_get_free_num
This commit is contained in:
parent
d9eafffa6a
commit
647e589a6a
@ -79,7 +79,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
|
||||
}
|
||||
self->sda_pin = sda;
|
||||
self->scl_pin = scl;
|
||||
self->i2c_num = i2c_num_status();
|
||||
self->i2c_num = peripherals_i2c_get_free_num();
|
||||
|
||||
if (self->i2c_num == I2C_NUM_MAX) {
|
||||
mp_raise_ValueError(translate("All I2C peripherals are in use"));
|
||||
|
@ -50,7 +50,7 @@ void common_hal_i2cperipheral_i2c_peripheral_construct(i2cperipheral_i2c_periphe
|
||||
|
||||
self->sda_pin = sda;
|
||||
self->scl_pin = scl;
|
||||
self->i2c_num = i2c_num_status();
|
||||
self->i2c_num = peripherals_i2c_get_free_num();
|
||||
|
||||
if (self->i2c_num == I2C_NUM_MAX) {
|
||||
mp_raise_ValueError(translate("All I2C peripherals are in use"));
|
||||
|
@ -68,11 +68,12 @@ void peripherals_i2c_deinit(i2c_port_t num) {
|
||||
i2c_status[num] = STATUS_FREE;
|
||||
}
|
||||
|
||||
i2c_port_t i2c_num_status(void) {
|
||||
i2c_port_t peripherals_i2c_get_free_num(void) {
|
||||
i2c_port_t i2c_num = I2C_NUM_MAX;
|
||||
for (i2c_port_t num = 0; num < I2C_NUM_MAX; num++) {
|
||||
if (i2c_status[num] == STATUS_FREE) {
|
||||
i2c_num = num;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i2c_num != I2C_NUM_MAX) {
|
||||
|
@ -33,6 +33,6 @@ extern void i2c_reset(void);
|
||||
extern void never_reset_i2c(i2c_port_t num);
|
||||
extern esp_err_t peripherals_i2c_init(i2c_port_t num, const i2c_config_t *i2c_conf);
|
||||
extern void peripherals_i2c_deinit(i2c_port_t num);
|
||||
extern i2c_port_t i2c_num_status(void);
|
||||
extern i2c_port_t peripherals_i2c_get_free_num(void);
|
||||
|
||||
#endif // MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_I2C_HANDLER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user