#include "distortos/chip/ChipUartLowLevel.hpp"
ChipUartLowLevel class is a low-level UART driver for USARTv1 in STM32
◆ ChipUartLowLevel()
constexpr distortos::chip::ChipUartLowLevel::ChipUartLowLevel |
( |
const Parameters & |
parameters | ) |
|
|
inlineexplicit |
ChipUartLowLevel's constructor.
- Parameters
-
[in] | parameters | is a reference to object with peripheral parameters |
◆ ~ChipUartLowLevel()
distortos::chip::ChipUartLowLevel::~ChipUartLowLevel |
( |
| ) |
|
|
override |
ChipUartLowLevel's destructor.
Does nothing if driver is already stopped. If it's not, performs forced stop of operation.
◆ interruptHandler()
void distortos::chip::ChipUartLowLevel::interruptHandler |
( |
| ) |
|
Interrupt handler.
- Note
- this must not be called by user code
◆ isReadInProgress()
bool distortos::chip::ChipUartLowLevel::isReadInProgress |
( |
| ) |
const |
|
inlineprivate |
- Returns
- true if read operation is in progress, false otherwise
◆ isStarted()
bool distortos::chip::ChipUartLowLevel::isStarted |
( |
| ) |
const |
|
inlineprivate |
- Returns
- true if driver is started, false otherwise
◆ isWriteInProgress()
bool distortos::chip::ChipUartLowLevel::isWriteInProgress |
( |
| ) |
const |
|
inlineprivate |
- Returns
- true if write operation is in progress, false otherwise
◆ start()
std::pair< int, uint32_t > distortos::chip::ChipUartLowLevel::start |
( |
devices::UartBase & |
uartBase, |
|
|
uint32_t |
baudRate, |
|
|
uint8_t |
characterLength, |
|
|
devices::UartParity |
parity, |
|
|
bool |
_2StopBits |
|
) |
| |
|
overridevirtual |
Starts low-level UART driver.
Not all combinations of data format are supported. The general rules are:
- if parity control is disabled, character length must not be 7,
- if parity control is enabled, character length must not be 9.
- Parameters
-
[in] | uartBase | is a reference to UartBase object that will be associated with this one |
[in] | baudRate | is the desired baud rate, bps |
[in] | characterLength | selects character length, bits, [7; 9] or [minCharacterLength; maxCharacterLength] |
[in] | parity | selects parity |
[in] | _2StopBits | selects whether 1 (false) or 2 (true) stop bits are used |
- Returns
- pair with return code (0 on success, error code otherwise) and real baud rate; error codes:
- EBADF - the driver is not stopped;
- EINVAL - selected baud rate and/or format are invalid;
Implements distortos::devices::UartLowLevel.
◆ startRead()
int distortos::chip::ChipUartLowLevel::startRead |
( |
void * |
buffer, |
|
|
size_t |
size |
|
) |
| |
|
overridevirtual |
Starts asynchronous read operation.
This function returns immediately. When the operation is finished (expected number of bytes were read), UartBase::readCompleteEvent() will be executed. For any detected error during reception, UartBase::receiveErrorEvent() will be executed. Note that overrun error may be reported even if it happened when no read operation was in progress.
- Parameters
-
[out] | buffer | is the buffer to which the data will be written |
[in] | size | is the size of buffer, bytes, must be even if selected character length is greater than 8 bits |
- Returns
- 0 on success, error code otherwise:
- EBADF - the driver is not started;
- EBUSY - read is in progress;
- EINVAL - buffer and/or size are invalid;
Implements distortos::devices::UartLowLevel.
◆ startWrite()
int distortos::chip::ChipUartLowLevel::startWrite |
( |
const void * |
buffer, |
|
|
size_t |
size |
|
) |
| |
|
overridevirtual |
Starts asynchronous write operation.
This function returns immediately. If no transmission is active, UartBase::transmitStartEvent() will be executed. When the operation is finished (expected number of bytes were written), UartBase::writeCompleteEvent() will be executed. When the transmission physically ends, UartBase::transmitCompleteEvent() will be executed.
- Parameters
-
[in] | buffer | is the buffer with data that will be transmitted |
[in] | size | is the size of buffer, bytes, must be even if selected character length is greater than 8 bits |
- Returns
- 0 on success, error code otherwise:
- EBADF - the driver is not started;
- EBUSY - write is in progress;
- EINVAL - buffer and/or size are invalid;
Implements distortos::devices::UartLowLevel.
◆ stop()
int distortos::chip::ChipUartLowLevel::stop |
( |
| ) |
|
|
overridevirtual |
Stops low-level UART driver.
- Returns
- 0 on success, error code otherwise:
- EBADF - the driver is not started;
- EBUSY - read and/or write are in progress;
Implements distortos::devices::UartLowLevel.
◆ stopRead()
size_t distortos::chip::ChipUartLowLevel::stopRead |
( |
| ) |
|
|
overridevirtual |
Stops asynchronous read operation.
This function returns immediately. After this call UartBase::readCompleteEvent() will not be executed.
- Returns
- number of bytes already read by low-level UART driver (and written to read buffer)
Implements distortos::devices::UartLowLevel.
◆ stopWrite()
size_t distortos::chip::ChipUartLowLevel::stopWrite |
( |
| ) |
|
|
overridevirtual |
Stops asynchronous write operation.
This function returns immediately. After this call UartBase::writeCompleteEvent() will not be executed. UartBase::transmitCompleteEvent() will not be suppressed.
- Returns
- number of bytes already written by low-level UART driver (and read from write buffer)
Implements distortos::devices::UartLowLevel.
◆ maxCharacterLength
constexpr uint8_t distortos::chip::ChipUartLowLevel::maxCharacterLength {9} |
|
static |
maximum allowed value for UART character length
◆ minCharacterLength
constexpr uint8_t distortos::chip::ChipUartLowLevel::minCharacterLength {7} |
|
static |
minimum allowed value for UART character length
◆ parameters_
const Parameters& distortos::chip::ChipUartLowLevel::parameters_ |
|
private |
reference to configuration parameters
◆ readBuffer_
uint8_t* volatile distortos::chip::ChipUartLowLevel::readBuffer_ |
|
private |
buffer to which the data is being written
◆ readPosition_
volatile size_t distortos::chip::ChipUartLowLevel::readPosition_ |
|
private |
current position in readBuffer_
◆ readSize_
volatile size_t distortos::chip::ChipUartLowLevel::readSize_ |
|
private |
size of readBuffer_, bytes
◆ uartBase_
pointer to UartBase object associated with this one
◆ writeBuffer_
const uint8_t* volatile distortos::chip::ChipUartLowLevel::writeBuffer_ |
|
private |
buffer with data that is being transmitted
◆ writePosition_
volatile size_t distortos::chip::ChipUartLowLevel::writePosition_ |
|
private |
current position in writeBuffer_
◆ writeSize_
volatile size_t distortos::chip::ChipUartLowLevel::writeSize_ |
|
private |
size of writeBuffer_, bytes
The documentation for this class was generated from the following files: