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...
Go to the source code of this file.
Data Structures |
struct | serial_info |
| Defines serial interface structure of 9 contiguous int variables. More...
|
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.
|
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.
- Copyright
- Copyright (c) 2008-2013, Steve Denson, all Rights MIT Licensed.
- 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
-
*device | Identifier returned by serial_open. |
serial* serial_open |
( |
int |
rxpin, |
|
|
int |
txpin, |
|
|
int |
mode, |
|
|
int |
baudrate |
|
) |
| |
Open a simple (half duplex) serial connection.
- Parameters
-
rxpin | Serial input pin, receives serial data. |
txpin | Serial output pin, transmits serial data. |
mode | Unused mode field (for FdSerial compatibility) |
baudrate | Bit 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
-
*device | Identifier 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
-
*device | is a previously open/started serial device. |
txbyte | The byte to send. |
- Returns
- Byte that was transmitted.