diff --git a/Makefile b/Makefile index 744cd7a..85a736e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -ARCH = ti +ARCH = avr include Makefile.$(ARCH) diff --git a/Makefile.avr b/Makefile.avr index e5a39d2..bcb8009 100644 --- a/Makefile.avr +++ b/Makefile.avr @@ -1,11 +1,15 @@ PROG = main +MCU = atmega328p + CC = avr-gcc -CFLAGS += -mmcu=atmega328p +CFLAGS += -mmcu=$(MCU) CFLAGS += -DF_CPU=16000000UL CFLAGS += -Os CFLAGS += -w +LDFLAGS += -mmcu=$(MCU) + AVDFLAGS += -p m328p AVDFLAGS += -c arduino AVDFLAGS += -b 115200 @@ -23,8 +27,11 @@ $(PROG).hex: $(PROG) main: main.o avr.o +#main.o: avr.h +#avr.o: avr.h + clean: - rm -f $(PROG) *.hex .upload + rm -f $(PROG) *.o *.hex .upload diff --git a/avr.h b/avr.h index a248e20..66fd12d 100644 --- a/avr.h +++ b/avr.h @@ -9,6 +9,8 @@ #define JIFFIES_PER_SECOND 50 #define JIFFY_uS (1000000 / JIFFIES_PER_SECOND) +#define bit(pin, bit, on) pin = (on ? (pin | bit) : (pin & ~bit)) + #define mode(on) bit(PORTD, _BV(0), on) #define sin(on) bit(PORTD, _BV(1), on) #define sclk(on) bit(PORTD, _BV(2), on) diff --git a/main.c b/main.c index 9d08e54..0d774ca 100644 --- a/main.c +++ b/main.c @@ -1,7 +1,15 @@ #include #include #include -#include "ti.h" + +#include +#include + +#if defined (__AVR_ATmega328P__) +# include "avr.h" +#else +# include "ti.h" +#endif // Number of shift registers in your scoreboard // If you want scores to go over 199, you need 8 @@ -40,9 +48,6 @@ enum { #define BTN_LEFT _BV(1) #define BTN_RIGHT _BV(0) - -#define bit(pin, bit, on) pin = (on ? (pin | bit) : (pin & ~bit)) - const uint8_t seven_segment_digits[] = { 0x7b, 0x60, 0x37, 0x76, 0x6c, 0x5e, 0x5f, 0x70, 0x7f, 0x7e }; diff --git a/ti.h b/ti.h index 8323788..c6bf051 100644 --- a/ti.h +++ b/ti.h @@ -8,6 +8,8 @@ #define JIFFIES_PER_SECOND 60 +#define bit(pin, bit, on) pin = (on ? (pin | bit) : (pin & ~bit)) + #define mode(on) bit(P1OUT, _BV(0), on) #define sin(on) bit(P1OUT, _BV(1), on) #define sclk(on) bit(P1OUT, _BV(2), on)