I have OMAP-L138 Experimenter Kit and I want to communicate with one of peripheral devices which is set on SPI 1 chip select 1 (there is also flash memory on SPI1 chip select 0).
I'm confused which registers should I use to select chip 1 ?
According to OMAP-L138 Technical Reference Manual, I should
set 4-pin mode
spi->SPIPC0 = SOMI | SIMO | CLK | SCS0; //4-pin mode with chip select
set 1 bit of SPIPC0.SCS0FUN to show that SPI_CS1 - is a SPI functional pin
SETBIT(spi->SPIPC0, 0x00000002);
set 17 bit of SPIDAT1.CSNR (It means that SPI_CS1 pin is driven high.)
spi->SPIDAT1 = 0; SETBIT(spi->SPIDAT1, 0x20000); //set 17th bit (corresponds to SPI_CS1)
set 1 bit of SPIDEF.CSDEF (It means that SPI_CS1 pin is driven high.)
spi->SPIDEF = 0; SETBIT(spi->SPIDEF, 0x00000002); //set 1st bit (corresponds to SPI_CS1) in CSDEF field
finally, before reading data from SPI1_CS1 device, I should set SPIDAT1.CSHOLD to held active chip select signal
SETBIT(spi->SPIDAT1,0x10000000); //set 28th bit which represents CSHOLD
Is that correct or I miss something? May be I also need do something with PINMUX5 (Pin Multiplexing Control 5 Register)? Thank you!
It seems that I have figured it out.
Setting up 4th bit in the register PINMUX5 - selects function SPI1_SCS[0]
EVMOMAPL138_pinmuxConfig(5, 0x00FFFFF0, 0x00111101); //enable chip select 1 EVMOMAPL138_pinmuxConfig(5, 0x00FFFFF0, 0x00111110); //enable chip select 0