Skip to content

Commit 156ccfc

Browse files
authored
Merge pull request #114 from VVESTM/hal_state_reset
initialize state before calling HAL_XXX_Init for SPI and I2C
2 parents 5f5b063 + 3e44d53 commit 156ccfc

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

Diff for: cores/arduino/stm32/spi_com.c

+1
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ void spi_init(spi_t *obj, uint32_t speed, spi_mode_e mode, uint8_t msb)
222222
/* Fill default value */
223223
handle->Instance = obj->spi;
224224
handle->Init.Mode = SPI_MODE_MASTER;
225+
handle->State = HAL_SPI_STATE_RESET;
225226

226227
spi_freq = spi_getClkFreqInst(obj->spi);
227228
if(speed >= (spi_freq/SPI_SPEED_CLOCK_DIV2_MHZ)) {

Diff for: cores/arduino/stm32/twi.c

+2
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ void i2c_custom_init(i2c_t *obj, i2c_timing_e timing, uint32_t addressingMode, u
253253
handle->Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
254254
handle->Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
255255

256+
handle->State = HAL_I2C_STATE_RESET;
257+
256258
if(master == 0) {
257259
HAL_NVIC_SetPriority(obj->irq, 0, 1);
258260
HAL_NVIC_EnableIRQ(obj->irq);

0 commit comments

Comments
 (0)