Thanks to visit codestin.com
Credit goes to github.com

Skip to content

clear out interrupt when freeing the timer #5613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -58,13 +59,17 @@ 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) {
intptr_t value = (intptr_t)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;
}