PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Classes | 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"
+ Include dependency graph for serial.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

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.
More...
 
void serial_close (serial *device)
 Close serial connection.
More...
 
int serial_rxChar (serial *device)
 Receive a byte. Waits until next byte is received. More...
 
int serial_txChar (serial *device, int txbyte)
 Send a byte. More...
 

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.

Definition in file serial.h.


Class Documentation

◆ serial_info

struct serial_info

Defines serial interface structure of 9 contiguous int variables.

Definition at line 55 of file serial.h.

+ Collaboration diagram for serial_info:
Class Members
int baud

Baud rate.

int mode

Mode value (not used).

int rx_pin

Character receive pin.

int ticks

Clock ticks for a 1/baud rate period.

int tx_pin

Character transmit pin.

Function Documentation

◆ serial_close()

void serial_close ( serial device)

Close serial connection.

Parameters
*deviceIdentifier returned by serial_open.
Examples
SimpleText_Demo.c.

Definition at line 11 of file serial_close.c.

◆ 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.
Examples
SimpleText_Demo.c.

Definition at line 14 of file serial_open.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serial_rxChar()

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

Definition at line 40 of file serial_rxtx.c.

+ Here is the caller graph for this function:

◆ serial_txChar()

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.

Definition at line 81 of file serial_rxtx.c.

+ Here is the caller graph for this function: