Skip to content

PWM interface not consistent across implementations #5441

Description

@cibomahto

The PWM interface appears to be only partially consistent across the various machine targets that implement it. I did a survey of the public interfaces for each of the implementations:

Image

tinygo pwm spelunking.ods

Across implementations, there are some inconsistencies:

  • The name of the PWM object type is not consistent across implementations. It is variously: timerType, PWM, pwmGroup, TCC, TIM
  • The name of the exported PWM objects is not consistent. It is variously: Timerx, PWMx, TCCx, TIMx

And in specific implementations, there are some issues as well:

  • machine_generic.go: Missing SetPeriod(), Period(), Counter(), and SetInverting(). Should probably be added since they seem to be part of the 'standard' interface
  • machine_rp2.go: The PWM type is not exported, so references to the exported PWM objects cannot be stored in, for example, a project pin initialization list, without extra work
  • machine_atsamd21.go, machine_atsamd51.go: Missing Period()
  • machine_esp32xx_pwm.go: Missing SetPeriod(), Period(), and Counter()
  • machine_nrf52xxx.go: Missing Period() and Counter()
  • machine_stm32_tim.go: Missing Period(). Counter() is mis-named Count()

It's also not clear to me that there is a written standard for the PWM interface. I attempted to document it here: tinygo-org/tinygo-site#505

Assuming that it is desirable to regularize these, I would be happy to help out with any of the platforms that I have dev hardware for (I think everything except atsamdxx).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions