#include <uart_dev.hpp>


Public Member Functions | |
void | setBaudRate (unsigned int baudRate) |
Reset the baud-rate after UART has been initialized. More... | |
bool | getChar (char *pInputChar, unsigned int timeout=portMAX_DELAY) |
bool | putChar (char out, unsigned int timeout=portMAX_DELAY) |
bool | flush (void) |
Flushed all pending transmission of the uart queue. More... | |
void | handleInterrupt () |
unsigned int | getRxQueueSize () const |
unsigned int | getTxQueueSize () const |
unsigned int | getRxQueueWatermark () const |
unsigned int | getTxQueueWatermark () const |
bool | recentlyActive (unsigned int ms=3000) const |
TickType_t | getLastActivityTime (void) const |
void | resetActivity (void) |
![]() | |
bool | gets (char *pBuff, int maxLen, unsigned int timeout=0xffffffff) |
int | printf (const char *format,...) |
int | scanf (const char *format,...) |
uint16_t | getPrintfMemSize (void) const |
bool | put (const char *pString, unsigned int timeout=0xffffffff) |
void | putline (const char *pBuff, unsigned int timeout=0xffffffff) |
bool | isReady (void) |
void | setReady (bool r) |
Protected Member Functions | |
bool | init (unsigned int pclk, unsigned int baudRate, int rxQSize=32, int txQSize=32) |
UartDev (unsigned int *pUARTBaseAddr) | |
~UartDev () | |
![]() | |
CharDev () | |
virtual | ~CharDev () |
Detailed Description
UART Base class that can be used to write drivers for all UART peripherals. Steps needed to write a UART driver:
- Inherit this class
- Call init() and configure PINSEL to select your UART pins
- When your UART(#) hardware interrupt occurs, call handleInterrupt()
To connect UART Interrupt with your UART, reference this example:
- Warning
- This class hasn't been tested for UART1 due to different memory map.
Constructor & Destructor Documentation
|
protected |
Protected constructor that requires parent class to provide UART's base register address for which to operate this UART driver
|
inlineprotected |
Member Function Documentation
|
virtual |
Flushed all pending transmission of the uart queue.
Reimplemented from CharDev.
|
virtual |
- Returns
- a character from the UART input
- Parameters
-
pInputChar The pointer to input char to store received character timeout Optional parameter which defaults to maximum value that will allow you to wait forever for a character to be received
- Returns
- true if a character was obtained within the given timeout
Implements CharDev.
|
inline |
|
inline |
Get the Rx and Tx queue information Watermarks provide the queue's usage to access the capacity usage
|
inline |
|
inline |
|
inline |
void UartDev::handleInterrupt | ( | ) |
When the UART interrupt occurs, this function should be called to handle future action to take due to the interrupt cause.
Bit Masks of IIR register Bits 3:1 that contain interrupt reason. Bits are shifted left because reasonForInterrupt contains Bits 3:0
If multiple sources of interrupt arise, let this interrupt exit, and re-enter for the new source of interrupt.
When THRE (Transmit Holding Register Empty) interrupt occurs, we can send as many bytes as the hardware FIFO supports (16)
While receive Hardware FIFO not empty, keep queuing the data. Even if xQueueSendFromISR() Fails (Queue is full), we still need to read RBR register otherwise interrupt will not clear
|
protected |
Initializes the UART register including Queues, baudrate and hardware. Parent class should call this method before initializing Pin-Connect-Block
- Parameters
-
pclk The system peripheral clock for this UART baudRate The baud rate to set rxQSize The receive queue size txQSize The transmit queue size
- Postcondition
- Sets 8-bit mode, no parity, no flow control.
- Warning
- This will not initialize the PINS, so user needs to do pin selection because LPC's same UART hardware, such as UART2 is available on multiple pins.
- Note
- If the txQSize is too small, functions performing printf will start to block.
|
virtual |
Outputs a char given by
- Parameters
-
out timeout Optional parameter which defaults to maximum value that will allow you to wait forever for a character to be sent
- Returns
- true if the output char was successfully written to Queue, or false if the output queue was full within the given timeout
Implements CharDev.
bool UartDev::recentlyActive | ( | unsigned int | ms = 3000 | ) | const |
Recent activity api Check to see if this UART received any Rx/Tx activity within the last #X OS ticks.
- Parameters
-
ms Optional Parameter: Defaults to 3000 milliseconds
|
inline |
void UartDev::setBaudRate | ( | unsigned int | baudRate | ) |
Reset the baud-rate after UART has been initialized.
The documentation for this class was generated from the following files:
- /var/www/html/SJSU-DEV-Linux/firmware/default/lib/L2_Drivers/base/uart_dev.hpp
- /var/www/html/SJSU-DEV-Linux/firmware/default/lib/L2_Drivers/base/uart_dev.cpp