Skip to content

Commit 0542763

Browse files
committed
Moved common structure in common file
1 parent 5f7d623 commit 0542763

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

Diff for: src/ModbusT1SCommon.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#include "ModbusT1SCommon.h"
2+
#if (defined(ARDUINO_UNOR4_WIFI) || defined(ARDUINO_UNOR4_MINIMA))
3+
INIT_TC6(SPI, CS_PIN, RESET_PIN, IRQ_PIN);
4+
#endif

Diff for: src/ModbusT1SCommon.h

+21-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
11
#ifndef _MODBUS_T1S_COMMON_H_INCLUDED
22
#define _MODBUS_T1S_COMMON_H_INCLUDED
3-
#if (defined(ARDUINO_UNOR4_WIFI) || defined(ARDUINO_UNOR4_MINIMA))
3+
44
#include <Arduino_10BASE_T1S.h>
55

6+
#define INIT_TC6(_SPI, _CS_PIN, _RESET_PIN, _IRQ_PIN) \
7+
TC6::TC6_Io* tc6_io = new TC6::TC6_Io \
8+
( _SPI \
9+
, _CS_PIN \
10+
, _RESET_PIN \
11+
, _IRQ_PIN); \
12+
TC6::TC6_Arduino_10BASE_T1S* tc6_inst = new TC6::TC6_Arduino_10BASE_T1S(tc6_io);
13+
14+
extern TC6::TC6_Arduino_10BASE_T1S* tc6_inst;
15+
extern TC6::TC6_Io* tc6_io;
16+
static void default_OnPlcaStatus(bool success, bool plcaStatus);
17+
18+
#if (defined(ARDUINO_UNOR4_WIFI) || defined(ARDUINO_UNOR4_MINIMA))
19+
#define RS485_SERIAL Serial1
20+
#define RS485_TX_PIN 1
21+
#define RS485_RX_PIN 0
22+
#define RS485_DE_PIN 8
23+
#define RS485_RE_PIN 7
24+
#endif
25+
626
enum ModbusT1SFunctionCode {
727
UDP_READ_COIL_PORT = 1,
828
UDP_WRITE_COIL_PORT,
@@ -12,11 +32,4 @@ enum ModbusT1SFunctionCode {
1232
UDP_WRITE_HR_PORT
1333
};
1434

15-
auto const tc6_io = new TC6::TC6_Io
16-
( SPI
17-
, CS_PIN
18-
, RESET_PIN
19-
, IRQ_PIN);
20-
auto const tc6_inst = new TC6::TC6_Arduino_10BASE_T1S(tc6_io);
21-
#endif
2235
#endif

0 commit comments

Comments
 (0)