uc-sdk
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
lpc17xx_uart.h File Reference

Contains all macro definitions and function prototypes support for UART firmware library on LPC17xx. More...

#include "LPC17xx.h"
#include "lpc_types.h"

Go to the source code of this file.

Classes

struct  UART_AB_CFG_Type
 Auto Baudrate mode configuration type definition. More...
 
struct  UART_CFG_Type
 UART Configuration Structure definition. More...
 
struct  UART_FIFO_CFG_Type
 UART FIFO Configuration Structure definition. More...
 
struct  UART1_RS485_CTRLCFG_Type
 UART1 Full modem - RS485 Control configuration type. More...
 

Macros

#define UART_BLOCKING_TIMEOUT   (0xFFFFFFFFUL)
 
#define UART_ACCEPTED_BAUDRATE_ERROR   (3)
 
#define UART_RBR_MASKBIT   ((uint8_t)0xFF)
 
#define UART_THR_MASKBIT   ((uint8_t)0xFF)
 
#define UART_LOAD_DLL(div)   ((div) & 0xFF)
 
#define UART_DLL_MASKBIT   ((uint8_t)0xFF)
 
#define UART_DLM_MASKBIT   ((uint8_t)0xFF)
 
#define UART_LOAD_DLM(div)   (((div) >> 8) & 0xFF)
 
#define UART_IER_RBRINT_EN   ((uint32_t)(1<<0))
 
#define UART_IER_THREINT_EN   ((uint32_t)(1<<1))
 
#define UART_IER_RLSINT_EN   ((uint32_t)(1<<2))
 
#define UART1_IER_MSINT_EN   ((uint32_t)(1<<3))
 
#define UART1_IER_CTSINT_EN   ((uint32_t)(1<<7))
 
#define UART_IER_ABEOINT_EN   ((uint32_t)(1<<8))
 
#define UART_IER_ABTOINT_EN   ((uint32_t)(1<<9))
 
#define UART_IER_BITMASK   ((uint32_t)(0x307))
 
#define UART1_IER_BITMASK   ((uint32_t)(0x38F))
 
#define UART_IIR_INTSTAT_PEND   ((uint32_t)(1<<0))
 
#define UART_IIR_INTID_RLS   ((uint32_t)(3<<1))
 
#define UART_IIR_INTID_RDA   ((uint32_t)(2<<1))
 
#define UART_IIR_INTID_CTI   ((uint32_t)(6<<1))
 
#define UART_IIR_INTID_THRE   ((uint32_t)(1<<1))
 
#define UART1_IIR_INTID_MODEM   ((uint32_t)(0<<1))
 
#define UART_IIR_INTID_MASK   ((uint32_t)(7<<1))
 
#define UART_IIR_FIFO_EN   ((uint32_t)(3<<6))
 
#define UART_IIR_ABEO_INT   ((uint32_t)(1<<8))
 
#define UART_IIR_ABTO_INT   ((uint32_t)(1<<9))
 
#define UART_IIR_BITMASK   ((uint32_t)(0x3CF))
 
#define UART_FCR_FIFO_EN   ((uint8_t)(1<<0))
 
#define UART_FCR_RX_RS   ((uint8_t)(1<<1))
 
#define UART_FCR_TX_RS   ((uint8_t)(1<<2))
 
#define UART_FCR_DMAMODE_SEL   ((uint8_t)(1<<3))
 
#define UART_FCR_TRG_LEV0   ((uint8_t)(0))
 
#define UART_FCR_TRG_LEV1   ((uint8_t)(1<<6))
 
#define UART_FCR_TRG_LEV2   ((uint8_t)(2<<6))
 
#define UART_FCR_TRG_LEV3   ((uint8_t)(3<<6))
 
#define UART_FCR_BITMASK   ((uint8_t)(0xCF))
 
#define UART_TX_FIFO_SIZE   (16)
 
#define UART_LCR_WLEN5   ((uint8_t)(0))
 
#define UART_LCR_WLEN6   ((uint8_t)(1<<0))
 
