microbuilder / LPC11U_LPC13U_CodeBase

Open source code base for ARM Cortex M3 LPC1347 or Cortex M0 LPC11U37/LPC11U24 MCUs
Other
55 stars 38 forks source link

SSP blocks are missing CS/SSEL initialization #2

Closed ynezz closed 11 years ago

ynezz commented 11 years ago

Hi,

how is CS/SSEL supposed to work on SSP0/SSP1? As SSEL isn't configured now in the init() functions I assume, that it's responsibility of the user of the SSP code?

microbuilder commented 11 years ago

SSEL/CS should always be separate from the SPI code in my opinion because the pins are dedicated one per SPI device. If I have 3 SPI devices connected, I will have one SSEL/CS pin per device, and as I use each device I assert its CS line. I have no way of knowing how many SPI devices are connected or where they're connected, so it's the responsibility of the driver to assert and de-assert CS whenever needed (just before and immediately after the SPI transaction).

The only case where SSEL/CS should be managed in the SPI driver is if you are using SPI in slave move, and it is communicating with another MCU in SPI master. This is why there is a dedicated CS pin on the MCU with an interrupt, etc.