Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/RS485CommClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ RS485CommClass::RS485CommClass(arduino::UART& uart_itf, PinName rs_tx_pin, PinNa
RS485CommClass::~RS485CommClass()
{ }

void RS485CommClass::begin(unsigned long baudrate)
{
begin(baudrate, SERIAL_8N1, RS485_DEFAULT_PRE_DELAY, RS485_DEFAULT_POST_DELAY);
}

void RS485CommClass::begin(unsigned long baudrate, int predelay, int postdelay)
{
begin(baudrate, SERIAL_8N1, predelay, postdelay);
}

void RS485CommClass::begin(unsigned long baudrate, uint16_t config)
{
begin(baudrate, config, RS485_DEFAULT_PRE_DELAY, RS485_DEFAULT_POST_DELAY);
}

void RS485CommClass::begin(unsigned long baudrate, uint16_t config, int predelay, int postdelay) {
/* Pinout configuration */
pinMode(PinNameToIndex(MC_RS485_TX_PIN), OUTPUT);
Expand Down
36 changes: 33 additions & 3 deletions src/RS485CommClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,47 @@ class RS485CommClass : public RS485Class {
*/
~RS485CommClass();

/**
* @brief Begin the RS485 communication protocol.
*
* This method initializes the RS485 communication protocol with the specified baud rate.
*
* @param baudrate The desired baud rate for the RS485 communication.
*/
void begin(unsigned long baudrate);

/**
* @brief Begin the RS485 communication protocol.
*
* This method initializes the RS485 communication protocol with the specified baud rate and pre/post delays.
*
* @param baudrate The desired baud rate for the RS485 communication.
* @param predelay The delay before sending data in the RS485 communication.
* @param postdelay The delay after sending data in the RS485 communication.
*/
void begin(unsigned long baudrate, int predelay, int postdelay);

/**
* @brief Begin the RS485 communication protocol.
*
* This method initializes the RS485 communication protocol with the specified baud rate and serial configuration.
*
* @param baudrate The desired baud rate for the RS485 communication.
* @param config The desired Serial config (bits, parity and stopbits), see HardwareSerial.h
*/
void begin(unsigned long baudrate, uint16_t config);

/**
* @brief Begin the RS485 communication protocol.
*
* This method initializes the RS485 communication protocol with the specified baud rate and pre/post delays.
*
* @param baudrate The desired baud rate for the RS485 communication.
* @param config The desired Serial config (bits, parity and stopbits), see HardwareSerial.h
* @param predelay The delay before sending data in the RS485 communication (default: RS485_DEFAULT_PRE_DELAY).
* @param postdelay The delay after sending data in the RS485 communication (default: RS485_DEFAULT_POST_DELAY).
* @param predelay The delay before sending data in the RS485 communication.
* @param postdelay The delay after sending data in the RS485 communication.
*/
void begin(unsigned long baudrate = 115200, uint16_t config = SERIAL_8N1, int predelay = RS485_DEFAULT_PRE_DELAY, int postdelay = RS485_DEFAULT_POST_DELAY);
void begin(unsigned long baudrate, uint16_t config, int predelay, int postdelay);

/**
* @brief Close the RS485 communication protocol.
Expand Down