brymen_bm869s_ir_cable

Brymen 869s Serial PC-Comm DIY Cable.
git clone htps://git.e1e0.net/brymen_bm869s_ir_cable.git
Log | Files | Refs | README

Makefile (3848B)


      1 MCU =		attiny85
      2 AVR_TYPE =	__AVR_ATtiny85__
      3 F_CPU =		8000000UL
      4 BAUD =		9600UL
      5 
      6 #LIBDIR = ${HOME}/src/electronics/avr_libs
      7 LIBDIR = 
      8 
      9 PROGRAMMER_TYPE = usbasp
     10 PROGRAMMER_ARGS = 
     11 
     12 ### Program Locations
     13 
     14 CC =		avr-gcc
     15 OBJCOPY =	avr-objcopy
     16 OBJDUMP =	avr-objdump
     17 AVRSIZE =	avr-size
     18 AVRDUDE =	avrdude
     19 
     20 ###------------------------------------------------------###
     21 ###                   Makefile Magic!                    ###
     22 ###         Summary:                                     ###
     23 ###             We want a .hex file                      ###
     24 ###        Compile source files into .elf                ###
     25 ###        Convert .elf file into .hex                   ###
     26 ###        You shouldn't need to edit below.             ###
     27 ###------------------------------------------------------###
     28 
     29 ## The name of your project (without the .c)
     30 TARGET = main
     31 ## Or name it automatically after the enclosing directory
     32 # TARGET = $(lastword $(subst /, ,$(CURDIR)))
     33 
     34 # Object files: will find all .c/.h files in current directory
     35 #  and in LIBDIR.  If you have any other (sub-)directories with code,
     36 #  you can add them in to SOURCES below in the wildcard statement.
     37 SOURCES=$(wildcard *.c $(LIBDIR)/*.c $(CURDIR)/lib/*.c)
     38 OBJECTS=$(SOURCES:.c=.o)
     39 HEADERS=$(SOURCES:.c=.h)
     40 
     41 ## Compilation options, type man avr-gcc if you're curious.
     42 CPPFLAGS = -DF_CPU=$(F_CPU) -DBAUD=$(BAUD) -D$(AVR_TYPE) -I. -I$(LIBDIR)
     43 CFLAGS = -Os -g -std=gnu99 -Wall
     44 ## Use short (8-bit) data types 
     45 CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums 
     46 ## Splits up object files per function
     47 CFLAGS += -ffunction-sections -fdata-sections 
     48 LDFLAGS = -Wl,-Map,$(TARGET).map 
     49 ## Optional, but often ends up with smaller code
     50 LDFLAGS += -Wl,--gc-sections 
     51 ## Relax shrinks code even more, but makes disassembly messy
     52 # LDFLAGS += -Wl,--relax
     53 # LDFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm  ## for floating-point printf
     54 # LDFLAGS += -Wl,-u,vfprintf -lprintf_min      ## for smaller printf
     55 TARGET_ARCH = -mmcu=$(MCU)
     56 
     57 ## Explicit pattern rules:
     58 ##  To make .o files from .c files 
     59 %.o: %.c $(HEADERS) Makefile
     60 	 $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -o $@ $<;
     61 
     62 $(TARGET).elf: $(OBJECTS)
     63 	$(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
     64 
     65 %.hex: %.elf
     66 	 $(OBJCOPY) -j .text -j .data -O ihex $< $@
     67 
     68 %.eeprom: %.elf
     69 	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ 
     70 
     71 %.lst: %.elf
     72 	$(OBJDUMP) -S $< > $@
     73 
     74 ## These targets don't have files named after them
     75 .PHONY: all debug size clean squeaky_clean flash flash_eeprom \
     76 	avrdude_terminal fuses show_fuses
     77 
     78 all: $(TARGET).hex 
     79 
     80 debug:
     81 	@echo
     82 	@echo "Source files:"   $(SOURCES)
     83 	@echo "MCU, F_CPU, BAUD:"  $(MCU), $(F_CPU), $(BAUD)
     84 	@echo	
     85 
     86 # Optionally show how big the resulting program is 
     87 size:  $(TARGET).elf
     88 	$(AVRSIZE) -C --mcu=$(MCU) $(TARGET).elf
     89 
     90 clean:
     91 	rm -f $(TARGET).elf $(TARGET).hex $(TARGET).obj \
     92 	$(TARGET).o $(TARGET).d $(TARGET).eep $(TARGET).lst \
     93 	$(TARGET).lss $(TARGET).sym $(TARGET).map $(TARGET)~ \
     94 	$(TARGET).eeprom
     95 
     96 squeaky_clean:
     97 	rm -f *.elf *.hex *.obj *.o *.d *.eep *.lst *.lss *.sym *.map *~ *.eeprom
     98 
     99 ### Flashing code to AVR using avrdude
    100 
    101 flash: $(TARGET).hex 
    102 	$(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -U flash:w:$<
    103 
    104 flash_eeprom: $(TARGET).eeprom
    105 	$(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -U eeprom:w:$<
    106 
    107 avrdude_terminal:
    108 	$(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -nt
    109 
    110 
    111 ### Fuse settings
    112 
    113 # 8Mhz internal / preserve EEPROM / programming enabled
    114 # see http://www.engbedded.com/fusecalc
    115 LFUSE = 0xe2
    116 HFUSE = 0xd7
    117 EFUSE = 0xff
    118 
    119 ## Generic 
    120 FUSE_STRING = -U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m -U efuse:w:$(EFUSE):m 
    121 
    122 fuses: 
    123 	$(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) \
    124 	           $(PROGRAMMER_ARGS) $(FUSE_STRING)
    125 show_fuses:
    126 	$(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -nv