NIBO Library 2.11
|
00001 /* BSD-License: 00002 00003 Copyright (c) 2007 by Nils Springob, nicai-systems, Germany 00004 00005 All rights reserved. 00006 00007 Redistribution and use in source and binary forms, with or without modification, 00008 are permitted provided that the following conditions are met: 00009 00010 * Redistributions of source code must retain the above copyright notice, 00011 this list of conditions and the following disclaimer. 00012 * Redistributions in binary form must reproduce the above copyright notice, 00013 this list of conditions and the following disclaimer in the documentation 00014 and/or other materials provided with the distribution. 00015 * Neither the name nicai-systems nor the names of its contributors may be 00016 used to endorse or promote products derived from this software without 00017 specific prior written permission. 00018 00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00020 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00021 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00022 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 00023 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00024 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00025 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00026 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00027 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00028 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00029 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00030 00031 */ 00032 00039 #ifndef NIBO_UART0_H_ 00040 #define NIBO_UART0_H_ 00041 #if defined(NIBO_USE_UART0) || defined (DOXYGEN) 00042 00043 #include <stdint.h> 00044 00045 #ifdef __cplusplus 00046 extern "C" { 00047 #endif 00048 00049 #define UART0_TXBUF_SIZE 8 00050 #define UART0_RXBUF_SIZE 8 00051 00055 void uart0_set_baudrate(uint16_t baud); 00056 00057 extern uint8_t uart0_txbuf[UART0_TXBUF_SIZE]; 00058 extern uint8_t uart0_rxbuf[UART0_RXBUF_SIZE]; 00059 00060 extern uint8_t uart0_txbuf_begin; 00061 extern uint8_t uart0_txbuf_end; 00062 00063 extern uint8_t uart0_rxbuf_begin; 00064 extern uint8_t uart0_rxbuf_end; 00065 00069 void uart0_enable(); 00070 00074 void uart0_disable(); 00075 00076 00081 char uart0_getchar(); 00082 00083 00088 char uart0_putchar(char c); 00089 00090 00094 static inline char uart0_rxempty() { 00095 return uart0_rxbuf_begin==uart0_rxbuf_end; 00096 } 00097 00098 00102 static inline char uart0_txempty() { 00103 return uart0_txbuf_begin==uart0_txbuf_end; 00104 } 00105 00106 00110 static inline char uart0_rxfull() { 00111 return uart0_rxbuf_end==UART0_RXBUF_SIZE; 00112 } 00113 00114 00118 static inline char uart0_txfull() { 00119 return uart0_txbuf_end==UART0_TXBUF_SIZE; 00120 } 00121 00122 #ifdef __cplusplus 00123 } // extern "C" 00124 #endif 00125 00126 #endif // NIBO_USE_UART0 00127 #endif // NIBO_UART0_H_