diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-09-22 22:45:18 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-09-22 22:45:18 +0300 |
| commit | b1d67364b4b4832b8efed112f7b0ead1a0b3cd3b (patch) | |
| tree | 7926bfb428703515438c08b98c61cbffd34b3cbb /src/components/uart/simple_uart.c | |
| parent | 32f9719e29762001f73460acd31f2a6da8fd6298 (diff) | |
| download | gran-b1d67364b4b4832b8efed112f7b0ead1a0b3cd3b.tar.gz gran-b1d67364b4b4832b8efed112f7b0ead1a0b3cd3b.zip | |
start experimenting with processor grids
Diffstat (limited to 'src/components/uart/simple_uart.c')
| -rw-r--r-- | src/components/uart/simple_uart.c | 28 |
1 files changed, 28 insertions, 0 deletions
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 <stdio.h> +#include <gran/uart/simple_uart.h> + +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; +} |
