From 0f562e37ede5dc41ec6b3821d415bb905882f535 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 10 Nov 2026 11:24:41 +0000 Subject: [PATCH] fix(display): return TWIM0 to its reset state before the application starts The I2C OLED path left SHORTS (LASTTX_STOP), the pin selects and stale events in TWIM0. The application starts with no reset in between, and the Adafruit nRF52 Arduino core never writes SHORTS: its repeated-start transfers get stopped by the leftover short and it then waits for EVENTS_SUSPENDED with no timeout. Refs #67 Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_015KcV6HbcJCxeQdgbjH49rq --- src/boards/boards.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/boards/boards.c b/src/boards/boards.c index 62409ab7..20194dcb 100644 --- a/src/boards/boards.c +++ b/src/boards/boards.c @@ -1171,6 +1171,20 @@ void board_display_teardown(void) { _display_present = false; } nrf_twim_disable(_twim); + + // The application starts with no reset in between and the Arduino core never + // writes SHORTS: a LASTTX_STOP left here stops its repeated-start transfers, + // and it then waits for SUSPENDED with no timeout. + nrf_twim_shorts_set(_twim, 0); + nrf_twim_event_clear(_twim, NRF_TWIM_EVENT_STOPPED); + nrf_twim_event_clear(_twim, NRF_TWIM_EVENT_ERROR); + nrf_twim_event_clear(_twim, NRF_TWIM_EVENT_SUSPENDED); + nrf_twim_event_clear(_twim, NRF_TWIM_EVENT_RXSTARTED); + nrf_twim_event_clear(_twim, NRF_TWIM_EVENT_TXSTARTED); + nrf_twim_event_clear(_twim, NRF_TWIM_EVENT_LASTRX); + nrf_twim_event_clear(_twim, NRF_TWIM_EVENT_LASTTX); + (void) nrf_twim_errorsrc_get_and_clear(_twim); + nrf_twim_pins_set(_twim, 0xFFFFFFFF, 0xFFFFFFFF); } static bool oled_write_page(uint8_t page, uint8_t col, uint8_t const* buf, size_t nbytes) {