#define UART_LCR_WLEN7   ((uint8_t)(2<<0))
 
#define UART_LCR_WLEN8   ((uint8_t)(3<<0))
 
#define UART_LCR_STOPBIT_SEL   ((uint8_t)(1<<2))
 
#define UART_LCR_PARITY_EN   ((uint8_t)(1<<3))
 
#define UART_LCR_PARITY_ODD   ((uint8_t)(0))
 
#define UART_LCR_PARITY_EVEN   ((uint8_t)(1<<4))
 
#define UART_LCR_PARITY_F_1   ((uint8_t)(2<<4))
 
#define UART_LCR_PARITY_F_0   ((uint8_t)(3<<4))
 
#define UART_LCR_BREAK_EN   ((uint8_t)(1<<6))
 
#define UART_LCR_DLAB_EN   ((uint8_t)(1<<7))
 
#define UART_LCR_BITMASK   ((uint8_t)(0xFF))
 
#define UART1_MCR_DTR_CTRL   ((uint8_t)(1<<0))
 
#define UART1_MCR_RTS_CTRL   ((uint8_t)(1<<1))
 
#define UART1_MCR_LOOPB_EN   ((uint8_t)(1<<4))
 
#define UART1_MCR_AUTO_RTS_EN   ((uint8_t)(1<<6))
 
#define UART1_MCR_AUTO_CTS_EN   ((uint8_t)(1<<7))
 
#define UART1_MCR_BITMASK   ((uint8_t)(0x0F3))
 
#define UART_LSR_RDR   ((uint8_t)(1<<0))
 
#define UART_LSR_OE   ((uint8_t)(1<<1))
 
#define UART_LSR_PE   ((uint8_t)(1<<2))
 
#define UART_LSR_FE   ((uint8_t)(1<<3))
 
#define UART_LSR_BI   ((uint8_t)(1<<4))
 
#define UART_LSR_THRE   ((uint8_t)(1<<5))
 
#define UART_LSR_TEMT   ((uint8_t)(1<<6))
 
#define UART_LSR_RXFE   ((uint8_t)(1<<7))
 
#define UART_LSR_BITMASK   ((uint8_t)(0xFF))
 
#define UART1_MSR_DELTA_CTS   ((uint8_t)(1<<0))
 
#define UART1_MSR_DELTA_DSR   ((uint8_t)(1<<1))
 
#define UART1_MSR_LO2HI_RI   ((uint8_t)(1<<2))
 
#define UART1_MSR_DELTA_DCD   ((uint8_t)(1<<3))
 
#define UART1_MSR_CTS   ((uint8_t)(1<<4))
 
#define UART1_MSR_DSR   ((uint8_t)(1<<5))
 
#define UART1_MSR_RI   ((uint8_t)(1<<6))
 
#define UART1_MSR_DCD   ((uint8_t)(1<<7))
 
#define UART1_MSR_BITMASK   ((uint8_t)(0xFF))
 
#define UART_SCR_BIMASK   ((uint8_t)(0xFF))
 
#define UART_ACR_START   ((uint32_t)(1<<0))
 
#define UART_ACR_MODE   ((uint32_t)(1<<1))
 
#define UART_ACR_AUTO_RESTART   ((uint32_t)(1<<2))
 
#define UART_ACR_ABEOINT_CLR   ((uint32_t)(1<<8))
 
#define UART_ACR_ABTOINT_CLR   ((uint32_t)(1<<9))
 
#define UART_ACR_BITMASK   ((uint32_t)(0x307))
 
#define UART_ICR_IRDAEN   ((uint32_t)(1<<0))
 
#define UART_ICR_IRDAINV   ((uint32_t)(1<<1))
 
#define UART_ICR_FIXPULSE_EN   ((uint32_t)(1<<2))
 
#define UART_ICR_PULSEDIV(n)   ((uint32_t)((n&0x07)<<3))
 
#define UART_ICR_BITMASK   ((uint32_t)(0x3F))
 
