#include <string.h>
#include <sys/atom.h>
#include <sys/heap.h>
#include <sys/event.h>
#include <sys/timer.h>
#include <sys/device.h>
#include <dev/irqreg.h>
#include <dev/tlc16c550.h>
#include <fcntl.h>
#include <stdio.h>
Go to the source code of this file.
Data Structures | |
struct | tagIRQDEFS |
#define | ACE_RBR_OFS 0 |
#define | ACE_THR_OFS 0 |
#define | ACE_DLL_OFS 0 |
#define | ACE_DLM_OFS 1 |
#define | ACE_IER_OFS 1 |
#define | ACE_FCR_OFS 2 |
#define | ACE_IIR_OFS 2 |
#define | ACE_LCR_OFS 3 |
#define | ACE_MCR_OFS 4 |
#define | ACE_LSR_OFS 5 |
#define | ACE_MSR_OFS 6 |
#define | ACE_SRC_OFS 7 |
#define | IER_RDA_MSK 0x01 |
#define | IER_THE_MSK 0x02 |
#define | IER_LST_MSK 0x04 |
#define | IER_MST_MSK 0x08 |
#define | FCR_ENABLE 0x01 |
#define | FCR_PURGE_I 0x02 |
#define | FCR_PURGE_O 0x04 |
#define | FCR_LEVEL_1 0x00 |
#define | FCR_LEVEL_4 0x40 |
#define | FCR_LEVEL_8 0x80 |
#define | FCR_LEVEL_14 0xc0 |
#define | IIR_MST_MSK 0x00 |
#define | IIR_TXE_MSK 0x02 |
#define | IIR_RDA_MSK 0x04 |
#define | IIR_TDA_MSK 0x0c |
#define | IIR_LST_MSK 0x06 |
#define | IIR_NON_MSK 0x01 |
#define | IIR_FIFO_MSK 0xc0 |
#define | LCR_WS0_MSK 0x01 |
#define | LCR_WS1_MSK 0x02 |
#define | LCR_STB_MSK 0x04 |
#define | LCR_PEN_MSK 0x08 |
#define | LCR_PRE_MSK 0x10 |
#define | LCR_PRS_MSK 0x20 |
#define | LCR_BRK_MSK 0x40 |
#define | LCR_ENB_MSK 0x80 |
#define | MCR_DTR_MSK 0x01 |
#define | MCR_RTS_MSK 0x02 |
#define | MCR_GP1_MSK 0x04 |
#define | MCR_GP2_MSK 0x08 |
#define | MCR_LOP_MSK 0x10 |
#define | LSR_RDR_MSK 0x01 |
#define | LSR_OVR_MSK 0x02 |
#define | LSR_PER_MSK 0x04 |
#define | LSR_FER_MSK 0x08 |
#define | LSR_BDT_MSK 0x10 |
#define | LSR_THE_MSK 0x20 |
#define | LSR_TXE_MSK 0x40 |
#define | LSR_EIF_MSK 0x80 |
#define | MSR_DCTS_MSK 0x01 |
#define | MSR_DDSR_MSK 0x02 |
#define | MSR_DRI_MSK 0x04 |
#define | MSR_DDCD_MSK 0x08 |
#define | MSR_CTS_MSK 0x10 |
#define | MSR_DSR_MSK 0x20 |
#define | MSR_RI_MSK 0x40 |
#define | MSR_DCD_MSK 0x80 |
typedef struct tagIRQDEFS | IRQDEFS |
int | AceInput (NUTDEVICE *dev) |
Wait for input. | |
int | AceOutput (NUTDEVICE *dev) |
Initiate output. | |
int | AceFlush (NUTDEVICE *dev) |
Wait for output buffer empty. | |
int | AceIOCtl (NUTDEVICE *dev, int req, void *conf) |
Perform ACE control functions. | |
int | AceInit (NUTDEVICE *dev) |
Initialize on chip ACE device. | |
int | AceRead (NUTFILE *fp, void *buffer, int size) |
Read from device. | |
int | AcePut (NUTDEVICE *dev, CONST void *buffer, int len, int pflg) |
Write to device. | |
int | AceWrite (NUTFILE *fp, CONST void *buffer, int len) |
int | AceWrite_P (NUTFILE *fp, PGM_P buffer, int len) |
NUTFILE * | AceOpen (NUTDEVICE *dev, CONST char *name, int mode, int acc) |
Open a device or file. | |
int | AceClose (NUTFILE *fp) |
Close a device or file. | |
long | AceSize (NUTFILE *fp) |
Request file size. |
#define ACE_RBR_OFS 0 |
\
Definition at line 82 of file tlc16c550.c.
#define ACE_THR_OFS 0 |
Definition at line 83 of file tlc16c550.c.
Referenced by AceOutput().
#define ACE_DLL_OFS 0 |
Definition at line 84 of file tlc16c550.c.
Referenced by AceIOCtl().
#define ACE_DLM_OFS 1 |
Definition at line 85 of file tlc16c550.c.
Referenced by AceIOCtl().
#define ACE_IER_OFS 1 |
Definition at line 86 of file tlc16c550.c.
#define ACE_FCR_OFS 2 |
Definition at line 87 of file tlc16c550.c.
Referenced by AceIOCtl().
#define ACE_IIR_OFS 2 |
Definition at line 88 of file tlc16c550.c.
#define ACE_LCR_OFS 3 |
Definition at line 89 of file tlc16c550.c.
Referenced by AceIOCtl().
#define ACE_MCR_OFS 4 |
Definition at line 90 of file tlc16c550.c.
#define ACE_LSR_OFS 5 |
Definition at line 91 of file tlc16c550.c.
#define ACE_MSR_OFS 6 |
Definition at line 92 of file tlc16c550.c.
#define ACE_SRC_OFS 7 |
Definition at line 93 of file tlc16c550.c.
#define IER_RDA_MSK 0x01 |
Definition at line 96 of file tlc16c550.c.
#define IER_THE_MSK 0x02 |
Definition at line 97 of file tlc16c550.c.
#define IER_LST_MSK 0x04 |
Definition at line 98 of file tlc16c550.c.
#define IER_MST_MSK 0x08 |
Definition at line 99 of file tlc16c550.c.
#define FCR_ENABLE 0x01 |
Definition at line 102 of file tlc16c550.c.
Referenced by AceIOCtl().
#define FCR_PURGE_I 0x02 |
Definition at line 103 of file tlc16c550.c.
Referenced by AceIOCtl().
#define FCR_PURGE_O 0x04 |
Definition at line 104 of file tlc16c550.c.
Referenced by AceIOCtl().
#define FCR_LEVEL_1 0x00 |
Definition at line 105 of file tlc16c550.c.
Referenced by AceIOCtl().
#define FCR_LEVEL_4 0x40 |
Definition at line 106 of file tlc16c550.c.
Referenced by AceIOCtl().
#define FCR_LEVEL_8 0x80 |
Definition at line 107 of file tlc16c550.c.
Referenced by AceIOCtl().
#define FCR_LEVEL_14 0xc0 |
Definition at line 108 of file tlc16c550.c.
Referenced by AceIOCtl().
#define IIR_MST_MSK 0x00 |
Definition at line 111 of file tlc16c550.c.
#define IIR_TXE_MSK 0x02 |
Definition at line 112 of file tlc16c550.c.
#define IIR_RDA_MSK 0x04 |
Definition at line 113 of file tlc16c550.c.
#define IIR_TDA_MSK 0x0c |
Definition at line 114 of file tlc16c550.c.
#define IIR_LST_MSK 0x06 |
Definition at line 115 of file tlc16c550.c.
#define IIR_NON_MSK 0x01 |
Definition at line 116 of file tlc16c550.c.
#define IIR_FIFO_MSK 0xc0 |
Definition at line 117 of file tlc16c550.c.
#define LCR_WS0_MSK 0x01 |
Definition at line 120 of file tlc16c550.c.
Referenced by AceIOCtl().
#define LCR_WS1_MSK 0x02 |
Definition at line 121 of file tlc16c550.c.
Referenced by AceIOCtl().
#define LCR_STB_MSK 0x04 |
Definition at line 122 of file tlc16c550.c.
Referenced by AceIOCtl().
#define LCR_PEN_MSK 0x08 |
Definition at line 123 of file tlc16c550.c.
Referenced by AceIOCtl().
#define LCR_PRE_MSK 0x10 |
Definition at line 124 of file tlc16c550.c.
Referenced by AceIOCtl().
#define LCR_PRS_MSK 0x20 |
Definition at line 125 of file tlc16c550.c.
Referenced by AceIOCtl().
#define LCR_BRK_MSK 0x40 |
Definition at line 126 of file tlc16c550.c.
#define LCR_ENB_MSK 0x80 |
Definition at line 127 of file tlc16c550.c.
Referenced by AceIOCtl().
#define MCR_DTR_MSK 0x01 |
Definition at line 130 of file tlc16c550.c.
#define MCR_RTS_MSK 0x02 |
Definition at line 131 of file tlc16c550.c.
#define MCR_GP1_MSK 0x04 |
Definition at line 132 of file tlc16c550.c.
#define MCR_GP2_MSK 0x08 |
Definition at line 133 of file tlc16c550.c.
#define MCR_LOP_MSK 0x10 |
Definition at line 134 of file tlc16c550.c.
#define LSR_RDR_MSK 0x01 |
Definition at line 137 of file tlc16c550.c.
#define LSR_OVR_MSK 0x02 |
Definition at line 138 of file tlc16c550.c.
#define LSR_PER_MSK 0x04 |
Definition at line 139 of file tlc16c550.c.
#define LSR_FER_MSK 0x08 |
Definition at line 140 of file tlc16c550.c.
#define LSR_BDT_MSK 0x10 |
Definition at line 141 of file tlc16c550.c.
#define LSR_THE_MSK 0x20 |
Definition at line 142 of file tlc16c550.c.
#define LSR_TXE_MSK 0x40 |
Definition at line 143 of file tlc16c550.c.
#define LSR_EIF_MSK 0x80 |
Definition at line 144 of file tlc16c550.c.
#define MSR_DCTS_MSK 0x01 |
Definition at line 147 of file tlc16c550.c.
#define MSR_DDSR_MSK 0x02 |
Definition at line 148 of file tlc16c550.c.
#define MSR_DRI_MSK 0x04 |
Definition at line 149 of file tlc16c550.c.
#define MSR_DDCD_MSK 0x08 |
Definition at line 150 of file tlc16c550.c.
#define MSR_CTS_MSK 0x10 |
Definition at line 151 of file tlc16c550.c.
#define MSR_DSR_MSK 0x20 |
Definition at line 152 of file tlc16c550.c.
#define MSR_RI_MSK 0x40 |
Definition at line 153 of file tlc16c550.c.
#define MSR_DCD_MSK 0x80 |
Definition at line 154 of file tlc16c550.c.
typedef struct tagIRQDEFS IRQDEFS |
int AceInput | ( | 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 ACE device. |
Definition at line 305 of file tlc16c550.c.
References _ACEDCB::dcb_rtimeout, _ACEDCB::dcb_rx_rdy, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, _IFSTREAM::if_rd_idx, _IFSTREAM::if_rx_idx, and NutEventWaitNext().
Referenced by AceInit(), and AceRead().
int AceOutput | ( | 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 ACE device. |
Definition at line 331 of file tlc16c550.c.
References ACE_MF_HALFDUPLEX, ACE_THR_OFS, _ACEDCB::dcb_modeflags, _ACEDCB::dcb_wfifo, _NUTDEVICE::dev_base, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, _IFSTREAM::if_tx_act, _IFSTREAM::if_tx_buf, _IFSTREAM::if_tx_idx, and _IFSTREAM::if_wr_idx.
Referenced by AceFlush(), and AceInit().
int AceFlush | ( | 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 ACE device. |
Definition at line 365 of file tlc16c550.c.
References AceOutput(), _ACEDCB::dcb_tx_rdy, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, _IFSTREAM::if_tx_idx, _IFSTREAM::if_wr_idx, and NutEventWaitNext().
Referenced by AceInit(), and AcePut().
int AceIOCtl | ( | NUTDEVICE * | dev, |
int | req, | ||
void * | conf | ||
) |
Perform ACE 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 484 of file tlc16c550.c.
References ACE_CLOCK, ACE_DLL_OFS, ACE_DLM_OFS, ACE_FCR_OFS, ACE_FIFO_SIZE, ACE_GETCOOKEDMODE, ACE_GETDATABITS, ACE_GETFIFO, ACE_GETFLOWCONTROL, ACE_GETLOCALECHO, ACE_GETPARITY, ACE_GETREADTIMEOUT, ACE_GETSPEED, ACE_GETSTATUS, ACE_GETSTOPBITS, ACE_GETWRITETIMEOUT, ACE_LCR_OFS, ACE_MF_COOKEDMODE, ACE_MF_HALFDUPLEX, ACE_MF_LOCALECHO, ACE_SETCOOKEDMODE, ACE_SETDATABITS, ACE_SETFIFO, ACE_SETFLOWCONTROL, ACE_SETLOCALECHO, ACE_SETPARITY, ACE_SETREADTIMEOUT, ACE_SETSPEED, ACE_SETSTATUS, ACE_SETSTOPBITS, ACE_SETWRITETIMEOUT, _ACEDCB::dcb_modeflags, _ACEDCB::dcb_rfifo, _ACEDCB::dcb_rtimeout, _ACEDCB::dcb_tx_rdy, _ACEDCB::dcb_wfifo, _ACEDCB::dcb_wtimeout, _NUTDEVICE::dev_base, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, FCR_ENABLE, FCR_LEVEL_1, FCR_LEVEL_14, FCR_LEVEL_4, FCR_LEVEL_8, FCR_PURGE_I, FCR_PURGE_O, _IFSTREAM::if_tx_act, _IFSTREAM::if_tx_idx, _IFSTREAM::if_wr_idx, LCR_ENB_MSK, LCR_PEN_MSK, LCR_PRE_MSK, LCR_PRS_MSK, LCR_STB_MSK, LCR_WS0_MSK, LCR_WS1_MSK, and NutEventPostAsync().
Referenced by AceInit().
int AceInit | ( | NUTDEVICE * | dev | ) |
Initialize on chip ACE device.
Prepares the device for subsequent reading or writing. Enables ACE transmitter and receiver interrupts.
dev | Identifies the device to initialize. |
Definition at line 743 of file tlc16c550.c.
References ACE_MF_NOBUFFER, ACE_SETDATABITS, ACE_SETFLOWCONTROL, ACE_SETPARITY, ACE_SETSPEED, ACE_SETSTOPBITS, AceFlush(), AceInput(), AceIOCtl(), AceOutput(), _ACEDCB::dcb_modeflags, _ACEDCB::dcb_rfifo, _ACEDCB::dcb_wfifo, _NUTDEVICE::dev_base, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, _NUTDEVICE::dev_irq, _ACEDCB::dev_next, _NUTDEVICE::dev_type, _IFSTREAM::if_flush, _IFSTREAM::if_input, _IFSTREAM::if_output, IFTYP_STREAM, memset(), tagIRQDEFS::nMask, NutRegisterIrqHandler(), tagIRQDEFS::pnIrqMskPort, tagIRQDEFS::pvIrq, sbi, and sig_OUTPUT_COMPARE3A.
int AceRead | ( | NUTFILE * | fp, |
void * | buffer, | ||
int | size | ||
) |
Read from device.
Definition at line 843 of file tlc16c550.c.
References ACE_MF_COOKEDMODE, AceInput(), _ACEDCB::dcb_modeflags, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, _IFSTREAM::if_last_eol, _IFSTREAM::if_rd_idx, _IFSTREAM::if_rx_buf, _IFSTREAM::if_rx_idx, and _NUTFILE::nf_dev.
int AcePut | ( | NUTDEVICE * | dev, |
CONST void * | buffer, | ||
int | len, | ||
int | pflg | ||
) |
Write to device.
Definition at line 904 of file tlc16c550.c.
References ACE_MF_COOKEDMODE, ACE_MF_LINEBUFFER, ACE_MF_NOBUFFER, AceFlush(), CONST, _ACEDCB::dcb_modeflags, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, _IFSTREAM::if_tx_buf, _IFSTREAM::if_tx_idx, _IFSTREAM::if_wr_idx, and PRG_RDB.
Referenced by AceWrite(), and AceWrite_P().
int AceWrite | ( | NUTFILE * | fp, |
CONST void * | buffer, | ||
int | len | ||
) |
Definition at line 967 of file tlc16c550.c.
References AcePut(), and _NUTFILE::nf_dev.
int AceWrite_P | ( | NUTFILE * | fp, |
PGM_P | buffer, | ||
int | len | ||
) |
Definition at line 972 of file tlc16c550.c.
References AcePut(), CONST, and _NUTFILE::nf_dev.
Open a device or file.
Definition at line 981 of file tlc16c550.c.
References _O_BINARY, ACE_MF_COOKEDMODE, _ACEDCB::dcb_modeflags, _NUTDEVICE::dev_dcb, _NUTFILE::nf_dev, _NUTFILE::nf_fcb, _NUTFILE::nf_next, NUTFILE_EOF, and NutHeapAlloc.
int AceClose | ( | NUTFILE * | fp | ) |
long AceSize | ( | NUTFILE * | fp | ) |
Request file size.
Definition at line 1015 of file tlc16c550.c.
References _NUTDEVICE::dev_icb, _IFSTREAM::if_rd_idx, _IFSTREAM::if_rx_idx, and _NUTFILE::nf_dev.