/**
* 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);
}
}
}