Comments (8)
Thanks for the response, yes something like that but in my case the number of combinations are close to 80 and I have at least 5-6 peripherals so the total number of permutations are very high. I was thinking more like
auto config = ConfigResolver::load()
auto spi = Spi::create(config.spi.interface, config.spi.mosi, config.spi.miso, config.spi.sck)
Apparently all the pin assignments are passed as template variables which is compile time only rather than runtime and I don't know if there's any way to get around this 🤔
from modm.
You mean something like this?
if (board_A) {
SpiMaster5::connect<GpioA5::Mosi, GpioA6::Miso, GpioA7::Sck>();
SpiMaster5::initialize<BoardA::SystemClock, 5_MHz>();
}
else if (board_B) {
SpiMaster5::connect<GpioB5::Mosi, GpioB6::Miso, GpioB7::Sck>();
SpiMaster5::initialize<BoardB::SystemClock, 1_MHz>();
}
else if (board_C) {
SpiMaster3::connect<GpioC5::Mosi, GpioC6::Miso, GpioC7::Sck>();
SpiMaster3::initialize<BoardC::SystemClock, 20_MHz>();
}
The connect methods compile into very compact code (just constants basically), including a few different configurations like this will probably still be less code than a fully dynamic computation.
from modm.
You can of course just call GpioA5::setAlternateFunction(id);
, which is what the connect function compiles down to, but you loose all of the compile-time sanity checks. The AF mapping is pretty random too for STM32.
from modm.
There’s no runtime API for this I’m afraid. I believe mbed has such an API, but it’s completeness may be lacking.
However, you can take a look at the modm:platform:gpio module to see how we transform the data from modm-devices into compile time structures, and perhaps transform it into a runtime friendly format instead. Or just generate one massive switch case with all permutations ;-p
from modm.
You can even use modm-devices on it’s own and extend another HAL with that data. That was the whole point of separating modm (the C++ library) from modm-devices after all.
from modm.
Thanks for the tips, I'll take a look and see what can I do. Extending from modm-devices
sounds interesting, wonder how complicated would that be 🤔
from modm.
Here’s an introductory blog post: https://blog.salkinium.com/modm-devices/#using-device-files
Haven’t gotten around to writing more though.
from modm.
I'm closing this since its out-of-scope for modm, but feel free to continue posting questions/issues here about using modm-devices.
from modm.
Related Issues (20)
- Unittest failing fdcan_test on Nucleo-G474RE
- monochrome graphic display won't compile - vector ? HOT 4
- [fiber] multi stack size ? HOT 5
- SAMD51/SAME5x cache not enabled? HOT 5
- STM32G0B1 currently black listed HOT 2
- Placement of data section in wrong memory for STM32H7 HOT 1
- Segmentation fault when building documentation files HOT 3
- Heap not implemented. HOT 6
- Most UART drivers don't implement the full `modm::Uart` interface
- External interrupt causes immediate reset on Arduino Mega 2560 HOT 1
- STM32H7 Flash Support? HOT 5
- vscode json generation HOT 2
- CI docs all job is broken
- Docs Page, Search Function is Intermittent? HOT 6
- OpenOCD cannot configure TPIU/SWO on STM32H7 HOT 5
- Error when trying to compile example on M1 mac HOT 2
- Using SPI on Linux/Darwin target HOT 3
- CMake usage in recommended project structure HOT 3
- lbuild fails when relative paths are on different Windows drives HOT 1
- Fibers not implemented on ARM64
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modm.