How morningstar-engineering/mc6-mkii-midi-controller works
Project Type and Purpose
This is an embedded‐firmware project for the “MC6 MKII” MIDI Controller. The firmware runs on a microcontroller and implements USB‐MIDI (and optionally USB‐Keyboard) interfaces, scans buttons/encoders, drives LEDs, and manages device configuration and firmware updates.
Architectural Overview
Although the repository file tree only lists configuration files and a README, the firmware’s internal structure typically follows these layers:
• Hardware Layer – Physical components (buttons, encoders, LEDs, USB transceiver, microcontroller pins)
• HAL (Hardware Abstraction Layer) – Pin drivers, timers, GPIO, ADC, I2C/SPI if needed
• USB Stack – USB enumeration, endpoint management (MIDI‐class, HID‐class for keyboard)
• MIDI/Keyboard Parsers – MIDI packet framing, transport over USB; optional HID keyboard report generation
• Application Logic – Mapping controls to MIDI messages, handling presets, macros, LED feedback
• Configuration & Persistence – Flash‐based storage of user settings, firmware bootloader for updates
A. Microcontroller (central node)
B. Hardware Peripherals
– Buttons/Encoders → scanned by HAL GPIO/ADC
– LEDs → controlled by HAL GPIO/PWM
– USB Transceiver → driven by USB Stack
C. Firmware Layers (stacked around the MCU)
1. Bootloader Module – handles firmware flashing & versioning
2. HAL – abstracts pin/timer peripherals
3. USB Stack – implements MIDI/HID USB class drivers
4. MIDI + Keyboard Parsers – packetize/depacketize messages
5. App Logic – mapping logic & UI feedback
6. Config Manager – reads/writes settings in flash memory
D. External Host (PC/DAW)
– Sends/receives MIDI messages over USB
– Optionally receives keyboard HID reports
E. Firmware Update Flow
– Host → USB Bootloader Endpoint → Flash rewrite
Architectural Patterns & Principles
• Layering: Hardware → HAL → Middleware (USB) → Domain Logic
• Modular Drivers: decouple USB, MIDI, hardware scans
• State Machines: for USB enumeration, MIDI message handling
• Persistent Storage Abstraction: treat flash settings like file I/O
Putting It All Together
2. Surround it with concentric layers for bootloader, HAL, USB stack, parsers, and app logic.
4. On the right, show the USB cable linking the USB stack to the Host.
5. On the left or top, show the configuration storage (Flash) and the bootloader update flow.