#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>
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 |
\
#define ACE_THR_OFS 0 |
Referenced by AceOutput().
#define ACE_DLL_OFS 0 |
Referenced by AceIOCtl().
#define ACE_DLM_OFS 1 |
Referenced by AceIOCtl().
#define ACE_IER_OFS 1 |
#define ACE_FCR_OFS 2 |
Referenced by AceIOCtl().
#define ACE_IIR_OFS 2 |
#define ACE_LCR_OFS 3 |
Referenced by AceIOCtl().
#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 |
Referenced by AceIOCtl().
#define FCR_PURGE_I 0x02 |
Referenced by AceIOCtl().
#define FCR_PURGE_O 0x04 |
Referenced by AceIOCtl().
#define FCR_LEVEL_1 0x00 |
Referenced by AceIOCtl().
#define FCR_LEVEL_4 0x40 |
Referenced by AceIOCtl().
#define FCR_LEVEL_8 0x80 |
Referenced by AceIOCtl().
#define FCR_LEVEL_14 0xc0 |
Referenced by AceIOCtl().
#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 |
Referenced by AceIOCtl().
#define LCR_WS1_MSK 0x02 |
Referenced by AceIOCtl().
#define LCR_STB_MSK 0x04 |
Referenced by AceIOCtl().
#define LCR_PEN_MSK 0x08 |
Referenced by AceIOCtl().
#define LCR_PRE_MSK 0x10 |
Referenced by AceIOCtl().
#define LCR_PRS_MSK 0x20 |
Referenced by AceIOCtl().
#define LCR_BRK_MSK 0x40 |
#define LCR_ENB_MSK 0x80 |
Referenced by AceIOCtl().
#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.
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. |
References _ACEDCB::dcb_rtimeout, _ACEDCB::dcb_rx_rdy, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, _IFSTREAM::if_rd_idx, _IFSTREAM::if_rx_idx, NutEventWaitNext(), and rc.
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. |
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. |
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. |
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, NutEventPostAsync(), and rc.
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. |
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, NULL, NutRegisterIrqHandler(), tagIRQDEFS::pnIrqMskPort, tagIRQDEFS::pvIrq, sbi, and sig_OUTPUT_COMPARE3A.
int AceRead | ( | NUTFILE * | fp, |
void * | buffer, | ||
int | size | ||
) |
Read from device.
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, _NUTFILE::nf_dev, and rc.
int AcePut | ( | NUTDEVICE * | dev, |
const void * | buffer, | ||
int | len, | ||
int | pflg | ||
) |
Write to device.
References ACE_MF_COOKEDMODE, ACE_MF_LINEBUFFER, ACE_MF_NOBUFFER, AceFlush(), _ACEDCB::dcb_modeflags, _NUTDEVICE::dev_dcb, _NUTDEVICE::dev_icb, _IFSTREAM::if_tx_buf, _IFSTREAM::if_tx_idx, _IFSTREAM::if_wr_idx, PRG_RDB, and rc.
Referenced by AceWrite(), and AceWrite_P().
int AceWrite | ( | NUTFILE * | fp, |
const void * | buffer, | ||
int | len | ||
) |
int AceWrite_P | ( | NUTFILE * | fp, |
PGM_P | buffer, | ||
int | len | ||
) |
Open a device or file.
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 | ) |
Close a device or file.
References NutHeapFree.
long AceSize | ( | NUTFILE * | fp | ) |
Request file size.
References _NUTDEVICE::dev_icb, _IFSTREAM::if_rd_idx, _IFSTREAM::if_rx_idx, and _NUTFILE::nf_dev.