MCU = atmega32u4
FORMAT = ihex
TARGET = daqi
-SRC = $(TARGET).c usb_serial.c
+SRC = $(TARGET).c usb_serial.c
ASRC =
-OPT = s
+OPT = 2
+PORT=/dev/ttyACM0
# Name of this Makefile (used for "make depend").
MAKEFILE = Makefile
CSTANDARD = -std=gnu99
# Place -D or -U options here
-CDEFS =
+CDEFS = -DF_CPU=16000000
# Place -I options here
CINCS =
CDEBUG = -g$(DEBUG)
-CWARN = -Wall -Wstrict-prototypes
-CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
+CWARN = -Wall -Wstrict-prototypes
+CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wl,--relax
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
-CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA)
+CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA) $(CTUNING)
#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
# Programming support using avrdude. Settings and variables.
-AVRDUDE_PROGRAMMER = dragon_isp
+AVRDUDE_PROGRAMMER = dragon_jtag
AVRDUDE_PORT = usb
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
# Uncomment the following if you do /not/ wish a verification to be
# performed after programming the device.
-#AVRDUDE_NO_VERIFY = -V
+AVRDUDE_NO_VERIFY = -V
# Increase verbosity level. Please use this when submitting bug
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
program: $(TARGET).hex $(TARGET).eep
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
-program_dfu: $(TARGET).hex
- dfu-programmer $(MCU) erase && dfu-programmer $(MCU) flash $(TARGET).hex && dfu-programmer $(MCU) start
-
+size:
+ $(SIZE) -C --mcu=$(MCU) $(TARGET).elf
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
COFFCONVERT=$(OBJCOPY) --debugging \
>> $(MAKEFILE); \
$(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
-.PHONY: all build elf hex eep lss sym program coff extcoff clean depend
+.PHONY: all build elf hex eep lss sym program coff extcoff clean depend program_bootloader program_arduino
+
+program_bootloader: all
+ dfu-programmer $(MCU) erase && dfu-programmer $(MCU) flash $(TARGET).hex && dfu-programmer $(MCU) start
+program_arduino: all
+ avrdude -patmega32u4 -cavr109 -P$(PORT) -b57600 -D -Uflash:w:$(TARGET).hex:i
#include <avr/io.h>
#include <usb_serial.h>
-#define NUM_LEDS 2
+#define NUM_LEDS 5
#define LED_RGB_HIGH() PORTF |= (1<<PF4)
#define LED_RGB_LOW() PORTF &= ~(1<<PF4)
uint8_t buffer[BUFFERSIZE];
uint8_t pointer = 0;
-uint8_t red[NUM_LEDS] = {0xff,0x00};
-uint8_t green[NUM_LEDS] = {0x00,0xff};
-uint8_t blue[NUM_LEDS] = {0x20,0x20};
+uint8_t red[NUM_LEDS] = {0xff};
+uint8_t green[NUM_LEDS] = {0xff};
+uint8_t blue[NUM_LEDS] = {0xff};
void init(void) {