Skip to content

Commit 8216529

Browse files
committed
Add constructor with PinName types for mbed boards
1 parent 466aef0 commit 8216529

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Diff for: src/RS485.cpp

+14-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@
1919

2020
#include "RS485.h"
2121

22+
#ifdef __MBED__
23+
#include "pinDefinitions.h"
24+
RS485Class::RS485Class(HardwareSerial& hwSerial, PinName txPin, PinName dePin, PinName rePin) :
25+
_serial(&hwSerial),
26+
_txPin(PinNameToIndex(txPin)),
27+
_dePin(PinNameToIndex(dePin)),
28+
_rePin(PinNameToIndex(rePin)),
29+
_transmisionBegun(false)
30+
{
31+
}
32+
#endif
33+
2234
RS485Class::RS485Class(HardwareSerial& hwSerial, int txPin, int dePin, int rePin) :
2335
_serial(&hwSerial),
2436
_txPin(txPin),
@@ -186,8 +198,8 @@ void RS485Class::setDelays(int predelay, int postdelay)
186198
_postdelay = postdelay;
187199
}
188200

189-
#ifdef RS285_SERIAL_PORT
190-
RS485Class RS485(RS285_SERIAL_PORT, RS485_DEFAULT_TX_PIN, RS485_DEFAULT_DE_PIN, RS485_DEFAULT_RE_PIN);
201+
#ifdef RS485_SERIAL_PORT
202+
RS485Class RS485(RS485_SERIAL_PORT, RS485_DEFAULT_TX_PIN, RS485_DEFAULT_DE_PIN, RS485_DEFAULT_RE_PIN);
191203
#else
192204
RS485Class RS485(SERIAL_PORT_HARDWARE, RS485_DEFAULT_TX_PIN, RS485_DEFAULT_DE_PIN, RS485_DEFAULT_RE_PIN);
193205
#endif

Diff for: src/RS485.h

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949

5050
class RS485Class : public Stream {
5151
public:
52+
#ifdef __MBED__
53+
RS485Class(HardwareSerial& hwSerial, PinName txPin, PinName dePin, PinName rePin);
54+
#endif
5255
RS485Class(HardwareSerial& hwSerial, int txPin, int dePin, int rePin);
5356

5457
virtual void begin(unsigned long baudrate);

0 commit comments

Comments
 (0)