Mercurial > ~darius > hgwebdir.cgi > modulator
comparison modulator.c @ 2:0d653f60dec8
Actually get data moving out.
Previous shape info caused a hard fault.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Mon, 29 Mar 2021 17:39:00 +1030 |
parents | a55e39064a71 |
children | b10097c3383d |
comparison
equal
deleted
inserted
replaced
1:b9ec45077bff | 2:0d653f60dec8 |
---|---|
21 #include "hardware/clocks.h" | 21 #include "hardware/clocks.h" |
22 #include "hardware/pio.h" | 22 #include "hardware/pio.h" |
23 | 23 |
24 #include "dac.pio.h" | 24 #include "dac.pio.h" |
25 | 25 |
26 #if 0 | |
26 extern void* shaped_trap_dat_size; | 27 extern void* shaped_trap_dat_size; |
27 extern void* shaped_trap_dat_start; | 28 extern void* shaped_trap_dat_start; |
28 | 29 |
29 extern void* sgauss_dat_size; | 30 extern void* sgauss_dat_size; |
30 extern void* sgauss_dat_start; | 31 extern void* sgauss_dat_start; |
32 #endif | |
33 | |
34 uint8_t shaped_trap_dat_start[] = { 0, 1, 2, 4, 8, 16, 32, 64, 128, 0, 0, 0, 0, 0, 0, 0 }; | |
35 //uint8_t shaped_trap_dat_start[] = { 0, 1, 2, 3, 1, 2, 0, 3, 1, 1, 2, 3, 0, 1, 2, 3 }; | |
31 | 36 |
32 int | 37 int |
33 main() { | 38 main() { |
34 int i; | 39 int i; |
35 const uint LED_PIN = PICO_DEFAULT_LED_PIN; | 40 const uint LED_PIN = PICO_DEFAULT_LED_PIN; |
42 // Load the clocked_input program, and configure a free state machine | 47 // Load the clocked_input program, and configure a free state machine |
43 // to run the program. | 48 // to run the program. |
44 PIO pio = pio0; | 49 PIO pio = pio0; |
45 uint offset = pio_add_program(pio, &dac_program); | 50 uint offset = pio_add_program(pio, &dac_program); |
46 uint sm = pio_claim_unused_sm(pio, true); | 51 uint sm = pio_claim_unused_sm(pio, true); |
47 dac_program_init(pio, sm, offset, 4); | 52 // XXX: I would prefer starting at GPIO16 but in that case the top 2 |
53 // bits don't seem to work | |
54 dac_program_init(pio, sm, offset, 14); | |
48 | 55 |
49 while (true) { | 56 while (true) { |
50 for (i = 0; i < (int)&shaped_trap_dat_size; i++) { | 57 for (int i = 0; i < sizeof(shaped_trap_dat_start) / 4; i++) { |
51 if (*(uint8_t *)shaped_trap_dat_start) | 58 pio_sm_put_blocking(pio, sm, ((uint32_t *)shaped_trap_dat_start)[i]); |
52 gpio_put(LED_PIN, 1); | |
53 else | |
54 gpio_put(LED_PIN, 0); | |
55 sleep_ms(250); | |
56 } | 59 } |
57 for (i = 0; i < (int)&sgauss_dat_size; i++) { | 60 #if 0 |
58 if (*(uint8_t *)sgauss_dat_start) | 61 gpio_put(LED_PIN, 1); |
59 gpio_put(LED_PIN, 1); | 62 sleep_ms(100); |
60 else | 63 gpio_put(LED_PIN, 0); |
61 gpio_put(LED_PIN, 0); | 64 #endif |
62 sleep_ms(250); | |
63 } | |
64 } | 65 } |
65 } | 66 } |