simpletext library  v0.99
Compact variations of put/get write/read and print/scan for smaller program sizes
Data Structures | Macros | Typedefs | Functions
serial.h File Reference

This library supports creating and managing one or more half 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 serial 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.

Data Structures

struct  serial_info
 Defines serial interface structure of 9 contiguous int variables. More...

Macros

#define SERIAL_MIN_PIN   0
 Min serial pin value.
#define SERIAL_MAX_PIN   31
 Max serial pin value.

Typedefs

typedef struct serial_info Serial_t
 Defines serial interface structure of 9 contiguous int variables.
typedef text_t serial
 Makes declarations like serial lcd to stand in for text_t lcd. Spelling is choice of Parallax education, not the author.

Functions

serialserial_open (int rxpin, int txpin, int mode, int baudrate)
 Open a simple (half duplex) serial connection.
void serial_close (serial *device)
 Close serial connection.
int serial_rxChar (serial *device)
 Receive a byte. Waits until next byte is received.
int serial_txChar (serial *device, int txbyte)
 Send a byte.

Detailed Description

This library supports creating and managing one or more half 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 serial 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.

Author
Steve Denson, with naming conventions supplied by Parallax.
Core Usage
No extra cores are used by the half duplex serial connection. The code gets copied to unused memory within the cog that calls serial_open.
Memory Models
Use with CMM or LMM.
Version
0.85
Help Improve this Library
Please submit bug reports, suggestions, and improvements to this code to edito.nosp@m.r@pa.nosp@m.ralla.nosp@m.x.co.nosp@m.m.

Function Documentation

void serial_close ( serial device)

Close serial connection.

Parameters
*deviceIdentifier returned by serial_open.
serial* serial_open ( int  rxpin,
int  txpin,
int  mode,
int  baudrate 
)

Open a simple (half duplex) serial connection.

Parameters
rxpinSerial input pin, receives serial data.
txpinSerial output pin, transmits serial data.
modeUnused mode field (for FdSerial compatibility)
baudrateBit value transmit rate, 9600, 115200, etc...
Returns
serial pointer for use as an identifier for serial and simpletext library functions that have serial or text_t parameter types.
int serial_rxChar ( serial device)

Receive a byte. Waits until next byte is received.

Parameters
*deviceIdentifier returned by serial_open.
Returns
receive byte 0 to 0xff or -1 if none available
int serial_txChar ( serial device,
int  txbyte 
)

Send a byte.

Parameters
*deviceis a previously open/started serial device.
txbyteThe byte to send.
Returns
Byte that was transmitted.