#define UART_FDR_DIVADDVAL(n)   ((uint32_t)(n&0x0F))
 
#define UART_FDR_MULVAL(n)   ((uint32_t)((n<<4)&0xF0))
 
#define UART_FDR_BITMASK   ((uint32_t)(0xFF))
 
#define UART_TER_TXEN   ((uint8_t)(1<<7))
 
#define UART_TER_BITMASK   ((uint8_t)(0x80))
 
#define UART1_RS485CTRL_NMM_EN   ((uint32_t)(1<<0))
 
#define UART1_RS485CTRL_RX_DIS   ((uint32_t)(1<<1))
 
#define UART1_RS485CTRL_AADEN   ((uint32_t)(1<<2))
 
#define UART1_RS485CTRL_SEL_DTR   ((uint32_t)(1<<3))
 
#define UART1_RS485CTRL_DCTRL_EN   ((uint32_t)(1<<4))
 
#define UART1_RS485CTRL_OINV_1   ((uint32_t)(1<<5))
 
#define UART1_RS485CTRL_BITMASK   ((uint32_t)(0x3F))
 
#define UART1_RS485ADRMATCH_BITMASK   ((uint8_t)(0xFF))
 
#define UART1_RS485DLY_BITMASK   ((uint8_t)(0xFF)) /** Bit mask value */
 
#define UART_FIFOLVL_RXFIFOLVL(n)   ((uint32_t)(n&0x0F))
 
#define UART_FIFOLVL_TXFIFOLVL(n)   ((uint32_t)((n>>8)&0x0F))
 
#define UART_FIFOLVL_BITMASK   ((uint32_t)(0x0F0F))
 
#define PARAM_UART_DATABIT(databit)
 
#define PARAM_UART_STOPBIT(stopbit)   ((stopbit==UART_STOPBIT_1) || (stopbit==UART_STOPBIT_2))
 
#define PARAM_UART_PARITY(parity)
 
#define PARAM_UART_FIFO_LEVEL(fifo)
 
#define PARAM_UART_INTCFG(IntCfg)
 
#define PARAM_UART1_INTCFG(IntCfg)   ((IntCfg==UART1_INTCFG_MS) || (IntCfg==UART1_INTCFG_CTS))
 
#define PARAM_UART_AUTOBAUD_MODE(ABmode)   ((ABmode==UART_AUTOBAUD_MODE0) || (ABmode==UART_AUTOBAUD_MODE1))
 
#define PARAM_UART_AUTOBAUD_INTSTAT(ABIntStat)
 
#define PARAM_UART_IrDA_PULSEDIV(PulseDiv)
 
#define PARAM_UART1_SIGNALSTATE(x)   ((x==INACTIVE) || (x==ACTIVE))
 
#define PARAM_UART1_MODEM_PIN(x)   ((x==UART1_MODEM_PIN_DTR) || (x==UART1_MODEM_PIN_RTS))
 
#define PARAM_UART1_MODEM_MODE(x)
 
#define PARAM_UART_RS485_DIRCTRL_PIN(x)   ((x==UART1_RS485_DIRCTRL_RTS) || (x==UART1_RS485_DIRCTRL_DTR))
 
#define PARAM_UARTx(x)
 
#define PARAM_UART_IrDA(x)   (((uint32_t *)x)==((uint32_t *)LPC_UART3))
 
#define PARAM_UART1_MODEM(x)   (((uint32_t *)x)==((uint32_t *)LPC_UART1))
 
#define PARAM_UART1_RS485_CFG_MATCHADDRVALUE(x)   ((x<0xFF))
 
#define PARAM_UART1_RS485_CFG_DELAYVALUE(x)   ((x<0xFF))
 

Enumerations

enum  UART_DATABIT_Type { UART_DATABIT_5 = 0, UART_DATABIT_6, UART_DATABIT_7, UART_DATABIT_8 }
 UART Databit type definitions. More...
 
enum  UART_STOPBIT_Type { UART_STOPBIT_1 = (0), UART_STOPBIT_2 }
 UART Stop bit type definitions. More...
 
