How yangyuanxin/stm32-i2c-scanner works
This is a standalone STM32F103 I²C address scanner: after boot checks, it probes the 7-bit bus, identifies known addresses, and presents diagnostics on an ST7735 screen with LED feedback. The main application owns the scan/recovery loop and selects progressively slower timing profiles. The README documents floating-bus checks, GPIO self-test, and recovery; the sampled code confirms scan probing, display rendering, and the register-based support layer. Some finer wiring is documented rather than visible in the excerpts.
Main entry points: main.c Scan state machine · stm32f103xb.h STM32 register definitions · i2c_bb.c Address probe · st7735.c ST7735 graphics driver
Components 17
Scanner application
- Scan state machine
src/main.c - GPIO self-test
src/main.c - Bus checks
src/main.c - Bus recovery
src/i2c_bb.c - Results and diagnostics
src/main.c - LED indication
src/main.c
I2C engine
- Speed profiles
src/i2c_bb.c - Address scan
src/i2c_bb.c - Address probe
src/i2c_bb.c - Floating-bus validation
src/i2c_bb.c - Known-device lookup
src/i2c_bb.c
Display output
- ST7735 graphics driver
src/st7735.c
Hardware support
- HAL compatibility layer
src/hal_stub.c - STM32 register definitions
include/stm32f103xb.h
Other components
- Technician
- I2C target devices
- ST7735 LCD
Connections 22
- Technician → Scan state machine: powers on
- Scan state machine → GPIO self-test: runs at boot
- Scan state machine → Bus checks: checks bus
- Scan state machine → Speed profiles: sets timing
- Scan state machine → Address scan: requests scan
- Scan state machine → Bus recovery: requests recovery
- Address scan → Floating-bus validation: checks pull-up
- Address scan → Address probe: probes addresses
- Address probe → I2C target devices: sends address
- I2C target devices → Address probe: ACKs or NACKs
- Scan state machine → Known-device lookup: looks up devices
- Scan state machine → Results and diagnostics: renders results
- Results and diagnostics → ST7735 graphics driver: draws interface
- ST7735 graphics driver → ST7735 LCD: sends SPI display data
- Scan state machine → LED indication: signals device count
- GPIO self-test → STM32 register definitions: tests GPIO
- Bus checks → STM32 register definitions: reads bus lines
- Bus recovery → STM32 register definitions: toggles bus GPIO
- Address probe → STM32 register definitions: bit-bangs GPIO
- ST7735 graphics driver → STM32 register definitions: controls SPI and GPIO
- Scan state machine → HAL compatibility layer: initializes and delays
- HAL compatibility layer → STM32 register definitions: accesses hardware