Hi there,
I ve been struggling with spi myself so i have a basic understanding.
I am not quit sure what are you asking. If I am getting it wrong please reply and be more specific.
First of all i2c is more straight forward and "suitable" for sensor reading. I think its the best practice, but let's focus on spi.
1. Use LPCOpen examples for ssp (Are you using them?)
LPCOpen Software for LPC43XX|NXP
2. Inside main function there is a Board_SSP_Init funtion.
This function uses the Chip_SCU_PinMuxSet function to set spi pins.
3. According to datasheet (what model of dev board do u have?) you can do sth like this
The below code is from lpcopen ssp example for 4367 dev board.
if (pSSP == LPC_SSP1) {
Chip_SCU_PinMuxSet(0x1, 5, (SCU_PINIO_FAST | SCU_MODE_FUNC5)); /* P1.5 => SSEL1 */
Chip_SCU_PinMuxSet(0xF, 4, (SCU_PINIO_FAST | SCU_MODE_FUNC0)); /* PF.4 => SCK1 */
Chip_SCU_PinMuxSet(0x1, 4, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC5)); /* P1.4 => MOSI1 */
Chip_SCU_PinMuxSet(0x1, 3, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC5)); /* P1.3 => MISO1 */
}
So when i wanted to initialize and set SSP0 i added
else if (pSSP == LPC_SSP0) {
Chip_SCU_PinMuxSet(0x1, 0, (SCU_PINIO_FAST | SCU_MODE_FUNC5));
Chip_SCU_PinMuxSet(0x3, 0, (SCU_PINIO_FAST | SCU_MODE_FUNC4));
Chip_SCU_PinMuxSet(0x1, 2, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC5));
Chip_SCU_PinMuxSet(0x1, 1, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC5));
The above code and the lpcopen example is configured to auto toggle the cs line every sent frame. If you want a different functionality of chip select you should assign chip select to gpio pins so that you can manually manipulate them.
Ive tried both and worked.
You are welcome for any further details.
The below link is my feedback on how manual gpio chip select works
SSEL as Gpio for SSP/SPI