⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 makefile

📁 Use optical mouse sensor from Logitech Mouse with an Atmel AVR controller Documentation in german
💻
字号:
# Tools and directories
CC		= avr-gcc
AS		= avr-gcc -x assembler-with-cpp	
RM		= rm -f
RN		= mv
BIN		= avr-objcopy
INCDIR	= .
LIBDIR	= $(AVR)\avr\lib
SHELL   = $(AVR)\bin\sh.exe
FORMAT  = srec
############################################################################################
	
# CPU type
#MCU = atmega32
#MCU = atmega644
#MCU = atmega161
#MCU = atmega168
MCU = atmega128

#F_CPU = 4000000
#F_CPU = 6000000
#F_CPU = 8000000
#F_CPU = 11059200
F_CPU = 16000000
#F_CPU = 20000000

# Target
TRG	=	main

# Assembler source files
#ASRC    = delay.s

# C-source files
SRC	= printf.c serial.c softspi.c $(TRG).c


# Libraries 
LIB = 

# Compiler flags
# This makes code smaller, but slower
#CPFLAGS	=  -g -Os -mcall-prologues -fregmove -fforce-addr -Wall -Wstrict-prototypes -Wa,-ahlms=$(<:.c=.lst)
# Good idea !
#CPFLAGS	=  -g -O2 -mcall-prologues -fregmove -fforce-addr -Wall -Wstrict-prototypes -Wa,-ahlms=$(<:.c=.lst)
# Fastest code
CPFLAGS	=  -g -O2 -fregmove -fforce-addr -Wall -Wstrict-prototypes -Wa,-ahlms=$(<:.c=.lst)

# Assembler flags
ASFLAGS = -Wa,-gstabs

# Linker flags
LDFLAGS = -Wl,--defsym,__init_wdtcr__=0x07,--defsym,__init_mcucr__=0x80,-Map=$(TRG).map,--cref


############################################################################################
############################################################################################

#define all project specific object files
	OBJ	= $(ASRC:.s=.o) $(SRC:.c=.o)
	CPFLAGS += -mmcu=$(MCU) -DF_CPU=$(F_CPU)
	ASFLAGS += -mmcu=$(MCU)
	LDFLAGS += -mmcu=$(MCU)

	  
#this defines the aims of the make process
all:	$(TRG).elf $(TRG).hex $(TRG).bin


#compile: instructions to create assembler and/or object files from C source
%o : %c 
	$(CC) -c $(CPFLAGS) -I$(INCDIR) $< -o $@

%s : %c
	$(CC) -S $(CPFLAGS) -I$(INCDIR) $< -o $@

#assemble: instructions to create object file from assembler files
%o : %s
	$(AS) -c $(ASFLAGS) -I$(INCDIR) $< -o $@


#link: instructions to create elf output file from object files
%elf: $(OBJ)
	$(CC) $(OBJ) $(LIB) $(LDFLAGS) -o $@

#create avrobj file from elf output file
%obj: %elf
	$(BIN) -O avrobj $< $@

#create bin (ihex, srec) file from elf output file
%rom: %elf
	$(BIN) -O $(FORMAT) $< $@

%hex: %elf
	$(BIN) -O ihex $< $@

%bin: %elf
	$(BIN) -O binary $< $@


	avr-size -B -d $(TRG).elf
	avr-size -B -d $(OBJ)


#make instruction to delete created files
clean:
	$(RM) $(OBJ)
	$(RM) $(TRG).map
	$(RM) $(TRG).elf
	$(RM) $(TRG).obj
#	$(RM) $(TRG).hex
#	$(RM) $(TRG).bin
	$(RM) *.bak
	$(RM) *.lst
	$(RM) ../*.lst
	$(RM) *.?_sym

clean_before:
	$(RM) $(TRG).hex
	$(RM) $(TRG).bin
	$(RM) *.err

############################################################################################
############################################################################################

###### dependecies, add any dependencies you need here ###################

#$(TRG).o	: $(TRG).c types.h

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -