Fixed makefile for atmega168.

This commit is contained in:
skarg
2007-08-15 22:41:53 +00:00
parent eb0b3266f0
commit f2e0bbe834
4 changed files with 35 additions and 35 deletions
+29 -31
View File
@@ -1,19 +1,27 @@
###############################################################################
# Makefile for the project bacnet
# Makefile for BACnet
###############################################################################
## General Flags
PROJECT = bacnet
MCU = atmega168
TARGET = bacnet.elf
TARGET = bacnet
CC = avr-gcc.exe
CSRC = main.c \
timer.c \
rs485.c
COBJ = $(CSRC:.c=.o)
## Options common to compile, link and assembly rules
COMMON = -mmcu=$(MCU)
OPTIMIZATION = -O0
#OPTIMIZATION = -Os
## Compile options common for all C compilation units.
CFLAGS = $(COMMON)
CFLAGS += -Wall -gdwarf-2 -O0
CFLAGS += -Wall -gdwarf-2 -DF_CPU=7372800UL $(OPTIMIZATION) -fsigned-char
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
## Assembly specific flags
@@ -23,61 +31,51 @@ ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
## Linker flags
LDFLAGS = $(COMMON)
LDFLAGS +=
LDFLAGS += -Wl,-Map=$(TARGET).map
## Intel Hex file production flags
HEX_FLASH_FLAGS = -R .eeprom
HEX_EEPROM_FLAGS = -j .eeprom
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
## Include Directories
INCLUDES = -I"C:\code\bacnet-stack\ports\atmega168\..\.."
INCLUDES = -I. -I..\..
## Objects that must be built in order to link
OBJECTS = main.o rs485.o timer.o
## Objects explicitly added by the user
LINKONLYOBJECTS =
OBJECTS = $(COBJ)
## Build
all: $(TARGET) bacnet.hex bacnet.eep size
TARGET_ELF=$(TARGET).elf
## Compile
main.o: ../main.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
rs485.o: ../rs485.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
timer.o: ../timer.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
all: $(TARGET_ELF) $(TARGET).hex $(TARGET).eep size
##Link
$(TARGET): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
$(TARGET_ELF): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) $(LIBDIRS) $(LIBS) -o $@
%.hex: $(TARGET)
%.hex: $(TARGET_ELF)
avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@
%.eep: $(TARGET)
%.eep: $(TARGET_ELF)
-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
%.lss: $(TARGET)
%.lss: $(TARGET_ELF)
avr-objdump -h -S $< > $@
size: ${TARGET}
$(COBJ): %.o : %.c Makefile
$(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@
size: ${TARGET_ELF}
@echo
@avr-size -C --mcu=${MCU} ${TARGET}
@avr-size -C --mcu=${MCU} ${TARGET_ELF}
## Clean target
.PHONY: clean
clean:
-rm -rf $(OBJECTS) bacnet.elf dep/* bacnet.hex bacnet.eep
touch Makefile
-rm -rf $(OBJECTS) $(TARGET_ELF) dep/*
-rm -rf $(TARGET).hex $(TARGET).eep $(TARGET).lss $(TARGET).map
## Other dependencies
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
File diff suppressed because one or more lines are too long
+4 -2
View File
@@ -32,7 +32,7 @@
/* Count: Timer0 counts up to 0xFF and then signals overflow */
#define TIMER_TICKS (FREQ_CPU/TIMER_PRESCALER/1000)
#if (TIMER_TICKS > 0xFF)
#error Timer Prescaler value too small
#error Timer Prescaler value is too small
#endif
#define TIMER_COUNT (0xFF-TIMER_TICKS)
/* Global variable millisecond timer - used by main.c for timers task */
@@ -65,13 +65,15 @@ void timer_initialize(void)
BIT_CLEAR(PRR,PRTIM0);
}
/* Timer interupt */
/* note: Global interupts must be enabled - sei() */
/* Timer Overflowed! Increment the time. */
ISR(TIMER0_OVF_vect)
{
/* Set the counter for the next interrupt */
TCNT0 = TIMER_COUNT;
/* Overflow Flag is automatically cleared */
/* Update the global timer */
if (Timer_Milliseconds < 0xFF)
Timer_Milliseconds++;
}
+1 -1
View File
@@ -63,7 +63,7 @@ static int RS485_Handle = -1;
included by <termios.h> */
static unsigned int RS485_Baud = B38400;
/* serial port name, /dev/ttyS0,
/dev/ttyUSB0 for USB->RS485 from SerialGear or USBGear */
/dev/ttyUSB0 for USB->RS485 from B&B Electronics USOPTL4 */
static char *RS485_Port_Name = "/dev/ttyUSB0";
/* serial I/O settings */
static struct termios RS485_oldtio;