diff --git a/src/RS485CommClass.cpp b/src/RS485CommClass.cpp index c7afa6d..26a976c 100644 --- a/src/RS485CommClass.cpp +++ b/src/RS485CommClass.cpp @@ -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); diff --git a/src/RS485CommClass.h b/src/RS485CommClass.h index a87d91e..0c2704c 100644 --- a/src/RS485CommClass.h +++ b/src/RS485CommClass.h @@ -48,6 +48,36 @@ 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. * @@ -55,10 +85,10 @@ class RS485CommClass : public RS485Class { * * @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.