blob: 5c97ccd9cd5fd43e03bf48f5ae99731ccececfca (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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;
}
|