]> Pileus Git - ~andy/csm213a-hw/blob - hw2/serial_irq.h
5595d14518778cd1c77e5523eaf37e0841404438
[~andy/csm213a-hw] / hw2 / serial_irq.h
1 #ifndef SERIAL_IRQ_H
2 #define SERIAL_IRQ_H
3
4 #include <stdarg.h>
5 #include <MKL46Z4.h>
6 #include <PinNames.h>
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 /* Sizes */
13 #define SIRQ_NUM_UART 3
14
15 /* Serial Ports */
16 typedef enum {
17         SIRQ_UART0,
18         SIRQ_UART1,
19         SIRQ_UART2,
20 } sirq_uart_t;
21
22 /* Port */
23 typedef struct sirq_t sirq_t;
24
25 /* Open */
26 sirq_t *sirq_open(sirq_uart_t uart, PinName tx, PinName rx, int baud);
27
28 /* Read/Write */
29 void sirq_putc(sirq_t *port, int byte);
30 int  sirq_getc(sirq_t *port);
31 void sirq_write(sirq_t *port, void *data, int len);
32
33 /* Read In */
34 int  sirq_ready(sirq_t *port);
35
36 /* Print */
37 void sirq_vprintf(const char *fmt, va_list ap);
38 void sirq_printf(const char *fmt, ...);
39
40 #ifdef __cplusplus
41 }
42 #endif
43
44 #endif