ring@macbook-pro build-pico $ ./pioasm/pioasm -o freepascal ~/devel/pico-fpcexamples/pio_ws2812/ws2812.pio (master)pico-examples
// -------------------------------------------------- //
// This file is autogenerated by pioasm; do not edit! //
// -------------------------------------------------- //
// ------ //
// ws2812 //
// ------ //
const ws2812_wrap_target=0;
const ws2812_wrap=3;
const ws2812_T1=2;
const ws2812_T2=5;
const ws2812_T3=3;
const ws2812_program_instructions : array of word = (
// .wrap_target
$6221, // 0: out x, 1 side 0 [2]
$1123, // 1: jmp !x, 3 side 1 [1]
$1400, // 2: jmp 0 side 1 [4]
$a442 // 3: nop side 0 [4]
// .wrap
);
const ws2812_program : Tpio_program = (
instructions : @ws2812_program_instructions;
length : 4;
origin : -1;
);
function ws2812_program_get_default_config(offset : longWord):Tpio_sm_config;
begin
Result := pio_get_default_sm_config();
sm_config_set_wrap(Result, offset + ws2812_wrap_target, offset + ws2812_wrap);
sm_config_set_sideset(Result, 1, false, false);
end;
procedure ws2812_program_init(var pio : TPIO_Registers; sm : longWord; offset : longWord; pin : TPinIdentifier; freq : Real; rgbw : boolean);
var
c : Tpio_sm_config;
cycles_per_bit : longWord;
&div : real;
begin
pio_gpio_init(pio, pin);
pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true);
c := ws2812_program_get_default_config(offset);
sm_config_set_sideset_pins(c, pin);
if rgbw = true then
sm_config_set_out_shift(c, false, true, 32)
else
sm_config_set_out_shift(c, false, true, 24);
sm_config_set_fifo_join(c, PIO_FIFO_JOIN_TX);
cycles_per_bit := ws2812_T1 + ws2812_T2 + ws2812_T3;
&div := clock_get_hz(clk_sys) / (freq * cycles_per_bit);
sm_config_set_clkdiv(c, &div);
pio_sm_init(pio, sm, offset, c);
pio_sm_set_enabled(pio, sm, true);
end;
// --------------- //
// ws2812_parallel //
// --------------- //
const ws2812_parallel_wrap_target=0;
const ws2812_parallel_wrap=3;
const ws2812_parallel_T1=2;
const ws2812_parallel_T2=5;
const ws2812_parallel_T3=3;
const ws2812_parallel_program_instructions : array of word = (
// .wrap_target
$6020, // 0: out x, 32
$a10b, // 1: mov pins, !null [1]
$a401, // 2: mov pins, x [4]
$a103 // 3: mov pins, null [1]
// .wrap
);
const ws2812_parallel_program : Tpio_program = (
instructions : @ws2812_parallel_program_instructions;
length : 4;
origin : -1;
);
function ws2812_parallel_program_get_default_config(offset : longWord):Tpio_sm_config;
begin
Result := pio_get_default_sm_config();
sm_config_set_wrap(Result, offset + ws2812_parallel_wrap_target, offset + ws2812_parallel_wrap);
end;