Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified to allow a custom SS (Chip Select) pin #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions libraries/ModbusIP_ENC28J60/ModbusIP_ENC28J60.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@

byte Ethernet::buffer[MODBUSIP_MAXFRAME];

uint8_t ENC28J60_CS = 10; //Default chip select pin

ModbusIP::ModbusIP() {
ether.hisport = MODBUSIP_PORT;
}

void ModbusIP::setSS(uint8_t ssPin) {
ENC28J60_CS = ssPin;
}

void ModbusIP::config(uint8_t *mac) {
ether.begin(sizeof Ethernet::buffer, mac, ENC28J60_CS);
ether.dhcpSetup();
Expand Down
3 changes: 2 additions & 1 deletion libraries/ModbusIP_ENC28J60/ModbusIP_ENC28J60.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#define MODBUSIP_PORT 502
#define MODBUSIP_MAXFRAME 200

#define ENC28J60_CS 10 //Default chip select pin
//#define ENC28J60_CS 10 //Default chip select pin
//#define TCP_KEEP_ALIVE

class ModbusIP : public Modbus {
Expand All @@ -21,6 +21,7 @@ class ModbusIP : public Modbus {

public:
ModbusIP();
void setSS(uint8_t ssPin);
void config(uint8_t *mac);
void config(uint8_t *mac, uint8_t * ip);
void config(uint8_t *mac, uint8_t * ip, uint8_t * dns);
Expand Down