You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
3.6KB

  1. # Name: Makefile
  2. # Author: <insert your name here>
  3. # Copyright: <insert your copyright message here>
  4. # License: <insert your license reference here>
  5. # This is a prototype Makefile. Modify it according to your needs.
  6. # You should at least check the settings for
  7. # DEVICE ....... The AVR device you compile for
  8. # CLOCK ........ Target AVR clock rate in Hertz
  9. # OBJECTS ...... The object files created from your source files. This list is
  10. # usually the same as the list of source files with suffix ".o".
  11. # PROGRAMMER ... Options to avrdude which define the hardware you use for
  12. # uploading to the AVR and the interface where this hardware
  13. # is connected. We recommend that you leave it undefined and
  14. # add settings like this to your ~/.avrduderc file:
  15. # default_programmer = "stk500v2"
  16. # default_serial = "avrdoper"
  17. # FUSES ........ Parameters for avrdude to flash the fuses appropriately.
  18. DEVICE = atmega328
  19. CLOCK = 16000000
  20. PROGRAMMER = -F -V -c arduino
  21. OBJECTS = main.o
  22. FUSES = #-U hfuse:w:0xd9:m -U lfuse:w:0x24:m
  23. ARDUINO_SERIAL = -P /dev/tty.usbserial-A900fqRc -b 115200
  24. # ATMega8 fuse bits used above (fuse bits for other devices are different!):
  25. # Example for 8 MHz internal oscillator
  26. # Fuse high byte:
  27. # 0xd9 = 1 1 0 1 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000)
  28. # ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0
  29. # | | | | | +-------- BOOTSZ1
  30. # | | | | +---------- EESAVE (set to 0 to preserve EEPROM over chip erase)
  31. # | | | +-------------- CKOPT (clock option, depends on oscillator type)
  32. # | | +---------------- SPIEN (if set to 1, serial programming is disabled)
  33. # | +------------------ WDTON (if set to 0, watchdog is always on)
  34. # +-------------------- RSTDISBL (if set to 0, RESET pin is disabled)
  35. # Fuse low byte:
  36. # 0x24 = 0 0 1 0 0 1 0 0
  37. # ^ ^ \ / \--+--/
  38. # | | | +------- CKSEL 3..0 (8M internal RC)
  39. # | | +--------------- SUT 1..0 (slowly rising power)
  40. # | +------------------ BODEN (if 0, brown-out detector is enabled)
  41. # +-------------------- BODLEVEL (if 0: 4V, if 1: 2.7V)
  42. #
  43. # For computing fuse byte values for other devices and options see
  44. # the fuse bit calculator at http://www.engbedded.com/fusecalc/
  45. # Tune the lines below only if you know what you are doing:
  46. AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE) $(ARDUINO_SERIAL)
  47. COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
  48. # symbolic targets:
  49. all: main.hex
  50. .c.o:
  51. $(COMPILE) -c $< -o $@
  52. .S.o:
  53. $(COMPILE) -x assembler-with-cpp -c $< -o $@
  54. # "-x assembler-with-cpp" should not be necessary since this is the default
  55. # file type for the .S (with capital S) extension. However, upper case
  56. # characters are not always preserved on Windows. To ensure WinAVR
  57. # compatibility define the file type manually.
  58. .c.s:
  59. $(COMPILE) -S $< -o $@
  60. flash: all
  61. $(AVRDUDE) -U flash:w:main.hex:i
  62. fuse:
  63. $(AVRDUDE) $(FUSES)
  64. # Xcode uses the Makefile targets "", "clean" and "install"
  65. install: flash fuse
  66. # if you use a bootloader, change the command below appropriately:
  67. load: all
  68. bootloadHID main.hex
  69. clean:
  70. rm -f main.hex main.elf $(OBJECTS)
  71. # file targets:
  72. main.elf: $(OBJECTS)
  73. $(COMPILE) -o main.elf $(OBJECTS)
  74. main.hex: main.elf
  75. rm -f main.hex
  76. avr-objcopy -j .text -j .data -O ihex main.elf main.hex
  77. avr-size --format=avr --mcu=$(DEVICE) main.elf
  78. # If you have an EEPROM section, you must also create a hex file for the
  79. # EEPROM and add it to the "flash" target.
  80. # Targets for code debugging and analysis:
  81. disasm: main.elf
  82. avr-objdump -d main.elf
  83. cpp:
  84. $(COMPILE) -E main.c