Repository navigation
Board detection: open hardware I2C in consumers, and route detection through board_detect::io - #367
Merged
Merged
Conversation
Detection communicates over software I2C only; opening hardware peripherals is outside its responsibility. Like SPI, hardware I2C ports are now initialized by their consumers. Remove preparation handoff and bus journaling. Initialize the affected backlights and CoreMatrix transport in their own setup. Observe Tab5 touch identities with scoped software I2C after power, preserving retries and partial-power-failure observations while keeping public options and NVS unchanged.
Keep driver and platform dependencies in a replaceable implementation so detection can be reused independently. Add compile-time selection for pin, timing, I2C and chip-data operations without exposing driver types. Leave identification, retry policies and dedicated-GPIO aggregation with the detectors. Preserve timing-sensitive operation sequences and replace SDK host stubs with independent I/O simulation plus a native adapter for construction fixtures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two changes to the board detection framework before it is released in 0.3.0. The first changes one contract; the second only moves code.
1. Board detection no longer opens a hardware I2C port
All I2C traffic during detection already used a software (bit-banged) port. Only at the end of
prepare()was the board's internal hardware I2C port opened and left open for later users. Opening a hardware peripheral is outside what detection should do, and SPI already works the other way: detection reads panel IDs by bit-banging, andBus_SPIopens the host itself.Hardware I2C is now opened by its consumers, as touch drivers,
Bus_I2Cand the other backlight classes already do:init().Panel_Device::init()initializes the light beforerst_control(), so the Core2 / CoreS3 reset lines driven through the PMIC / IO expander still find the port open.Bus_I2C::init()owns it afterwards.board_result_t::prepared; NVS contents and the public option values are unchanged.After
M5GFX::init()the internal port is still open whenever the board has a touch controller or an I2C backlight, because those open it; M5Unified'sIn_I2C.begin()opens it in any case.2. Detection goes through
board_detect::ioDetection code called lgfx GPIO / I2C / timing functions and ESP-IDF registers directly from about a dozen files. These now go through one inline layer,
src/board_detect/detect_io.hpp(contract) anddetect_io_default.inl(the default implementation, which forwards to lgfx and ESP-IDF). The detection files no longer referencelgfx::,esp_*or register macros, apart from the publicboard_tvalues and display construction.boolwith output arguments, no driver result types), chip information (package, eFuse fields, chip revision, PSRAM state, USB-Serial/JTAG frame number) and the low-level ESP32-S3 dedicated-GPIO and classic ESP32 touch / LED operations.M5GFX_BOARD_DETECT_IO_HEADER), no virtual calls. Forwarders arealways_inline; the LED pulse routine stays in IRAM.No behavior change is intended in this part. Comparing the disassembly of
M5GFX.cpp.obefore and after on ESP32, S3, C5, C6, C61 and P4: timing-sensitive functions (bit-banged SPI, held-SDA release, pull measurements, the S3 dedicated-GPIO sampling loop, classic ESP32 touch measurement and LED clear) have the same instruction sequences apart from compact encodings and alignment. The remaining differences are log line numbers and register allocation from thebool/ output-argument returns.Testing
test/board_detect): all pass; added cases for the Tab5 observation (each touch result, DSI fallback, fixed / detected, power step failure) and the CoreMatrix port release.extras/board_spec:npm testandnpm run checkpass.