broke out interrupts into isr.cpp
This commit is contained in:
37
fw/HackSpaceCon/src/isr.cpp
Normal file
37
fw/HackSpaceCon/src/isr.cpp
Normal 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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user