https://developer.mbed.org/users/abouillot/code/PwmReader/#ebc39fb22351