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

[architecture] Require setting SPI config in SpiDevice based drivers #820

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

chris-durand
Copy link
Member

@chris-durand chris-durand commented Feb 5, 2022

PR to move the discussion about a new API for setting the SPI configuration in SpiDevice based device drivers to a different place.

As a first step a new SpiConfiguration struct is added under architecture. Furthermore, modm::SpiDevice will take that config struct as a non-type template parameter and provides a default configureBus() function that applies the settings to the SPI master.

EDIT: this does not work as expected, the platform-specific SpiMaster driver won't accept modm::Spi::DataMode as an argument to SpiMaster::setDataMode(). modm::platform::SpiMaster::DataMode has to be used.

The SPI configuration is specified as a non-type template parameter to
`modm::SpiDevice`. `SpiDevice` will provide a `configureBus()` function
to apply the required mode settings for the device.
@chris-durand
Copy link
Member Author

The DataMode type is dependent on the peripheral driver. I have tried to make the config struct a template. Now gcc segfaults:

In file included from main.cpp:14:
modm/src/modm/driver/adc/ads816x.hpp:102:65: internal compiler error: Segmentation fault
  102 |     public modm::SpiDevice<SpiMaster, Ads816xSpiConfig<SpiMaster>>,
      |                                                                 ^~
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
scons: *** [/home/chris/modm/build/nucleo_f429zi/adc_ads816x/scons-release/main.o] Error 1
scons: building terminated because of errors.

😆

@chris-durand
Copy link
Member Author

I found the mistake, now without segfault.

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

Successfully merging this pull request may close these issues.

2 participants