Koduino
|
Serial / USART library (use on global objects Serial<x>
where <x>
can be 1, 2, 3)
More...
#include <USARTClass.h>
Serial / USART library (use on global objects Serial<x>
where <x>
can be 1, 2, 3)
Public Member Functions | |
void | begin (uint32_t baud, uint8_t mode) |
Opens a serial connection and configures the RX and TX pins. More... | |
void | end () |
Close the serial port. | |
void | setPins (uint8_t tx, uint8_t rx) |
Change the default RX and TX pins. More... | |
virtual int | available (void) |
Return the number of bytes in the receive buffer. More... | |
virtual int | peek (void) |
Reads a single byte from the receive buffer. More... | |
virtual int | read (void) |
Reads a single byte from the receive buffer. More... | |
virtual void | flush (void) |
Waits till the previous write operation is finished. | |
virtual bool | writeComplete () |
Check if the previous write operation is finished. More... | |
virtual size_t | write (uint8_t c) |
Write a single character. More... | |
Public Member Functions inherited from Stream | |
void | setTimeout (uint32_t timeout) |
Sets maximum milliseconds to wait for stream data. More... | |
bool | find (char *target) |
Reads data from the stream until the target string is found. More... | |
bool | find (char *target, size_t length) |
Reads data from the stream until the target string of given length is found. More... | |
bool | findUntil (char *target, char *terminator) |
Same as find() but search ends if the terminator string is found. More... | |
int | parseInt () |
Returns the first valid (long) integer value from the current position. More... | |
float | parseFloat () |
Float version of parseInt() More... | |
size_t | readBytes (char *buffer, size_t length) |
Read chars from stream into buffer. More... | |
size_t | readBytesUntil (char terminator, char *buffer, size_t length) |
Same as readBytes() with terminator character. More... | |
Inherits Stream.
|
virtual |
void USARTClass::begin | ( | uint32_t | baud, |
uint8_t | mode | ||
) |
Opens a serial connection and configures the RX and TX pins.
Use setPins() to change the default RX and TX pins
baud | Baud rate as an integer |
mode | One of SERIAL_<x> where <x> can be 8N1 , 8N2 , 7E1 , 8E1 , 7E2 , 8E2 , 7O1 , 8O2 (default if omitted is 8N1 ) |
|
virtual |
Reads a single byte from the receive buffer.
Does not increment the buffer pointer
Implements Stream.
|
virtual |
Reads a single byte from the receive buffer.
Increments the buffer pointer
Implements Stream.
void USARTClass::setPins | ( | uint8_t | tx, |
uint8_t | rx | ||
) |
Change the default RX and TX pins.
Should be called before begin(). Defaults are
PA9
, PA10
for Serial1
PB3
, PB4
for Serial2
PB8
, PB9
for Serial3
tx | New TX pin |
rx | New RX pin |
|
virtual |
Write a single character.
Does not block. Uses a ring buffer to queue outgoing transfers and interrupt handlers to transmit the queue.
Note: No output is allowed for the first 1 second on the bootloading port, Serial1
in order to not interfere with auto-reset and bootloading
c | Character to write |
|
virtual |
Check if the previous write operation is finished.
true
if complete