NiboRoboLib 3.1 - NIBObee Library
usart.h
gehe zur Dokumentation dieser Datei
1 /* BSD-License:
2 
3 Copyright (c) 2007 by Nils Springob, nicai-systems, Germany
4 
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9 
10  * Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12  * Redistributions in binary form must reproduce the above copyright notice,
13  this list of conditions and the following disclaimer in the documentation
14  and/or other materials provided with the distribution.
15  * Neither the name nicai-systems nor the names of its contributors may be
16  used to endorse or promote products derived from this software without
17  specific prior written permission.
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 */
32 
39 #ifndef NIBOBEE_USART_H_
40 #define NIBOBEE_USART_H_
41 
42 #include <stdint.h>
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 #define USART_TXBUF_SIZE 16
49 #define USART_RXBUF_SIZE 8
50 
54 void usart_setbaudrate(uint16_t baud);
55 
56 extern uint8_t usart_txbuf[USART_TXBUF_SIZE];
57 extern uint8_t usart_rxbuf[USART_RXBUF_SIZE];
58 
59 extern volatile uint8_t usart_txbuf_begin;
60 extern volatile uint8_t usart_txbuf_end;
61 
62 extern volatile uint8_t usart_rxbuf_begin;
63 extern volatile uint8_t usart_rxbuf_end;
64 
68 void usart_enable();
69 
73 void usart_disable();
74 
75 
80 char usart_getchar();
81 
82 
87 char usart_putchar(char c);
88 
89 
93 static inline char usart_rxempty() {
94  return usart_rxbuf_begin==usart_rxbuf_end;
95 }
96 
97 
101 static inline char usart_txempty() {
102  return usart_txbuf_begin==usart_txbuf_end;
103 }
104 
105 
109 static inline char usart_rxfull() {
110  return usart_rxbuf_end==USART_RXBUF_SIZE;
111 }
112 
113 
117 static inline char usart_txfull() {
118  return usart_txbuf_end==USART_TXBUF_SIZE;
119 }
120 
121 #ifdef __cplusplus
122 } // extern "C"
123 #endif
124 
125 #endif // NIBOBEE_USART_H_
char usart_putchar(char c)
void usart_setbaudrate(uint16_t baud)
char usart_getchar()
void usart_enable()
void usart_disable()