How erwinschrodinger1/dln2-generic works
dln2-generic is firmware and reusable components for making a microcontroller act as a DLN2 USB I/O adapter. Its main workflow is: a Linux DLN2 host sends commands over USB bulk endpoints; the USB class driver hands transfers to the protocol layer, which dispatches by module to GPIO, I2C, SPI, or ADC handlers; handlers use platform driver interfaces to operate hardware and form protocol responses. GPIO events and I2C bus recovery are additional capabilities. The source excerpts show transport dispatch and several handler-to-driver calls; subsystem links not shown directly are omitted or marked unverified.
Main entry points: dln2.c Transfer and slots · dln2-i2c-master.c I2C master · dln2-gpio.c GPIO commands · gpio_driver.h GPIO interface
Components 16
USB transport
- USB descriptors
src/tusb/usb_descriptors.c - USB class driver
src/app/driver.c
Protocol handling
- Transfer and slots
src/app/dln2.c - Protocol definitions
src/app/dln2.h - Pin ownership
src/app/dln2-pin.c - Logging
src/utils/dln2_log.h
I/O modules
- GPIO commands
src/app/dln2-gpio.c - I2C master
src/app/dln2-i2c-master.c - SPI master
src/app/dln2-spi-master.c - ADC commands
src/app/dln2-adc.c
Platform interfaces
- GPIO interface
src/drivers/gpio_driver.h - I2C interface
src/drivers/i2c_master_driver.h - SPI interface
src/drivers/spi_master_driver.h - ADC interface
src/drivers/adc_driver.h
Other components
- DLN2 host
- MCU hardware
Connections 20
- DLN2 host → USB class driver: sends bulk commands
README.md - USB descriptors → DLN2 host: exposes bulk interface
src/tusb/usb_descriptors.c - USB class driver → Transfer and slots: forwards transfers
src/app/driver.c - Transfer and slots → Protocol definitions: uses definitions
src/app/dln2.c - Transfer and slots → GPIO commands: dispatches commands
src/app/dln2.c - Transfer and slots → I2C master: dispatches commands
src/app/dln2.c - Transfer and slots → SPI master: dispatches commands
src/app/dln2.c - Transfer and slots → ADC commands: dispatches commands
src/app/dln2.c - GPIO commands → GPIO interface: calls driver
src/app/dln2-gpio.c - I2C master → I2C interface: calls driver
src/app/dln2-i2c-master.c - I2C master → GPIO interface: recovers bus
src/app/dln2-i2c-master.c - SPI master → SPI interface: uses driver
- ADC commands → ADC interface: uses driver
src/app/dln2-adc.c - GPIO commands → Pin ownership: claims pins
- I2C master → Pin ownership: claims pins
src/app/dln2-i2c-master.c - GPIO interface → MCU hardware: operates pins
- I2C interface → MCU hardware: operates bus
- SPI interface → MCU hardware: operates bus
- ADC interface → MCU hardware: reads channels
- Transfer and slots → Logging: logs transfers
src/app/dln2.c