Send and receive data via the Make Controller's serial ports.
|
Defines |
#define | SERIAL_0 0 |
| Index to be used to specify serial port 0.
|
#define | SERIAL_1 1 |
| Index to be used to specify serial port 1.
|
Functions |
int | Serial_SetActive (int index, int state) |
| Set the active state of a serial port.
|
bool | Serial_GetActive (int index) |
| Read the active state of the Serial subsystem.
|
int | Serial_Write (int index, uchar *buffer, int count, int timeout) |
| Write a block of data to the Serial port.
|
int | Serial_Read (int index, uchar *buffer, int size, int timeout) |
| Read data from the Serial port.
|
int | Serial_GetReadable (int index) |
| Returns the number of bytes in the queue waiting to be read.
|
int | Serial_SetChar (int index, int character) |
| Sends a character (in the range of 0 to 255) to the write queue.
|
int | Serial_SetBaud (int index, int baud) |
| Sets the serial baud rate.
|
int | Serial_SetBits (int index, int bits) |
| Sets the number of bits per character.
|
int | Serial_SetParity (int index, int parity) |
| Sets the parity.
|
int | Serial_SetStopBits (int index, int stopBits) |
| Sets the stop bits per character.
|
int | Serial_SetHardwareHandshake (int index, int hardwareHandshake) |
| Sets whether hardware handshaking is being used.
|
int | Serial_GetChar (int index) |
| Returns a single character from the receive queue if available.
|
int | Serial_GetBaud (int index) |
| Returns the current baud rate.
|
int | Serial_GetBits (int index) |
| Returns the number of bits for each character.
|
int | Serial_GetParity (int index) |
| Returns the current parity.
|
int | Serial_GetStopBits (int index) |
| Returns the number of stop bits.
|
int | Serial_GetHardwareHandshake (int index) |
| Returns whether hardware handshaking is being employed or not.
|
void | Serial_Flush (int index) |
| Clear out the serial port.
|
void | Serial_ClearErrors (int index) |
| Reset the error flags in the serial system.
|
bool | Serial_GetErrors (int index, bool *overrun, bool *frame, bool *parity) |
| Read whether there are any errors.
|
void | Serial_StartBreak (int index) |
| Start the transimission of a break.
|
void | Serial_StopBreak (int index) |
| Stop the transimission of a break.
|
Send and receive data via the Make Controller's serial ports.
There are 2 full serial ports on the Make Controller, and this library provides support for both of them.
The subsystem is supplied with small input and output buffers (of 100 characters each) and at present the implementation is interrupt per character so it's not particularly fast.
void Serial_ClearErrors |
( |
int |
index |
) |
|
Reset the error flags in the serial system.
In the normal course of operation, the serial system may experience a variety of different error modes, including buffer overruns, framing and parity errors, and more. When in an error state, the serial system may behave differently than normal.
Serial_ClearErrors() resets the appropriate status bits to a state of normal operation. It will only reset the error states if there are currently any errors.
- Parameters:
-
| index | Which serial port - SERIAL_0 or SERIAL_1 |
- See also:
- Serial_GetErrors
Example
Definition at line 529 of file serial.c.
bool Serial_GetErrors |
( |
int |
index, |
|
|
bool * |
overrun, |
|
|
bool * |
frame, |
|
|
bool * |
parity | |
|
) |
| | |
Read whether there are any errors.
We can check for three kinds of errors in the serial system:
- buffer overrun
- framing error
- parity error
Each parameter will be set with a true or a false given the current error state. If you don't care to check one of the parameters, just pass in 0.
- Parameters:
-
| index | Which serial port - SERIAL_0 or SERIAL_1 |
| overrun | A bool that will be set with the overrun error state. |
| frame | A bool that will be set with the frame error state. |
| parity | A bool that will be set with the parity error state. |
- Returns:
- True if there were any errors, false if there were no errors.
- See also:
- Serial_ClearErrors( )
Example bool over, fr, par;
if( Serial_GetErrors( SERIAL_0, &over, &fr, &par ) )
{
if(over)
{
}
if(fr)
{
}
if(par)
{
}
}
else
{
}
Definition at line 583 of file serial.c.