For the developers who are using both Teensy and STM32duino boards, it would be nice if the two libraries would be compatible. In this case, the PWM frequency is already managed by Teensy library, and it would be nice if the support is added using the same syntax and functionality.

One problem I can see is if anyone changes the frequency, the value that needs to be passed to pwmWrite would change, as the overflow value may no longer be 65535 (max unsigned 16 bit number)

So for maximum conpatibility I would need to change pwmWrite as well as analogWrite

However I'm tempted to leave pwmWrite alone and just modify analogWrite so that it reads the current overflow value using timer_get_reload()

And... I've also realised we don't currently support

analogWriteResolution()

This would not be that hard to implement, except we'd need a global to store this setting, so that analogWrite can determine the divisor value that is required.

Also...

In terms of whether we follow the teensy or ESP8266 API.

The ESP8266 API causes the least confusion, as we could initialise all the timers with the same prescaler and overflow at in the same function.

We could also implement the Teensy style API, e.g. its a different function signature, but if people tried to set 2 pins which use the same timer with different frequencies, they may not get what they expect