Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I run an SPI controller in slave mode? #107

Open
robbie01 opened this issue Apr 8, 2020 · 1 comment
Open

How do I run an SPI controller in slave mode? #107

robbie01 opened this issue Apr 8, 2020 · 1 comment

Comments

@robbie01
Copy link

robbie01 commented Apr 8, 2020

I am currently working on a design involving an STM32F042 microcontroller that involves the use of both SPI controllers, one operating as a master and one operating as a slave. While this HAL does offer facilities for driving an SPI controller in master mode, I do not see any code for abstracting over a slave controller. How would I go about that, if I were to use this library to handle other aspects of the microcontroller?

@therealprof
Copy link
Member

@robbie01 👋

As you've noticed there's currently no code to implement the slave part. My SPI slave knowledge is unfortunately rather limited so I'm not sure that we already have the necessary parts in embedded-hal to produce a generic abstraction. That would problably the first thing to check.

The second thing would be the slave implementation. We can probably refactor some of the initialisation code of the master out to more generic functions and then have a separate init function for the slave implementation like spiX_slave() which provides either a generic abstraction or a custom one (depending on the outcome of the first step above) to receive data a word at a time.

The third step would probably be making it really efficient by using a DMAed buffer.

If you feel comfortable taking a stab at that I'd be happy to support you along the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants