6 years, 10 months ago.

SPI buffered communication - LPC1768

I need a buffered SPI communication where you have a FIFO buffer for tx and you can check whether buffer is full or not. I do not understand why the member function transfer() does not work for me, the IDE states that such member function is not found. Is that related to the hardware, i.e. LPC1768? Any other suggestion to get similar library for buffered SPI communication?

If you are using an rtos you can use a queue or mail and handle writes one at a time. You have one thread dedicated to writing to spi and it blocks waiting for a new mail message. Helper function in the same module is called by other threads to put items into the mailbox. Mailbox can contain as many slots as you need. Here's 16. I'm writing to an sd card here, so need file name and message string to put into the mailbox.

typedef struct {
    char         name[13];       // File type we are writing to
    char        message[100];    //
} mail_t;

Mail<mail_t, 16> mail_box;

Also, I've not used it, but you can take a look at the CircularBuffer class in mbed.

posted by Graham S. 31 May 2017
Be the first to answer this question.