/**
 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include "pico/stdlib.h"
#include "hardware/pio.h"
#include "hardware/gpio.h"
#include "hardware/clocks.h"
#include "nespad.h"

int main() {
  PIO pio = pio0;                        // pio0 or pio1
  uint sm = pio_claim_unused_sm(pio, true);
  const uint data_pin_base = 12;
  const uint clock_pin_base = 14;
  uint offset = pio_add_program(pio, &nespad_program);
  nespad_program_init(pio, sm, offset, data_pin_base, clock_pin_base);

  const uint LED_PIN = 25;
  gpio_init(LED_PIN);
  gpio_set_dir(LED_PIN, GPIO_OUT);
  while (true) {
      if (!pio_sm_is_rx_fifo_empty(pio, sm)) {
        uint32_t rc = pio->rxf[sm];
        printf("%l\n", rc);
      }
  }
}
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT
D0D1D2D3D4D5D6D7GNDLOGIC