Skip to content

Commit 242277d

Browse files
committed
LVPDB no more bus recovery tomfoolery
1 parent 0a17346 commit 242277d

3 files changed

Lines changed: 2 additions & 38 deletions

File tree

LVPDB/Core/User/Src/FEB_Main.c

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ static uint8_t uart_tx_buf[4096];
2222
static uint8_t uart_rx_buf[256];
2323

2424
static 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
* ============================================================================ */

LVPDB/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.6
1+
1.5.7

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.8
1+
1.5.9

0 commit comments

Comments
 (0)