Mercurial > ~darius > hgwebdir.cgi > modulator
comparison dac.pio @ 5:2db42eaba3c8
WIP
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Sat, 15 Feb 2025 22:57:18 +1030 |
parents | 0d653f60dec8 |
children | 3acdebd7eec7 |
comparison
equal
deleted
inserted
replaced
4:b6416c4aadc8 | 5:2db42eaba3c8 |
---|---|
17 nop side 1 | 17 nop side 1 |
18 out pins 8 side 0 | 18 out pins 8 side 0 |
19 .wrap | 19 .wrap |
20 | 20 |
21 % c-sdk { | 21 % c-sdk { |
22 static inline void dac_program_init(PIO pio, uint sm, uint offset, uint pin) { | 22 static inline void dac_program_init(PIO pio, uint sm, uint offset, uint pin, uint clkdiv) { |
23 pio_sm_config c = dac_program_get_default_config(offset); | 23 pio_sm_config c = dac_program_get_default_config(offset); |
24 | 24 |
25 // Set the OUT base pin to the provided `pin` parameter. | 25 // Set the OUT base pin to the provided `pin` parameter. |
26 // First 8 pins are data, last is clock | 26 // First 8 pins are data, last is clock |
27 sm_config_set_out_pins(&c, pin, 9); | 27 sm_config_set_out_pins(&c, pin, 9); |
33 | 33 |
34 sm_config_set_out_shift( | 34 sm_config_set_out_shift( |
35 &c, | 35 &c, |
36 true, // Shift-to-right | 36 true, // Shift-to-right |
37 false, // Autopull enabled | 37 false, // Autopull enabled |
38 8 // Autopull threshold (bits!) | 38 32 // Autopull threshold (bits!) |
39 ); | 39 ); |
40 | 40 |
41 // Configure clock as sideset pin | 41 // Configure clock as sideset pin |
42 sm_config_set_sideset_pins(&c, pin + 7); | 42 sm_config_set_sideset_pins(&c, pin + 7); |
43 | 43 |
44 // We only send, so disable the RX FIFO to make the TX FIFO deeper. | 44 // We only send, so disable the RX FIFO to make the TX FIFO deeper. |
45 sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX); | 45 sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX); |
46 | 46 |
47 // sm_config_set_clkdiv(&c, 100); | 47 sm_config_set_clkdiv(&c, clkdiv); |
48 | 48 |
49 // Load our configuration, and start the program from the beginning | 49 // Load our configuration, and start the program from the beginning |
50 pio_sm_init(pio, sm, offset, &c); | 50 pio_sm_init(pio, sm, offset, &c); |
51 pio_sm_set_enabled(pio, sm, true); | 51 pio_sm_set_enabled(pio, sm, true); |
52 } | 52 } |