distortos  v0.4.0
object-oriented C++ RTOS for microcontrollers
distortos::devices::Rs485 Class Reference

#include <Rs485.hpp>

Inheritance diagram for distortos::devices::Rs485:
[legend]
Collaboration diagram for distortos::devices::Rs485:
[legend]

Public Member Functions

constexpr Rs485 (UartLowLevel &uart, void *const readBuffer, const size_t readBufferSize, void *const writeBuffer, const size_t writeBufferSize, OutputPin &driverEnablePin, const bool driverEnabledState)
 Rs485's constructor. More...
 
 ~Rs485 ()
 Rs485's destructor. More...
 
- Public Member Functions inherited from distortos::devices::SerialPort
constexpr SerialPort (UartLowLevel &uart, void *const readBuffer, const size_t readBufferSize, void *const writeBuffer, const size_t writeBufferSize)
 SerialPort's constructor. More...
 
 ~SerialPort () override
 SerialPort's destructor. More...
 
int close ()
 Closes SerialPort. More...
 
int open (uint32_t baudRate, uint8_t characterLength, devices::UartParity parity, bool _2StopBits)
 Opens SerialPort. More...
 
std::pair< int, size_t > read (void *buffer, size_t size, size_t minSize=1, const TickClock::time_point *timePoint=nullptr)
 Reads data from SerialPort. More...
 
std::pair< int, size_t > tryReadFor (const TickClock::duration duration, void *const buffer, const size_t size, const size_t minSize=1)
 Wrapper for read() with relative timeout. More...
 
template<typename Rep , typename Period >
std::pair< int, size_t > tryReadFor (const std::chrono::duration< Rep, Period > duration, void *const buffer, const size_t size, const size_t minSize=1)
 Wrapper for read() with relative timeout. More...
 
std::pair< int, size_t > tryReadUntil (const TickClock::time_point timePoint, void *const buffer, const size_t size, const size_t minSize=1)
 Wrapper for read() with absolute timeout. More...
 
template<typename Duration >
std::pair< int, size_t > tryReadUntil (const std::chrono::time_point< TickClock, Duration > timePoint, void *const buffer, const size_t size, const size_t minSize=1)
 Wrapper for read() with absolute timeout. More...
 
std::pair< int, size_t > tryWriteFor (const TickClock::duration duration, const void *const buffer, const size_t size, const size_t minSize=SIZE_MAX)
 Wrapper for write() with relative timeout. More...
 
template<typename Rep , typename Period >
std::pair< int, size_t > tryWriteFor (const std::chrono::duration< Rep, Period > duration, const void *const buffer, const size_t size, const size_t minSize=SIZE_MAX)
 Wrapper for write() with relative timeout. More...
 
std::pair< int, size_t > tryWriteUntil (const TickClock::time_point timePoint, const void *const buffer, const size_t size, const size_t minSize=SIZE_MAX)
 Wrapper for write() with absolute timeout. More...
 
template<typename Duration >
std::pair< int, size_t > tryWriteUntil (const std::chrono::time_point< TickClock, Duration > timePoint, const void *const buffer, const size_t size, const size_t minSize=SIZE_MAX)
 Wrapper for write() with absolute timeout. More...
 
std::pair< int, size_t > write (const void *buffer, size_t size, size_t minSize=SIZE_MAX, const TickClock::time_point *timePoint=nullptr)
 Writes data to SerialPort. More...
 

Protected Member Functions

void transmitCompleteEvent () override
 "Transmit complete" event More...
 
void transmitStartEvent () override
 "Transmit start" event More...
 
- Protected Member Functions inherited from distortos::devices::SerialPort
void readCompleteEvent (size_t bytesRead) override
 "Read complete" event More...
 
void receiveErrorEvent (ErrorSet errorSet) override
 "Receive error" event More...
 
void transmitCompleteEvent () override
 "Transmit complete" event More...
 
void transmitStartEvent () override
 "Transmit start" event More...
 
void writeCompleteEvent (size_t bytesWritten) override
 "Write complete" event More...
 

Private Member Functions

void enableDriver (bool enable) const
 Enables or disables RS-485 driver. More...
 

Private Attributes

OutputPindriverEnablePin_
 reference to output pin used to control the state of RS-485 driver More...
 
bool driverEnabledState_
 state of driverEnablePin_ in which RS-485 driver is enabled More...
 

Detailed Description

Rs485 class is a RS-485 variant of serial port with an interface similar to standard files

Constructor & Destructor Documentation

◆ Rs485()

constexpr distortos::devices::Rs485::Rs485 ( UartLowLevel uart,
void *const  readBuffer,
const size_t  readBufferSize,
void *const  writeBuffer,
const size_t  writeBufferSize,
OutputPin driverEnablePin,
const bool  driverEnabledState 
)
inline

Rs485's constructor.

Parameters
[in]uartis a reference to low-level implementation of UartLowLevel interface
[in]readBufferis a buffer for read operations
[in]readBufferSizeis the size of readBuffer, bytes, should be even, must be greater than or equal to 2
[in]writeBufferis a buffer to write operations
[in]writeBufferSizeis the size of writeBuffer, bytes, should be even, must be greater than or equal to 2
[in]driverEnablePinis a reference to output pin used to control the state of RS-485 driver
[in]driverEnabledStateis the state of driverEnablePin in which RS-485 driver is enabled
Here is the call graph for this function:

◆ ~Rs485()

distortos::devices::Rs485::~Rs485 ( )

Rs485's destructor.

Disables RS-485 driver.

Warning
This function must not be called from interrupt context!
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ enableDriver()

void distortos::devices::Rs485::enableDriver ( bool  enable) const
private

Enables or disables RS-485 driver.

Parameters
[in]enableselects whether RS-485 driver will be enabled (true) or disabled (false)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ transmitCompleteEvent()

void distortos::devices::Rs485::transmitCompleteEvent ( )
overrideprotectedvirtual

"Transmit complete" event

Called by low-level UART driver when the transmission is physically finished.

Disables RS-485 driver and calls SerialPort::transmitCompleteEvent().

Implements distortos::devices::UartBase.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ transmitStartEvent()

void distortos::devices::Rs485::transmitStartEvent ( )
overrideprotectedvirtual

"Transmit start" event

Called by low-level UART driver when new transmission starts.

Enables RS-485 driver and calls SerialPort::transmitStartEvent().

Implements distortos::devices::UartBase.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ driverEnabledState_

bool distortos::devices::Rs485::driverEnabledState_
private

state of driverEnablePin_ in which RS-485 driver is enabled

◆ driverEnablePin_

OutputPin& distortos::devices::Rs485::driverEnablePin_
private

reference to output pin used to control the state of RS-485 driver


The documentation for this class was generated from the following files: