stm32f1xx-hal
stm32f1xx-hal copied to clipboard
Remove the tuple based return in the Pwm subsystem
The current implementation of the Pwm subsystem returns a tuple, one entry in the tuple for each channels/pins that were configured. This leads to calls such as
pwm_channels.1.enable();
In this call it is not clear if the 1
is the first, second, third, or fourth channel in the timer. It is dependent on the way upon the pwm
method is called.
I propose that the pwm
method instead return a fixed structure with the four possible enumerated channels. For channels that are not configured, they could take on the value of NoChannel
and channels that are configured can be instances of a PwmChannel
.
Once this change is in place, the Pwm
trait implementation should be adjusted to do all operations on the configured channels to reduce code duplication.