@@ -22,7 +22,6 @@ static uint8_t uart_tx_buf[4096];
2222static uint8_t uart_rx_buf [256 ];
2323
2424static void FEB_Variable_Conversion (void );
25- static void FEB_I2C1_Bus_Recovery (void );
2625
2726/* ============================================================================
2827 * TPS Device Handles and Data
@@ -414,41 +413,6 @@ void FEB_1ms_Callback(void)
414413 }
415414}
416415
417- /* ============================================================================
418- * I2C Bus Recovery
419- * ============================================================================ */
420-
421- /**
422- * Bit-bang up to 9 SCL pulses on PB8/PB9 to free a slave that is holding SDA
423- * low after an aborted transaction, then issue a manual STOP and re-init the
424- * I2C peripheral.
425- */
426- static void FEB_I2C1_Bus_Recovery (void )
427- {
428- HAL_StatusTypeDef init_st ;
429- GPIO_PinState scl_entry = HAL_GPIO_ReadPin (SCL_GPIO_Port , SCL_Pin );
430- GPIO_PinState sda_entry = HAL_GPIO_ReadPin (SDA_GPIO_Port , SDA_Pin );
431-
432- /* The HAL_I2C_DeInit / HAL_I2C_Init dance does not actually reset the I2C
433- * peripheral's internal logic on STM32F4 — fields like the BUSY flag in
434- * SR2 can stay latched after a TIMEOUT and corrupt every subsequent
435- * transaction. Toggling CR1.SWRST is the only thing that clears them.
436- * Sequence: PE=0 → SWRST=1 (hold) → SWRST=0 → re-init via HAL_I2C_Init. */
437-
438- __HAL_I2C_DISABLE (& hi2c1 );
439- hi2c1 .Instance -> CR1 |= I2C_CR1_SWRST ;
440- /* SWRST must be held; a few NOPs is enough but HAL_Delay(1) is safe. */
441- HAL_Delay (1 );
442- hi2c1 .Instance -> CR1 &= ~I2C_CR1_SWRST ;
443-
444- /* Force HAL_I2C_Init to redo the full configure path. */
445- hi2c1 .State = HAL_I2C_STATE_RESET ;
446- init_st = HAL_I2C_Init (& hi2c1 );
447-
448- LOG_I (TAG_MAIN , "BusRecovery: entry SCL=%d SDA=%d | SWRST done | Init=%d ErrCode=0x%08lX" , (int )scl_entry ,
449- (int )sda_entry , (int )init_st , (unsigned long )hi2c1 .ErrorCode );
450- }
451-
452416/* ============================================================================
453417 * Data Conversion and Filtering
454418 * ============================================================================ */
0 commit comments