Embedded Rust Experiments: Is My STM32 MCU Running Fast?
nercury.github.io
nercury.github.io
(I wish such diagrams in datasheets would let you click on the appropriate blocks to jump directly to their registers and description sections.)
The original article even includes an example of using Cube to configure the clocks and then use those configurations together with Rust.
I agree that it isn’t ideal at all and kinda wonky. But more links in the datasheets would be nice.
Quite complex stuff.
Many gadgets later I trust the programmatic detection of external crystal use and appropriate PLL function. If you HAVE to know if the crystal fails you can use the CSS (Clock Security System) to generate interrupts in case you fall back to the internal oscillator.
This is why the PWM-out is useful -- it gives you a buffered, divided-down version of the crystal clock.
You can translate C line by line into identical rust at no cost except that you have to write "unsafe" once per fn. With the exception of macros, but rust's replacements there are just better.
Keeping everything in one language seems like a worthwhile reason not to use C to me.
Proprietary software for this is also available with superior UI and features, and I expect people serious about high-reliability embedded systems already use it.
Rust Nightly does have limited support for printing stack usage by function with -Z emit-stack-sizes, but I could not find anything for analysis of worst case stack usage in whole programs.
At the $15 end of the market, developers have a good chance of wanting to import code from other sources. For example, depending on the application, they might need an RTOS to provide multi-threading, FAT32 for an SD card, or a network stack with SSL implementation.
Often, the developer will want a 'lightweight' library, i.e. one intended for microcontrollers, and often this will be written in C.