Set K60 GPIO as SPI chip select with MQX 3.8

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Set K60 GPIO as SPI chip select with MQX 3.8

ソリューションへジャンプ
1,019件の閲覧回数
il_mix
Contributor II

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!

0 件の賞賛
1 解決策
426件の閲覧回数
Xuejian
Contributor II

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.

元の投稿で解決策を見る

0 件の賞賛
2 返答(返信)
426件の閲覧回数
Xuejian
Contributor II

I have the same question. How to use IO_IOCTL_SPI_SET_CS in ioctl()? Seems no exact example.

0 件の賞賛
427件の閲覧回数
Xuejian
Contributor II

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.

0 件の賞賛