Datasheet

Table Of Contents
Ê71 #define ws2812_parallel_T2 5
Ê72 #define ws2812_parallel_T3 3
Ê73
Ê74 static const uint16_t ws2812_parallel_program_instructions[] = {
Ê75 // .wrap_target
Ê76 0x6020, // 0: out x, 32
Ê77 0xa10b, // 1: mov pins, !null [1]
Ê78 0xa401, // 2: mov pins, x [4]
Ê79 0xa103, // 3: mov pins, null [1]
Ê80 // .wrap
Ê81 };
Ê82
Ê83 #if !PICO_NO_HARDWARE
Ê84 static const struct pio_program ws2812_parallel_program = {
Ê85 .instructions = ws2812_parallel_program_instructions,
Ê86 .length = 4,
Ê87 .origin = -1,
Ê88 };
Ê89
Ê90 static inline pio_sm_config ws2812_parallel_program_get_default_config(uint offset) {
Ê91 pio_sm_config c = pio_get_default_sm_config();
Ê92 sm_config_set_wrap(&c, offset + ws2812_parallel_wrap_target, offset +
Ê ws2812_parallel_wrap);
Ê93 return c;
Ê94 }
Ê95
Ê96 #include "hardware/clocks.h"
Ê97
Ê98 static inline void ws2812_parallel_program_init(PIO pio, uint sm, uint offset, uint
Ê pin_base, uint pin_count,
Ê99 float freq) {
100 for (uint i = pin_base; i < pin_base + pin_count; i++) {
101 pio_gpio_select(pio, i);
102 }
103 pio_sm_set_consecutive_pindirs(pio, sm, pin_base, pin_count, true);
104 pio_sm_config c = ws2812_parallel_program_get_default_config(offset);
105 sm_config_set_out_shift(&c, true, true, 32);
106 sm_config_set_out_pins(&c, pin_base, pin_count);
107 sm_config_set_set_pins(&c, pin_base, pin_count);
108 sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX);
109 int cycles_per_bit = ws2812_parallel_T1 + ws2812_parallel_T2 + ws2812_parallel_T3;
110 float div = clock_get_hz(clk_sys) / (freq * cycles_per_bit);
111 sm_config_set_clkdiv(&c, div);
112 pio_sm_init(pio, sm, offset, &c);
113 pio_sm_enable(pio, sm, true);
114 }
115
116 #endif
3.3.9.2. python
The python language generator produces a single python file with all the programs in the PIO source file:
The pass thru sections (% python {) wouble be embedded in the output, and the PUBLIC defines are available as python
variables.
Also note the use of .lang_opt python to pass initializers for the @pico.asm_pio decorator
RP2040 Datasheet
3.3. PIO Assembler (pioasm) 320