PropWare
2.1.2
C++ objects and CMake build system for Parallax Propeller
|
Click here for docs on the
develop
branch.
This library supports creating and managing one or more full duplex serial connections with peripheral devices. The pointer returned when a connection is opened can be used to identify the connection for other calls with fdserial parameter types in this library. The identifier can also be used to identify the serial connection for higher level formatted text transmit/receive functions with text_t parameter types in the simpletext library. More...
#include "simpletext.h"
Go to the source code of this file.
Classes | |
struct | fdserial_struct |
Defines fdserial interface structure of 9 contiguous longs + buffers. More... | |
Macros | |
#define | FDSERIAL_BUFF_MASK 0x3f |
#define | FDSERIAL_MODE_NONE 0 |
#define | FDSERIAL_MODE_INVERT_RX 1 |
#define | FDSERIAL_MODE_INVERT_TX 2 |
#define | FDSERIAL_MODE_OPENDRAIN_TX 4 |
#define | FDSERIAL_MODE_IGNORE_TX_ECHO 8 |
Typedefs | |
typedef text_t | fdserial |
Defines text_t data type as fdserial to allow declarations like fdserial *MyDevice. After storing the value returned by fdserial_start in MyDevice, it can be passed as an identifying parameter to fdserial and simpletext library functions that have fdserial or text_t parameter types. | |
typedef struct fdserial_struct | fdserial_st |
Defines fdserial interface structure of 9 contiguous longs + buffers. | |
Functions | |
fdserial * | fdserial_open (int rxpin, int txpin, int mode, int baudrate) |
Open a full duplex serial connection. More... | |
void | fdserial_close (fdserial *term) |
Stop stops the cog running the native assembly driver. More... | |
int | fdserial_rxCheck (fdserial *term) |
Gets a byte from the receive buffer if available, but does not wait if there's nothing in the buffer. More... | |
void | fdserial_rxFlush (fdserial *term) |
Empties the receive buffer. More... | |
int | fdserial_rxReady (fdserial *term) |
Check if a byte is ready in the receive buffer. More... | |
int | fdserial_rxTime (fdserial *term, int ms) |
Gets a byte from the receive buffer if available, or wait for up to timeout ms to receive a byte. More... | |
int | fdserial_rxChar (fdserial *term) |
Get a byte from the receive buffer, or if it's emtpy, wait until a byte is received. More... | |
int | fdserial_rxCount (fdserial *term) |
Get number of bytes available in the receive buffer without receiving any. NOTE: This function is not designed for detecting buffer overflow, just for reporting how many bytes have accumulated in the input buffer. More... | |
int | fdserial_rxPeek (fdserial *term) |
Get a byte from the receive buffer without changing the pointers. The function does not block. More... | |
int | fdserial_txChar (fdserial *term, int txbyte) |
Send a byte by adding it to the transmit buffer. More... | |
int | fdserial_txEmpty (fdserial *term) |
Check if the transmit buffer is empty. More... | |
void | fdserial_txFlush (fdserial *term) |
Remove any bytes that might be waiting in the transmit buffer. | |
This library supports creating and managing one or more full duplex serial connections with peripheral devices. The pointer returned when a connection is opened can be used to identify the connection for other calls with fdserial parameter types in this library. The identifier can also be used to identify the serial connection for higher level formatted text transmit/receive functions with text_t parameter types in the simpletext library.
Definition in file fdserial.h.
struct fdserial_struct |
Defines fdserial interface structure of 9 contiguous longs + buffers.
Definition at line 85 of file fdserial.h.
#define FDSERIAL_BUFF_MASK 0x3f |
Defines buffer length. hard coded into asm driver ... s/b bigger
Definition at line 54 of file fdserial.h.
#define FDSERIAL_MODE_IGNORE_TX_ECHO 8 |
Mode bit 3 can be set to 1 to ignore copy of txpin's signal if received by rxpin.
Definition at line 80 of file fdserial.h.
#define FDSERIAL_MODE_INVERT_RX 1 |
Mode bit 0 can be set to 1 for inverted signal to rxpin.
Definition at line 64 of file fdserial.h.
#define FDSERIAL_MODE_INVERT_TX 2 |
Mode bit 1 can be set to 1 for inverted signal from txpin.
Definition at line 69 of file fdserial.h.
#define FDSERIAL_MODE_NONE 0 |
All mode bits set to 0 for non-inverted asynchronous serial communication.
Definition at line 59 of file fdserial.h.
#define FDSERIAL_MODE_OPENDRAIN_TX 4 |
Mode bit 2 can be set to 1 to open collector/drain txpin communication with a pull-up resistor on the line.
Definition at line 75 of file fdserial.h.
void fdserial_close | ( | fdserial * | term | ) |
Stop stops the cog running the native assembly driver.
*term | Device ID returned by fdserial_open. |
Definition at line 68 of file fdserial.c.
fdserial* fdserial_open | ( | int | rxpin, |
int | txpin, | ||
int | mode, | ||
int | baudrate | ||
) |
Open a full duplex serial connection.
rxpin | Serial receive input pin number. |
txpin | Serial transmit output pin number. |
mode | Set/clear bits to define mode: mode bit 0 = invert rx mode bit 1 = invert tx mode bit 2 = open-drain/source tx mode bit 3 = ignore tx echo on rx |
baudrate | Rate binary values are transmitted, like 115200, 57600,..., 9600 etc. |
Definition at line 20 of file fdserial.c.
int fdserial_rxChar | ( | fdserial * | term | ) |
Get a byte from the receive buffer, or if it's emtpy, wait until a byte is received.
*term | Device ID returned by fdserial_open. |
Oldest byte (0 to 255) in receive buffer
Definition at line 117 of file fdserial.c.
int fdserial_rxCheck | ( | fdserial * | term | ) |
Gets a byte from the receive buffer if available, but does not wait if there's nothing in the buffer.
*term | Device ID returned by fdserial_open. |
Definition at line 99 of file fdserial.c.
int fdserial_rxCount | ( | fdserial * | term | ) |
Get number of bytes available in the receive buffer without receiving any. NOTE: This function is not designed for detecting buffer overflow, just for reporting how many bytes have accumulated in the input buffer.
*term | Device ID returned by fdserial_open. |
Definition at line 79 of file fdserial_utils.c.
void fdserial_rxFlush | ( | fdserial * | term | ) |
Empties the receive buffer.
*term | Device ID returned by fdserial_open. |
Definition at line 14 of file fdserial_utils.c.
int fdserial_rxPeek | ( | fdserial * | term | ) |
Get a byte from the receive buffer without changing the pointers. The function does not block.
Definition at line 61 of file fdserial_utils.c.
int fdserial_rxReady | ( | fdserial * | term | ) |
Check if a byte is ready in the receive buffer.
*term | Device ID returned by fdserial_open. |
Definition at line 25 of file fdserial_utils.c.
int fdserial_rxTime | ( | fdserial * | term, |
int | ms | ||
) |
Gets a byte from the receive buffer if available, or wait for up to timeout ms to receive a byte.
*term | Device ID returned by fdserial_open. |
ms | is number of milliseconds to wait for a char |
Definition at line 37 of file fdserial_utils.c.
int fdserial_txChar | ( | fdserial * | term, |
int | txbyte | ||
) |
Send a byte by adding it to the transmit buffer.
*term | Device ID returned by fdserial_open. |
txbyte | is byte to send. |
Definition at line 129 of file fdserial.c.
int fdserial_txEmpty | ( | fdserial * | term | ) |
Check if the transmit buffer is empty.
*term | Device ID returned by fdserial_open. |
Definition at line 88 of file fdserial.c.