fdserial library  v0.86
Functions for connecting with full duplex serial devices
Functions
fdserial.c File Reference
#include <stdlib.h>
#include "fdserial.h"

Functions

fdserialfdserial_open (int rxpin, int txpin, int mode, int baudrate)
 Open a full duplex serial connection.
void fdserial_close (fdserial *term)
 Stop stops the cog running the native assembly driver.
int fdserial_txEmpty (fdserial *term)
 Check if the transmit buffer is empty.
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.
int fdserial_rxChar (fdserial *term)
 Get a byte from the receive buffer, or if it's emtpy, wait until a byte is received.
int fdserial_txChar (fdserial *term, int txbyte)
 Send a byte by adding it to the transmit buffer.

Detailed Description

Full Duplex Serial adapter module.

Copyright (c) 2008-2013, Steve Denson See end of file for terms of use.

Function Documentation

void fdserial_close ( fdserial term)

Stop stops the cog running the native assembly driver.

Parameters
*termDevice ID returned by fdserial_open.
fdserial* fdserial_open ( int  rxpin,
int  txpin,
int  mode,
int  baudrate 
)

Open a full duplex serial connection.

Parameters
rxpinSerial receive input pin number.
txpinSerial transmit output pin number.
modeSet/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
baudrateRate binary values are transmitted, like 115200, 57600,..., 9600 etc.
Returns
fdserial pointer for use as an identifier for fdserial and simpletext library functions that have fdserial or text_t parameter types.
int fdserial_rxChar ( fdserial term)

Get a byte from the receive buffer, or if it's emtpy, wait until a byte is received.

Parameters
*termDevice ID returned by fdserial_open.

Oldest byte (0 to 255) in receive buffer

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.

Parameters
*termDevice ID returned by fdserial_open.
Returns
Oldest byte (0 to 255) in receive buffer, or -1 if buffer is empty.
int fdserial_txChar ( fdserial term,
int  txbyte 
)

Send a byte by adding it to the transmit buffer.

Parameters
*termDevice ID returned by fdserial_open.
txbyteis byte to send.
Returns
The byte that was sent, or returns the byte that was received if mode bit 3 was set in the fdserial_open call.
int fdserial_txEmpty ( fdserial term)

Check if the transmit buffer is empty.

Parameters
*termDevice ID returned by fdserial_open.
Returns
non-zero if transmit buffer is empty.