SPI_NO_CS flag in SPI_MODE seems to have no effect.
Posted: Tue Oct 17, 2017 6:10 pm
I'm not seeing any difference on how the chipselects operate when SPI_NO_CS is set/cleared. My intention is to configure the system to use GPIO chipselects. I need to leave the chipselect de-asserted for some transfers.
I'm running Raspbian (March 2017 Jessie) on a Pi 2 Model B V. 1.1.
I've included some simplified code for what I'm trying to do here:
I read through drivers/spi/spi-bcm2835.c, and I think the SPI_NO_CS flag might only work if the native hardware chipselect is used. I think I can come up with a workaround with some creative use of the cs_change and SPI_CS_HIGH flags, but I want to make sure I'm not missing something with how SPI_NO_CS is supposed to work before I go down that path.
I'm running Raspbian (March 2017 Jessie) on a Pi 2 Model B V. 1.1.
Code: Select all
# This is my config.txt:
dtparam=audio=on
disable_splash=1
gpu_mem=128
disable_audio_dither=1
lcd_rotate=2
dtoverlay=spi0-cs,cs0_pin=4,cs1_pin=0
dtoverlay=spi1-2cs,cs0_pin=12,cs1_pin=16
Code: Select all
// send byte WITH CHANGING CHIPSELECT
mode = SPI_MODE_0;
ioctl(fds[0], SPI_IOC_WR_MODE, &mode) < 0)
memset(&spi, 0, sizeof(spi));
spi.tx_buf = (unsigned long) &outmessage;
spi.rx_buf = (unsigned long) &inmessage;
spi.len = 1;
spi.delay_usecs = 0;
spi.speed_hz = speed;
spi.bits_per_word = bpw;
spi.cs_change = 0;
ioctl(fds[0], SPI_IOC_MESSAGE(1), &spi);
// send byte WITHOUT CHANGING CHIPSELECT
mode = SPI_MODE_0 | SPI_NO_CS;
ioctl(fds[0], SPI_IOC_WR_MODE, &mode) < 0)
memset(&spi, 0, sizeof(spi));
spi.tx_buf = (unsigned long) &outmessage;
spi.rx_buf = (unsigned long) &inmessage;
spi.len = 1;
spi.delay_usecs = 0;
spi.speed_hz = speed;
spi.bits_per_word = bpw;
spi.cs_change = 0;
ioctl(fds[0], SPI_IOC_MESSAGE(1), &spi);