SPI Slave Driver

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
Tabulous
Posts: 509
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 17 times

SPI Slave Driver

Postby Tabulous » Thu Feb 25, 2016 3:37 pm

Hi Did this ever get implemented ?

There was alot of talk about it pre 3.0

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: SPI Slave Driver

Postby Giovanni » Thu Feb 25, 2016 4:44 pm

Not yet, I have no a clear idea of how a SSPI API should look like.

Giovanni

Tabulous
Posts: 509
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 17 times

Re: SPI Slave Driver

Postby Tabulous » Thu Feb 25, 2016 5:01 pm

Giovanni wrote:Not yet, I have no a clear idea of how a SSPI API should look like.

Giovanni


I'm trying to hack together something using the SPIv1 (on F103) setting up should not be an issue as just needed to let the lower level driver know its either Master or Slave, do this by adding another variable to the SPIConfig struct.


The issue will be around what does one do to wait for incoming data from SPI master ?


Do you have any ideas ? Would be nice a callback interface, so every reception from the SPI you get a callback where you can process the recieved data and then send back response message.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: SPI Slave Driver

Postby Giovanni » Thu Feb 25, 2016 5:25 pm

The problem is when you have a scenario when the incoming data is not of fixed size (you can hack the existing driver for that). Imagine having to implement an SD/MMC card in SPI mode, a driver should be flexible enough to allow something like that.

Giovanni

Tabulous
Posts: 509
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 17 times

Re: SPI Slave Driver

Postby Tabulous » Fri Feb 26, 2016 10:11 am

If the data is fixed length, then will the current driver able able to receive data and send data when set in slave mode ?

if so what is the best method / API calls i.e

spiExchange(&SPID1, 1, txbuf, rxbuf); /* Atomic transfer operations. */

or

spiReceive
spiSend

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: SPI Slave Driver

Postby Giovanni » Fri Feb 26, 2016 10:25 am

I know somebody did it, I have no details.

I think you can use any of those functions, depending on what you need to do.

Giovanni

Tabulous
Posts: 509
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 17 times

Re: SPI Slave Driver

Postby Tabulous » Fri Feb 26, 2016 2:21 pm

Giovanni wrote:I know somebody did it, I have no details.

I think you can use any of those functions, depending on what you need to do.

Giovanni


but i believe they used a raw interface not the dma one as used by the current driver.

So not sure if the dma will cause me issues

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: SPI Slave Driver

Postby Giovanni » Fri Feb 26, 2016 2:46 pm

Tabulous wrote:
Giovanni wrote:I know somebody did it, I have no details.

I think you can use any of those functions, depending on what you need to do.

Giovanni


but i believe they used a raw interface not the dma one as used by the current driver.

So not sure if the dma will cause me issues


It does: you need to know the transfer size beforehand.

Giovanni

Tabulous
Posts: 509
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 17 times

Re: SPI Slave Driver

Postby Tabulous » Fri Feb 26, 2016 2:56 pm

transfer size before hand is not an issue, lets say it is 10bytes everytime

then should the current dma based API calls like spiRecieve work ok ?

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: SPI Slave Driver

Postby Giovanni » Fri Feb 26, 2016 3:01 pm

It should, you will know for sure after testing it :)

Giovanni


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 3 guests