distortos  v0.4.0
object-oriented C++ RTOS for microcontrollers
Rs485.hpp
Go to the documentation of this file.
1 
12 #ifndef INCLUDE_DISTORTOS_DEVICES_COMMUNICATION_RS485_HPP_
13 #define INCLUDE_DISTORTOS_DEVICES_COMMUNICATION_RS485_HPP_
14 
16 
17 namespace distortos
18 {
19 
20 namespace devices
21 {
22 
23 class OutputPin;
24 
31 class Rs485 : public SerialPort
32 {
33 public:
34 
49  constexpr Rs485(UartLowLevel& uart, void* const readBuffer, const size_t readBufferSize, void* const writeBuffer,
50  const size_t writeBufferSize, OutputPin& driverEnablePin, const bool driverEnabledState) :
51  SerialPort{uart, readBuffer, readBufferSize, writeBuffer, writeBufferSize},
52  driverEnablePin_{driverEnablePin},
53  driverEnabledState_{driverEnabledState}
54  {
55 
56  }
57 
66  ~Rs485();
67 
68 protected:
69 
78  void transmitCompleteEvent() override;
79 
88  void transmitStartEvent() override;
89 
90 private:
91 
98  void enableDriver(bool enable) const;
99 
102 
105 };
106 
107 } // namespace devices
108 
109 } // namespace distortos
110 
111 #endif // INCLUDE_DISTORTOS_DEVICES_COMMUNICATION_RS485_HPP_
void transmitStartEvent() override
"Transmit start" event
Definition: Rs485.cpp:41
~Rs485()
Rs485's destructor.
Definition: Rs485.cpp:26
Definition: OutputPin.hpp:29
void transmitCompleteEvent() override
"Transmit complete" event
Definition: Rs485.cpp:35
OutputPin & driverEnablePin_
reference to output pin used to control the state of RS-485 driver
Definition: Rs485.hpp:101
bool driverEnabledState_
state of driverEnablePin_ in which RS-485 driver is enabled
Definition: Rs485.hpp:104
SerialPort class header.
void enableDriver(bool enable) const
Enables or disables RS-485 driver.
Definition: Rs485.cpp:51
Top-level namespace of distortos project.
Definition: SerialPort.hpp:36
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.
Definition: Rs485.hpp:49
Definition: UartLowLevel.hpp:35
Definition: Rs485.hpp:31