diff options
| author | Damien George <damien@micropython.org> | 2022-01-21 14:59:13 +1100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-01-21 15:10:30 +1100 |
| commit | 7d71ae25edc4b405dd03222f044bc7cf3b77f956 (patch) | |
| tree | e5c1f9c9266ebb6b5f18b58c53d82b15fab419e2 /extmod/machine_i2c.c | |
| parent | a707fe50b085ec83722106609f6fd219faf9f030 (diff) | |
extmod/machine_i2c: Increase default SoftI2C timeout to 50ms.
Some devices, eg BNO055, can stretch SCL for a long time, so make the
default large to accommodate them. 50ms matches the current default for
stm32 hardware I2C .
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'extmod/machine_i2c.c')
| -rw-r--r-- | extmod/machine_i2c.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/extmod/machine_i2c.c b/extmod/machine_i2c.c index b2e39c534..2b1275e5b 100644 --- a/extmod/machine_i2c.c +++ b/extmod/machine_i2c.c @@ -33,6 +33,8 @@ #include "py/runtime.h" #include "extmod/machine_i2c.h" +#define SOFT_I2C_DEFAULT_TIMEOUT_US (50000) // 50ms + #if MICROPY_PY_MACHINE_SOFTI2C typedef mp_machine_soft_i2c_obj_t machine_i2c_obj_t; @@ -651,7 +653,7 @@ STATIC void mp_machine_soft_i2c_init(mp_obj_base_t *self_in, size_t n_args, cons { MP_QSTR_scl, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, { MP_QSTR_sda, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, { MP_QSTR_freq, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 400000} }, - { MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 255} }, + { MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = SOFT_I2C_DEFAULT_TIMEOUT_US} }, }; mp_machine_soft_i2c_obj_t *self = (mp_machine_soft_i2c_obj_t *)self_in; |
