OpenMV Feature: CAN Support for IMXRT and ALIF
Description
Add machine CAN module for ALIF and MIMXRT. RT driver is already done but needs to be ported to the new API: https://github.com/micropython/micropython/pull/12324
Code Size
No response
Implementation
I hope the MicroPython maintainers or community will implement this feature
Code of Conduct
Yes, I agree
alif: implement `machine.PWM` support
Summary
This PR adds machine.PWM support to the alif port. It uses the existing common machine bindings and implements the standard set of functionality.
It uses the UTIMER peripheral and makes PWM available on all pins that have an alt function connection to a UTIMER, which is 54 pins (see below about UTIMER11).
Testing
Tested on ALIF_ENSEMBLE and OPENMV_AE3, using an oscilloscope, fading LEDs and the existing tests/extmod_hardware/machine_pwm.py test.
Sample test code that works on both alif boards:
import time, machine
p = machine.PWM("LED_RED", invert=True)
p.freq(1000)
for _ in range(10):
for duty in range(101):
p.duty_ns(duty * 10000)
time.sleep_ms(10)
Trade-offs and Alternatives
This uses the UTIMER peripheral, but not UTIMER11 which is already in use by the HE core for its systick timer. So the following pins don't have PWM available because they need UTIMER11: P2_6, P2_7, P7_6, P7_7, P12_6, P12_7. For OPENMV_AE3, none of those pins are exposed to the user so they don't need PWM.
For the implementation I tried to use the Alif SDK driver, but it's quite limited so most of the code here uses direct register reads/writes.