#include "PioAsm.h"


#define PIN_BUS_0 2
#define BUS_BIT_COUNT 8

static void read_address_program_init(PIO pio, uint sm)
{
    pio_sm_config c = read_address_program_get_default_config(0);
    // Map the state machine's OUT pin group to one pin, namely the `pin`
    // parameter to this function.
    sm_config_set_out_pins(&c, PIN_BUS_0, BUS_BIT_COUNT);
    sm_config_set_set_pins(&c, PIN_BUS_0, BUS_BIT_COUNT);
    //sm_config_set_set_pins(&c, PIN_BUS_0, BUS_BIT_COUNT);

    // Set pin's GPIO function (connect PIO to the pad)
    for (int p = PIN_BUS_0; p < PIN_BUS_0 + BUS_BIT_COUNT; ++p )
    {
      pio_gpio_init(pio, p);
      //gpio_set_function(p, GPIO_FUNC_PIO0);
    }

    pio_sm_set_consecutive_pindirs(pio, sm, PIN_BUS_0, BUS_BIT_COUNT, true);

    // Load our configuration, and jump to the start of the program
    pio_sm_init(pio, sm, 0, &c);

    // Set the state machine running
    pio_sm_set_enabled(pio, sm, true);
}

void setup()
{
  pio_add_program(pio0, &read_address_program);
  read_address_program_init(pio0, 0);

  pio_sm_put_blocking(pio0, 0, 0xAAAAAAAA);
}

void loop()
{
  delay(1000);
}


/*





*/
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT