From 2d22070aa37b66e11f37baf6d15ad59ffc5a4e3e Mon Sep 17 00:00:00 2001 From: mstroh76 Date: Sat, 10 Jan 2026 17:06:26 +0100 Subject: [PATCH] #411 support CS0-4 --- documentation/deutsch/functions.md | 4 ++-- documentation/english/functions.md | 4 ++-- wiringPi/wiringPiSPI.c | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/documentation/deutsch/functions.md b/documentation/deutsch/functions.md index 8b78d56..f0c87b3 100644 --- a/documentation/deutsch/functions.md +++ b/documentation/deutsch/functions.md @@ -809,8 +809,8 @@ int wiringPiSPISetupMode(int channel, int speed, int mode) int wiringPiSPIxSetupMode(const int number, const int channel, const int speed, const int mode) ``` -``number``: SPI Nummer (typisch 0, bei Compute Modul 0-7). -``channel``: SPI Kanal (typisch 0 oder 1, bei Compute Modul 0-3). +``number``: SPI Nummer (typisch 0, bei Compute Modul 0-6). +``channel``: SPI Kanal (typisch 0 oder 1, bei Compute Modul oder entsprechenden overlay 0-4). ``speed``: SPI Taktrate. ``mode``: SPI Modus (https://www.kernel.org/doc/Documentation/spi/spidev). ``Rückgabewert``: Datei Handle zum SPI-Bus diff --git a/documentation/english/functions.md b/documentation/english/functions.md index 6875205..f1ec746 100644 --- a/documentation/english/functions.md +++ b/documentation/english/functions.md @@ -798,8 +798,8 @@ int wiringPiSPISetupMode(int channel, int speed, int mode); int wiringPiSPIxSetupMode(const int number, const int channel, const int speed, const int mode); ``` -``number``: SPI number (typically 0, on Compute Module 0-7). -``channel``: SPI channel (typically 0 or 1, on Compute Module 0-3). +``number``: SPI number (typically 0, on Compute Module 0-6). +``channel``: SPI channel (typically 0 or 1, on Compute Module or the corresponding overlay 0-4). ``speed``: SPI clock speed in Hz (500,000 to 32,000,000). ``mode``: SPI mode ([www.kernel.org/doc/Documentation/spi/spidev](https://www.kernel.org/doc/Documentation/spi/spidev)). ``Return Value``: File handle to the SPI bus, or -1 on error. diff --git a/wiringPi/wiringPiSPI.c b/wiringPi/wiringPiSPI.c index 581a079..e182523 100644 --- a/wiringPi/wiringPiSPI.c +++ b/wiringPi/wiringPiSPI.c @@ -44,9 +44,11 @@ //static const char *spiDev1 = "/dev/spidev0.1" ; static const uint8_t spiBPW = 8 ; static const uint16_t spiDelay = 0 ; -//https://datasheets.raspberrypi.com/cm4/cm4-datasheet.pdf +//https://datasheets.raspberrypi.com/cm4/cm4-datasheet.pdf SPI0-6, CS0-2 +//cm5-datasheet.pdf SPI0-5, CS depend on SPInumber, can be up to 4 +//spi0-4cs.dts extention for supporting CS0-4 const uint8_t WPI_MaxSPINumbers = 7 ; -const uint8_t WPI_MaxSPIChannels = 3 ; +const uint8_t WPI_MaxSPIChannels = 5 ; static uint32_t spiSpeeds [7][3] =