thanks all, i did a little google (re)search on the topic and stumbled into many articles
apparently the most common charging strategies for lithium ion batteries is constant current below 4.2v and constant voltage 4.2v at the end.
there are quite many articles around the internet
https://en.wikipedia.org/wiki/Lithium-i ... _discharge
https://www.electronics-notes.com/artic ... arging.php
https://www.eetimes.com/current-voltage ... -charging/
https://www.eetimes.com/current-voltage ... ng-part-2/
apparently a large influence factor on the durability and hence safety of the battery is the temperature !
charging at 1 C is actually pretty high it translates to 1 ampere for 1 hour for a 1 AH battery.
i think more commonly currents are lower for the average usb connection more like 250-500 mA (there are many better chargers these days that can supply in the ranges of amps, most likely some buck converters) and for small solar cells / panel getting 100-500 mA is good on a sunny day.
hence with solar cells we'd get an coincidental 'constant current' charging simply due to the limited solar power that can be delivered
what would be somewhat curious is can pwm mimic the constant current, constant voltage charging that's typically done with possibly analog circuits.
if that pwm CC CV charging is possible, stm32 can be its own li-ion battery charger with just a single mosfet say from a usb power source. i think the main aim of the CC charging phase is to limit the heating of the battery, that can be done by simply reducing the pwm duty cycle
apparently, this isn't really all that new, some have been there done that
https://www.embedded.com/managing-devic ... odulation/
interestingly found an app note from ST
https://www.st.com/resource/en/applicat ... ronics.pdf
in the proposed circuit, it is basically a buck converter, driven by the mcu using pwm, but it is quite interesting
there is actually some incentive for doing all these, the mcu is both the charger and columb counter, it manages the complete state of the battery and can give indications of the battery state and even estimated power remaining and estimated charging time, while still doing other things