>Hmm .. embedded is mostly the domain of hardware guys, writing firmware using -O0 as a compiler option.
Do not expect applause here
Have no idea what you are talking about, I use nothing but -Os. I'm not sure what domain I'm in, or what domain I'm supposed to be in, but I seem to be dealing with hardware and software and probably am in no single category.
The links should already have that info-
-Os -mcpu=cortex-m0plus -std=c++14
Another variation, where the pin properties can be used in the constructor, and in any order or not at all-
https://godbolt.org/z/Xs39xDGpio<PC6, LOWISON> led(SPEEDHI, OUTPUT);
Gpio<PA0, LOWISON> sw1(INPUT, PULLUP);
Gpio<PA1> led2(OUTPUT);
Gpio<PA2> analog1;
Gpio<PA3, LOWISON> pump(ODRAIN, PULLUP, OUTPUT);
The 2 template parameters need to remain as template parameters (second has a default value) as that info is needed in the functions (the template parameters are carried around wherever the var name goes, so no storage of that info is needed).
If you miss all the macro work, in c++ you can replace all that fun with a different fun- templates.
...and another variation, where only one template parameter needed-
https://godbolt.org/z/JVJVXythe pin is the only template parameter, and each pin has an alternate name with L added to it for LOWISON-
Gpio<PC6L> led(SPEEDHI, OUTPUT);
Gpio<PA0L> sw1(INPUT, PULLUP);
Gpio<PA1> led2(OUTPUT);
Gpio<PA2> analog1;
Gpio<PA3L> pump(ODRAIN, PULLUP, OUTPUT);
The LOWISON is needed for the on/off/isOn/isOff functions, so you do not need to keep track of what value is on/off. When created, you specify whether low is on or not, and when used you just need to do on()/off() and no longer need to know what on/off actual values are-
led.on(); //whether that is high/low, don't need to know as it was already specified at 'led' creation (PC6L)