mbed seminar Eindhoven and SPI suggestions

20 Nov 2010

Simon and others,

Thanks for a great workshop in Eindhoven today! Will you post the picture you took at the beginning?

We talked briefly about improvements to the SPI Slave interface. In the first place it is important to know if the read() function is blocking, meaning that these will wait until there is data to read.
The same is true for the reply() function. Since the SPI Slave uses the SSP controller, it has an 8-word FIFO, so before doing the reply() you must find out if the FIFO has enough room. I have now solved it with the following code macro, with the libraries from DriverLibrary (note that the code below works only on SSP1 on pins p11, p12, p13, p14).

#include "lpc17xx_ssp.h" // from http://mbed.org/users/igorsk/programs/DriverLibrary/601ro
// macros for managing the SSP interface SSP1 only!
#define tx_fifo_notfull  (SSP_GetStatus(LPC_SSP1, SSP_STAT_TXFIFO_NOTFULL))
#define tx_fifo_empty    (SSP_GetStatus(LPC_SSP1, SSP_STAT_TXFIFO_EMPTY))
#define rx_fifo_notempty (SSP_GetStatus(LPC_SSP1, SSP_STAT_RXFIFO_NOTEMPTY))
#define rx_fifo_full     (SSP_GetStatus(LPC_SSP1, SSP_STAT_RXFIFO_FULL)
It would be nice to have this functionality in the standard library,

Meindert

 

21 Nov 2010

I was a bit stupid and then asked myself why the example above worked, but not perfect. The SSP interface on P11 to P14 is SSP0 and nOT SSP1!

Meindert