Hi everyone!
I would like to connect several SPI devices to my K60. Now I'm testing with the K60N512 tower module.
With a single device attached to the board, I use the SPI2_CS1 signal as chip select, using SPI_PUSHR_PCS(1 << 1) as a parameter for IO_IOCTL_SPI_SET_CS command; in this way I define a default SPI2 chip select signals enable mask for the driver (only the CS set to '1' in the mask will be used by the driver. Am I right?)
Now I would like to use a simple GPIO as chip select (i.e., TWRPI_GPIO1 on PTB8, TWRPI_GPIO2 on PTB9, ...).
Solution 1: don't set any CS for the SPI driver (using 0 as mask for IO_IOCTL_SPI_SET_CS?) and drive the GPIO manually just before and after the SPI operation (GPIO=0 -> read/write SPI -> GPIO=1)
Solution 2: set the GPIO as CS for the SPI driver. I want to use this one ... but how to do it?
I've read this post that seems to use the second solution, but I didn't understand wery well various things (how does the CS_MUX works? How to use it?)
Or maybe there's a simpler solution.
Any hint will be really appreciated!
Thanks!
Solved! Go to Solution.
Oh, I tested it. It seems we don't need to worry about it if we didn't change BSP. BSP sets and clears CS before and after write/read automatically.
I have the same question. How to use IO_IOCTL_SPI_SET_CS in ioctl()? Seems no exact example.
Oh, I tested it. It seems we don't need to worry about it if we didn't change BSP. BSP sets and clears CS before and after write/read automatically.