1
6
7
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
60
/* ... */
#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/multicore.h"
#include "hardware/pio.h"
#include "hardware/uart.h"
#include "uart_rx.pio.h"
6 includes
#define SERIAL_BAUD PICO_DEFAULT_UART_BAUD_RATE
#define HARD_UART_INST uart1
#define HARD_UART_TX_PIN 4
#define PIO_RX_PIN 3
void core1_main() {
const char *s = (const char *) multicore_fifo_pop_blocking();
uart_puts(HARD_UART_INST, s);
}{ ... }
int main() {
setup_default_uart();
printf("Starting PIO UART RX example\n");
uart_init(HARD_UART_INST, SERIAL_BAUD);
gpio_set_function(HARD_UART_TX_PIN, GPIO_FUNC_UART);
PIO pio = pio0;
uint sm = 0;
uint offset = pio_add_program(pio, &uart_rx_program);
uart_rx_program_init(pio, sm, offset, PIO_RX_PIN, SERIAL_BAUD);
multicore_launch_core1(core1_main);
const char *text = "Hello, world from PIO! (Plus 2 UARTs and 2 cores, for complex reasons)\n";
multicore_fifo_push_blocking((uint32_t) text);
while (true) {
char c = uart_rx_program_getc(pio, sm);
putchar(c);
}while (true) { ... }
}{ ... }