libpropeller
Making PropellerGCC Easier
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
FullDuplexSerial Class Reference

This driver, once started, implements a serial port in one cog. More...

#include <full_duplex_serial.h>

Public Member Functions

void Start (int Rxpin, int Txpin, int Mode, int Baudrate)
 Start serial driver in new cog. More...
 
void Stop (void)
 Stop the serial driver (if running) and free a cog. More...
 
void GetFlush (void)
 Clear the receive buffer of all bytes. More...
 
int Get (const int timeout=-1)
 Receive a byte of data. More...
 
void Put (const char Txbyte)
 Transmit a byte of data. More...
 
void Put (const char *string)
 Transmit a C string. More...
 
int PutDec (int Value)
 Transmit the decimal representation of a number. More...
 

Detailed Description

This driver, once started, implements a serial port in one cog.

Hardware: To read 3.3v signals just connect the signal directly to any I/O pin. To read a 5v signal connect it to any I/O pin through a 3.3kOhm (or higher) resistor.

Software: The maximum standard baud rate on an 80MHz clock is 230400 baud.

This object is derived from FullDuplexSerial.spin v1.2.1 by Chip Gracey, Jeff Martin, and Daniel Harris. Thanks!

Copyright (c) 2013 Kenneth Bedolla (libpr.nosp@m.opel.nosp@m.ler@k.nosp@m.enne.nosp@m.thbed.nosp@m.olla.nosp@m..com)

Member Function Documentation

int FullDuplexSerial::Get ( const int  timeout = -1)
inline

Receive a byte of data.

If there are bytes in the buffer this function returns immediately. Otherwise, it waits as specified by the timeout parameter.

Parameters
timeoutThe maximum duration to wait for a byte in milliseconds. A timeout of -1 indicates no wait.
Returns
-1 if a timeout, otherwise the byte received.
void FullDuplexSerial::GetFlush ( void  )
inline

Clear the receive buffer of all bytes.

After calling this function the receive buffer has 0 bytes in it, and a call to Get() without a timeout will wait until a byte is received.

void FullDuplexSerial::Put ( const char  Txbyte)
inline

Transmit a byte of data.

Parameters
Txbytethe byte to send.

Here is the call graph for this function:

void FullDuplexSerial::Put ( const char *  string)
inline

Transmit a C string.

Note: the null at the end is not transmitted.

Parameters
stringThe null terminated string to transmit.

Here is the call graph for this function:

int FullDuplexSerial::PutDec ( int  Value)
inline

Transmit the decimal representation of a number.

Warning
This function is provided only for short term convenience. SRLM plans on taking it away sometime and to replace it with a proper formatting object for the conversion.
Parameters
Valuethe number whose value to print as a decimal
Returns

Here is the call graph for this function:

void FullDuplexSerial::Start ( int  Rxpin,
int  Txpin,
int  Mode,
int  Baudrate 
)
inline

Start serial driver in new cog.

Parameters
RxpinInput to the Propeller
TxpinOutput from the Propeller
ModeBitwise mode configuration variable:
  • 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
BaudrateAny rate will work, up to the maximum baud

Here is the call graph for this function:

void FullDuplexSerial::Stop ( void  )
inline

Stop the serial driver (if running) and free a cog.


The documentation for this class was generated from the following file: