| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Modules | Functions
CHIP: LPC11xx UART Driver
LPC11xx chip specific drivers

## Detailed Description

## Modules
| CHIP: LPC11xx UART Driver blocking transfer functions
| CHIP: LPC11xx UART Driver interrupt transfer functions

## Functions
void | Chip_UART_Init (LPC_USART_T *pUART)
| Initializes the pUART peripheral.
void | Chip_UART_DeInit (LPC_USART_T *pUART)
| De-initializes the pUART peripheral.
STATIC INLINE void | Chip_UART_TXEnable (LPC_USART_T *pUART)
| Enable transmission on UART TxD pin.
STATIC INLINE void | Chip_UART_TXDisable (LPC_USART_T *pUART)
| Disable transmission on UART TxD pin.
STATIC INLINE void | Chip_UART_SendByte (LPC_USART_T *pUART, uint8_t data)
| Transmit a single byte through the UART peripheral.
STATIC INLINE uint8_t | Chip_UART_ReadByte (LPC_USART_T *pUART)
| Get a single data from UART peripheral.
int | Chip_UART_Send (LPC_USART_T *pUART, const void *data, int numBytes)
| Transmit a byte array through the UART peripheral (non-blocking)
int | Chip_UART_Read (LPC_USART_T *pUART, void *data, int numBytes)
| Read data through the UART peripheral (non-blocking)
STATIC INLINE void | Chip_UART_IntEnable (LPC_USART_T *pUART, uint32_t intMask)
| Enable UART interrupts.
STATIC INLINE void | Chip_UART_IntDisable (LPC_USART_T *pUART, uint32_t intMask)
| Disable UART interrupts.
STATIC INLINE uint32_t | Chip_UART_ReadIntIDReg (LPC_USART_T *pUART)
| Read the Interrupt Identification Register (IIR)
STATIC INLINE void | Chip_UART_SetupFIFOS (LPC_USART_T *pUART, uint32_t fcr)
| Setup the UART FIFOs.
STATIC INLINE void | Chip_UART_ConfigData (LPC_USART_T *pUART, uint32_t config)
| Configure data width, parity mode and stop bits.
STATIC INLINE void | Chip_UART_EnableDivisorAccess (LPC_USART_T *pUART)
| Enable access to Divisor Latches.
STATIC INLINE void | Chip_UART_DisableDivisorAccess (LPC_USART_T *pUART)
| Disable access to Divisor Latches.
STATIC INLINE void | Chip_UART_SetDivisorLatches (LPC_USART_T *pUART, uint8_t dll, uint8_t dlm)
| Set LSB and MSB divisor latch registers.
STATIC INLINE uint32_t | Chip_UART_ReadModemControl (LPC_USART_T *pUART)
| Return modem control register/status.
STATIC INLINE void | Chip_UART_SetModemControl (LPC_USART_T *pUART, uint32_t mcr)
| Set modem control register/status.
STATIC INLINE void | Chip_UART_ClearModemControl (LPC_USART_T *pUART, uint32_t mcr)
| Clear modem control register/status.
STATIC INLINE uint32_t | Chip_UART_ReadLineStatus (LPC_USART_T *pUART)
| Return Line Status register/status (LSR)
STATIC INLINE uint32_t | Chip_UART_ReadModemStatus (LPC_USART_T *pUART)
| Return Modem Status register/status (MSR)
STATIC INLINE void | Chip_UART_SetScratch (LPC_USART_T *pUART, uint8_t data)
| Write a byte to the scratchpad register.
STATIC INLINE uint8_t | Chip_UART_ReadScratch (LPC_USART_T *pUART)
| Returns current byte value in the scratchpad register.
STATIC INLINE void | Chip_UART_SetAutoBaudReg (LPC_USART_T *pUART, uint32_t acr)
| Set autobaud register options.
STATIC INLINE void | Chip_UART_ClearAutoBaudReg (LPC_USART_T *pUART, uint32_t acr)
| Clear autobaud register options.
STATIC INLINE void | Chip_UART_SetRS485Flags (LPC_USART_T *pUART, uint32_t ctrl)
| Set RS485 control register options.
STATIC INLINE void | Chip_UART_ClearRS485Flags (LPC_USART_T *pUART, uint32_t ctrl)
| Clear RS485 control register options.
STATIC INLINE void | Chip_UART_SetRS485Addr (LPC_USART_T *pUART, uint8_t addr)
| Set RS485 address match value.
STATIC INLINE uint8_t | Chip_UART_GetRS485Addr (LPC_USART_T *pUART)
| Read RS485 address match value.
STATIC INLINE void | Chip_UART_SetRS485Delay (LPC_USART_T *pUART, uint8_t dly)
| Set RS485 direction control (RTS or DTR) delay value.
STATIC INLINE uint8_t | Chip_UART_GetRS485Delay (LPC_USART_T *pUART)
| Read RS485 direction control (RTS or DTR) delay value.
uint32_t | Chip_UART_SetBaud (LPC_USART_T *pUART, uint32_t baudrate)
| Sets best dividers to get a target bit rate (without fractional divider)
STATIC INLINE uint32_t | Chip_UART_SetBaudFDR (LPC_USART_T *pUART, uint32_t baudrate)
| Sets best dividers to get a target bit rate (with fractional divider)

