Skip to content

Commit

Permalink
Moved common structure in common file
Browse files Browse the repository at this point in the history
  • Loading branch information
Rocketct committed Nov 14, 2024
1 parent 3818090 commit 98eb594
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/ModbusT1SCommon.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "ModbusT1SCommon.h"
#if (defined(ARDUINO_UNOR4_WIFI) || defined(ARDUINO_UNOR4_MINIMA))
INIT_TC6(SPI, CS_PIN, RESET_PIN, IRQ_PIN);
#endif
29 changes: 21 additions & 8 deletions src/ModbusT1SCommon.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
#ifndef _MODBUS_T1S_COMMON_H_INCLUDED
#define _MODBUS_T1S_COMMON_H_INCLUDED
#if (defined(ARDUINO_UNOR4_WIFI) || defined(ARDUINO_UNOR4_MINIMA))

#include <Arduino_10BASE_T1S.h>

#define INIT_TC6(_SPI, _CS_PIN, _RESET_PIN, _IRQ_PIN) \
TC6::TC6_Io* tc6_io = new TC6::TC6_Io \
( _SPI \
, _CS_PIN \
, _RESET_PIN \
, _IRQ_PIN); \
TC6::TC6_Arduino_10BASE_T1S* tc6_inst = new TC6::TC6_Arduino_10BASE_T1S(tc6_io);

extern TC6::TC6_Arduino_10BASE_T1S* tc6_inst;
extern TC6::TC6_Io* tc6_io;
static void default_OnPlcaStatus(bool success, bool plcaStatus);

#if (defined(ARDUINO_UNOR4_WIFI) || defined(ARDUINO_UNOR4_MINIMA))
#define RS485_SERIAL Serial1
#define RS485_TX_PIN 1
#define RS485_RX_PIN 0
#define RS485_DE_PIN 8
#define RS485_RE_PIN 7
#endif

enum ModbusT1SFunctionCode {
UDP_READ_COIL_PORT = 1,
UDP_WRITE_COIL_PORT,
Expand All @@ -12,11 +32,4 @@ enum ModbusT1SFunctionCode {
UDP_WRITE_HR_PORT
};

auto const tc6_io = new TC6::TC6_Io
( SPI
, CS_PIN
, RESET_PIN
, IRQ_PIN);
auto const tc6_inst = new TC6::TC6_Arduino_10BASE_T1S(tc6_io);
#endif
#endif

0 comments on commit 98eb594

Please sign in to comment.