Merge pull request #5613 from jepler/issue5418

clear out interrupt when freeing the timer
This commit is contained in:
Scott Shawcroft 2021-12-28 10:57:58 -08:00 committed by GitHub
commit 08d09ac493
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -33,6 +33,7 @@
#include "shared-module/rgbmatrix/RGBMatrix.h"
#include "src/rp2_common/hardware_pwm/include/hardware/pwm.h"
#include "src/rp2_common/hardware_irq/include/hardware/irq.h"
void *common_hal_rgbmatrix_timer_allocate(rgbmatrix_rgbmatrix_obj_t *self) {
// Choose a PWM channel based on the first RGB pin
@ -58,6 +59,8 @@ void common_hal_rgbmatrix_timer_enable(void *ptr) {
void common_hal_rgbmatrix_timer_disable(void *ptr) {
int8_t slice = ((intptr_t)ptr) & 0xff;
pwm_set_enabled(slice, false);
irq_set_enabled(PWM_IRQ_WRAP, false);
pwm_clear_irq(slice);
}
void common_hal_rgbmatrix_timer_free(void *ptr) {
@ -65,6 +68,8 @@ void common_hal_rgbmatrix_timer_free(void *ptr) {
uint8_t slice = value & 0xff;
uint8_t channel = value >> 8;
pwm_set_enabled(slice, false);
irq_set_enabled(PWM_IRQ_WRAP, false);
pwm_clear_irq(slice);
pwmout_free(slice, channel);
return;
}