## Function Documentation

STATIC INLINE void Chip_UART_ClearAutoBaudReg | ( | LPC_USART_T * | pUART,
|  | uint32_t | acr
| ) |  |

Clear autobaud register options.

Parameters

  pUART | : Pointer to selected UART peripheral
  acr | : Or'ed values to clear for ACR register

Returns
  Nothing

Note
  Use an Or'ed value of UART_ACR_* definitions with this call to clear specific options.

Definition at line 339 of file uart_11xx.h.

STATIC INLINE void Chip_UART_ClearModemControl | ( | LPC_USART_T * | pUART,
|  | uint32_t | mcr
| ) |  |

Clear modem control register/status.

Parameters

  pUART | : Pointer to selected UART peripheral
  mcr | : Modem control register flags to clear

Returns
  Nothing

Note
  Use an Or'ed value of UART_MCR_* definitions with this call to clear specific options.

Definition at line 268 of file uart_11xx.h.

STATIC INLINE void Chip_UART_ClearRS485Flags | ( | LPC_USART_T * | pUART,
|  | uint32_t | ctrl
| ) |  |

Clear RS485 control register options.

Parameters

  pUART | : Pointer to selected UART peripheral
  ctrl | : Or'ed values to clear for RS485 control register

Returns
  Nothing

Note
  Use an Or'ed value of UART_RS485CTRL_* definitions with this call to clear specific options.

Definition at line 365 of file uart_11xx.h.

STATIC INLINE void Chip_UART_ConfigData | ( | LPC_USART_T * | pUART,
|  | uint32_t | config
| ) |  |

Configure data width, parity mode and stop bits.

Parameters

  pUART | : Pointer to selected pUART peripheral
  config | : UART configuration, Or'ed values of UART_LCR_* defines

Returns
  Nothing

Note
  Select OR'ed config options for the UART from the UART_LCR_* definitions. For example, a configuration of 8 data bits, 1 stop bit, and even (enabled) parity would be (UART_LCR_WLEN8 | UART_LCR_SBS_1BIT | UART_LCR_PARITY_EN | UART_LCR_PARITY_EVEN).

Definition at line 194 of file uart_11xx.h.

void Chip_UART_DeInit | ( | LPC_USART_T * | pUART | ) |

De-initializes the pUART peripheral.

Parameters

  pUART | : Pointer to selected pUART peripheral

Returns
  Nothing

Definition at line 64 of file uart_11xx.c.

STATIC INLINE void Chip_UART_DisableDivisorAccess | ( | LPC_USART_T * | pUART | ) |

Disable access to Divisor Latches.

Parameters

  pUART | : Pointer to selected UART peripheral

Returns
  Nothing

Definition at line 215 of file uart_11xx.h.

