📄 pcl4c.ref
字号:
7 1024 bytes Size1024 or Size1K
8 2048 bytes Size2048 or Size2K
9 4096 bytes Size4096 or Size4K
10 8192 bytes Size8192 or Size8K
11 16384 bytes Size16384 or Size16K
12 32768 bytes Size32768 or Size32K
Returns -4 : No such port. Expect 0 to MaxPort.
-10 : Bad buffer size code. Expecting 0 to 11.
Example char RxBuf[1024]; /* declare as global */
...
/* setup 1K receive buffer */
SioRxBuf(COM1, RxBuf, Size1024);
/* ready to call SioReset */
See Also SioReset.
PCL4C Reference Manual Page 32
SioRxFlush
Function To flush the receive buffer associated with the
specified port.
Syntax int SioRxFlush(Port)
int Port; /* Port selected (COM1 thru COM4) */
Remarks The SioRxFlush function will delete any characters in
the receive buffer for the specified port. After
execution, the receive buffer will be empty. Call
SioRxBuf after resetting a port in order to delete any
spurious characters.
Returns -2 : Port not enabled. Call SioReset first.
-4 : No such port. Expect 0 to MaxPort.
Example char buffer[1024];
...
/* setup receive buffer & reset port */
SioRxBuf(COM1,buffer,Size1024);
SioReset(COM1,Baud115200);
/* flush any spurious character */
SioRxFlush(COM1);
/* ready for serial processing ! */
...
See Also SioRxQue.
PCL4C Reference Manual Page 33
SioRxQue
Function Returns the number of characters in the receive queue.
Syntax int SioRxQue(Port)
int Port; /* Port selected (COM1 thru COM4) */
Remarks The SioRxQue function will return the number of
characters in the receive queue at the time of the
call. It can be used to implement XON/XOFF flow
control.
Returns -2 : Port not enabled. Call SioReset first.
-4 : No such port. Expect 0 to MaxPort.
Example #define XON 0x11
#define XOFF 0x13
int count;
char last = XON;
char Buffer[128];
...
SioRxBuf(COM1,Buffer,Size128);
/* implement XON / XOFF */
count = SioRxQue(COM1);
if((last==XON)&&(count>120))
{SioPutc(COM1,XOFF);
last = XOFF;
}
if((last==XOFF)&&(count<8))
{SioPutc(COM1,XON);
last = XON;
}
See Also SioRxFlush.
PCL4C Reference Manual Page 34
SioTimer
Function Returns the number of system clock tics since midnight.
Syntax long SioTimer()
Remarks The SioTimer function will return the number of system
clock tics since midnight, at 18.2065 tics per second.
This function is usefull for timing various functions.
Also see SioDelay.
Returns timer tics.
Example long time;
...
time = SioTimer();
...
printf("Elasped time = %ld tics\n",SioTimer() - time);
See Also SioDelay.
PCL4C Reference Manual Page 35
SioTxBuf
Function Sets up transmitter buffer.
Syntax int SioTxBuf(Port,Buffer,SizeCode)
int Port; /* Port selected (COM1 thru COM4) */
char *Buffer /* Transmit buffer */
int SizeCode; /* Buffer size code */
Remarks The SioTxBuf function passes the address and size of
the transmit buffer to PCL4C, provided that you will
link with a PCL4C library with transmitter interrupts
enabled. PCL4C requires a transmit buffer for each
port in simultaneous operation if you are using the
version of the library with transmitter interrupts
enabled (PCL4C_?2.LIB). SioTxBuf() must be called
before SioReset. Buffer size codes are listed in
"PCL4C.H".
Size Code Buffer Size PCL4C.H Name
0 8 bytes Size8
1 16 bytes Size16
2 32 bytes Size32
3 64 bytes Size64
4 128 bytes Size128
5 256 bytes Size256
6 512 bytes Size512
7 1024 bytes Size1024 or Size1K
8 2048 bytes Size2048 or Size2K
9 4096 bytes Size4096 or Size4K
10 8192 bytes Size8192 or Size8K
11 16384 bytes Size16384 or Size16K
12 32768 bytes Size32768 or Size32K
This function is not used unless the transmitter
interrupts are enabled (PCL4C_S2.LIB, PCL4C_M2.LIB,
PCL4C_C2.LIB, and PCL4C_L2.LIB). Refer to the PCL4C
Users Manual for information on transmitter (TX)
interrupts.
Returns -4 : No such port. Expect 0 to MaxPort.
-10 : Bad buffer size code. Expecting 0 to 11.
Example char TxBuf[1024]; /* declare as global */
...
/* setup 1K transmit buffer */
SioTxBuf(COM1, TxBuf, Size1024);
/* ready to call SioReset */
See Also SioRxBuf and SioReset.
PCL4C Reference Manual Page 36
SioTxFlush
Function To flush the transmit buffer associated with the
specified port.
Syntax int SioTxFlush(Port)
int Port; /* Port selected (COM1 thru COM4) */
Remarks The SioTxFlush function will delete any characters in
the transmit buffer for the specified port, provided
that you will link with a PCL4C library with
transmitter interrupts enabled. After execution, the
transmit buffer will be empty.
Once this function is called, any character in the
transmit buffer (put there by SioPutc) will be lost
and therefore not transmitted.
This function is not used unless the transmitter
interrupts are enabled (PCL4C_S2.LIB, PCL4C_M2.LIB,
PCL4C_C2.LIB, and PCL4C_L2.LIB). Refer to the
PCL4C Users Manual for information on transmitter
(TX) interrupts.
Returns -2 : Port not enabled. Call SioReset first.
-4 : No such port. Expect 0 to MaxPort.
Example char buffer[1024];
...
/* setup transmit buffer & reset port */
SioTxBuf(COM1,buffer,Size1024);
SioReset(COM1,Baud115200);
/* flush any spurious character */
SioTxFlush(COM1);
/* ready for serial processing ! */
...
See Also SioTxQue.
PCL4C Reference Manual Page 37
SioTxQue
Function Returns the number of characters in the transmit queue.
Syntax int SioTxQue(Port)
int Port; /* Port selected (COM1 thru COM4) */
Remarks The SioTxQue function will return the number of
characters in the transmit queue at the time of the
call, provided that you will link with a PCL4C library
with transmitter interrupts enabled.
This function is not used unless the transmitter
interrupts are enabled (PCL4C_S2.LIB, PCL4C_M2.LIB,
PCL4C_C2.LIB, and PCL4C_L2.LIB). Refer to the PCL4C
Users Manual for information on transmitter (TX)
interrupts.
Returns -2 : Port not enabled. Call SioReset first.
-4 : No such port. Expect 0 to MaxPort.
Example int Count;
char Buffer[128];
...
SioTxBuf(COM1,Buffer,Size128);
/* display # bytes in transmitter queue */
Count = SioTxQue(COM1);
printf("%d bytes in transmitter queue\n",Count);
...
See Also SioTxFlush.
PCL4C Reference Manual Page 38
SioUART
Function Sets the UART base address.
Syntax int SioUART(Port,Address)
int Port; /* COM1 to COM4 */
int Address; /* UART address */
Remarks The SioUART function sets the UART base address for
the specified port. SioUART must be called before
SioReset in order to have effect. Be extremely sure
that you know what you are doing! Note that PCL4C uses
the standard PC/XT/AT port addresses, interrupt
request lines, and interrupt service vectors.
Therefore, this function is only needed for
non-standard ports.
Returns >0 : The previous base address for this port.
-4 : No such port. Expect 0 to MaxPort.
-15 : Port already enabled. SioReset has already been
called.
Example /* Record the fact that you don't have COM4 */
SioUART(COM4, 0);
See Also SioPorts, SioIRQ, and SioReset.
PCL4C Reference Manual Page 39
SioUnGetc
Function "Un-gets" the last character read with SioGetc().
Syntax int SioUnGetc(Port,c)
int Port; /* Port selected (COM1 thru COM4) */
char c; /* character to unget */
Remarks The SioUnGetc function returns ("pushes") the
character back into the serial input buffer. The
character pushed will be the next character returned
by SioGetc. Only one character can be pushed back.
This function works just like the "ungetc" function in
the C language.
Returns -
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -