aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/e300/battery/Makefile
blob: 1ce0bf279fe11c1d0dde189b5696fd82017e38bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# USRP E310 Firmware
# Copyright (C) 2014-2015 Ettus Research
# This file is part of the USRP E310 Firmware
# The USRP E310 Firmware is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# The USRP E310 Firmware is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with the USRP E310 Firmware. If not, see <http://www.gnu.org/licenses/>.

##################################################
# Compiler
##################################################
CC = avr-gcc
OBJCOPY = avr-objcopy
STRIP = avr-strip
SIZE = avr-size
OBJDUMP = avr-objdump
SREC = srec_cat
CFLAGS = -Os -std=c11 -Wall -fshort-enums -pedantic -Wl,--gc-sections \
	-Wstrict-prototypes -Wcast-align -Wshadow

##################################################
# Files
##################################################
HDRS =
SRCS =  main.c adc.c bq2419x.c fpga.c i2c_twi.c interrupt.c io.c ltc294x.c ltc3675.c \
	pmu.c spi.c timer.c tps54478.c eeprom.c led.c
TARGET = main

##################################################
# Device
##################################################
MMCU = attiny88
PROGRAMMER = jtag3isp
PORT = usb
AVRDUDE = avrdude -p $(MMCU) -c $(PROGRAMMER) -P $(PORT) -V
FUSES = -U hfuse:w:hfuse.hex:i -U lfuse:w:lfuse.hex:i -U efuse:w:efuse.hex:i -u

##################################################
# Global Targets
##################################################
all: $(TARGET).hex size hfuse.hex lfuse.hex efuse.hex

clean:
	$(RM) *.o *.elf *.hex

install: all
	$(AVRDUDE) -U flash:w:$(TARGET).hex:i $(FUSES)

size: $(TARGET).hex
	@$(SIZE) --format=SysV --mcu=$(MMCU) $(TARGET).elf
	@$(SIZE) -C --mcu=$(MMCU) $(TARGET).elf

##################################################
# Dependency Targets
##################################################
fuses.hex: $(TARGET).elf
	$(OBJCOPY) -j .fuse -O ihex $< $@ --change-section-lma .fuse=0

lfuse.hex: fuses.hex
	$(SREC) $< -Intel -crop 0x00 0x01 -offset  0x00 -O $@ -Intel

hfuse.hex: fuses.hex
	$(SREC) $< -Intel -crop 0x01 0x02 -offset -0x01 -O $@ -Intel

efuse.hex: fuses.hex
	$(SREC) $< -Intel -crop 0x02 0x03 -offset -0x02 -O $@ -Intel

$(TARGET).hex: $(TARGET).elf
	$(OBJCOPY) -R .eeprom -R .fuse -O ihex $< $@

$(TARGET).elf: $(SRCS:.c=.o)
	$(CC) -mmcu=$(MMCU) $^ -o $@

%.o: %.c $(HDRS) Makefile
	$(CC) -mmcu=$(MMCU) -c $< -o $@ $(CFLAGS)