Add LP5562 driver, M1 smoke test, and milestone-based plan

- Integrate LP5562 driver from sibling project (ntag5-samd21-lp562)
  with full doc comments restored
- Update main.rs with complete M1 test: I2C init, GPIO EN, RGBW cycle
- Rewrite DEVELOPMENT_PLAN.md from waterfall to milestone-based groups
  organized by hardware availability (Groups A-E)
- Rewrite STATUS.md with milestone checklist tracking
- Add LP5562 timing constraints and flash script docs to CLAUDE.md
- Add flash_when_ready.sh for auto-flash dev workflow
- Add brainstorm design doc for plan redesign rationale

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
michael
2026-03-03 10:26:24 -08:00
parent bae64c1e3a
commit e4195d2583
8 changed files with 1171 additions and 357 deletions

View File

@@ -1,106 +1,124 @@
# xblink Project Status
**Current Phase**: Phase 0 — Project Setup
**Current Milestone**: M1 — LED Smoke Test (code ready, needs USB cable to flash)
**Last Updated**: 2026-03-03
---
## Phase 0 — Project Setup
## Phase 0 — Project Setup (COMPLETE)
- [x] Initialize git repository
- [x] Initialize Rust project with `cargo init`
- [x] Configure `.cargo/config.toml` for thumbv6m-none-eabi
- [x] Set up `Cargo.toml` with XIAO M0 BSP and embedded-hal 1.0
- [x] Create `.gitignore`
- [x] Create initial `src/main.rs` (blink + LP5562 EN pin on D0/A0)
- [x] Create project directory structure (`src/led/`, `src/ntag5/`, `src/pattern/`, `docs/`)
- [x] Create README.md
- [x] Create CLAUDE.md
- [x] Create docs/STATUS.md (this file)
- [x] Create docs/DEVELOPMENT_PLAN.md
- [x] Initialize git repository and Rust project
- [x] Configure build target (thumbv6m-none-eabi)
- [x] Create project documentation (README, CLAUDE.md, STATUS, DEVELOPMENT_PLAN)
- [x] Verify `cargo build --release` compiles
- [x] Initial git commit
## Phase 1 — LP5562 Driver Integration
## Group A — LP5562 Only
- [ ] Copy LP5562 driver from `../ntag5-samd21-lp562/src/lp5562.rs`
- [ ] Define `LedController` trait in `src/led/mod.rs`
- [ ] Wrap LP5562 driver to implement `LedController`
- [ ] Add GPIO EN pin control to LP5562 wrapper (D0/A0 hardware enable)
- [ ] Test LP5562 direct PWM on XIAO M0 + LP5562EVM
- [ ] Test LP5562 engine programs (breathing, color cycling)
- [ ] Implement `SimplePwm` driver as second `LedController` implementation
**Hardware needed**: XIAO M0 + LP5562EVM + mini-USB cable
## Phase 2 — NTAG5Link Driver (MCU-side I2C Slave)
### M1: LED Smoke Test
- [ ] Implement NTAG5Link register map (`src/ntag5/registers.rs`)
- [ ] Implement EEPROM block read/write via I2C (`src/ntag5/eeprom.rs`)
- [ ] Implement SRAM mailbox read/write (`src/ntag5/sram.rs`)
- [x] Copy LP5562 driver from `../ntag5-samd21-lp562/src/lp5562.rs`
- [x] Create `src/led/mod.rs` with re-exports
- [x] Update `main.rs` with I2C init + GPIO EN + LP5562 direct PWM test
- [x] Verify `cargo build --release` compiles
- [ ] Flash and verify RGBW LED channels on LP5562EVM
### M2: Engine Patterns
- [ ] Build breathing pattern (1 engine, ramp up/down, branch loop)
- [ ] Build heartbeat pattern (1 engine, fast ramp, slow decay)
- [ ] Build RGB color cycle (3 engines, trigger sync)
- [ ] Verify LP5562 runs patterns autonomously (MCU idle loop)
- [ ] Verify MCU can stop and switch patterns
### M3: Hardcoded Pattern Library
- [ ] Define 4-5 const patterns in firmware
- [ ] Implement pattern selector (compile-time or boot-cycle)
- [ ] Reduce LED current to 2-5mA/ch (EH-realistic budget)
- [ ] Document actual engine program structures (informs M5 format design)
## Group B — Add NTAG5Link
**Hardware needed**: + NTAG5Link Click board + I2C jumper
### M4: NTAG5 EEPROM Read/Write
- [ ] Write `Ntag5Link<I2C>` driver (`src/ntag5/mod.rs`)
- [ ] Implement register map (`src/ntag5/registers.rs`)
- [ ] Implement EEPROM block read/write
- [ ] Implement session register access
- [ ] Test EEPROM read/write with XIAO M0 + NTAG5Link Click board
- [ ] Test SRAM mailbox read/write
- [ ] Verify round-trip: write pattern via PCSC reader, read back on MCU
- [ ] Test round-trip: PCSC writes EEPROM, MCU reads back, displays on LEDs
## Phase 3 — Pattern Storage Format
### M5: Boot-from-EEPROM
- [ ] Design binary pattern format (header + engine programs + LED mapping)
- [ ] Document format in `docs/PATTERN_FORMAT.md`
- [ ] Design binary pattern format (informed by M2-M3 experience)
- [ ] Implement pattern deserializer (`src/pattern/mod.rs`)
- [ ] Implement LP5562 engine program builder from pattern data (`src/pattern/engine.rs`)
- [ ] Implement pattern serializer (for MCU-side EEPROM writes)
- [ ] Test: write pattern via PCSC, MCU reads and programs LP5562
- [ ] Implement engine program builder (`src/pattern/engine.rs`)
- [ ] Update main.rs: boot → read EEPROM → parse → program LP5562 → idle
- [ ] Write Python serializer tool for PCSC pattern uploads
## Phase 4 — Power Management
### M6: SRAM Mailbox
- [ ] Characterize energy harvesting power budget with oscilloscope
- [ ] Determine optimal EH voltage/current settings (target: 3.0V, 9.0mA+)
- [ ] Implement SAMD21E STANDBY sleep mode
- [ ] Configure EIC wake on NTAG5Link FD pin
- [ ] Configure EIC wake on hall sensor GPIO
- [ ] Test full boot → program → sleep → wake cycle
- [ ] Measure total system current draw in each state
## Phase 5 — NFC Communication Protocol
- [ ] Design SRAM mailbox protocol (command/response frames)
- [ ] Implement SRAM read/write (`src/ntag5/sram.rs`)
- [ ] Design command/response protocol
- [ ] Implement MCU-side protocol handler
- [ ] Implement chunked transfer for patterns > 252 bytes
- [ ] Extend ntag5sensor Python tooling with xblink protocol commands
- [ ] Test pattern upload via PCSC reader
- [ ] Test with VivoKey RawNFC app
- [ ] Test pattern update via NFC without power-cycling
## Phase 6 — Recovery and Safe Mode
## Group C — Power + Recovery
- [ ] Implement hall sensor GPIO input with debounce
- [ ] Implement recovery mode detection at boot
- [ ] Recovery behavior: hardcoded default pattern, skip EEPROM, stay awake
- [ ] Set recovery flag in SRAM for phone app detection
- [ ] Test recovery mode end-to-end
**Hardware needed**: + Hall sensor + multimeter
## Phase 7 — Firmware Update Strategy
### M7: Sleep/Wake
- [ ] Evaluate NFC pass-through bootloader feasibility (see DEVELOPMENT_PLAN.md)
- [ ] Evaluate UF2 + NFC hybrid approach
- [ ] Implement chosen update mechanism
- [ ] Test firmware update end-to-end
- [ ] Document update procedure
- [ ] Configure SAMD21 EIC for FD pin wake
- [ ] Implement STANDBY sleep after LP5562 programming
- [ ] Verify LP5562 keeps running during MCU sleep
- [ ] Measure current: active vs standby vs total system
## Phase 8 — Custom PCB (SAMD21E)
### M8: Recovery Mode
- [ ] Port from `xiao_m0` BSP to bare `atsamd-hal` with `samd21e` feature
- [ ] Remap pin assignments for SAMD21E18A (32-pin QFN)
- [ ] Provide custom `memory.x` linker script
- [ ] Design PCB schematic (SAMD21E + NTAG5Link + LP5562 + hall sensor + antenna)
- [ ] PCB layout for implant form factor
- [ ] Fabricate and test prototype PCB
- [ ] Wire hall sensor to EIC-capable GPIO
- [ ] Implement boot-time hall sensor check
- [ ] Recovery: load default pattern, skip EEPROM, stay awake
- [ ] Test with magnet
## Phase 9 — Companion App
### M9: Power Characterization
- [ ] React Native project setup
- [ ] NFC communication layer (ISO15693 via platform APIs)
- [ ] Pattern editor UI
- [ ] Pattern upload via NFC
- [ ] Firmware version check / status display
- [ ] Measure current at various LED current settings
- [ ] Test NTAG5Link EH output with phone NFC
- [ ] Find optimal brightness vs EH budget balance
- [ ] Document real power numbers
## Group D — Abstraction + Polish
### M10: LedController Trait
- [ ] Define trait based on proven usage patterns from Groups A-C
- [ ] Implement for LP5562 wrapper
- [ ] Refactor main.rs to trait-based API
### M11: SimplePwm Driver
- [ ] Implement only if single-color LED hardware is available
## Group E — Future
### Custom PCB (SAMD21E)
- [ ] Port to `atsamd-hal` with `samd21e` feature
- [ ] Custom `memory.x` linker script
- [ ] PCB design and fabrication
### Companion App (React Native)
- [ ] NFC communication + pattern editor + upload
### Firmware Update (NFC OTA)
- [ ] Custom bootloader if needed post-implant
---
@@ -108,12 +126,11 @@
| Question | Status | Notes |
|----------|--------|-------|
| Energy harvesting power budget | TBD | Need oscilloscope measurements with LP5562EVM + NTAG5 Click |
| Optimal LED current per channel | TBD | Must fit within EH budget, probably 2-5mA/ch |
| Firmware update strategy | Under evaluation | NFC pass-through vs UF2 hybrid, see DEVELOPMENT_PLAN.md |
| NTAG5Link I2C slave address | Assumed 0x54 | Verify with Click board when jumper available |
| SAMD21E18A package sourcing | Not started | Verify QFN-32 availability for custom PCB phase |
| Antenna design | Not started | Loop antenna for 13.56MHz, PCB-integrated or wire coil |
| Energy harvesting power budget | TBD | Multimeter measurements in M9 |
| Optimal LED current per channel | TBD | Probably 2-5mA/ch, verify in M9 |
| Firmware update strategy | Deferred | UF2 for dev, NFC OTA evaluated later |
| NTAG5Link I2C slave address | Assumed 0x54 | Verify in M4 with Click board |
| Pattern binary format | Deferred to M5 | Design after M2-M3 engine experience |
## Hardware Inventory
@@ -121,6 +138,8 @@
|------|--------|-------|
| Seeed XIAO M0 | Available | Dev board MCU (SAMD21G18A) |
| LP5562EVM | Available | TI eval module, RGBW LEDs, I2C addr 0x30 |
| Mini-USB cable | Not on hand | Needed to flash XIAO M0 |
| NTAG5 Link Click | Available, partially wired | Missing I2C jumper to XIAO |
| Hall effect sensor | Not available | Need to source |
| ACR1552 PCSC reader | Available | For ntag5sensor Python tooling |
| Multimeter | Available | For power budget measurements |