Creating Alternate implementation of an existing module #833
Replies: 2 comments 2 replies
-
You should upstream everything, even if it's not perfect or has a different API from the rest, so that other people can later learn from it and maybe refactor it into a new better API. Most of modm was built that way, since there are way too many devices that you can know in enough detail. The "official" way to handle this is to make lbuild generate different files for the same module name by switching on the
I don't know the SAM hardware at all, so I just let people design it how they see fit with the idea to later look at the differences and refactor into a shared API. This is how we did it for the STM32 RCC peripheral, which is also very different on each family.
You can switch on the
I'm aware that our compile flags being global and thus also applying to So feel free to change things, if the changes are incompatible you can switch them via an lbuild option. |
Beta Was this translation helpful? Give feedback.
-
The GCLK hardware is structurally fairly consistent among devices. It is present in about half of all SAM controllers. What is different is which clock sources and peripheral clock sinks are available. This information has to be extracted from device data and CMSIS headers. Also, registers often have inconsistent naming but jinja templates can fix that. The GCLK peripheral consists of clock generators which receive a clock signal and optionally divide it. For every peripheral there is a mux to select which clock generator it connects to: I have started with getting SAM E5x devices supported and have been facing exactly the same issues as you with the L2x devices. The current GCLK driver code makes a lot of choices that should be left to the user and hard codes information that is different for each SAM device. I will most likely continue with the SAME5x support this weekend and implement parsing the GCLK clock sources and peripheral channels from manufacturer provided device data. That way it should be easier to make a portable low-level API for configuring the GCLK. Furthermore, I am working on a common API for enabling the synchronous APB peripheral clocks for both devices with GCLK/MCLK and those with PMC. This will be very similar to the modm STM32 API that has |
Beta Was this translation helpful? Give feedback.
-
I've been in and out over the past few years, doing some of the initial modm-devices work on SAM processors. finally the project I've been circling has actual resources and I am adding the processor for the project so we can use modm! It's the SAML10/SAML11 m23 chip.
All that being said I have UART/GCLK/GPIO/etc all working, but I would like to maybe make an alternative implementation for a few things. I would love to push those new versions upstream, so i want to do it right.
Is there a good example of how to handle this? It seems easiest to keep it separate for now, since in the end it will either stay separate or get merged maybe some help from the community.
Examples
GCLK
The current SAM implementation is great, but makes a lot of assumptions about how each GCLK is used, and what the prescalers are. I would like to make an implementation that models the clock tree config tool in ASF4. The goal would be able to set up the clock in arbitrary ways, but with expressive coding and the compile time checking we expect. This could also make a code generator as mentioning in #715 easier to do.
CMake
The current CMake implementation is designed well for a self contained binary. We kind of want to package the HAL/BSP we generate as a library that we can use from other projects using CMake
FetchContent
etc. Leave most of the compiler flags that aren't absolutley required, etc to the consuming project. Make the linker script a target to it can be used or not.M23 differences
not really an existing module, but similar question. A lot of peripheral code is shared with other SAM chips. But some of the GCLK stuff the input file ended up with pretty much
Beta Was this translation helpful? Give feedback.
All reactions