You've already forked torvalds-GuitarPedal
mirror of
https://github.com/torvalds/GuitarPedal.git
synced 2026-08-18 21:26:54 +00:00
'Software' was the directory everything that was not KiCad ended up in, which stopped describing anything a while ago - Validation and the web app are software too. Worse, it put the shared parts inside the firmware, where they read as the firmware's own. They are not. Effects/ has three consumers built from it: the firmware, Validation's bench, and the web app's controls, all generated from the same POT: comments by gen_effects.py. Audio/ has two - the bench compiles the same biquads, the same envelope followers and the same single_sample(), which is the whole reason a measurement on a workstation says anything about the pedal. Neither belongs under Firmware/, so neither is under it any more: Effects/ one file per effect Audio/ the DSP they are built from, and the audio loop Firmware/ the rest of what runs on the pedal, and the submodules WebMIDI/ the web app scripts/ what the build runs Validation/ unchanged Hardware/, Documentation/, Images/ CMakeLists.txt and the wrapper Makefile move to the top with them, because the build now consumes four of those directories and generates into a fifth. board.local and build/ come along; MIDI_CC_MAP.md is generated into Documentation/ rather than into the old Software/ root. scripts/ goes with the build rather than staying under the firmware, because six of the ten had nothing to do with the firmware: gen_effects.py reads Effects/ and writes to three different places, pow2/log2/quarter_sine generate Audio/'s tables, check-readme.py compares Effects/ against the README, and server.py serves the web app. Four of them are invoked from Validation, which was reaching into Firmware/ for tooling - the same burying this commit is undoing. The four that really are about the firmware are ELF checks the top-level build drives anyway, and a second scripts directory would only be a second place to look. C includes say "Audio/foo.h" and the generated map says "Effects/bar.h", with the repository root on the include path for both the firmware and the bench. Spelling the directory out rather than relying on a bare name is what keeps Audio/cycles.h shimmable: a quoted include searches the including file's own directory first. The submodules are renamed as well as moved. git mv updates their paths but leaves the section names, and 'Software/pico-sdk' surviving in .gitmodules would be the word this commit removes, still load-bearing. That meant the nested modules under pico-sdk too - six .git files pointing into .git/modules/Software - which is why 'git submodule update --init --recursive' is worth running once after pulling this. Verified rather than assumed: a clean configure and build, make check (failing only on the missing-eeprom case it already failed on), check-effects, all four analysis pages reproducing every series and drawing every chart, and a flash to the board that still measures a routed reverb where it did before. One latent bug fell out of it. bench/coeff declared only quarter_sine.h of the three generated math tables, and Audio/util.h includes pow2.h and log2.h as well - so building that target with an empty gen/ could never have worked. 'make bench' builds bench/bench first, which generates all three, so it stayed hidden until this rebuilt everything from nothing. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
110 lines
2.8 KiB
Plaintext
110 lines
2.8 KiB
Plaintext
;
|
|
; We want a target sample frequency of 48kHz, which
|
|
; with 32-bit i2s data means a dot clock of 3.072MHz.
|
|
;
|
|
; We clock the rp2354 to 153.6MHz, which is exactly
|
|
; 50x that dot clock frequency.
|
|
;
|
|
; We then use a PIO divider of 25, and make the PIO
|
|
; program do 2 cycles per clock.
|
|
;
|
|
; i2s: FSYNC and each data bit is transmitted on the
|
|
; falling edge of BCLK, so we set those bits the cycle
|
|
; when BCLK goes low ("side 0") so that they are stable
|
|
; on the rising edge ("side 1").
|
|
;
|
|
; The actual data is transmitted one cycle after FSYNC
|
|
; goes low
|
|
;
|
|
.pio_version 1
|
|
|
|
.program i2s_tx
|
|
.fifo tx
|
|
.clock_div 25
|
|
.side_set 2
|
|
|
|
.wrap_target
|
|
out pins, 1 side 0b00 ; Cycle 0: FSYNC low. Output R0 (from previous frame)
|
|
public start_tx:
|
|
set x, 30 side 0b01
|
|
loop_low:
|
|
out pins, 1 side 0b00 ; Cycle 2: Output L31..L1
|
|
jmp x-- loop_low side 0b01
|
|
|
|
out pins, 1 side 0b10 ; Cycle 64: FSYNC high. Output L0
|
|
set x, 30 side 0b11
|
|
loop_high:
|
|
out pins, 1 side 0b10 ; Cycle 66: Output R31..R1
|
|
jmp x-- loop_high side 0b11
|
|
.wrap
|
|
|
|
% c-sdk {
|
|
//
|
|
// 'pin' is BCLK (MCU output)
|
|
// 'pin+1' is FSYNC (MCU output)
|
|
// 'pin+2' is DIN (MCU output! It's DIN from the CODEC standpoint!)
|
|
// 'pin+3' is DOUT (MCU input! It's DOUT from the CODEC standpoint!)
|
|
//
|
|
static inline void i2s_tx_program_init(PIO pio, uint sm, uint offset, uint pin)
|
|
{
|
|
pio_sm_config c = i2s_tx_program_get_default_config(offset);
|
|
|
|
pio_gpio_init(pio, pin);
|
|
pio_gpio_init(pio, pin+1);
|
|
pio_gpio_init(pio, pin+2);
|
|
pio_gpio_init(pio, pin+3);
|
|
|
|
// three output pins, one input
|
|
pio_sm_set_pindirs_with_mask(pio, sm, 0b0111 << pin, 0b1111 << pin);
|
|
|
|
// BCLK and FSYNC using sideset
|
|
sm_config_set_sideset_pin_base(&c, pin);
|
|
// DOUT using 'OUT' instruction
|
|
sm_config_set_out_pins(&c, pin+2, 1);
|
|
// Auto-pull, shift left (MSB first), 32 bits
|
|
sm_config_set_out_shift(&c, false, true, 32);
|
|
|
|
// Load and run the program
|
|
pio_sm_init(pio, sm, offset + i2s_tx_offset_start_tx, &c);
|
|
pio_sm_set_enabled(pio, sm, true);
|
|
}
|
|
%}
|
|
|
|
.program i2s_rx
|
|
.fifo rx
|
|
.clock_div 25
|
|
|
|
public start_rx:
|
|
wait 1 jmppin ; wait for FSYNC going high
|
|
wait 0 jmppin [1] ; wait for FSYNC going low, delay to sample middle
|
|
|
|
.wrap_target
|
|
set x, 30
|
|
loop_left:
|
|
in pins, 1
|
|
jmp x-- loop_left
|
|
in pins, 1 ; sample LSB of left channel
|
|
|
|
set x, 30
|
|
loop_right:
|
|
in pins, 1
|
|
jmp x-- loop_right
|
|
in pins, 1 ; sample LSB of right channel
|
|
.wrap
|
|
|
|
% c-sdk {
|
|
static inline void i2s_rx_program_init(PIO pio, uint sm, uint offset, uint pin)
|
|
{
|
|
pio_sm_config c = i2s_rx_program_get_default_config(offset);
|
|
|
|
sm_config_set_jmp_pin(&c, pin+1); // FSYNC
|
|
sm_config_set_in_pins(&c, pin+3); // DOUT
|
|
// Auto-push, shift left (MSB first), 32 bits
|
|
sm_config_set_in_shift(&c, false, true, 32);
|
|
|
|
// Load and run the program
|
|
pio_sm_init(pio, sm, offset + i2s_rx_offset_start_rx, &c);
|
|
pio_sm_set_enabled(pio, sm, true);
|
|
}
|
|
%}
|