Re: [RFC]PWM API Update

Andy Ross

Liu, Baohong wrote:
As for the unit for period and pulse width, I understand that both time
(micro-second) and clock cycles are popularly used. To cater for this,
the above-mentioned API will be expanded into two.

pwm_set_pin_usec(uint8_t pin, uint32_t period_usec, uint32_t pulse_usec)
pwm_set_pin_cycles(uint8_t pin, uint32_t period_cycles, uint32_t pulse_cycles)
When PWM is used correctly, this shouldn't make any difference at all
because the period will be much, much longer than the underlying clock (which
is the whole point).

Why bother with having two ways to do this when they're going to be
exactly equivalent in all but the weirdest apps? Just set them in
arbitrary units of "cycles". And if an application really, truly
needs to know the underlying cycle time of the hardware (which is
going to be device-dependent), give them an API like
"pwm_get_cycle_time()" which returns a cycle time in picoseconds or


Join to automatically receive all group messages.