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

Faster hardware SPI writes on SAMD #77

Merged
merged 3 commits into from
Feb 2, 2022
Merged

Conversation

monroewilliams
Copy link
Contributor

In the Adafruit_SPIDevice class, when running on the SAMD architecture in the hardware SPI case, use the SPIClass::transfer(txbuf, rxbuf, count, block) method when writing instead of looping over individual bytes.

This makes use of DMA and is noticeably faster.

…e in the hardware SPI case, use the SPIClass::transfer(txbuf, rxbuf, count, block) method when writing instead of looping over individual bytes.

This makes use of DMA and is noticeably faster.
@monroewilliams
Copy link
Contributor Author

monroewilliams commented Jan 14, 2022

Hmm... I see the automated build is failing, and it looks like the transfer function I'm calling doesn't exist?
I'm building this under PlatformIO using the current default version of the atmelsam core (looks like 7.0.0 according to their versioning), and not seeing this failure locally.

@ladyada
Copy link
Member

ladyada commented Jan 14, 2022

################################################################################ SWITCHING TO arduino:samd:arduino_zero_native Installing arduino:samd ✓ arduino:samd 1.8.12 1.8.12 Arduino SAMD Boards (32-bits ARM Cortex-M0+) ################################################################################ i2c_address_detect.ino ❌

arduino samd zero (non-adafruit samd) is not compiling

@monroewilliams
Copy link
Contributor Author

Gotcha. That's this core, right? https://github.com/arduino/ArduinoCore-samd

There doesn't appear to be an analogue to void transfer(const void* txbuf, void* rxbuf, size_t count, bool block); in that core, so I guess I'll just need to disable this optimization for that case.

I don't see a preprocessor define I can use to specifically check for the presence of that method. I assume the check I'll need to make is that we're using the Adafruit core.

What's the most appropriate #if to use for that? Is there some sort of versioning #define that can tell cleanly which core is being used?

It looks like I could differentiate that it's using the Adafruit version of SPI.h with an ugly hack like #if defined(_ADAFRUIT_ZERODMA_H_), but that just seems wrong.

@ladyada
Copy link
Member

ladyada commented Jan 21, 2022

yeah i think you will have to 'fake' it with an #ifdef and just comment why - we added some rough DMA support but we aren't caught up on the arduino core so we weren't able to PR the change!

@ladyada ladyada merged commit 512fde0 into adafruit:master Feb 2, 2022
@ladyada
Copy link
Member

ladyada commented Feb 2, 2022

thanks! will try it

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

Successfully merging this pull request may close these issues.

None yet

2 participants