00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00046 #ifndef _UART_H_
00047 #define _UART_H_
00048
00049 #include <stdio.h>
00050 #include <aversive.h>
00051 #include <uart_config.h>
00052
00053 #include <cirbuf.h>
00054
00056 struct uart_config {
00057 uint8_t enabled : 1,
00058 intr_enabled : 1,
00059 use_double_speed : 1,
00060 parity : 2,
00061 stop_bits : 1,
00062 reserved : 1;
00063 uint8_t nbits;
00064 uint32_t baudrate;
00065 };
00066
00067
00074 void uart_init(void);
00075
00080 int8_t uart_setconf(uint8_t num, struct uart_config *u);
00081
00083 void uart_getconf(uint8_t num, struct uart_config *u);
00084
00090 int uart_recv(uint8_t num);
00091
00096 int uart_recv_nowait(uint8_t num);
00097
00101 int uart_9bits_recv(uint8_t num);
00102
00106 int uart_9bits_recv_nowait(uint8_t num);
00107
00114 int uart_send_nowait(uint8_t num, char c);
00115
00121 int uart_send(uint8_t num, char c);
00122
00127 int uart_send_9bits_nowait(uint8_t num, int c);
00128
00129
00130
00131
00132 int uart_send_9bits(uint8_t num, int c);
00133
00134
00135
00140 void uart_register_tx_event(uint8_t num, void (*f)(char));
00141
00146 void uart_register_rx_event(uint8_t num, void (*f)(char));
00147
00148
00155 void uart_register_tx_9bits_event(uint8_t num, void (*f)(int));
00156
00163 void uart_register_rx_9bits_event(uint8_t num, void (*f)(int));
00164
00165
00166 int uart0_dev_send_nowait(char c, FILE* f);
00167 int uart0_dev_send(char c, FILE* f);
00168 int uart0_dev_recv_nowait(FILE* f);
00169 int uart0_dev_recv(FILE* f);
00170
00171 int uart1_dev_send_nowait(char c, FILE* f);
00172 int uart1_dev_send(char c, FILE* f);
00173 int uart1_dev_recv_nowait(FILE* f);
00174 int uart1_dev_recv(FILE* f);
00175
00176 int uart2_dev_send_nowait(char c, FILE* f);
00177 int uart2_dev_send(char c, FILE* f);
00178 int uart2_dev_recv_nowait(FILE* f);
00179 int uart2_dev_recv(FILE* f);
00180
00181 int uart3_dev_send_nowait(char c, FILE* f);
00182 int uart3_dev_send(char c, FILE* f);
00183 int uart3_dev_recv_nowait(FILE* f);
00184 int uart3_dev_recv(FILE* f);
00185
00186
00187 #endif
00188