|
Fang-Robotics-MCB
Fang Robotics Team Codebase
|
#include <uart.hpp>
Public Types | |
| enum | UartPort { Uart1 , Uart3 , Uart6 } |
| using | Parity = modm::platform::UartBase::Parity |
Public Member Functions | |
| Uart ()=default | |
| mockable | ~Uart ()=default |
| template<UartPort port, modm::baudrate_t baudrate, Parity parity = Parity::Disabled> | |
| void | init () |
| mockable bool | read (UartPort port, uint8_t *data) |
| mockable std::size_t | read (UartPort port, uint8_t *data, std::size_t length) |
| mockable std::size_t | discardReceiveBuffer (UartPort port) |
| mockable bool | write (UartPort port, uint8_t data) |
| mockable std::size_t | write (UartPort port, const uint8_t *data, std::size_t length) |
| mockable bool | isWriteFinished (UartPort port) const |
| mockable void | flushWriteBuffer (UartPort port) |
Class that wraps modm's Uart implementation.
Currently only wraps the uart ports that we are generating modm code for. If additional UartPort's are added, they must be added to this wrapper class here.
| using tap::communication::serial::Uart::Parity = modm::platform::UartBase::Parity |
|
default |
|
default |
| std::size_t tap::communication::serial::Uart::discardReceiveBuffer | ( | UartPort | port | ) |
Empty the receive FIFO queue and hardware buffer.
| [in] | port | the port's buffer to discard. |
| void tap::communication::serial::Uart::flushWriteBuffer | ( | UartPort | port | ) |
|
inline |
| bool tap::communication::serial::Uart::isWriteFinished | ( | UartPort | port | ) | const |
Because the data is buffered, check here to see if the buffer is empty (implying everything has been written).
| [in] | port | the port to see if writing is finished. |
true if the buffer is empty and the last byte has been sent. | bool tap::communication::serial::Uart::read | ( | UartPort | port, |
| uint8_t * | data | ||
| ) |
Read a single byte.
| [in] | port | the port to read from. |
| [out] | data | Byte read, if any. |
true if a byte was received, false otherwise. | std::size_t tap::communication::serial::Uart::read | ( | UartPort | port, |
| uint8_t * | data, | ||
| std::size_t | length | ||
| ) |
Read a block of bytes.
| [in] | port | the port to read from. |
| [out] | data | pointer to a buffer big enough to store length bytes |
| [in] | length | number of bytes to be read. |
length. | std::size_t tap::communication::serial::Uart::write | ( | UartPort | port, |
| const uint8_t * | data, | ||
| std::size_t | length | ||
| ) |
Pushes a block of bytes into the buffer.
| [in] | port | the port to write to. |
| [in] | data | pointer to a buffer big enough to store length bytes. |
| [in] | length | number of bytes to be written. |
| bool tap::communication::serial::Uart::write | ( | UartPort | port, |
| uint8_t | data | ||
| ) |
Pushes a single byte into the buffer.
| [in] | port | the port to write to. |
true if data has been successfully sent, false if buffer is full.