Nut/OS  4.10.3
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:

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

\

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

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

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.

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.

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

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

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.

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

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.

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.

Here is the call graph for this function:

int AceRead ( NUTFILE fp,
void *  buffer,
int  size 
)
int AcePut ( NUTDEVICE dev,
CONST void *  buffer,
int  len,
int  pflg 
)
int AceWrite ( NUTFILE fp,
CONST void *  buffer,
int  len 
)

Definition at line 967 of file tlc16c550.c.

References AcePut(), and _NUTFILE::nf_dev.

Here is the call graph for this function:

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.

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.

Definition at line 1005 of file tlc16c550.c.

References NutHeapFree.

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.