This commit is to cherry-pick all fixes in the reverted commits to make future GPIO related fixes be as easy as possible.
These also contain small fixes which were in the reverted commits, but not really related to the issues for which this revert is meant.
Implemented a GPIO timer for the scheduler to schedule a GPIO state change.
These will be stopped async:
- Tone > 50 msec duration
- Longpulse and longpulse_ms
Also implemented a frequency parameter for the `pwm` command.