adafruit / Adafruit_Protomatter

RGB matrix library for Arduino
66 stars 23 forks source link

rp2040: circuitpython: Actually make dynamic PWM allocation work #36

Closed jepler closed 3 years ago

jepler commented 3 years ago

My initial testing was always done with PWM slice 0, so it didn't matter that _PM_pwm_slice was never set to a nonzero value. Limor tested with the first pin as GPIO6, which led to use of slice 3 and after that everything got sad really quickly.

Since Arduino doesn't use _PM_pwm_slice now, this means that _PM_timerInit's implementation becomes unshared; because _PM_timerInit nees to refer to _PM_PWM_ISR or _PM_timerISR, those newly require forward (static) declarations. That makes this change look bigger than it is. The only "real" change is intended to be something like

 #ifdef CIRCUITPYTHON
 void _PM_timerInit(void *tptr) {
 #if _PM_CLOCK_PWM
+  _PM_pwm_slice = (int)tptr & 0xff;

With this iteration of the code, I successfully ran CircuitPython in these configurations:

... across resets, typing in the REPL, etc.