STATIC INLINE void Chip_UART_EnableDivisorAccess | ( | LPC_USART_T * | pUART | ) |

Enable access to Divisor Latches.

Parameters

  pUART | : Pointer to selected UART peripheral

Returns
  Nothing

Definition at line 205 of file uart_11xx.h.

STATIC INLINE uint8_t Chip_UART_GetRS485Addr | ( | LPC_USART_T * | pUART | ) |

Read RS485 address match value.

Parameters

  pUART | : Pointer to selected UART peripheral

Returns
  Address match value for RS-485/EIA-485 mode

Definition at line 386 of file uart_11xx.h.

STATIC INLINE uint8_t Chip_UART_GetRS485Delay | ( | LPC_USART_T * | pUART | ) |

Read RS485 direction control (RTS or DTR) delay value.

Parameters

  pUART | : Pointer to selected UART peripheral

Returns
  direction control (RTS or DTR) delay value

Note
  This delay time is in periods of the baud clock. Any delay time from 0 to 255 bit times may be programmed.

Definition at line 411 of file uart_11xx.h.

void Chip_UART_Init | ( | LPC_USART_T * | pUART | ) |

Initializes the pUART peripheral.

Parameters

  pUART | : Pointer to selected pUART peripheral

Returns
  Nothing

Definition at line 54 of file uart_11xx.c.

STATIC INLINE void Chip_UART_IntDisable | ( | LPC_USART_T * | pUART,
|  | uint32_t | intMask
| ) |  |

Disable UART interrupts.

Parameters

  pUART | : Pointer to selected UART peripheral
  intMask | : Or'ed Interrupts to disable in the Interrupt Enable Register (IER)

Returns
  Nothing

Note
  Use an Or'ed value of UART_IER_* definitions with this call to disable specific UART interrupts. The Divisor Latch Access Bit (DLAB) in LCR must be cleared in order to access the IER register. This function doesn't alter the DLAB state.

Definition at line 154 of file uart_11xx.h.

STATIC INLINE void Chip_UART_IntEnable | ( | LPC_USART_T * | pUART,
|  | uint32_t | intMask
| ) |  |

Enable UART interrupts.

Parameters

  pUART | : Pointer to selected UART peripheral
  intMask | : Or'ed Interrupts to enable in the Interrupt Enable Register (IER)

Returns
  Nothing

Note
  Use an Or'ed value of UART_IER_* definitions with this call to enable specific UART interrupts. The Divisor Latch Access Bit (DLAB) in LCR must be cleared in order to access the IER register. This function doesn't alter the DLAB state.

Definition at line 139 of file uart_11xx.h.

int Chip_UART_Read | ( | LPC_USART_T * | pUART,
|  | void * | data,
|  | int | numBytes
| ) |  |

Read data through the UART peripheral (non-blocking)

Parameters

  pUART | : Pointer to selected UART peripheral
  data | : Pointer to bytes array to fill
  numBytes | : Size of the passed data array

Returns
  The actual number of bytes read

Note
  This function reads data from the receive FIFO until either all the data has been read or the passed buffer is completely full. This function will not block. This function ignores errors.

Definition at line 106 of file uart_11xx.c.

STATIC INLINE uint8_t Chip_UART_ReadByte | ( | LPC_USART_T * | pUART | ) |

Get a single data from UART peripheral.

Parameters

  pUART | : Pointer to selected UART peripheral

Returns
  A single byte of data read

Note
  This function reads a byte from the UART receive FIFO or receive hold register regard regardless of UART state. The FIFO status should be read first prior to using this function.

Definition at line 99 of file uart_11xx.h.

STATIC INLINE uint32_t Chip_UART_ReadIntIDReg | ( | LPC_USART_T * | pUART | ) |

Read the Interrupt Identification Register (IIR)

Parameters

  pUART | : Pointer to selected UART peripheral

Returns
  Current pending interrupt status per the IIR register

Definition at line 164 of file uart_11xx.h.

