Nut/OS  5.0.5
API Reference
tlc16c550.c File Reference
#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>
Include dependency graph for tlc16c550.c:

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)
NUTFILEAceOpen (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 Documentation

#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 Documentation

typedef struct tagIRQDEFS IRQDEFS

Function Documentation

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.

Parameters:
devIndicates the ACE device.
Returns:
0 on success, -1 on timeout.

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().

Here is the call graph for this function:

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.

Parameters:
devIndicates the ACE device.
Returns:
0 on success, -1 otherwise.

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.

Parameters:
devIndicates the ACE device.
Returns:
0 on success, -1 otherwise.

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().

Here is the call graph for this function:

int AceIOCtl ( NUTDEVICE dev,
int  req,
void *  conf 
)

Perform ACE control functions.

Parameters:
devIdentifies the device that receives the device-control function.
reqRequested control function. May be set to one of the following constants:
  • ACE_SETSPEED, conf points to an uint32_t value containing the baudrate.
  • ACE_GETSPEED, conf points to an uint32_t value receiving the current baudrate.
  • ACE_SETDATABITS, conf points to an uint32_t value containing the number of data bits, 5, 6, 7 or 8.
  • ACE_GETDATABITS, conf points to an uint32_t value receiving the number of data bits, 5, 6, 7 or 8.
  • ACE_SETPARITY, conf points to an uint32_t value containing the parity, 0 (no), 1 (odd) or 2 (even).
  • ACE_GETPARITY, conf points to an uint32_t value receiving the parity, 0 (no), 1 (odd) or 2 (even).
  • ACE_SETSTOPBITS, conf points to an uint32_t value containing the number of stop bits 1 or 2.
  • ACE_GETSTOPBITS, conf points to an uint32_t value receiving the number of stop bits 1 or 2.
  • ACE_SETSTATUS
  • ACE_GETSTATUS
  • ACE_SETREADTIMEOUT, conf points to an uint32_t value containing the read timeout.
  • ACE_GETREADTIMEOUT, conf points to an uint32_t value receiving the read timeout.
  • ACE_SETWRITETIMEOUT, conf points to an uint32_t value containing the write timeout.
  • ACE_GETWRITETIMEOUT, conf points to an uint32_t value receiving the write timeout.
  • ACE_SETLOCALECHO, conf points to an uint32_t value containing 0 (off) or 1 (on).
  • ACE_GETLOCALECHO, conf points to an uint32_t value receiving 0 (off) or 1 (on).
  • ACE_SETFLOWCONTROL, conf points to an uint32_t value containing combined ACE_FCR_ values.
  • ACE_GETFLOWCONTROL, conf points to an uint32_t value containing receiving ACE_FCR_ values.
  • ACE_SETCOOKEDMODE, conf points to an uint32_t value containing 0 (off) or 1 (on).
  • ACE_GETCOOKEDMODE, conf points to an uint32_t value receiving 0 (off) or 1 (on).
confPoints to a buffer that contains any data required for the given control function or receives data from that function.
Returns:
0 on success, -1 otherwise.
Warning:
Timeout values are given in milliseconds and are limited to the granularity of the system timer. To disable timeout, set the parameter to NUT_WAIT_INFINITE.

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().

Here is the call graph for this function:

int AceInit ( NUTDEVICE dev)

Initialize on chip ACE device.

Prepares the device for subsequent reading or writing. Enables ACE transmitter and receiver interrupts.

Parameters:
devIdentifies the device to initialize.
Returns:
0 on success, -1 otherwise.

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.

Here is the call graph for this function:

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.

Here is the call graph for this function:

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().

Here is the call graph for this function:

int AceWrite ( NUTFILE fp,
const void *  buffer,
int  len 
)

References AcePut(), and _NUTFILE::nf_dev.

Here is the call graph for this function:

int AceWrite_P ( NUTFILE fp,
PGM_P  buffer,
int  len 
)

References AcePut(), and _NUTFILE::nf_dev.

Here is the call graph for this function:

NUTFILE* AceOpen ( NUTDEVICE dev,
const char *  name,
int  mode,
int  acc 
)
int AceClose ( NUTFILE fp)

Close a device or file.

References NutHeapFree.

long AceSize ( NUTFILE fp)