Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vor 8 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. ##########------------------------------------------------------##########
  2. ########## Project-specific Details ##########
  3. ########## Check these every time you start a new project ##########
  4. ##########------------------------------------------------------##########
  5. MCU = atmega168
  6. F_CPU = 1000000UL
  7. BAUD = 9600UL
  8. ## Also try BAUD = 19200 or 38400 if you're feeling lucky.
  9. ## A directory for common include files and the simple USART library.
  10. ## If you move either the current folder or the Library folder, you'll
  11. ## need to change this path to match.
  12. LIBDIR = ../../AVR-Programming-Library
  13. ##########------------------------------------------------------##########
  14. ########## Programmer Defaults ##########
  15. ########## Set up once, then forget about it ##########
  16. ########## (Can override. See bottom of file.) ##########
  17. ##########------------------------------------------------------##########
  18. PROGRAMMER_TYPE = usbtiny
  19. # extra arguments to avrdude: baud rate, chip type, -F flag, etc.
  20. PROGRAMMER_ARGS =
  21. ##########------------------------------------------------------##########
  22. ########## Program Locations ##########
  23. ########## Won't need to change if they're in your PATH ##########
  24. ##########------------------------------------------------------##########
  25. CC = avr-gcc
  26. OBJCOPY = avr-objcopy
  27. OBJDUMP = avr-objdump
  28. AVRSIZE = avr-size
  29. AVRDUDE = avrdude
  30. ##########------------------------------------------------------##########
  31. ########## Makefile Magic! ##########
  32. ########## Summary: ##########
  33. ########## We want a .hex file ##########
  34. ########## Compile source files into .elf ##########
  35. ########## Convert .elf file into .hex ##########
  36. ########## You shouldn't need to edit below. ##########
  37. ##########------------------------------------------------------##########
  38. ## The name of your project (without the .c)
  39. # TARGET = blinkLED
  40. ## Or name it automatically after the enclosing directory
  41. TARGET = $(lastword $(subst /, ,$(CURDIR)))
  42. # Object files: will find all .c/.h files in current directory
  43. # and in LIBDIR. If you have any other (sub-)directories with code,
  44. # you can add them in to SOURCES below in the wildcard statement.
  45. SOURCES=$(wildcard *.c $(LIBDIR)/*.c)
  46. OBJECTS=$(SOURCES:.c=.o)
  47. HEADERS=$(SOURCES:.c=.h)
  48. ## Compilation options, type man avr-gcc if you're curious.
  49. CPPFLAGS = -DF_CPU=$(F_CPU) -DBAUD=$(BAUD) -I. -I$(LIBDIR)
  50. CFLAGS = -Os -g -std=gnu99 -Wall
  51. ## Use short (8-bit) data types
  52. CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
  53. ## Splits up object files per function
  54. CFLAGS += -ffunction-sections -fdata-sections
  55. LDFLAGS = -Wl,-Map,$(TARGET).map
  56. ## Optional, but often ends up with smaller code
  57. LDFLAGS += -Wl,--gc-sections
  58. ## Relax shrinks code even more, but makes disassembly messy
  59. ## LDFLAGS += -Wl,--relax
  60. ## LDFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm ## for floating-point printf
  61. ## LDFLAGS += -Wl,-u,vfprintf -lprintf_min ## for smaller printf
  62. TARGET_ARCH = -mmcu=$(MCU)
  63. ## Explicit pattern rules:
  64. ## To make .o files from .c files
  65. %.o: %.c $(HEADERS) Makefile
  66. $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -o $@ $<;
  67. $(TARGET).elf: $(OBJECTS)
  68. $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
  69. %.hex: %.elf
  70. $(OBJCOPY) -j .text -j .data -O ihex $< $@
  71. %.eeprom: %.elf
  72. $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
  73. %.lst: %.elf
  74. $(OBJDUMP) -S $< > $@
  75. ## These targets don't have files named after them
  76. .PHONY: all disassemble disasm eeprom size clean squeaky_clean flash fuses
  77. all: $(TARGET).hex
  78. debug:
  79. @echo
  80. @echo "Source files:" $(SOURCES)
  81. @echo "MCU, F_CPU, BAUD:" $(MCU), $(F_CPU), $(BAUD)
  82. @echo
  83. # Optionally create listing file from .elf
  84. # This creates approximate assembly-language equivalent of your code.
  85. # Useful for debugging time-sensitive bits,
  86. # or making sure the compiler does what you want.
  87. disassemble: $(TARGET).lst
  88. disasm: disassemble
  89. # Optionally show how big the resulting program is
  90. size: $(TARGET).elf
  91. $(AVRSIZE) -C --mcu=$(MCU) $(TARGET).elf
  92. clean:
  93. rm -f $(TARGET).elf $(TARGET).hex $(TARGET).obj \
  94. $(TARGET).o $(TARGET).d $(TARGET).eep $(TARGET).lst \
  95. $(TARGET).lss $(TARGET).sym $(TARGET).map $(TARGET)~ \
  96. $(TARGET).eeprom
  97. squeaky_clean:
  98. rm -f *.elf *.hex *.obj *.o *.d *.eep *.lst *.lss *.sym *.map *~ *.eeprom
  99. ##########------------------------------------------------------##########
  100. ########## Programmer-specific details ##########
  101. ########## Flashing code to AVR using avrdude ##########
  102. ##########------------------------------------------------------##########
  103. flash: $(TARGET).hex
  104. $(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -U flash:w:$<
  105. ## An alias
  106. program: flash
  107. flash_eeprom: $(TARGET).eeprom
  108. $(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -U eeprom:w:$<
  109. avrdude_terminal:
  110. $(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -nt
  111. ## If you've got multiple programmers that you use,
  112. ## you can define them here so that it's easy to switch.
  113. ## To invoke, use something like `make flash_arduinoISP`
  114. flash_usbtiny: PROGRAMMER_TYPE = usbtiny
  115. flash_usbtiny: PROGRAMMER_ARGS = # USBTiny works with no further arguments
  116. flash_usbtiny: flash
  117. flash_usbasp: PROGRAMMER_TYPE = usbasp
  118. flash_usbasp: PROGRAMMER_ARGS = # USBasp works with no further arguments
  119. flash_usbasp: flash
  120. flash_arduinoISP: PROGRAMMER_TYPE = avrisp
  121. flash_arduinoISP: PROGRAMMER_ARGS = -b 19200 -P /dev/ttyACM0
  122. ## (for windows) flash_arduinoISP: PROGRAMMER_ARGS = -b 19200 -P com5
  123. flash_arduinoISP: flash
  124. flash_109: PROGRAMMER_TYPE = avr109
  125. flash_109: PROGRAMMER_ARGS = -b 9600 -P /dev/ttyUSB0
  126. flash_109: flash
  127. ##########------------------------------------------------------##########
  128. ########## Fuse settings and suitable defaults ##########
  129. ##########------------------------------------------------------##########
  130. ## Mega 48, 88, 168, 328 default values
  131. LFUSE = 0x62
  132. HFUSE = 0xdf
  133. EFUSE = 0x00
  134. ## Generic
  135. FUSE_STRING = -U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m -U efuse:w:$(EFUSE):m
  136. fuses:
  137. $(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) \
  138. $(PROGRAMMER_ARGS) $(FUSE_STRING)
  139. show_fuses:
  140. $(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -nv
  141. ## Called with no extra definitions, sets to defaults
  142. set_default_fuses: FUSE_STRING = -U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m -U efuse:w:$(EFUSE):m
  143. set_default_fuses: fuses
  144. ## Set the fuse byte for full-speed mode
  145. ## Note: can also be set in firmware for modern chips
  146. set_fast_fuse: LFUSE = 0xE2
  147. set_fast_fuse: FUSE_STRING = -U lfuse:w:$(LFUSE):m
  148. set_fast_fuse: fuses
  149. ## Set the EESAVE fuse byte to preserve EEPROM across flashes
  150. set_eeprom_save_fuse: HFUSE = 0xD7
  151. set_eeprom_save_fuse: FUSE_STRING = -U hfuse:w:$(HFUSE):m
  152. set_eeprom_save_fuse: fuses
  153. ## Clear the EESAVE fuse byte
  154. clear_eeprom_save_fuse: FUSE_STRING = -U hfuse:w:$(HFUSE):m
  155. clear_eeprom_save_fuse: fuses