3 ms·
Really high level (as in visual programming) is actually the most optimal way to do some of the embedded programming - in particular when it comes to the setup/
by jemynine 3y ago
Really high level (as in visual programming) is actually the most optimal way to do some of the embedded programming - in particular when it comes to the setup/configuring part.
Setting up the clock tree, configuring pins/port functions, enabling peripheral clocks, interrupts (which ones and their priority levels), fixing erratas, etc.
All of that should at the end of the day come down to a couple loads/stores to some memory mapped registers, and these registers are usually "wide" where they contain N bits to set N things - so if you design a C (or rust) api something like this:
enable_clock(int clock_id);
You wont get optimal code for:
enable_clock(FOO);
enable_clock(BAR);
Because if FOO and BAR are both enabled by setting bit 3 and 7 in register X you get two loads, two bitwise or's and two stores when a single store with a single constant would have sufficed.
So fire up a GUI program that lets you click on "enable FOO, enable BAR", "set main clock to crystal oscillator at N MHz, enable PLL x4, etc", have that generate optimal code and go from there.
- uticus 3y agomakes sense. did you have in mind something like makecode[0], something else, or wishing for something that hadn't been invented yet? [0] https://makecode.adafruit.com/ https://makecode.adafruit.com/
- yakubin 3y agoOr you could write an API like set(FOO | BAR) and get the same benefit for comparably basically no cost (+ now you get nice diffs in git).
- uticus 3y agogood point on nice diffs. collaborative work (using git or other source control) is really why text is king. there's no good way to collaborate, compare, etc with a low-code format.
- jackieooh 3y agoProblem is that some registers have non-zero default values (swd debug pin functions for example) so the set() function would still need to do a read modify write operation which isn't the theoretically optimal code gen.
- yakubin 3y agoThen it’s a question of annotating this function with ALWAYS_INLINE and letting the compiler optimise it.