|
Mobil_surveillance_system 1
|
00001 #ifndef UART2_H_ 00002 #define UART2_H_ 00003 00005 00012 #include <string.h> // due to: using predefinition of NULL 00013 #include <stdlib.h> // due to: calloc function 00014 00015 #include "msp430f2617.h" 00016 #include "Bitmanip.h" // due to: the bit manipulations macros 00017 #include "FIFO.h" // due to: uart2 rx and tx buffer 00018 #include "Interrupts.h" // due to: rx and tx interrupts 00019 00020 00021 //***************************************************************************** 00022 // 00023 // Types and Definitions 00024 // 00025 //***************************************************************************** 00026 00028 #define UART2_RX_BUFFER_SIZE 16 00029 00031 #define UART2_TX_BUFFER_SIZE 16 00032 00033 00034 #ifndef DEFINE_TBOOLEAN // define unsigned char as tBoolean in only that case when it hasn't been defined yet somewhere else in the scope 00035 00037 typedef unsigned char tBoolean; // use as bool 00038 #define DEFINE_TBOOLEAN 00039 00040 #endif // DEFINE_TBOOLEAN 00041 00042 00044 typedef void (*tpfUART2AppendResponseCallbackFunction) (const char*); 00045 00046 //***************************************************************************** 00047 // 00048 // Globale variables 00049 // 00050 //***************************************************************************** 00051 00053 extern tBoolean ge_tbUART2RXITFLAG; 00054 00056 extern tBoolean ge_tbUART2TXITFLAG; 00057 00058 //***************************************************************************** 00059 // 00060 // Macros to determine number of free and used bytes in the transmit buffer. 00061 // 00062 //***************************************************************************** 00063 00065 #define UART2_TX_BUFFER_USED (FIFO_getBufferCount(&g_uiUart2TxReadIndex,\ 00066 &g_uiUart2TxWriteIndex,\ 00067 UART2_TX_BUFFER_SIZE)) 00068 00069 00071 #define UART2_TX_BUFFER_FREE (UART2_TX_BUFFER_SIZE - UART2_TX_BUFFER_USED) 00072 00073 00075 #define UART2_TX_BUFFER_EMPTY (FIFO_isBufferEmpty(&g_uiUart2TxReadIndex,\ 00076 &g_uiUart2TxWriteIndex)) 00077 00078 00080 #define UART2_TX_BUFFER_FULL (FIFO_isBufferFull(&g_uiUart2TxReadIndex,\ 00081 &g_uiUart2TxWriteIndex,\ 00082 UART2_TX_BUFFER_SIZE)) 00083 00084 00086 #define UART2_ADVANCE_TX_BUFFER_INDEX(Index) ((Index) = ((Index) + 1) % UART2_TX_BUFFER_SIZE) 00087 00088 00089 //***************************************************************************** 00090 // 00091 // Macros to determine number of free and used bytes in the receive buffer. 00092 // 00093 //***************************************************************************** 00094 00095 00097 #define UART2_RX_BUFFER_USED (FIFO_getBufferCount(&g_uiUart2RxReadIndex,\ 00098 &g_uiUart2RxWriteIndex,\ 00099 UART2_RX_BUFFER_SIZE)) 00100 00101 00103 #define UART2_RX_BUFFER_FREE (UART2_RX_BUFFER_SIZE - UART2_RX_BUFFER_USED) 00104 00105 00107 #define UART2_RX_BUFFER_EMPTY (FIFO_isBufferEmpty(&g_uiUart2RxReadIndex,\ 00108 &g_uiUart2RxWriteIndex)) 00109 00110 00112 #define UART2_RX_BUFFER_FULL (FIFO_isBufferFull(&g_uiUart2RxReadIndex,\ 00113 &g_uiUart2RxWriteIndex, \ 00114 UART2_RX_BUFFER_SIZE)) 00115 00116 00118 #define UART2_ADVANCE_RX_BUFFER_INDEX(Index) ((Index) = ((Index) + 1) % UART2_RX_BUFFER_SIZE) 00119 00120 //***************************************************************************** 00121 // 00122 // Function declarations 00123 // 00124 //***************************************************************************** 00125 00129 void UART2_rxHandler( void ); 00130 00131 00135 void UART2_txHandler( void ); 00136 00137 00141 void UART2_initUART2( void ); 00142 00143 00147 int UART2_read( void ); 00148 00149 00153 int UART2_write( char* pcBuffer, unsigned int uiLength ); 00154 00155 00159 void UART2_sendChar( void ); 00160 00161 00165 tBoolean UART2_isWritingDone( void ); 00166 00167 00171 void UART2_primeTransmit( void ); 00172 00173 00177 void UART2_flushRx( void ); 00178 00179 00183 void UART2_flushTx( void ); 00184 00185 00189 void UART2_setAppendResponseCallbackFunction( tpfUART2AppendResponseCallbackFunction pfCallbackAppendResponse ); 00190 00191 #endif /*UART2_H_*/ 00192
1.7.4