M5Unit-RS485 0.2.0 git rev:0956c20
Loading...
Searching...
No Matches
m5::unit::Tab5BuiltinRS485 Class Reference

M5Stack Tab5 built-in RS-485 (SIT3088 with DIR pin fixed to GPIO34) More...

#include <M5UnitUnifiedRS485.hpp>

Inheritance diagram for m5::unit::Tab5BuiltinRS485:
m5::unit::UnitSIT3088 m5::unit::RS485Component

Public Member Functions

 Tab5BuiltinRS485 (Tab5BuiltinRS485 &&) noexcept=default
 Move constructor. Declared because the destructor above suppresses the implicit one.
 
Tab5BuiltinRS485 & operator= (Tab5BuiltinRS485 &&) noexcept=default
 Move assignment. Declared for the same reason as the move constructor.
 
- Public Member Functions inherited from m5::unit::UnitSIT3088
 UnitSIT3088 ()
 Constructor. dir_pin remains unset; set via config() before begin().
 
virtual ~UnitSIT3088 ()=default
 Destructor.
 
virtual bool begin () override
 Configure the DIR pin, then begin using the registered UART adapter.
 
config_t config () const
 Gets the configuration.
 
void config (const config_t &cfg)
 Sets the configuration.
 
- Public Member Functions inherited from m5::unit::RS485Component
virtual ~RS485Component ()=default
 Destructor.
 
 RS485Component (const RS485Component &)=delete
 Deleted: a component owns its serial backend, so it cannot be copied.
 
RS485Component & operator= (const RS485Component &)=delete
 Deleted: a component owns its serial backend, so it cannot be copied.
 
config_t config () const
 Gets the configuration.
 
void config (const config_t &cfg)
 Sets the configuration.
 
 operator bool () const
 Returns true if the unit is registered.
 
uint32_t baudRate () const
 Returns the baud rate the serial port is running at.
 
int available ()
 Returns the number of available bytes to read.
 
int availableForWrite ()
 Returns the number of bytes that can be written without blocking.
 
int peek ()
 Peeks the next incoming byte without removing it.
 
int read ()
 Reads one byte.
 
size_t read (uint8_t *buffer, const size_t size)
 Reads up to size bytes into buffer.
 
size_t read (char *buffer, const size_t size)
 Reads up to size bytes into buffer.
 
size_t readBytes (uint8_t *buffer, const size_t length)
 Reads bytes with timeout defined by underlying Serial.
 
size_t readBytes (char *buffer, const size_t length)
 Reads bytes with timeout defined by underlying Serial.
 
size_t readBytes (uint8_t *buffer, const size_t length, const uint32_t timeout_ms)
 Reads bytes with an explicit timeout.
 
size_t readBytes (char *buffer, const size_t length, const uint32_t timeout_ms)
 Reads bytes with an explicit timeout.
 
void flush ()
 Flushes the serial port.
 
void flush (const bool txOnly)
 Flushes the serial port.
 
size_t write (const uint8_t d)
 Writes one byte.
 
size_t write (const uint8_t *buffer, const size_t size)
 Writes bytes from buffer.
 
size_t write (const char *buffer, const size_t size)
 Writes bytes from buffer.
 
size_t write (const char *s)
 Writes a null-terminated string.
 
template<typename Size , typename std::enable_if<!std::is_integral< Size >::value||std::is_same< Size, char >::value||std::is_same< Size, signed char >::value||std::is_same< Size, bool >::value, int >::type = 0>
size_t write (const uint8_t *buffer, const Size size)=delete
 Deleted: the second argument of write() is a byte count.
 
template<typename Size , typename std::enable_if<!std::is_integral< Size >::value||std::is_same< Size, char >::value||std::is_same< Size, signed char >::value, int >::type = 0>
size_t write (const char *buffer, const Size size)=delete
 Deleted: the second argument of write() is a byte count.
 
template<typename Wait , typename std::enable_if< std::is_same< Wait, bool >::value, int >::type = 0>
size_t write (const uint8_t d, const Wait wait)
 Writes one byte, optionally waiting for the transmission to complete.
 
size_t write (const uint8_t *buffer, const size_t size, const bool wait)
 Writes bytes from buffer, optionally waiting for the transmission to complete.
 
size_t write (const char *buffer, const size_t size, const bool wait)
 Writes bytes from buffer, optionally waiting for the transmission to complete.
 
template<typename Wait , typename std::enable_if< std::is_same< Wait, bool >::value, int >::type = 0>
size_t write (const char *s, const Wait wait)
 Writes a null-terminated string, optionally waiting for the transmission to complete.
 
template<typename T , bool LittleEndian = true>
bool readValue (T &value)
 Read a trivially copyable value.
 
template<typename T , bool LittleEndian = true>
bool writeValue (const T value)
 Write a trivially copyable value.
 

Additional Inherited Members

- Protected Member Functions inherited from m5::unit::UnitSIT3088
virtual void configure_dir_pin (const int8_t pin)
 One-time setup of the DIR pin as an output (called by begin()).
 
virtual void set_transmit (const bool tx_enable)
 Switch the transceiver into transmit (true) or receive (false) mode.
 
virtual std::unique_ptr< ISerial > make_serial (AdapterUART *ad) override
 Factory hook: build the concrete ISerial to be used by begin().
 
int8_t configured_dir_pin () const
 
- Protected Member Functions inherited from m5::unit::RS485Component
 RS485Component (const uint8_t addr)
 Base constructor (concrete subclasses pass their DEFAULT_ADDRESS)
 
 RS485Component (RS485Component &&other) noexcept
 Move constructor.
 
RS485Component & operator= (RS485Component &&other) noexcept
 Move assignment.
 
size_t write_waiting (const uint8_t *buffer, const size_t size)
 
ISerial * iserial ()
 
void install_serial (std::unique_ptr< ISerial > serial)
 Installs a serial backend, taking over ownership and replacing the current one.
 
- Static Protected Member Functions inherited from m5::unit::RS485Component
template<typename T >
static T byteswap_if_needed (T v)
 
template<typename T >
static T byteswap_if_needed_impl (T v, byteswap_value_tag)
 
template<typename T >
static T byteswap_if_needed_impl (T v, byteswap_none_tag)
 
- Protected Attributes inherited from m5::unit::RS485Component
config_t _cfg {}
 

Detailed Description

M5Stack Tab5 built-in RS-485 (SIT3088 with DIR pin fixed to GPIO34)

Thin UnitSIT3088 subclass that bakes the Tab5-specific DIR pin (G34) into config() so that Tab5BuiltinRS485 unit; alone yields a ready-to-begin instance. The wiring helper m5::unit::rs485::wiring::addTab5BuiltinRS485UART still handles Serial pins and baud.