Works on both platforms now

This commit is contained in:
Neale Pickett 2013-04-01 21:17:18 -06:00
parent dccbe8a47e
commit 5ac5333879
5 changed files with 23 additions and 7 deletions

View File

@ -1,4 +1,4 @@
ARCH = ti ARCH = avr
include Makefile.$(ARCH) include Makefile.$(ARCH)

View File

@ -1,11 +1,15 @@
PROG = main PROG = main
MCU = atmega328p
CC = avr-gcc CC = avr-gcc
CFLAGS += -mmcu=atmega328p CFLAGS += -mmcu=$(MCU)
CFLAGS += -DF_CPU=16000000UL CFLAGS += -DF_CPU=16000000UL
CFLAGS += -Os CFLAGS += -Os
CFLAGS += -w CFLAGS += -w
LDFLAGS += -mmcu=$(MCU)
AVDFLAGS += -p m328p AVDFLAGS += -p m328p
AVDFLAGS += -c arduino AVDFLAGS += -c arduino
AVDFLAGS += -b 115200 AVDFLAGS += -b 115200
@ -23,8 +27,11 @@ $(PROG).hex: $(PROG)
main: main.o avr.o main: main.o avr.o
#main.o: avr.h
#avr.o: avr.h
clean: clean:
rm -f $(PROG) *.hex .upload rm -f $(PROG) *.o *.hex .upload

2
avr.h
View File

@ -9,6 +9,8 @@
#define JIFFIES_PER_SECOND 50 #define JIFFIES_PER_SECOND 50
#define JIFFY_uS (1000000 / JIFFIES_PER_SECOND) #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 mode(on) bit(PORTD, _BV(0), on)
#define sin(on) bit(PORTD, _BV(1), on) #define sin(on) bit(PORTD, _BV(1), on)
#define sclk(on) bit(PORTD, _BV(2), on) #define sclk(on) bit(PORTD, _BV(2), on)

13
main.c
View File

@ -1,7 +1,15 @@
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include "ti.h"
#include <avr/io.h>
#include <util/delay.h>
#if defined (__AVR_ATmega328P__)
# include "avr.h"
#else
# include "ti.h"
#endif
// Number of shift registers in your scoreboard // Number of shift registers in your scoreboard
// If you want scores to go over 199, you need 8 // If you want scores to go over 199, you need 8
@ -40,9 +48,6 @@ enum {
#define BTN_LEFT _BV(1) #define BTN_LEFT _BV(1)
#define BTN_RIGHT _BV(0) #define BTN_RIGHT _BV(0)
#define bit(pin, bit, on) pin = (on ? (pin | bit) : (pin & ~bit))
const uint8_t seven_segment_digits[] = { const uint8_t seven_segment_digits[] = {
0x7b, 0x60, 0x37, 0x76, 0x6c, 0x5e, 0x5f, 0x70, 0x7f, 0x7e 0x7b, 0x60, 0x37, 0x76, 0x6c, 0x5e, 0x5f, 0x70, 0x7f, 0x7e
}; };

2
ti.h
View File

@ -8,6 +8,8 @@
#define JIFFIES_PER_SECOND 60 #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 mode(on) bit(P1OUT, _BV(0), on)
#define sin(on) bit(P1OUT, _BV(1), on) #define sin(on) bit(P1OUT, _BV(1), on)
#define sclk(on) bit(P1OUT, _BV(2), on) #define sclk(on) bit(P1OUT, _BV(2), on)