enum  UART_PARITY_Type {
  UART_PARITY_NONE = 0, UART_PARITY_ODD, UART_PARITY_EVEN, UART_PARITY_SP_1,
  UART_PARITY_SP_0
}
 UART Parity type definitions. More...
 
enum  UART_FITO_LEVEL_Type { UART_FIFO_TRGLEV0 = 0, UART_FIFO_TRGLEV1, UART_FIFO_TRGLEV2, UART_FIFO_TRGLEV3 }
 FIFO Level type definitions. More...
 
enum  UART_INT_Type {
  UART_INTCFG_RBR = 0, UART_INTCFG_THRE, UART_INTCFG_RLS, UART1_INTCFG_MS,
  UART1_INTCFG_CTS, UART_INTCFG_ABEO, UART_INTCFG_ABTO
}
 UART Interrupt Type definitions. More...
 
enum  UART_LS_Type {
  UART_LINESTAT_RDR = UART_LSR_RDR, UART_LINESTAT_OE = UART_LSR_OE, UART_LINESTAT_PE = UART_LSR_PE, UART_LINESTAT_FE = UART_LSR_FE,
  UART_LINESTAT_BI = UART_LSR_BI, UART_LINESTAT_THRE = UART_LSR_THRE, UART_LINESTAT_TEMT = UART_LSR_TEMT, UART_LINESTAT_RXFE = UART_LSR_RXFE
}
 UART Line Status Type definition. More...
 
enum  UART_AB_MODE_Type { UART_AUTOBAUD_MODE0 = 0, UART_AUTOBAUD_MODE1 }
 UART Auto-baudrate mode type definition. More...
 
enum  UART_ABEO_Type { UART_AUTOBAUD_INTSTAT_ABEO = UART_IIR_ABEO_INT, UART_AUTOBAUD_INTSTAT_ABTO = UART_IIR_ABTO_INT }
 UART End of Auto-baudrate type definition. More...
 
enum  UART_IrDA_PULSE_Type {
  UART_IrDA_PULSEDIV2 = 0, UART_IrDA_PULSEDIV4, UART_IrDA_PULSEDIV8, UART_IrDA_PULSEDIV16,
  UART_IrDA_PULSEDIV32, UART_IrDA_PULSEDIV64, UART_IrDA_PULSEDIV128, UART_IrDA_PULSEDIV256
}
 
enum  UART1_SignalState { INACTIVE = 0, ACTIVE = !INACTIVE }
 UART1 Full modem - Signal states definition. More...
 
enum  UART_MODEM_STAT_type {
  UART1_MODEM_STAT_DELTA_CTS = UART1_MSR_DELTA_CTS, UART1_MODEM_STAT_DELTA_DSR = UART1_MSR_DELTA_DSR, UART1_MODEM_STAT_LO2HI_RI = UART1_MSR_LO2HI_RI, UART1_MODEM_STAT_DELTA_DCD = UART1_MSR_DELTA_DCD,
  UART1_MODEM_STAT_CTS = UART1_MSR_CTS, UART1_MODEM_STAT_DSR = UART1_MSR_DSR, UART1_MODEM_STAT_RI = UART1_MSR_RI, UART1_MODEM_STAT_DCD = UART1_MSR_DCD
}
 UART modem status type definition. More...
 
enum  UART_MODEM_PIN_Type { UART1_MODEM_PIN_DTR = 0, UART1_MODEM_PIN_RTS }
 Modem output pin type definition. More...
 
enum  UART_MODEM_MODE_Type { UART1_MODEM_MODE_LOOPBACK = 0, UART1_MODEM_MODE_AUTO_RTS, UART1_MODEM_MODE_AUTO_CTS }
 UART Modem mode type definition. More...
 
enum  UART_RS485_DIRCTRL_PIN_Type { UART1_RS485_DIRCTRL_RTS = 0, UART1_RS485_DIRCTRL_DTR }
 UART Direction Control Pin type definition. More...
 

