Collaboration diagram for * USART Driver Frame:
![]() |
The USART device driver implements buffered, interrupt controlled serial communication. It supports software and hardware handshake, 9-bit communication, half duplex and synchronous operation.
The driver's code is devided into a general part and a hardware dependant part, which simplifies porting it to different USART chips. The AVR USART Devices provide support for the ATmega128/103 on-chip USARTs.
Data Structures | |
struct | _RINGBUF |
Character device ring buffer structure. More... | |
struct | _USARTDCB |
USART device low level information structure. More... | |
struct | _RINGBUF |
Character device ring buffer structure. More... | |
struct | _USARTDCB |
USART device low level information structure. More... | |
Ring Buffer | |
#define | USART_RXBUFSIZ 256 |
Initial receive buffer size. | |
#define | USART_RXHIWMARK 240 |
Receiver's initial high water mark. | |
#define | USART_RXLOWMARK 208 |
Receiver's initial low water mark. | |
#define | USART_TXBUFSIZ 64 |
Initial transmit buffer size. | |
#define | USART_TXHIWMARK 56 |
Transmitter's initial high water mark. | |
#define | USART_TXLOWMARK 40 |
Transmitter's initial low water mark. | |
typedef _RINGBUF | RINGBUF |
Character device ring buffer type. | |
Initial UART Configuration | |
#define | USART_INITSPEED 115200 |
Initial bit rate. | |
Defines | |
#define | USART_MF_RTSCONTROL |
#define | USART_MF_CTSSENSE |
#define | USART_MF_DTRCONTROL |
#define | USART_MF_DSRSENSE |
#define | USART_MF_DCDSENSE |
#define | USART_MF_SENSEMASK |
#define | USART_MF_CONTROLMASK |
#define | USART_MF_XONXOFF |
Software handshake. | |
#define | USART_MF_LOCALECHO |
#define | USART_MF_COOKEDMODE |
#define | USART_MF_NOBUFFER |
#define | USART_MF_LINEBUFFER |
#define | USART_MF_BUFFERMASK |
#define | USART_MF_HALFDUPLEX |
#define | USART_MF_BLOCKREAD |
#define | USART_SF_RTSOFF |
#define | USART_SF_CTSOFF |
#define | USART_SF_DTROFF |
#define | USART_SF_DSROFF |
#define | USART_SF_DCDOFF |
#define | USART_SF_TXDISABLED |
#define | USART_SF_RXDISABLED |
Typedefs | |
typedef _USARTDCB | USARTDCB |
Functions | |
*int | UsartInit (NUTDEVICE *dev) |
Initialize the USART device. | |
int | UsartRead (NUTFILE *fp, void *buffer, int size) |
Read from device. | |
int | UsartWrite (NUTFILE *fp, CONST void *buffer, int len) |
Write a device or file. | |
int | UsartWrite_P (NUTFILE *fp, PGM_P buffer, int len) |
Write a device or file. | |
int | UsartClose (NUTFILE *fp) |
Close an USART device. | |
NUTFILE * | UsartOpen (NUTDEVICE *dev, CONST char *name, int mode, int acc) |
Open an USART device. | |
int | UsartIOCtl (NUTDEVICE *dev, int req, void *conf) |
Perform USART control functions. | |
long | UsartSize (NUTFILE *fp) |
Retrieves the number of characters in input buffer. |
|
Block read enabled |
|
Masks buffering mode flags. |
|
Handshake control mask. |
|
Should be used in stream, not device. |
|
DTE input. |
|
DTE input. |
|
DTE input. |
|
DTE output. |
|
Half duplex control. |
|
Line buffered. |
|
Should be used in stream, not device. |
|
No buffering. |
|
DTE output. |
|
Handshake sense mask. |
|
Software handshake. It is recommended to set a proper read timeout with software handshake. In this case a timeout may occur, if the communication peer lost our last XON character. The application may then use ioctl() to disable the receiver and do the read again. This will send out another XON. |
|
Receiver's initial high water mark. Disables receiver handshake. |
|
Receiver's initial low water mark. Enables receiver handshake. |
|
Set if CTS line is off. |
|
Set if DCD line is off. |
|
Set if DSR line is off. |
|
Set if DTR line is off. |
|
Set if RTS line is off. |
|
Receiver disabled. |
|
Transmitter disabled. |
|
Transmitter's initial high water mark. Starts the transmitter. |
|
Transmitter's initial low water mark. Wakes up transmitting threads. |
|
USART device low level information type. |
|
Close an USART device. This function is called by the low level close routine of the C runtime library, using the _NUTDEVICE::dev_close entry.
|
|
Initialize the USART device. This function is called by NutRegisterDevice(), using the _NUTDEVICE::dev_init entry. It will call the low level driver's _USARTDCB::dcb_init routine to initialize the hardware.
|
|
Perform USART control functions. This function is called by the ioctl() function of the C runtime library.
|
|
Open an USART device. This function is called by the low level open routine of the C runtime library, using the _NUTDEVICE::dev_open entry.
|
|
Read from device. This function is called by the low level input routines of the C runtime library, using the _NUTDEVICE::dev_read entry. The function may block the calling thread until at least one character has been received or a timeout occurs. It is recommended to set a proper read timeout with software handshake. In this case a timeout may occur, if the communication peer lost our last XON character. The application may then use ioctl() to disable the receiver and do the read again. This will send out another XON.
|
|
Retrieves the number of characters in input buffer. This function is called by the low level size routine of the C runtime library, using the _NUTDEVICE::dev_size entry.
|
|
Write a device or file. This function is called by the low level output routines of the C runtime library, using the _NUTDEVICE::dev_write entry. The function may block the calling thread.
|
|
Write a device or file. Similar to UsartWrite() except that the data is located in program memory. This function is called by the low level output routines of the C runtime library, using the _NUTDEVICE::dev_write_P entry. The function may block the calling thread.
|