aboutsummaryrefslogtreecommitdiffstats
path: root/src/sequencer.c
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2023-05-28 18:54:03 +0200
committerBad Diode <bd@badd10de.dev>2023-05-28 18:54:03 +0200
commit765dc3ab3d79bdca696a0d651385af3020c895c6 (patch)
tree628a6ad09f1f0d9f2d8918a5a8924ded0ce001c4 /src/sequencer.c
parent5024c6631ab583c0b375f0002e2ad6d6373d84ee (diff)
downloadstepper-765dc3ab3d79bdca696a0d651385af3020c895c6.tar.gz
stepper-765dc3ab3d79bdca696a0d651385af3020c895c6.zip
Add initial link cable clock sync
Diffstat (limited to 'src/sequencer.c')
-rw-r--r--src/sequencer.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/sequencer.c b/src/sequencer.c
index 867e686..7c989f2 100644
--- a/src/sequencer.c
+++ b/src/sequencer.c
@@ -20,6 +20,19 @@ bool redraw_piano_note = true;
20bool update_bpm = false; 20bool update_bpm = false;
21 21
22void 22void
23gate_off(void) {
24 SIO_MODE = SIO_MODE_GP
25 | SIO_SC_OUT(1)
26 | SIO_SD_OUT(1)
27 | SIO_SI_OUT(0)
28 | SIO_SO_OUT(1)
29 | SIO_SC(0)
30 | SIO_SD(1)
31 | SIO_SO(0);
32 TIMER_CTRL_1 = 0;
33}
34
35void
23play_step(void) { 36play_step(void) {
24 Pattern *pat = &patterns[current_pattern]; 37 Pattern *pat = &patterns[current_pattern];
25 if (current_pattern != next_pattern && step_counter == 15) { 38 if (current_pattern != next_pattern && step_counter == 15) {
@@ -135,6 +148,22 @@ play_step(void) {
135 SOUND_NOISE_CTRL = 0; 148 SOUND_NOISE_CTRL = 0;
136 SOUND_NOISE_FREQ = 0; 149 SOUND_NOISE_FREQ = 0;
137 } 150 }
151 // TODO: This should be configurable e.g. po needs a 1 each 2 to sync
152 // exactly, but we can also just want a pseudo clock divider.
153 if (step_counter % 2 == 0) {
154 SIO_MODE = SIO_MODE_GP
155 | SIO_SC_OUT(1)
156 | SIO_SD_OUT(1)
157 | SIO_SI_OUT(0)
158 | SIO_SO_OUT(1)
159 | SIO_SC(1)
160 | SIO_SD(1)
161 | SIO_SO(0);
162 int n_ticks = -244181 / 600;
163 irs_set(IRQ_TIMER_1, gate_off);
164 TIMER_DATA_1 = n_ticks;
165 TIMER_CTRL_1 = TIMER_CTRL_IRQ | TIMER_CTRL_ENABLE | TIMER_CTRL_FREQ_3;
166 }
138 step_counter = (step_counter + 1) % 16; 167 step_counter = (step_counter + 1) % 16;
139 redraw_piano_note = true; 168 redraw_piano_note = true;
140} 169}