Files
seedbox/firmware/drivers/midi_uart.c
Gee 2196633ed5
Some checks failed
check / check (push) Has been cancelled
Seedbox v0.1 + firmware, generic kit/synth, ROOT/SCALE pages
First commit of the repo. Contents beyond the v0.1 simulator and layout:

- Full Pico 2 W firmware (firmware/app, drivers, engine port, host test).
- BANK page and 404 mode A/B removed; learned pads play exactly what was learned.
- 404/MiniFreak renamed to KIT/SYNTH throughout (jacks, code, sim, docs,
  layout labels; wiring rebuilt).
- ROLL returns to page select after a re-roll; a freshly learned track turns on.
- LCD contrast 66.
- ROOT and SCALE pages: 21 scales, AUTO = the seed picks; global and sticky.

Intended music change: the scale table grew from 8 to 21 and AUTO picks from
all of them, so every seed's scale changed. Vectors regenerated with
npm run vectors, plus new key-override cases. Flash record is now version 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 20:39:36 +03:00

38 lines
1.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "midi_uart.h"
#include "hardware/gpio.h"
#include "hardware/uart.h"
#define PIN_OUT_KIT 0 /* UART0 TX */
#define PIN_IN 1 /* UART0 RX, 6N137 output with a 1 kΩ pull-up on the board */
#define PIN_OUT_SYNTH 4 /* UART1 TX */
#define MIDI_BAUD 31250
static uart_inst_t *const PORTS[2] = { uart0, uart1 };
void midi_init(void){
uart_init(uart0, MIDI_BAUD);
uart_init(uart1, MIDI_BAUD);
uart_set_format(uart0, 8, 1, UART_PARITY_NONE);
uart_set_format(uart1, 8, 1, UART_PARITY_NONE);
gpio_set_function(PIN_OUT_KIT, GPIO_FUNC_UART);
gpio_set_function(PIN_IN, GPIO_FUNC_UART);
gpio_set_function(PIN_OUT_SYNTH, GPIO_FUNC_UART); /* GP5 (UART1 RX) stays a matrix row */
gpio_pull_up(PIN_IN);
/* each MIDI current loop draws 6–8 mA, above the 4 mA default */
gpio_set_drive_strength(PIN_OUT_KIT, GPIO_DRIVE_STRENGTH_12MA);
gpio_set_drive_strength(PIN_OUT_SYNTH, GPIO_DRIVE_STRENGTH_12MA);
}
void midi_send(int port, const uint8_t *bytes, int n){ uart_write_blocking(PORTS[port], bytes, (size_t)n); }
void midi_note_on(int port, int ch, int note, int vel){
uint8_t m[3] = { (uint8_t)(0x90 | (ch & 15)), (uint8_t)(note & 127), (uint8_t)(vel & 127) };
midi_send(port, m, 3);
}
void midi_note_off(int port, int ch, int note){
uint8_t m[3] = { (uint8_t)(0x80 | (ch & 15)), (uint8_t)(note & 127), 0 };
midi_send(port, m, 3);
}
int midi_in_read(void){ return uart_is_readable(uart0) ? uart_getc(uart0) : -1; }