adafruit / Adafruit_Blinka

Add CircuitPython hardware API and libraries to MicroPython & CPython devices
https://learn.adafruit.com/circuitpython-on-raspberrypi-linux
MIT License
453 stars 340 forks source link

Some microcontroller definitions may be incorrect. #839

Open nopnop2002 opened 3 months ago

nopnop2002 commented 3 months ago

Board Name

microcontroller/rockchip

Steps

I've been looking into hardware PWM and found a few flaws.

Description

This is what the tutorial below says:

https://learn.adafruit.com/adding-a-single-board-computer-to-blinka/adding-more-features

To add natively supported PWM, you'll first need to add pwmOuts to your Chip file such as:

pwmOuts = (
  ((0, 0), PWM1),
  ((1, 0), PWM2),
  ((2, 0), PWM3),
)
The first parameter is a tuple and consists of the PWM chip number and the PWM channel of that chip.

The second parameter is the PWM pin and can be found by either a web search or referring to the manufacturer data.

But some chip definitions are not like that.

All PWM chip numbers and PWM channels are the same. https://github.com/adafruit/Adafruit_Blinka/blob/main/src/adafruit_blinka/microcontroller/rockchip/rk3399/pin.py#L225 https://github.com/adafruit/Adafruit_Blinka/blob/main/src/adafruit_blinka/microcontroller/rockchip/rk3568/pin.py#L238

It is a list instead of a tuple. https://github.com/adafruit/Adafruit_Blinka/blob/main/src/adafruit_blinka/microcontroller/rockchip/rk3566/pin.py#L186

PWM chip number and the PWM channel may be reversed https://github.com/adafruit/Adafruit_Blinka/blob/main/src/adafruit_blinka/microcontroller/rockchip/rk3588/pin.py#L288

Additional information

I don't have these boards, so I can't check the exact contents.