|
| ~Serial () |
|
bool | Start (const int rxpin, const int txpin, const int rate, const int ctspin=-1) |
| Start Serial driver in a new cog. More...
|
|
void | Stop (void) |
| Stops the Serial PASM engine, if it is running. More...
|
|
bool | SetBaud (const int rate) |
| Does a live update of the baud rate in the Serial engine. More...
|
|
bool | SetBaudClock (const unsigned int rate, const unsigned int sysclock) |
| Does a live update of the baud rate in the Serial engine. More...
|
|
void | Put (const char character) |
| Transmit a single character. More...
|
|
int | Put (const char *buffer_ptr, const int count) |
| Transmit a set of bytes. More...
|
|
int | Put (const char *buffer_ptr) |
| Transmit a C string. More...
|
|
int | PutFormatted (const char *format,...) |
| Transmit a string (printf function-alike). More...
|
|
int | Get (const int timeout=-1) |
| Receive a byte (wait) or timeout. More...
|
|
int | Get (char *const buffer, const int length, const int timeout=-1) |
| Get a buffer of characters. More...
|
|
int | Get (char *const buffer, const char terminator= '\n') |
| Get a terminated string of characters. More...
|
|
void | GetFlush (void) |
| Flushes receive buffer. More...
|
|
int | GetCount (void) const |
| Get the number of bytes in the receive buffer. More...
|
|
A high speed and high accuracy serial driver.
Based on Fast Full-Duplex Serial 1 (FFDS1) version 0.9 by Jonathan Dummer (lonesock). C++ Port done by SRLM.
Serial provides a fast and stable serial interface using a single cog.
Max baudrate = clkfreq / (86 * 2)
Clock | MaxBaud | Standard ----—+------—+------— 96 MHz | 558_139 | 500_000 - 6MHz XTAL at 16x PLL 80 MHz | 465_116 | 460_800 - 5MHz XTAL at 16x PLL (most common) 12 MHz | 69_767 | 57_600 - approx RCFAST 20 kHz | 116 | hah hah - approx RCSLOW
Bit period is calculated to the nearest 2 clocks. So, the bit period should be within 1 clock, or 12.5 ns at 80 MHz.
- Author
- SRLM (srlm@.nosp@m.srlm.nosp@m.produ.nosp@m.ctio.nosp@m.ns.co.nosp@m.m)
int Serial::PutFormatted |
( |
const char * |
format, |
|
|
|
... |
|
) |
| |
|
inline |
Transmit a string (printf function-alike).
This function is based on the requirements found on this page: http://www.cplusplus.com/reference/cstdio/printf/
- Warning
- This function does not implement the full printf functionality.
Formatters must follow the following prototype: %[flags][width]specifier The following flags are supported
- 0 (only with x,X,b,B). Sets padding to the 0 character instead of space. This function supports the following specifiers:
- d or i : signed decimal integer. The width specifier will pad with spaces if necessary.
- x or X : hexadecimal integer. All caps (with either). The width specifier will pad with spaces (or 0s if the 0 flag is set) if necessary
- c : output a single character.
- s : output a string of characters, 0 terminated.
- % : output a % symbol.
Each specifier must have a matching typed optional argument.
Behavior is undefined if % is used without a specifier.
- Parameters
-
format | the string to send, optionally with specifiers. |
... | additional arguments. Depending on the format string, the function may expect a sequence of additional arguments. |
- Returns
- on success, the total number of characters written. On error, a negative number is returned.
const int Serial::kBufferLength = 512 |
|
static |
Size of the RX buffer in bytes.
No restrictions on size (well, Hub RAM limits [8^) Does not need to be a power of 2. There is no TX buffer, Serial sends directly from Hub RAM.
For some reason, 117 seems to be the minimum buffer size before the tests start to lock up. Originally, it was 512. Seems safe to change, as long as it's >= 117.