STATIC INLINE uint32_t Chip_UART_ReadLineStatus | ( | LPC_USART_T * | pUART | ) |

Return Line Status register/status (LSR)

Parameters

  pUART | : Pointer to selected UART peripheral

Returns
  Line Status register (status)

Note
  Mask bits of the returned status value with UART_LSR_* definitions for specific statuses.

Definition at line 280 of file uart_11xx.h.

STATIC INLINE uint32_t Chip_UART_ReadModemControl | ( | LPC_USART_T * | pUART | ) |

Return modem control register/status.

Parameters

  pUART | : Pointer to selected UART peripheral

Returns
  Modem control register (status)

Note
  Mask bits of the returned status value with UART_MCR_* definitions for specific statuses.

Definition at line 242 of file uart_11xx.h.

STATIC INLINE uint32_t Chip_UART_ReadModemStatus | ( | LPC_USART_T * | pUART | ) |

Return Modem Status register/status (MSR)

Parameters

  pUART | : Pointer to selected UART peripheral

Returns
  Modem Status register (status)

Note
  Mask bits of the returned status value with UART_MSR_* definitions for specific statuses.

Definition at line 292 of file uart_11xx.h.

STATIC INLINE uint8_t Chip_UART_ReadScratch | ( | LPC_USART_T * | pUART | ) |

Returns current byte value in the scratchpad register.

Parameters

  pUART | : Pointer to selected UART peripheral

Returns
  Byte value read from scratchpad register

Definition at line 313 of file uart_11xx.h.

int Chip_UART_Send | ( | LPC_USART_T * | pUART,
|  | const void * | data,
|  | int | numBytes
| ) |  |

Transmit a byte array through the UART peripheral (non-blocking)

Parameters

  pUART | : Pointer to selected UART peripheral
  data | : Pointer to bytes to transmit
  numBytes | : Number of bytes to transmit

Returns
  The actual number of bytes placed into the FIFO

Note
  This function places data into the transmit FIFO until either all the data is in the FIFO or the FIFO is full. This function will not block in the FIFO is full. The actual number of bytes placed into the FIFO is returned. This function ignores errors.

Definition at line 73 of file uart_11xx.c.

STATIC INLINE void Chip_UART_SendByte | ( | LPC_USART_T * | pUART,
|  | uint8_t | data
| ) |  |

Transmit a single byte through the UART peripheral.

Transmit a 8 bits data.

Parameters

  pUART | : Pointer to selected UART peripheral
  data | : Byte to transmit

Returns
  Nothing

Note
  This function attempts to place a byte into the UART transmit FIFO or transmit hold register regard regardless of UART state.

Definition at line 86 of file uart_11xx.h.

STATIC INLINE void Chip_UART_SetAutoBaudReg | ( | LPC_USART_T * | pUART,
|  | uint32_t | acr
| ) |  |

Set autobaud register options.

Parameters

  pUART | : Pointer to selected UART peripheral
  acr | : Or'ed values to set for ACR register

Returns
  Nothing

Note
  Use an Or'ed value of UART_ACR_* definitions with this call to set specific options.

Definition at line 326 of file uart_11xx.h.

uint32_t Chip_UART_SetBaud | ( | LPC_USART_T * | pUART,
|  | uint32_t | baudrate
| ) |  |

Sets best dividers to get a target bit rate (without fractional divider)

Parameters

  pUART | : Pointer to selected UART peripheral
  baudrate | : Target baud rate (baud rate = bit rate)

Returns
  The actual baud rate, or 0 if no rate can be found

Definition at line 139 of file uart_11xx.c.

STATIC INLINE uint32_t Chip_UART_SetBaudFDR | ( | LPC_USART_T * | pUART,
|  | uint32_t | baudrate
| ) |  |

Sets best dividers to get a target bit rate (with fractional divider)

Parameters

  pUART | : Pointer to selected UART peripheral
  baudrate | : Target baud rate (baud rate = bit rate)

Returns
  The actual baud rate, or 0 if no rate can be found

Definition at line 430 of file uart_11xx.h.

