adafruit / Adafruit_CircuitPython_PIOASM

Simple assembler to convert pioasm to bytes
MIT License
27 stars 17 forks source link

Pretty print and bugfix #37

Closed jepler closed 2 years ago

jepler commented 2 years ago

This fixes a bug with **pioasm_kwargs and also adds printing of programs into C snippets, like

const int pio_ws2812_short_sideset_pin_count = 1;
const bool pio_ws2812_short_sideset_enable = 0;
const uint16_t pio_ws2812_short[] = {
    0x6121, 0x1123, 0x1100, 0xa142
};

Or, with the new 'debug info' enabled,

static const uint16_t pio_ws2812[] = {
            // .program ws2812
            // .side_set 1
            // .wrap_target
            // bitloop:
    0x6121, //   out x 1        side 0 [1]; Side-set still takes place when instruction stalls
    0x1123, //   jmp !x do_zero side 1 [1]; Branch on the bit we shifted out. Positive pulse
            // do_one:
    0x1100, //   jmp  bitloop   side 1 [1]; Continue driving high, for a long pulse
            // do_zero:
    0xa142, //   nop            side 0 [1]; Or drive low, for a short pulse
            // .wrap
};
jepler commented 2 years ago

whether or not it's merged, I'll be using the new printing functionality for myself. I can make just the bugfix as a separate PR if this PR as a whole isn't desirable.