I am attempting to design a device using a Pi Zero which needs to connect to both an ENC18J60 SPI ethernet controller, and a VGA monitor via Mode 3 DPI and the Mincepi Pi Zero pi2vga schematic. While pins GPIO9, GPIO10 and GPIO11 (physical pins 21, 19 and 23), used for SPI, are left open, the CS pins GPIO8 and GPIO7 are both used. Unfortunately, no other DPI modes free these pins. The SPI1 interface is also not fully accessible in any DPI mode.

As such, I have been looking into ways to reassign the CS pin for SPI0 to another, unused GPIO, such as GPIO19, which goes unused in DPI mode 3. In the /boot/overlays/README file, it mentions the ability to use spi0-cs, which "Allows the (software) CS pins for SPI0 to be changed".

Apparently, I could set the cs0_pin parameter of this to, for example, 19, and run my CS somewhere else. However, from what I can tell in the file, this is "software" CS, which presumably exists at a higher level than CS on pins GPIO7 and GPIO8.

As such, my two questions are as follow:

  • How do I configure it to use CS for SPI0 on Pin GPIO19? Do I just set the spi0-cs parameter, or are there other details? It mentions "spi0-hw-cs", which "Re-enables hardware CS/CE (chip selects) for SPI0", so I presume that "Re-enables" means they are, by default, disabled when spi0-cs is configured? If not, how do I disable the hardware CS so as not to conflict with my DPI interface?
  • Will the ENC18J60 function properly with "software" CS using a different pin? Are any changes needed to the kernel, drivers, etc (e.g. ENC18J60 driver somehow assumes it's at Pin 8 and needs to be modified), does changing the CS pin here mean it should work, or will it be completely broken because the ENC18J60 somehow operates at a lower level than wherever the "software" CS exists?
  • Theoretically you can use any pin for a CS. I did this when I was using a different chip and wanted to talk with more than 2 devices. – NomadMaker Jan 30 '18 at 21:37
  • @NomadMaker I plan to use the official driver, which is apparently built into the kernel. Were you bitbanging your CS pin, or did you configure it with spi0-cs and then use regular SPI support? – DodoDude700 Jan 30 '18 at 21:45
  • This was around 15 years ago, so I don't remember many of the details. I left one of the CS pins empty, and I just wrote a wrapper function around the SPI functions that let me use any pin I wished. I've always wondered why they only specified 2 CS pins with SPI rather than just allow any digital output pin as a CS. – NomadMaker Jan 31 '18 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.