# SN-L00 Firmware RP2040-based firmware for the SN-L00 Eurorack latency tester. ## Requirements - [Raspberry Pi Pico SDK](https://github.com/raspberrypi/pico-sdk) v1.5+ - CMake 3.13+ - ARM GCC toolchain (`arm-none-eabi-gcc`) ## Building ### Linux/macOS ```bash # Set SDK path (add to .bashrc/.zshrc for persistence) export PICO_SDK_PATH=/path/to/pico-sdk # Build cd firmware mkdir build && cd build cmake .. make ``` ### Output files After building: - `sn_l00.uf2` - Flash via USB (drag to RPI-RP2 drive) - `sn_l00.elf` - For debugging with SWD ## Flashing 1. Hold BOOTSEL button on RP2040-Zero 2. Connect USB cable (or press reset while holding BOOTSEL) 3. Drag `sn_l00.uf2` to the `RPI-RP2` drive 4. Module reboots automatically ## Usage ### Modes | Mode | Entry | Display | Behavior | |------|-------|---------|----------| | Single | Default / Long press from Continuous | `SINGLE` | Press button to measure once | | Continuous | Long press from Single | `CONT` | Auto-measures every 500ms | | Stats | Short press from Continuous | Min/Max/Avg | Shows measurement statistics | ### Controls - **Short press**: Trigger measurement (Single mode) / Exit to Stats (Continuous) - **Long press (>500ms)**: Toggle between Single and Continuous modes - **Any press in Stats**: Return to Single mode, reset statistics ## USB Serial The firmware exposes USB CDC serial for debugging: - Baud: 115200 (or any, it's USB CDC) - Shows measurement results and mode changes ```bash # Linux screen /dev/ttyACM0 115200 # macOS screen /dev/tty.usbmodem* 115200 ``` ## GPIO Pinout | GPIO | Function | Direction | |------|----------|-----------| | GP0 | I2C SDA (OLED) | Bidir | | GP1 | I2C SCL (OLED) | Output | | GP2 | Trigger Output | Output | | GP3 | Return Input | Input | | GP4 | Button | Input (pull-up) | ## Code Structure ``` firmware/ ├── CMakeLists.txt # Build configuration ├── include/ │ ├── config.h # Pin definitions, timing constants │ ├── display.h # OLED display interface │ ├── latency.h # Measurement functions │ └── button.h # Button handling └── src/ ├── main.c # Application entry, state machine ├── display.c # SSD1306 OLED driver ├── latency.c # Timer-based latency measurement └── button.c # Debounced button with long press ``` ## Measurement Accuracy - Timer resolution: ~1µs (RP2040 @ 125MHz) - Display resolution: 0.01ms (10µs) - Polling loop: ~1-2µs per iteration - Practical accuracy: ±10µs The main latency contributors are: 1. Input buffer propagation delay (~10ns, negligible) 2. GPIO read latency (~10ns, negligible) 3. Polling loop timing (~1-2µs) ## Future Improvements - [ ] Configurable trigger pulse width - [ ] Sample rate display (in samples @ 44.1/48/96kHz) - [ ] CV output proportional to latency - [ ] Threshold adjustment via long button hold - [ ] EEPROM settings storage