Skip to content
Merged
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
4 changes: 2 additions & 2 deletions examples/RS485_fullduplex/RS485_fullduplex.ino
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void setup() {
// - Half Duplex
// - No A/B and Y/Z 120 Ohm termination enabled
// Enable the RS485/RS232 system
MachineControl_RS485Comm.begin(115200, 0, 500); // Specify baudrate, and preamble and postamble times for RS485 communication
MachineControl_RS485Comm.begin(115200, SERIAL_8N1, 0, 500); // Specify baudrate, serial_config and preamble and postamble times for RS485 communication

// Enable Full Duplex mode
// This will also enable A/B and Y/Z 120 Ohm termination resistors
Expand Down Expand Up @@ -70,4 +70,4 @@ void loop() {

sendNow = millis() + sendInterval;
}
}
}
4 changes: 2 additions & 2 deletions examples/RS485_halfduplex/RS485_halfduplex.ino
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void setup() {
// - Half Duplex
// - No A/B and Y/Z 120 Ohm termination enabled
// Enable the RS485/RS232 system
MachineControl_RS485Comm.begin(115200, 0, 500); // Specify baudrate, and preamble and postamble times for RS485 communication
MachineControl_RS485Comm.begin(115200, SERIAL_8N1, 0, 500); // Specify baudrate, serial config and preamble and postamble times for RS485 communication

// Start in receive mode
MachineControl_RS485Comm.receive();
Expand Down Expand Up @@ -65,4 +65,4 @@ void loop() {

sendNow = millis() + sendInterval;
}
}
}
6 changes: 3 additions & 3 deletions src/RS485CommClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RS485CommClass::RS485CommClass(arduino::UART& uart_itf, PinName rs_tx_pin, PinNa
RS485CommClass::~RS485CommClass()
{ }

void RS485CommClass::begin(unsigned long baudrate, int predelay, int postdelay) {
void RS485CommClass::begin(unsigned long baudrate, uint16_t config, int predelay, int postdelay) {
/* Pinout configuration */
pinMode(PinNameToIndex(MC_RS485_TX_PIN), OUTPUT);
pinMode(PinNameToIndex(MC_RS485_RX_PIN), OUTPUT);
Expand Down Expand Up @@ -45,7 +45,7 @@ void RS485CommClass::begin(unsigned long baudrate, int predelay, int postdelay)
_enable();

/* Call begin() base class to initialize RS485 communication */
RS485Class::begin(baudrate, predelay, postdelay);
RS485Class::begin(baudrate, config, predelay, postdelay);

return;
}
Expand Down Expand Up @@ -92,4 +92,4 @@ void RS485CommClass::_disable() {

arduino::UART _UART4_ {MC_RS485_TX_PIN, MC_RS485_RX_PIN, NC, NC};
RS485CommClass MachineControl_RS485Comm(_UART4_);
/**** END OF FILE ****/
/**** END OF FILE ****/
3 changes: 2 additions & 1 deletion src/RS485CommClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ class RS485CommClass : public RS485Class {
* 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).
*/
void begin(unsigned long baudrate = 115200, int predelay = RS485_DEFAULT_PRE_DELAY, int postdelay = RS485_DEFAULT_POST_DELAY);
void begin(unsigned long baudrate = 115200, uint16_t config = SERIAL_8N1, int predelay = RS485_DEFAULT_PRE_DELAY, int postdelay = RS485_DEFAULT_POST_DELAY);

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