STATIC INLINE void Chip_UART_SetDivisorLatches | ( | LPC_USART_T * | pUART,
|  | uint8_t | dll,
|  | uint8_t | dlm
| ) |  |

Set LSB and MSB divisor latch registers.

Parameters

  pUART | : Pointer to selected UART peripheral
  dll | : Divisor Latch LSB value
  dlm | : Divisor Latch MSB value

Returns
  Nothing

Note
  The Divisor Latch Access Bit (DLAB) in LCR must be set in order to access the USART Divisor Latches. This function doesn't alter the DLAB state.

Definition at line 230 of file uart_11xx.h.

STATIC INLINE void Chip_UART_SetModemControl | ( | LPC_USART_T * | pUART,
|  | uint32_t | mcr
| ) |  |

Set modem control register/status.

Parameters

  pUART | : Pointer to selected UART peripheral
  mcr | : Modem control register flags to set

Returns
  Nothing

Note
  Use an Or'ed value of UART_MCR_* definitions with this call to set specific options.

Definition at line 255 of file uart_11xx.h.

STATIC INLINE void Chip_UART_SetRS485Addr | ( | LPC_USART_T * | pUART,
|  | uint8_t | addr
| ) |  |

Set RS485 address match value.

Parameters

  pUART | : Pointer to selected UART peripheral
  addr | : Address match value for RS-485/EIA-485 mode

Returns
  Nothing

Definition at line 376 of file uart_11xx.h.

STATIC INLINE void Chip_UART_SetRS485Delay | ( | LPC_USART_T * | pUART,
|  | uint8_t | dly
| ) |  |

Set RS485 direction control (RTS or DTR) delay value.

Parameters

  pUART | : Pointer to selected UART peripheral
  dly | : direction control (RTS or DTR) delay value

Returns
  Nothing

Note
  This delay time is in periods of the baud clock. Any delay time from 0 to 255 bit times may be programmed.

Definition at line 399 of file uart_11xx.h.

STATIC INLINE void Chip_UART_SetRS485Flags | ( | LPC_USART_T * | pUART,
|  | uint32_t | ctrl
| ) |  |

Set RS485 control register options.

Parameters

  pUART | : Pointer to selected UART peripheral
  ctrl | : Or'ed values to set for RS485 control register

Returns
  Nothing

Note
  Use an Or'ed value of UART_RS485CTRL_* definitions with this call to set specific options.

Definition at line 352 of file uart_11xx.h.

STATIC INLINE void Chip_UART_SetScratch | ( | LPC_USART_T * | pUART,
|  | uint8_t | data
| ) |  |

Write a byte to the scratchpad register.

Parameters

  pUART | : Pointer to selected UART peripheral
  data | : Byte value to write

Returns
  Nothing

Definition at line 303 of file uart_11xx.h.

STATIC INLINE void Chip_UART_SetupFIFOS | ( | LPC_USART_T * | pUART,
|  | uint32_t | fcr
| ) |  |

Setup the UART FIFOs.

Parameters

  pUART | : Pointer to selected UART peripheral
  fcr | : FIFO control register setup OR'ed flags

Returns
  Nothing

Note
  Use an Or'ed value of UART_FCR_* definitions with this call to select specific options. For example, to enable the FIFOs with a RX trip level of 8 characters, use something like (UART_FCR_FIFO_EN | UART_FCR_TRG_LEV2).

Definition at line 179 of file uart_11xx.h.

STATIC INLINE void Chip_UART_TXDisable | ( | LPC_USART_T * | pUART | ) |

Disable transmission on UART TxD pin.

Parameters

  pUART | : Pointer to selected pUART peripheral

Returns
  Nothing

Definition at line 73 of file uart_11xx.h.

STATIC INLINE void Chip_UART_TXEnable | ( | LPC_USART_T * | pUART | ) |

Enable transmission on UART TxD pin.

Parameters

  pUART | : Pointer to selected pUART peripheral

Returns
  Nothing

Definition at line 63 of file uart_11xx.h.