diff options
| author | Damien George | 2018-02-02 19:04:36 +1100 |
|---|---|---|
| committer | Damien George | 2018-02-02 19:04:36 +1100 |
| commit | 4b8e58756bf408f4a899d7cf787ed1961f6f9682 (patch) | |
| tree | c91e8c9e9ac79718908e5920b91ff60bd2757312 /ports/stm32/i2c.c | |
| parent | 5ddd1488bd5ac7a41d76e68b84ff858d7fa0aad7 (diff) | |
stm32/i2c: Allow I2C peripheral state to persist across a soft reset.
The I2C sub-system is independent from the uPy state (eg the heap) and so
can safely persist across a soft reset.
Diffstat (limited to 'ports/stm32/i2c.c')
| -rw-r--r-- | ports/stm32/i2c.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/ports/stm32/i2c.c b/ports/stm32/i2c.c index 6cb6538cb..56c63684f 100644 --- a/ports/stm32/i2c.c +++ b/ports/stm32/i2c.c @@ -217,21 +217,18 @@ uint32_t i2c_get_baudrate(I2C_InitTypeDef *init) { #endif void i2c_init0(void) { - // reset the I2C1 handles + // Initialise the I2C handles. + // The structs live on the BSS so all other fields will be zero after a reset. #if defined(MICROPY_HW_I2C1_SCL) - memset(&I2CHandle1, 0, sizeof(I2C_HandleTypeDef)); I2CHandle1.Instance = I2C1; #endif #if defined(MICROPY_HW_I2C2_SCL) - memset(&I2CHandle2, 0, sizeof(I2C_HandleTypeDef)); I2CHandle2.Instance = I2C2; #endif #if defined(MICROPY_HW_I2C3_SCL) - memset(&I2CHandle3, 0, sizeof(I2C_HandleTypeDef)); I2CHandle3.Instance = I2C3; #endif #if defined(MICROPY_HW_I2C4_SCL) - memset(&I2CHandle4, 0, sizeof(I2C_HandleTypeDef)); I2CHandle4.Instance = I2C4; #endif } |
