From b1d67364b4b4832b8efed112f7b0ead1a0b3cd3b Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 22 Sep 2024 22:45:18 +0300 Subject: start experimenting with processor grids --- src/components/uart/simple_uart.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/components/uart/simple_uart.c (limited to 'src/components/uart/simple_uart.c') diff --git a/src/components/uart/simple_uart.c b/src/components/uart/simple_uart.c new file mode 100644 index 0000000..5c97ccd --- /dev/null +++ b/src/components/uart/simple_uart.c @@ -0,0 +1,28 @@ +#include +#include + +struct simple_uart { + struct component component; +}; + +static stat simple_uart_write(struct simple_uart *uart, struct packet *pkt) +{ + (void)uart; + size_t size = packet_size(pkt); + if (size != 1) + return EBUS; + + putchar(*(uint8_t *)packet_data(pkt)); + packet_set_state(pkt, PACKET_DONE); + return OK; +} + +struct component *create_simple_uart() +{ + struct simple_uart *uart = calloc(1, sizeof(struct simple_uart)); + if (!uart) + return NULL; + + uart->component.write = (write_callback)simple_uart_write; + return (struct component *)uart; +} -- cgit v1.3