/*
 * esp32_s3_devkitc_midi2.h, public API of the esp32-s3-devkitc-usb-midi2
 * board core.
 *
 * The application layer (showcase) consumes this header and never
 * touches tud_*, esp_*, or any USB symbol directly. After init, the
 * m2device + m2ci instances are wired to the platform USB stack through
 * midi2cpp's five public hooks (setWriteFn, feedRx, setNowFn,
 * setMounted, CI::setRngFn). The app then registers callbacks, sends
 * UMPs, and calls task() in the FreeRTOS loop.
 *
 * Replicating this pattern for another ESP32 board is a matter of
 * writing <board>_midi2.{h,cpp} that exposes the same two-function
 * surface plus an LED helper if the board has one.
 */
#pragma once

#include "midi2cpp.h"

namespace esp32_s3_devkitc_midi2 {

// Boots USB-OTG PHY, installs TinyUSB device task, sets up the MIDI 2.0
// device class, and wires the five midi2cpp platform hooks into the
// supplied m2device / m2ci. After this returns, the app can register
// callbacks, send UMPs, and call task() in its main loop.
//
// Must be called once from app_main(), before any midi.send* / ci.*
// calls.
void init(midi2::m2device& midi, midi2::m2ci& ci);

// Drains the USB stack (tud_task is run on its own FreeRTOS task by
// TinyUSB; this helper drains UMP RX into midi.feedRx and refreshes
// mounted/alt state). Call every iteration of the main loop.
void task(midi2::m2device& midi);

// On-board RGB LED feedback (GPIO48 WS2812). Green pulse when mounted,
// red when not mounted. Optional, callable from the main loop.
void led_show_mounted(bool mounted);

}  // namespace esp32_s3_devkitc_midi2
