initial commit

This commit is contained in:
2025-12-07 15:19:56 -07:00
commit 4664add5db
5 changed files with 65 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
#include <stdbool.h>
#include <stdint.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include "config.h"
uint32_t ms_since_boot = 0;
ISR(TIM1_COMPA_vect)
{
ms_since_boot++;
}
void setupio(void) {
// Set port A to inputs
DDRA = 0x00;
PORTA |= PORTA0 | PORTA1; // pull-up
// Set port B0 to output
DDRB = 0x01;
}
void setup_clock(void) {
OSCCAL = OSCILLATOR_CALIBRATION;
TCCR1B = 0x09;
OCR1A = 1000;
TIMSK1 = 0x02;
}
bool button_pressed(uint8_t pin) {
return (PINA & (1 << pin)) == 0;
}
int main() {
setupio();
setup_clock();
sei();
while(true) {
uint32_t sec = ms_since_boot / 1000;
if(sec % 2 == 0) {
PORTB = 1;
} else {
PORTB = 0;
}
}
}