diff --git a/cores/arduino/stm32/spi_com.c b/cores/arduino/stm32/spi_com.c index a1f0cc0e73..d389cf37da 100644 --- a/cores/arduino/stm32/spi_com.c +++ b/cores/arduino/stm32/spi_com.c @@ -222,6 +222,7 @@ void spi_init(spi_t *obj, uint32_t speed, spi_mode_e mode, uint8_t msb) /* Fill default value */ handle->Instance = obj->spi; handle->Init.Mode = SPI_MODE_MASTER; + handle->State = HAL_SPI_STATE_RESET; spi_freq = spi_getClkFreqInst(obj->spi); if(speed >= (spi_freq/SPI_SPEED_CLOCK_DIV2_MHZ)) { diff --git a/cores/arduino/stm32/twi.c b/cores/arduino/stm32/twi.c index 193d7fc7ab..211afb0c82 100644 --- a/cores/arduino/stm32/twi.c +++ b/cores/arduino/stm32/twi.c @@ -253,6 +253,8 @@ void i2c_custom_init(i2c_t *obj, i2c_timing_e timing, uint32_t addressingMode, u handle->Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; handle->Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; + handle->State = HAL_I2C_STATE_RESET; + if(master == 0) { HAL_NVIC_SetPriority(obj->irq, 0, 1); HAL_NVIC_EnableIRQ(obj->irq);