Skip to content

Commit e056966

Browse files
committed
esp32/8266 compatible fix
1 parent 9114fa4 commit e056966

File tree

3 files changed

+35
-29
lines changed

3 files changed

+35
-29
lines changed

Diff for: library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ArduinoRS485
2-
version=1.0.4
2+
version=1.0.5
33
author=Arduino
44
maintainer=Arduino <[email protected]>
55
sentence=Enables sending and receiving data using the RS-485 standard with RS-485 shields, like the MKR 485 Shield.

Diff for: src/RS485.h

+1-28
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,8 @@
2121
#define _RS485_H_INCLUDED
2222

2323
#include <Arduino.h>
24+
#include "RS485_defs.h"
2425

25-
#ifdef PIN_SERIAL1_TX
26-
#define RS485_DEFAULT_TX_PIN PIN_SERIAL1_TX
27-
#else
28-
#define RS485_DEFAULT_TX_PIN 1
29-
#endif
30-
31-
#ifdef __AVR__
32-
#define RS485_DEFAULT_DE_PIN 2
33-
#define RS485_DEFAULT_RE_PIN -1
34-
#elif defined(ESP32) || defined(ESP8266)
35-
#define RS485_DEFAULT_DE_PIN 0
36-
#define RS485_DEFAULT_RE_PIN 0
37-
#else
38-
#define RS485_DEFAULT_DE_PIN A6
39-
#define RS485_DEFAULT_RE_PIN A5
40-
#endif
41-
42-
#if defined(ESP8266)
43-
#define RS485_SER_CONF_TYPE SerialConfig
44-
#elif defined(ESP32)
45-
#define RS485_SER_CONF_TYPE uint32_t
46-
#else
47-
#define RS485_SER_CONF_TYPE uint16_t
48-
#endif
49-
50-
51-
#define RS485_DEFAULT_PRE_DELAY 50
52-
#define RS485_DEFAULT_POST_DELAY 50
5326

5427
class RS485Class : public Stream {
5528
public:

Diff for: src/RS485_defs.h

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#ifndef _ARDUINO_RS485_DEFS_H_INCLUDED
2+
#define _ARDUINO_RS485_DEFS_H_INCLUDED
3+
4+
#ifdef PIN_SERIAL1_TX
5+
#define RS485_DEFAULT_TX_PIN PIN_SERIAL1_TX
6+
#else
7+
#define RS485_DEFAULT_TX_PIN 1
8+
#endif
9+
10+
#ifdef __AVR__
11+
#define RS485_DEFAULT_DE_PIN 2
12+
#define RS485_DEFAULT_RE_PIN -1
13+
#elif defined(ESP32) || defined(ESP8266)
14+
#define RS485_DEFAULT_DE_PIN 0
15+
#define RS485_DEFAULT_RE_PIN 0
16+
#else
17+
#define RS485_DEFAULT_DE_PIN A6
18+
#define RS485_DEFAULT_RE_PIN A5
19+
#endif
20+
21+
#if defined(ESP8266)
22+
#define RS485_SER_CONF_TYPE SerialConfig
23+
#elif defined(ESP32)
24+
#define RS485_SER_CONF_TYPE uint32_t
25+
#else
26+
#define RS485_SER_CONF_TYPE uint16_t
27+
#endif
28+
29+
30+
#define RS485_DEFAULT_PRE_DELAY 50
31+
#define RS485_DEFAULT_POST_DELAY 50
32+
33+
#endif

0 commit comments

Comments
 (0)