stm32-rs / stm32g0xx-hal

Peripheral access API for STM32G0 series microcontrollers
Apache License 2.0
73 stars 51 forks source link

Implemented tim3 as pwm for stmg070. Added set_compare_mode for pwm output #81

Closed smeenka closed 2 years ago

dotcypress commented 2 years ago

Do we really want a new trait PwmPinMode here? Maybe we can move set_compare_mode to PwmPin<$TIMX, $CH> implementation?

@andresv any thoughts on this?

andresv commented 2 years ago

@dotcypress, if it is under struct PwmPin then we cannot use it in generic functions. Currently we can do:


fn set_mode<P: PwmPinMode>(pin: P) {
   p.set_compare_mode(OutputCompareMode::Frozen);
}
smeenka commented 2 years ago

The name for the trait PwmPinMode is too specific. What is needed is a trait for all functions not specified in the hal trait. This requirement is not only for this device but very generic. So I propose to have a DeviceIoCtl or IoCtl trait for each device, containing the device specific api functions not in the hal. A bit like the ioctl function in the posix interface

dotcypress commented 2 years ago

@andresv yeah, make sense!

@smeenka I think DeviceIoCtl or IoCtl is too abstract, let stick with PwmPinMode then. Could you fix formatting issue and we good to merge this PR

smeenka commented 2 years ago

No change after cargo fmt in my feature branch, so can you tell me the formatting issue?

dotcypress commented 2 years ago

@smeenka cargo fmt sometimes isn't working inside a macro. I will fix formatting manually. Thant you!