In hindsight, I probably should have organized the AVR code this way.