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.
This commit is contained in:
parent
5ddd1488bd
commit
4b8e58756b
@ -217,21 +217,18 @@ uint32_t i2c_get_baudrate(I2C_InitTypeDef *init) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void i2c_init0(void) {
|
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)
|
#if defined(MICROPY_HW_I2C1_SCL)
|
||||||
memset(&I2CHandle1, 0, sizeof(I2C_HandleTypeDef));
|
|
||||||
I2CHandle1.Instance = I2C1;
|
I2CHandle1.Instance = I2C1;
|
||||||
#endif
|
#endif
|
||||||
#if defined(MICROPY_HW_I2C2_SCL)
|
#if defined(MICROPY_HW_I2C2_SCL)
|
||||||
memset(&I2CHandle2, 0, sizeof(I2C_HandleTypeDef));
|
|
||||||
I2CHandle2.Instance = I2C2;
|
I2CHandle2.Instance = I2C2;
|
||||||
#endif
|
#endif
|
||||||
#if defined(MICROPY_HW_I2C3_SCL)
|
#if defined(MICROPY_HW_I2C3_SCL)
|
||||||
memset(&I2CHandle3, 0, sizeof(I2C_HandleTypeDef));
|
|
||||||
I2CHandle3.Instance = I2C3;
|
I2CHandle3.Instance = I2C3;
|
||||||
#endif
|
#endif
|
||||||
#if defined(MICROPY_HW_I2C4_SCL)
|
#if defined(MICROPY_HW_I2C4_SCL)
|
||||||
memset(&I2CHandle4, 0, sizeof(I2C_HandleTypeDef));
|
|
||||||
I2CHandle4.Instance = I2C4;
|
I2CHandle4.Instance = I2C4;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -458,6 +458,9 @@ int main(void) {
|
|||||||
switch_init0();
|
switch_init0();
|
||||||
#endif
|
#endif
|
||||||
spi_init0();
|
spi_init0();
|
||||||
|
#if MICROPY_HW_ENABLE_HW_I2C
|
||||||
|
i2c_init0();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(USE_DEVICE_MODE)
|
#if defined(USE_DEVICE_MODE)
|
||||||
// default to internal flash being the usb medium
|
// default to internal flash being the usb medium
|
||||||
@ -553,10 +556,6 @@ soft_reset:
|
|||||||
can_init0();
|
can_init0();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MICROPY_HW_ENABLE_HW_I2C
|
|
||||||
i2c_init0();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
pyb_usb_init0();
|
pyb_usb_init0();
|
||||||
|
|
||||||
// Initialise the local flash filesystem.
|
// Initialise the local flash filesystem.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user