ntruchsess / arduino_uip

UIPEthernet: A plugin-replacement of the stock Arduino Ethernet library for ENC28J60 shields and breakout boards. Full support for persistent (streaming) TCP-connections and UDP (Client and Server each), ARP, ICMP, DHCP and DNS. Build around Adam Dunkels uIP Stack. Further developed version can be found on https://github.com/UIPEthernet/UIPEthernet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to change the CS pin in software?

petit-miner opened this issue · comments

Hello,
I would like to change the CS pin in software, because the CS pin is hardwired on a PCB.
How can I do that?

I think you can find something here (line #30)

UIPEthernet\utility\Enc28J60Network.h

`
#define ENC28J60_CONTROL_CS SS

#define SPI_MOSI MOSI

#define SPI_MISO MISO

#define SPI_SCK SCK

#define SPI_SS SS
`

I would like to expand on what Bistronic has suggested.

If you edit the header files for the library and you use it in different projects with different hardware setup you will run into trouble. Which is why the great guys of Arduino have made board definitions and board variants. If the CS is hard wired I guess then either the PCB is an Arduino shield (in which case it better use the default CS) or it is a custom board. I dealt with the latter case recently and after some googling I found it is actually quite easy to setup a custom board variant where you can specify what the SS pin is. Once you do that all the libraries will use the correct pins and work out of the box.

Google for boards.txt and board variants. The latter is where the magic of defining your custom board and its pin map happens.

Nice, thank you. I will try that!