Go to the documentation of this file.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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #ifndef _USART_
00054 #define _USART_
00055
00056
00057
00058
00059
00060 #include "chip.h"
00061
00062 #include <stdint.h>
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 #define USART_MODE_ASYNCHRONOUS (US_MR_CHRL_8_BIT | US_MR_PAR_NO)
00078
00079 #define MAX_RX_TIMEOUT 131071
00080
00081
00082 #define USART_MODE_IRDA \
00083 (US_MR_USART_MODE_IRDA | US_MR_CHRL_8_BIT | US_MR_PAR_NO | US_MR_FILTER)
00084
00085
00086 #define AT91C_US_USMODE_SPIM 0xE
00087 #define US_SPI_CPOL_0 (0x0<<16)
00088 #define US_SPI_CPHA_0 (0x0<<8)
00089 #define US_SPI_CPOL_1 (0x1<<16)
00090 #define US_SPI_CPHA_1 (0x1<<8)
00091 #define US_SPI_BPMODE_0 (US_SPI_CPOL_0|US_SPI_CPHA_1)
00092 #define US_SPI_BPMODE_1 (US_SPI_CPOL_0|US_SPI_CPHA_0)
00093 #define US_SPI_BPMODE_2 (US_SPI_CPOL_1|US_SPI_CPHA_1)
00094 #define US_SPI_BPMODE_3 (US_SPI_CPOL_1|US_SPI_CPHA_0)
00095
00096 #ifdef __cplusplus
00097 extern "C" {
00098 #endif
00099
00100
00101
00102
00103
00104
00105 void USART_Configure( Usart *pUsart, uint32_t mode, uint32_t baudrate,
00106 uint32_t masterClock ) ;
00107
00108 void USART_SetBaudrate(Usart *pUsart, uint8_t OverSamp, uint32_t baudrate,
00109 uint32_t masterClock);
00110
00111 uint32_t USART_GetStatus( Usart *usart ) ;
00112
00113
00114 void USART_ResetRx(Usart *pUsart);
00115
00116 void USART_ResetTx(Usart *pUsart);
00117
00118 void USART_EnableTx(Usart *pUsart);
00119
00120 void USART_EnableRx(Usart *pUsart);
00121
00122 void USART_DisableRx(Usart *pUsart);
00123
00124 void USART_DisableTx(Usart *pUsart);
00125
00126 void USART_EnableIt( Usart *usart,uint32_t mode ) ;
00127
00128 void USART_DisableIt( Usart *usart,uint32_t mode ) ;
00129
00130 uint32_t USART_GetItMask( Usart * usart ) ;
00131
00132 void USART_SetTransmitterEnabled( Usart *usart, uint8_t enabled ) ;
00133
00134 void USART_SetReceiverEnabled( Usart *usart, uint8_t enabled ) ;
00135
00136 void USART_SetRTSEnabled(Usart *usart, uint8_t enabled);
00137
00138 void USART_Write( Usart *usart, uint16_t data, volatile uint32_t timeOut ) ;
00139
00140 uint16_t USART_Read( Usart *usart, volatile uint32_t timeOut ) ;
00141
00142 uint8_t USART_IsDataAvailable( Usart *usart ) ;
00143
00144 void USART_SetIrdaFilter(Usart *pUsart, uint8_t filter);
00145
00146 void USART_PutChar( Usart *usart, uint8_t c ) ;
00147
00148 uint32_t USART_IsRxReady( Usart *usart ) ;
00149
00150 uint8_t USART_GetChar( Usart *usart ) ;
00151
00152 void USART_EnableRecvTimeOut(Usart *usart, uint32_t timeout);
00153
00154 void USART_EnableTxTimeGaurd(Usart *pUsart, uint32_t TimeGaurd);
00155
00156 void USART_AcknowledgeRxTimeOut(Usart *usart, uint8_t Periodic);
00157
00158
00159 #ifdef __cplusplus
00160 }
00161 #endif
00162
00163 #endif
00164