broke out interrupts into isr.cpp

This commit is contained in:
true
2025-04-03 14:41:33 -07:00
parent b5bf65fead
commit 9413b9997a
3 changed files with 44 additions and 34 deletions

View File

@@ -0,0 +1,37 @@
#include <Arduino.h>
extern uint8_t run_rgb_program;
// TCB0 general interrupt
ISR(TCB0_INT_vect)
{
// reset the INTFLAGS - necessary on this series
uint8_t intflags = TCB0.INTFLAGS;
TCB0.INTFLAGS = intflags;
// in this program, this interrupt is only used for timing.
// we'll now return to executing loop()
}
// button interrupt
ISR(PORTA_PORT_vect)
{
// reset the INTFLAGS - necessary on this series
uint8_t intflags = PORTA.INTFLAGS;
PORTA.INTFLAGS = intflags;
// was our pin changed?
if (intflags & PIN3_bm) {
// is the pin low?
if (!digitalRead(PIN_PA3)) {
// start running a program if one isn't running already
if (!run_rgb_program) run_rgb_program = 1;
} else if (run_rgb_program == 2) {
// if we're running a program when the button is released (likely),
// then skip this interrupt
run_rgb_program++;
}
}
}