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

📄 makefile

📁 LCD using AVR controller
💻
字号:
# sample makefile for graphics LCD using
# Atmel ATmega644 microcontroller
#
# Revisions:
#	07-13-06	included in LCDSample project
#
# adapted from WinAVR makefile sample
# by Cathy Saxton, robotics@idleloop.com
#
# on the command line:
#   make all      - build the program
#   make clean    - remove all built files
#   make program  - download program (using AVRDUDE defines below)
#   make setfuse  - set fuse bits (using AVRDUDE defines below)
#
# stuff you may want to edit:
#
#   PRG         - the name of the program
#   SRC         - the list of CPP files to be compiled
#	HEADERS     - the list of H files used by the program
#   MCU_TARGET  - the microprocessor for which we're building
#
#   AVRDUDE_PART        - AVRDUDE's part id for the microprocessor
#   AVRDUDE_PROGRAMMER  - the programmer used for downloading
#   AVRDUDE_PORT        - the port the programmer is plugged into
#
#	the last 2 can be specified by environment variables


PRG            = LCDSample

MCU_TARGET     = atmega644

SRC            = main.cpp Bitmaps.cpp
HEADERS        = Bitmaps.h

# library files; note that Config.h is listed with these headers
#   since changing it requires rebuilding the library files.
LIB_SRC        = Timer.cpp InOut.cpp LCD-color.cpp Fonts.cpp
LIB_HEADERS    = Config.h Util.h Timer.h InOut.h LCD-color.h Fonts.h

# location of AVR library files
AVR_LIB        = ./lib

PRG_OBJ        = $(SRC:.cpp=.o)
LIB_OBJ        = $(LIB_SRC:.cpp=.o)
OBJ            = $(LIB_OBJ) $(PRG_OBJ)
OPTIMIZE       = -Os
INC            = -I"." -I"$(AVR_LIB)"
DEFS           = -D DEBUG
#DEFS           = 
LIBS           =

# compile of .c auto with $(CC) -c $(CPPFLAGS) $(CFLAGS)
# compile of .cpp auto with $(CXX) -c $(CPPFLAGS) $(CXXFLAGS)
# (CPPFLAGS are preprocessor flags)
CC             = avr-gcc
CXX            = avr-g++

# Override is only needed by avr-lib build system.
override CFLAGS        = -g -Wall $(OPTIMIZE) $(INC) -mmcu=$(MCU_TARGET) $(DEFS)
override CPPFLAGS      = -g -Wall $(OPTIMIZE) $(INC) -mmcu=$(MCU_TARGET) $(DEFS)
override LDFLAGS       = -Wl,-Map,$(PRG).map

OBJCOPY        = avr-objcopy
OBJDUMP        = avr-objdump
AVRDUDE        = avrdude     # for downloading

# AVRDUDE definitions; m644 is the ATmega644;
# you can define environment variables to override the programmer and port settings
AVRDUDE_PART       = m644
ifndef AVRDUDE_PROGRAMMER
AVRDUDE_PROGRAMMER = avrisp
endif
ifndef AVRDUDE_PORT
AVRDUDE_PORT       = com1
endif
AVRDUDE_FLAGS      = -p $(AVRDUDE_PART) -c $(AVRDUDE_PROGRAMMER) -P $(AVRDUDE_PORT) 

#look for .cpp and .h files in the "library" folder, too!
vpath %.cpp $(AVR_LIB)
vpath %.h $(AVR_LIB)

# (this is the default rule since it's first)
all: $(PRG).elf lst bin
#all: $(PRG).elf lst bin ebin
#all: $(PRG).elf lst bin eeprom_files

clean:
	rm -f *.o $(PRG).elf *.lst *.map *.bin

program: $(PRG).bin
	avrdude $(AVRDUDE_FLAGS) -e -U flash:w:$(PRG).bin:r

# set fuse bits for mega644
# efuse: 0xfd .... .101 - BOD 2.7V
# hfuse: 0xd1 1101 0001 - no OCD, no JTAG, SPI, no watchdog, EEPROM preserve, boot size, reset vector unprog.
# lfuse: 0xc2 1100 0010 - no ckdiv8, no ckout, SUT for BOD, internal oscillator @ 8 MHz
setfuse:
	avrdude $(AVRDUDE_FLAGS) -u -U efuse:w:0xfd:m
	avrdude $(AVRDUDE_FLAGS) -u -U hfuse:w:0xd1:m
	avrdude $(AVRDUDE_FLAGS) -u -U lfuse:w:0xc2:m

# fuse bit suggestions for other controllers:
# --- mega128, 8 MHz internal RC oscillator: CKOPT=0, CKSEL=0100, SUT=00
# extended  0xff .... ..11 - no mega103 compatibility, no watchdog
# high      0xC1 1100 0001 - no OCD, no JTAG, SPI download, CKOPT, preserve EEPROM, (boot size), (reset vector)
# low       0x04 0000 0100 - BOD: 4V, SUT, CKSEL
# --- mega16, 8 MHz internal RC oscillator
#   hfuse: 0xd1 1101 0001 - no OCD, no JTAG, SPI, CKOPT, EEPROM preserve, boot size, reset vector unprog.
#   lfuse: 0x04 0000 0100 - BOD 4V, SUT for BOD, internal oscillator @ 8 MHz
#     or   0x84 1000 0100 - BOD 2.7V, SUT for BOD, internal oscillator @ 8 MHz
# --- mega8, 8 MHz internal RC oscillator
# hfuse: 0xD1 1101 0001 - PC6=reset, no WDT, SPI, CKOPT, EEPROM preserve, boot size, reset vector unprog.
# lfuse: 0x04 0000 0100 - BOD 4V, SUT for BOD, CKSEL = 8 MHz
#   or   0x84 1000 0100 - BOD 2.7V, SUT for BOD, CKSEL = 8 MHz

# rebuild the obj files if any .h (or the makefile) changes
$(PRG_OBJ): $(HEADERS) $(LIB_HEADERS) makefile
# rebuild the library obj files if any of its .h (or the makefile) changes
$(LIB_OBJ): $(LIB_HEADERS) makefile

# binary file (to download to robot)
bin:  $(PRG).bin

$(PRG).elf: $(OBJ)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)

%.bin: %.elf
	$(OBJCOPY) -j .text -j .data -O binary $< $@

# code/asm listing
lst:  $(PRG).lst

%.lst: %.elf
	$(OBJDUMP) -h -S $< > $@

%.lst: %.o
	$(OBJDUMP) -h -S $< > $@


# generate .hex/bin/srec for eeprom
# [Rules for building the .eeprom rom images]

eeprom_files: ehex ebin esrec

ehex:  $(PRG)_eeprom.hex
ebin:  $(PRG)_eeprom.bin
esrec: $(PRG)_eeprom.srec

%_eeprom.hex: %.elf
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@

%_eeprom.srec: %.elf
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@

%_eeprom.bin: %.elf
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@

⌨️ 快捷键说明

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