Device driver for ATmega On-Chip UART. More...
![]() |
Data Structures | |
struct | _UARTDCB |
UART device control block structure. More... | |
Defines | |
#define | UART_MF_RTSSENSE 0x00000001UL |
#define | UART_MF_CTSCONTROL 0x00000002UL |
#define | UART_MF_DTRSENSE 0x00000004UL |
#define | UART_MF_DSRCONTROL 0x00000008UL |
#define | UART_MF_DCDCONTROL 0x00000010UL |
#define | UART_MF_RTSCONTROL 0x00000020UL |
#define | UART_MF_CTSSENSE 0x00000040UL |
#define | UART_MF_DTRCONTROL 0x00000080UL |
#define | UART_MF_DSRSENSE 0x00000100UL |
#define | UART_MF_DCDSENSE 0x00000200UL |
#define | UART_MF_SENSEMASK 0x0345 |
#define | UART_MF_CONTROLMASK 0x00BC |
#define | UART_MF_XONXOFF 0x00000400UL |
#define | UART_MF_LOCALECHO 0x00010000UL |
#define | UART_MF_COOKEDMODE 0x00020000UL |
#define | UART_MF_NOBUFFER 0x00100000UL |
#define | UART_MF_LINEBUFFER 0x00200000UL |
#define | UART_MF_BUFFERMASK 0x00300000UL |
#define | UART_MF_RAWMODE 0x00400000UL |
#define | UART_SF_RTSOFF 0x00000001UL |
#define | UART_SF_CTSOFF 0x00000002UL |
#define | UART_SF_DTROFF 0x00000004UL |
#define | UART_SF_DSROFF 0x00000008UL |
#define | UART_SF_DCDOFF 0x00000010UL |
#define | HDLC_SF_FLUSH 0x00001000UL |
#define | HDLC_SF_ESCAPED 0x00002000UL |
#define | UART_SF_TXDISABLED 0x00000040UL |
#define | UART_SF_RXDISABLED 0x00000080UL |
#define | UART_HS_DCERTSCTS 0x00000003UL |
#define | UART_HS_DCEFULL 0x0000001FUL |
#define | UART_HS_DTERTSCTS 0x00000060UL |
#define | UART_HS_DTEFULL 0x000003E0UL |
#define | UART_HS_XONXOFF 0x00000400UL |
Typedefs | |
typedef struct _UARTDCB | UARTDCB |
Functions | |
int | UartAvrInput (NUTDEVICE *dev) |
Wait for input. | |
int | UartAvrOutput (NUTDEVICE *dev) |
Initiate output. | |
int | UartAvrFlush (NUTDEVICE *dev) |
Wait for output buffer empty. | |
int | UartAvrIOCtl (NUTDEVICE *dev, int req, void *conf) |
Perform on-chip UART control functions. | |
int | UartAvrInit (NUTDEVICE *dev) |
Initialize on chip uart device. | |
int | UartAvrRead (NUTFILE *fp, void *buffer, int size) |
Read from device. | |
int | UartAvrPut (NUTDEVICE *dev, CONST void *buffer, int len, int pflg) |
Write to device. | |
int | UartAvrWrite (NUTFILE *fp, CONST void *buffer, int len) |
int | UartAvrWrite_P (NUTFILE *fp, PGM_P buffer, int len) |
NUTFILE * | UartAvrOpen (NUTDEVICE *dev, CONST char *name, int mode, int acc) |
Open a device or file. | |
int | UartAvrClose (NUTFILE *fp) |
Close a device or file. | |
long | UartAvrSize (NUTFILE *fp) |
Request file size. | |
Variables | |
NUTDEVICE | devUart0 |
UART 0 Device information structure. | |
NUTDEVICE | devUart1 |
UART 1 Device information structure. |
Device driver for ATmega On-Chip UART.
This device driver writes data to and reads data from the UART on the ATmega128/103 chip. Both, input and output data is buffered and send resp. transmitted by interrupt routines.
Not all ioctl() function are fully implemented. New applications should use the USART device driver.
#define UART_MF_RTSSENSE 0x00000001UL |
#define UART_MF_CONTROLMASK 0x00BC |
#define UART_MF_LOCALECHO 0x00010000UL |
#define UART_MF_COOKEDMODE 0x00020000UL |
#define UART_MF_BUFFERMASK 0x00300000UL |
#define UART_MF_RAWMODE 0x00400000UL |
Send data as raw, disables data encapsulation for device.
Definition at line 111 of file uartavr.h.
Referenced by AhdlcAt91IOCtl(), AhdlcAvrIOCtl(), AhdlcOutput(), and AhdlcRx().
#define HDLC_SF_FLUSH 0x00001000UL |
#define HDLC_SF_ESCAPED 0x00002000UL |
#define UART_SF_TXDISABLED 0x00000040UL |
#define UART_SF_RXDISABLED 0x00000080UL |
#define UART_HS_DCERTSCTS 0x00000003UL |
#define UART_HS_DTERTSCTS 0x00000060UL |
int UartAvrInput | ( | NUTDEVICE * | dev | ) |
Wait for input.
This function checks the input buffer for any data. If the buffer is empty, the calling thread will be blocked until at least one new character is received or a timeout occurs.
dev | Indicates the UART device. |
Definition at line 182 of file uartavr.c.
References _UARTDCB::dcb_rtimeout, _UARTDCB::dcb_rx_rdy, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, _IFSTREAM::if_rd_idx, _IFSTREAM::if_rx_idx, NutEnterCritical, NutEventWait(), and NutExitCritical.
Referenced by UartAvrInit(), and UartAvrRead().
int UartAvrOutput | ( | NUTDEVICE * | dev | ) |
Initiate output.
This function checks the output buffer for any data. If the buffer contains at least one character, the transmitter is started, if not already running. The function returns immediately, without waiting for the character being completely transmitted. Any remaining characters in the output buffer are transmitted in the background.
dev | Indicates the UART device. |
Definition at line 233 of file uartavr.c.
References _NUTDEVICE::dev_base, _NUTDEVICE::dev_icb, _IFSTREAM::if_tx_act, _IFSTREAM::if_tx_buf, _IFSTREAM::if_tx_idx, _IFSTREAM::if_wr_idx, outb, and UDR.
Referenced by UartAvrFlush(), and UartAvrInit().
int UartAvrFlush | ( | NUTDEVICE * | dev | ) |
Wait for output buffer empty.
If the output buffer contains any data, the calling thread is suspended until all data has been transmitted.
dev | Indicates the UART device. |
Definition at line 260 of file uartavr.c.
References _UARTDCB::dcb_tx_rdy, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, _IFSTREAM::if_tx_idx, _IFSTREAM::if_wr_idx, NutEnterCritical, NutEventWait(), NutExitCritical, and UartAvrOutput().
Referenced by UartAvrInit(), and UartAvrPut().
int UartAvrIOCtl | ( | NUTDEVICE * | dev, |
int | req, | ||
void * | conf | ||
) |
Perform on-chip UART control functions.
dev | Identifies the device that receives the device-control function. |
req | Requested control function. May be set to one of the following constants:
|
conf | Points to a buffer that contains any data required for the given control function or receives data from that function. |
Definition at line 400 of file uartavr.c.
References bit_is_set, _UARTDCB::dcb_modeflags, _UARTDCB::dcb_rtimeout, _UARTDCB::dcb_wtimeout, _NUTDEVICE::dev_base, _NUTDEVICE::dev_dcb, devUart0, NutGetCpuClock(), UART_GETCOOKEDMODE, UART_GETDATABITS, UART_GETFLOWCONTROL, UART_GETLOCALECHO, UART_GETPARITY, UART_GETREADTIMEOUT, UART_GETSPEED, UART_GETSTATUS, UART_GETSTOPBITS, UART_GETWRITETIMEOUT, UART_MF_COOKEDMODE, UART_MF_LOCALECHO, UART_SETCOOKEDMODE, UART_SETDATABITS, UART_SETFLOWCONTROL, UART_SETLOCALECHO, UART_SETPARITY, UART_SETREADTIMEOUT, UART_SETSPEED, UART_SETSTATUS, UART_SETSTOPBITS, UART_SETWRITETIMEOUT, and UBRR.
Referenced by UartAvrInit().
int UartAvrInit | ( | NUTDEVICE * | dev | ) |
Initialize on chip uart device.
Prepares the device for subsequent reading or writing. Enables UART transmitter and receiver interrupts.
dev | Identifies the device to initialize. |
Definition at line 641 of file uartavr.c.
References _UARTDCB::dcb_modeflags, _NUTDEVICE::dev_base, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, _NUTDEVICE::dev_irq, _NUTDEVICE::dev_type, _IFSTREAM::if_flush, _IFSTREAM::if_input, _IFSTREAM::if_output, IFTYP_STREAM, memset(), NutRegisterIrqHandler(), sig_UART0_RECV, sig_UART0_TRANS, sig_UART1_RECV, sig_UART1_TRANS, UART_MF_NOBUFFER, UART_SETSPEED, UartAvrFlush(), UartAvrInput(), UartAvrIOCtl(), and UartAvrOutput().
int UartAvrRead | ( | NUTFILE * | fp, |
void * | buffer, | ||
int | size | ||
) |
Read from device.
Definition at line 699 of file uartavr.c.
References _UARTDCB::dcb_modeflags, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, _IFSTREAM::if_last_eol, _IFSTREAM::if_rd_idx, _IFSTREAM::if_rx_buf, _IFSTREAM::if_rx_idx, _NUTFILE::nf_dev, UART_MF_COOKEDMODE, and UartAvrInput().
int UartAvrPut | ( | NUTDEVICE * | dev, |
CONST void * | buffer, | ||
int | len, | ||
int | pflg | ||
) |
Write to device.
Definition at line 758 of file uartavr.c.
References CONST, _UARTDCB::dcb_modeflags, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, _IFSTREAM::if_tx_buf, _IFSTREAM::if_tx_idx, _IFSTREAM::if_wr_idx, PRG_RDB, UART_MF_COOKEDMODE, UART_MF_LINEBUFFER, UART_MF_NOBUFFER, and UartAvrFlush().
Referenced by UartAvrWrite(), and UartAvrWrite_P().
int UartAvrWrite | ( | NUTFILE * | fp, |
CONST void * | buffer, | ||
int | len | ||
) |
Definition at line 821 of file uartavr.c.
References _NUTFILE::nf_dev, and UartAvrPut().
int UartAvrWrite_P | ( | NUTFILE * | fp, |
PGM_P | buffer, | ||
int | len | ||
) |
Definition at line 826 of file uartavr.c.
References CONST, _NUTFILE::nf_dev, and UartAvrPut().
Open a device or file.
Definition at line 835 of file uartavr.c.
References _O_BINARY, _UARTDCB::dcb_modeflags, _NUTDEVICE::dev_dcb, _NUTFILE::nf_dev, _NUTFILE::nf_fcb, _NUTFILE::nf_next, NUTFILE_EOF, NutHeapAlloc, and UART_MF_COOKEDMODE.
int UartAvrClose | ( | NUTFILE * | fp | ) |
long UartAvrSize | ( | NUTFILE * | fp | ) |
Request file size.
Definition at line 869 of file uartavr.c.
References _NUTDEVICE::dev_icb, _IFSTREAM::if_rd_idx, _IFSTREAM::if_rx_idx, and _NUTFILE::nf_dev.
{ 0, {'u', 'a', 'r', 't', '0', 0, 0, 0, 0}, IFTYP_STREAM, 0, 0, &ifs_uart0, &dcb_uart0, UartAvrInit, UartAvrIOCtl, UartAvrRead, UartAvrWrite, UartAvrWrite_P, UartAvrOpen, UartAvrClose, UartAvrSize }
UART 0 Device information structure.
Definition at line 94 of file uart0.c.
Referenced by AhdlcAvrIOCtl(), and UartAvrIOCtl().
{ 0, {'u', 'a', 'r', 't', '1', 0, 0, 0, 0}, IFTYP_STREAM, 1, 0, &ifs_uart1, &dcb_uart1, UartAvrInit, UartAvrIOCtl, UartAvrRead, UartAvrWrite, UartAvrWrite_P, UartAvrOpen, UartAvrClose, UartAvrSize }
UART 1 Device information structure.