Datasheet

Table Of Contents
51
52 .define public T1 2
53 .define public T2 5
54 .define public T3 3
55
56 .wrap_target
57 out x, 32
58 mov pins, !null [T1-1]
59 mov pins, x [T2-1]
60 mov pins, null [T3-2]
61 .wrap
62
63 % c-sdk {
64 #include "hardware/clocks.h"
65
66 static inline void ws2812_parallel_program_init(PIO pio, uint sm, uint offset, uint
Ê pin_base, uint pin_count, float freq) {
67 for(uint i=pin_base; i<pin_base+pin_count; i++) {
68 pio_gpio_select(pio, i);
69 }
70 pio_sm_set_consecutive_pindirs(pio, sm, pin_base, pin_count, true);
71
72 pio_sm_config c = ws2812_parallel_program_get_default_config(offset);
73 sm_config_set_out_shift(&c, true, true, 32);
74 sm_config_set_out_pins(&c, pin_base, pin_count);
75 sm_config_set_set_pins(&c, pin_base, pin_count);
76 sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX);
77
78 int cycles_per_bit = ws2812_parallel_T1 + ws2812_parallel_T2 + ws2812_parallel_T3;
79 float div = clock_get_hz(clk_sys) / (freq * cycles_per_bit);
80 sm_config_set_clkdiv(&c, div);
81
82 pio_sm_init(pio, sm, offset, &c);
83 pio_sm_enable(pio, sm, true);
84 }
85 %}
3.3.9.1. c-sdk
The c-sdk language generator produces a single header file with all the programs in the PIO source file:
The pass thru sections (% c-sdk {) are embedded in the output, and the PUBLIC defines are available via #define
TIP
A method is created for each program (e.g. ws2812_program_get_default_config()) which sets up a pio_sm_config based
on the .side_set, .wrap and .wrap_target settings of the program, which you can then use as a basis for configuration
the PIO state machine.
Pico Examples: https://github.com/raspberrypi/pico-examples/tree/pre_release/pio/ws2812/generated/ws2812.pio.h Lines 1 - 117
ÊÊ1 // -------------------------------------------------- //
ÊÊ2 // This file is autogenerated by pioasm; do not edit! //
ÊÊ3 // -------------------------------------------------- //
ÊÊ4
ÊÊ5 #if !PICO_NO_HARDWARE
ÊÊ6
ÊÊ7 #include "hardware/pio.h"
ÊÊ8
RP2040 Datasheet
3.3. PIO Assembler (pioasm) 318