uart.h
Go to the documentation of this file.
00001 #ifndef __MSP430WARE_UART_H__
00002 #define __MSP430WARE_UART_H__
00003 
00004 //*****************************************************************************
00005 //
00006 //The following are the defines to include the required modules for this
00007 //peripheral in msp430xgeneric.h file
00008 //
00009 //*****************************************************************************
00010 #define __MSP430_HAS_USCI_Ax__
00011 
00012 //*****************************************************************************
00013 //
00014 //The following are values that can be passed to the UART_init() API
00015 //as the parity parameter.
00016 //
00017 //*****************************************************************************
00018 #define UART_NO_PARITY   0x00
00019 #define UART_ODD_PARITY  0x01
00020 #define UART_EVEN_PARITY 0x02
00021 
00022 //*****************************************************************************
00023 //
00024 //The following are values that can be passed to the UART_init() API
00025 //as the selectClockSource parameter.
00026 //
00027 //*****************************************************************************
00028 #define UART_CLOCKSOURCE_ACLK    UCSSEL__ACLK
00029 #define UART_CLOCKSOURCE_SMCLK   UCSSEL__SMCLK
00030 
00031 //*****************************************************************************
00032 
00033 //*****************************************************************************
00034 //
00035 //The following are values that can be passed to the UART_init() API
00036 //as the numberofStopBits parameter.
00037 //
00038 //*****************************************************************************
00039 #define UART_ONE_STOP_BIT    0x00
00040 #define UART_TWO_STOP_BITS   UCSPB
00041 
00042 
00043 //*****************************************************************************
00044 //
00045 //The following are values that can be passed to the UART_init() API
00046 //as the msborLsbFirst parameter.
00047 //
00048 //*****************************************************************************
00049 #define UART_MSB_FIRST    UCMSB
00050 #define UART_LSB_FIRST    0x00
00051 
00052 //*****************************************************************************
00053 //
00054 //The following are values that can be passed to the UART_getInterruptStatus(),
00055 //as the mask parameter.
00056 //
00057 //*****************************************************************************
00058 #define UART_RECEIVE_INTERRUPT_FLAG            UCRXIFG
00059 #define UART_TRANSMIT_INTERRUPT_FLAG           UCTXIFG
00060 
00061 //*****************************************************************************
00062 //
00063 //The following are values that can be passed to the UART_enableInterrupt(),
00064 //UART_disableInterrupt() API as the mask parameter.
00065 //
00066 //*****************************************************************************
00067 #define UART_RECEIVE_INTERRUPT                  UCRXIE
00068 #define UART_TRANSMIT_INTERRUPT                 UCTXIE
00069 #define UART_RECEIVE_ERRONEOUSCHAR_INTERRUPT    UCRXEIE
00070 #define UART_BREAKCHAR_INTERRUPT                UCBRKIE
00071 
00072 //*****************************************************************************
00073 //
00074 //The following are values that can be passed to the UART_queryStatusFlags()
00075 //API as the mask parameter.
00076 //
00077 //*****************************************************************************
00078 #define UART_LISTEN_ENABLE      UCLISTEN
00079 #define UART_FRAMING_ERROR      UCFE
00080 #define UART_OVERRUN_ERROR      UCOE
00081 #define UART_PARITY_ERROR       UCPE
00082 #define UARTBREAK_DETECT        UCBRK
00083 #define UART_RECEIVE_ERROR      UCRXERR
00084 #define UART_ADDRESS_RECEIVED   UCADDR
00085 #define UART_IDLELINE           UCIDLE
00086 #define UART_BUSY               UCBUSY
00087 
00088 //*****************************************************************************
00089 //
00090 //The following are values that can be passed to the UART_init()
00091 //API as the mode parameter.
00092 //
00093 //*****************************************************************************
00094 #define UART_MODE                              UCMODE_0
00095 #define UART_IDLE_LINE_MULTI_PROCESSOR_MODE    UCMODE_1
00096 #define UART_ADDRESS_BIT_MULTI_PROCESSOR_MODE  UCMODE_2
00097 #define UART_AUTOMATIC_BAUDRATE_DETECTION_MODE UCMODE_3
00098 
00099 //*****************************************************************************
00100 //
00101 //The following are values that can be passed to the UART_init()
00102 //API as the overSampling parameter.
00103 //
00104 //*****************************************************************************
00105 #define UART_OVERSAMPLING_BAUDRATE_GENERATION     0x01
00106 #define UART_LOW_FREQUENCY_BAUDRATE_GENERATION    0x00
00107 
00108 
00109 //*****************************************************************************
00110 //
00111 //The following are values are the sync characters possible
00112 //
00113 //*****************************************************************************
00114 #define DEFAULT_SYNC 0x00
00115 #define UART_AUTOMATICBAUDRATE_SYNC 0x55
00116 
00117 //*****************************************************************************
00118 //
00119 //Prototypes for the APIs.
00120 //
00121 //*****************************************************************************
00122 extern
00123 unsigned short UART_init ( unsigned int baseAddress,
00124     unsigned char selectClockSource,
00125     unsigned long clockSourceFrequency,
00126     unsigned long desiredUartBaudRate,
00127     unsigned char parity,
00128     unsigned char msborLsbFirst,
00129     unsigned char numberofStopBits,
00130     unsigned char uartMode,
00131     unsigned short overSampling
00132     );
00133 extern
00134 unsigned short UART_initAdvance ( unsigned int baseAddress,
00135     unsigned char selectClockSource,
00136     unsigned int clockPrescalar,
00137     unsigned char firstModReg,
00138     unsigned char secondModReg,
00139     unsigned char parity,
00140     unsigned char msborLsbFirst,
00141     unsigned char numberofStopBits,
00142     unsigned char uartMode,
00143     unsigned short overSampling
00144     );
00145 extern
00146 void UART_transmitData ( unsigned int baseAddress,
00147     unsigned char transmitData
00148     );
00149 extern
00150 unsigned char UART_receiveData (unsigned int baseAddress);
00151 extern
00152 void UART_enableInterrupt (unsigned int baseAddress,
00153     unsigned char mask
00154     );
00155 extern
00156 void UART_disableInterrupt (unsigned int baseAddress,
00157     unsigned char mask
00158     );
00159 extern
00160 unsigned char UART_getInterruptStatus (unsigned int baseAddress,
00161     unsigned char mask
00162     );
00163 extern
00164 void UART_clearInterruptFlag (unsigned int baseAddress,
00165     unsigned char mask
00166     );
00167 extern
00168 void UART_enable (unsigned int baseAddress);
00169 extern
00170 void UART_disable (unsigned int baseAddress);
00171 extern
00172 unsigned char UART_queryStatusFlags (unsigned int baseAddress,
00173     unsigned char mask);
00174 extern
00175 void UART_setDormant (unsigned int baseAddress);
00176 extern
00177 void UART_resetDormant (unsigned int baseAddress);
00178 extern
00179 void UART_transmitAddress (unsigned int baseAddress,
00180     unsigned char transmitAddress);
00181 extern
00182 void UART_transmitBreak (unsigned int baseAddress);
00183 extern
00184 unsigned long UART_getReceiveBufferAddressForDMA (unsigned int baseAddress);
00185 extern
00186 unsigned long UART_getTransmitBufferAddressForDMA (unsigned int baseAddress);
00187 #endif

Copyright 2012, Texas Instruments Incorporated