Functions

void UART_Init (LPC_UART_TypeDef *UARTx, UART_CFG_Type *UART_ConfigStruct)
 
void UART_DeInit (LPC_UART_TypeDef *UARTx)
 
void UART_ConfigStructInit (UART_CFG_Type *UART_InitStruct)
 
void UART_SendByte (LPC_UART_TypeDef *UARTx, uint8_t Data)
 
uint8_t UART_ReceiveByte (LPC_UART_TypeDef *UARTx)
 
uint32_t UART_Send (LPC_UART_TypeDef *UARTx, uint8_t *txbuf, uint32_t buflen, TRANSFER_BLOCK_Type flag)
 
uint32_t UART_Receive (LPC_UART_TypeDef *UARTx, uint8_t *rxbuf, uint32_t buflen, TRANSFER_BLOCK_Type flag)
 
void UART_FIFOConfig (LPC_UART_TypeDef *UARTx, UART_FIFO_CFG_Type *FIFOCfg)
 
void UART_FIFOConfigStructInit (UART_FIFO_CFG_Type *UART_FIFOInitStruct)
 
uint32_t UART_GetIntId (LPC_UART_TypeDef *UARTx)
 
uint8_t UART_GetLineStatus (LPC_UART_TypeDef *UARTx)
 
void UART_IntConfig (LPC_UART_TypeDef *UARTx, UART_INT_Type UARTIntCfg, FunctionalState NewState)
 
void UART_TxCmd (LPC_UART_TypeDef *UARTx, FunctionalState NewState)
 
FlagStatus UART_CheckBusy (LPC_UART_TypeDef *UARTx)
 
void UART_ForceBreak (LPC_UART_TypeDef *UARTx)
 
void UART_ABClearIntPending (LPC_UART_TypeDef *UARTx, UART_ABEO_Type ABIntType)
 
void UART_ABCmd (LPC_UART_TypeDef *UARTx, UART_AB_CFG_Type *ABConfigStruct, FunctionalState NewState)
 
void UART_FullModemForcePinState (LPC_UART1_TypeDef *UARTx, UART_MODEM_PIN_Type Pin, UART1_SignalState NewState)
 
void UART_FullModemConfigMode (LPC_UART1_TypeDef *UARTx, UART_MODEM_MODE_Type Mode, FunctionalState NewState)
 
uint8_t UART_FullModemGetStatus (LPC_UART1_TypeDef *UARTx)
 
void UART_RS485Config (LPC_UART1_TypeDef *UARTx, UART1_RS485_CTRLCFG_Type *RS485ConfigStruct)
 
void UART_RS485ReceiverCmd (LPC_UART1_TypeDef *UARTx, FunctionalState NewState)
 
void UART_RS485SendSlvAddr (LPC_UART1_TypeDef *UARTx, uint8_t SlvAddr)
 
uint32_t UART_RS485SendData (LPC_UART1_TypeDef *UARTx, uint8_t *pData, uint32_t size)
 
void UART_IrDAInvtInputCmd (LPC_UART_TypeDef *UARTx, FunctionalState NewState)
 
void UART_IrDACmd (LPC_UART_TypeDef *UARTx, FunctionalState NewState)
 
void UART_IrDAPulseDivConfig (LPC_UART_TypeDef *UARTx, UART_IrDA_PULSE_Type PulseDiv)
 

Detailed Description

Contains all macro definitions and function prototypes support for UART firmware library on LPC17xx.

Version
3.0
Date
18. June. 2010
Author
NXP MCU SW Application Team

Software that is described herein is for illustrative purposes only which provides customers with programming information regarding the products. This software is supplied "AS IS" without any warranties. NXP Semiconductors assumes no responsibility or liability for the use of the software, conveys no license or title under any patent, copyright, or mask work right to the product. NXP Semiconductors reserves the right to make changes in the software without notification. NXP Semiconductors also make no representation or warranty that such application will be suitable for the specified use without further testing or modification.

Definition in file lpc17xx_uart.h.