AVR based brushless motor controller
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.

65 lines
1.4 KiB

  1. PRG = blmc
  2. OBJ = blmc.o eeprom.o i2c-slave.o main.o
  3. MCU_TARGET = atmega8
  4. OPTIMIZE = -Os
  5. DEFS =
  6. LIBS =
  7. # You should not have to change anything below here.
  8. CC = avr-gcc
  9. # Override is only needed by avr-lib build system.
  10. override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
  11. override LDFLAGS = -Wl,-Map,$(PRG).map
  12. OBJCOPY = avr-objcopy
  13. OBJDUMP = avr-objdump
  14. SIZE = avr-size
  15. all: $(PRG).elf lst text ehex ebin
  16. $(SIZE) -x -A $(PRG).elf
  17. $(PRG).elf: $(OBJ)
  18. $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
  19. clean:
  20. rm -rf *.o *.lst *.map $(PRG).elf *.hex *.bin
  21. lst: $(PRG).lst
  22. %.lst: %.elf
  23. $(OBJDUMP) -h -S $< > $@
  24. # Rules for building the .text rom images
  25. text: hex bin
  26. hex: $(PRG).hex
  27. bin: $(PRG).bin
  28. %.hex: %.elf
  29. $(OBJCOPY) -j .text -j .data -O ihex $< $@
  30. %.bin: %.elf
  31. $(OBJCOPY) -j .text -j .data -O binary $< $@
  32. # Rules for building the .eeprom rom images
  33. eeprom: ehex ebin
  34. ehex: $(PRG)_eeprom.hex
  35. ebin: $(PRG)_eeprom.bin
  36. %_eeprom.hex: %.elf
  37. $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
  38. %_eeprom.bin: %.elf
  39. $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
  40. install: text
  41. # uisp -dprog=avr910 -dserial=/dev/ttyS0 -dspeed=115200 -dpart=M8 --erase --upload if=$(PRG).hex
  42. avrdude -p m8 -c butterfly -b 115200 -P /dev/ttyUSB1 -u -e -V -U flash:w:$(PRG).hex