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