AnsweredAssumed Answered

Set K60 GPIO as SPI chip select with MQX 3.8

Question asked by Massimo Cristofolini on Jun 6, 2012
Latest reply on Aug 9, 2012 by steven zhao

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!