9d1938db8c3003938f0c22d3470995587f520421
[hackover2013-badge-firmware.git] / Makefile
1 ##########################################################################
2 # User configuration and firmware specific object files
3 ##########################################################################
4
5 # The target, flash and ram of the LPC1xxx microprocessor.
6 # Use for the target the value: LPC11xx, LPC13xx or LPC17xx
7 TARGET = LPC13xx
8 FLASH = 32K
9 SRAM = 8K
10
11 # For USB HID support the LPC134x reserves 384 bytes from the sram,
12 # if you don't want to use the USB features, just use 0 here.
13 SRAM_USB = 384
14
15 ##########################################################################
16 # Debug settings
17 ##########################################################################
18
19 # Set DEBUGBUILD to 'TRUE' for full debugging (larger, slower binaries),
20 # or to 'FALSE' for release builds (smallest, fastest binaries)
21 DEBUGBUILD = FALSE
22
23 ##########################################################################
24 # IDE Flags (Keeps various IDEs happy)
25 ##########################################################################
26
27 #OPTDEFINES = -D __NEWLIB__ -DR0KET
28 OPTDEFINES = -D __NEWLIB__ -DHOB_REV2
29 ##########################################################################
30 # Project-specific files
31 ##########################################################################
32
33 SRCS = \
34 badge/main.c \
35 badge/init.c \
36 badge/jumpnrun/collision.c \
37 badge/jumpnrun/enemies.c \
38 badge/jumpnrun/items.c \
39 badge/jumpnrun/jumpnrun.c \
40 badge/jumpnrun/level_load.c \
41 badge/jumpnrun/tiles.c \
42 badge/ui/display.c \
43 badge/ui/event.c \
44 badge/ui/font.c \
45 badge/ui/sprite.c
46
47 SRCS += \
48 dataflash/iobase.c \
49 dataflash/diskio.c \
50 dataflash/at45db041d.c
51
52 SRCS += \
53 funk/nrf24l01p.c
54
55 SRCS += \
56 project/commands.c
57
58 SRCS += \
59 project/commands/cmd_chibi_addr.c \
60 project/commands/cmd_chibi_tx.c \
61 project/commands/cmd_i2ceeprom_read.c \
62 project/commands/cmd_i2ceeprom_write.c \
63 project/commands/cmd_lm75b_gettemp.c \
64 project/commands/cmd_reset.c \
65 project/commands/cmd_sd_dir.c \
66 project/commands/cmd_sysinfo.c \
67 project/commands/cmd_uart.c \
68 project/commands/cmd_pwm.c
69
70 SRCS += \
71 project/commands/drawing/cmd_backlight.c \
72 project/commands/drawing/cmd_bmp.c \
73 project/commands/drawing/cmd_button.c \
74 project/commands/drawing/cmd_calibrate.c \
75 project/commands/drawing/cmd_circle.c \
76 project/commands/drawing/cmd_clear.c \
77 project/commands/drawing/cmd_line.c \
78 project/commands/drawing/cmd_orientation.c \
79 project/commands/drawing/cmd_pixel.c \
80 project/commands/drawing/cmd_progress.c \
81 project/commands/drawing/cmd_rectangle.c \
82 project/commands/drawing/cmd_roundedcorner.c \
83 project/commands/drawing/cmd_text.c \
84 project/commands/drawing/cmd_textw.c \
85 project/commands/drawing/cmd_tsthreshhold.c \
86 project/commands/drawing/cmd_tswait.c \
87 project/commands/drawing/cmd_triangle.c
88
89 ##########################################################################
90 # Optional driver files
91 ##########################################################################
92
93 # Chibi Light-Weight Wireless Stack (AT86RF212)
94 SRCS += \
95 drivers/rf/chibi/chb.c \
96 drivers/rf/chibi/chb_buf.c \
97 drivers/rf/chibi/chb_drvr.c \
98 drivers/rf/chibi/chb_eeprom.c \
99 drivers/rf/chibi/chb_spi.c
100
101 # 4K EEPROM
102 SRCS += \
103 drivers/storage/eeprom/eeprom.c \
104 drivers/storage/eeprom/mcp24aa/mcp24aa.c
105
106 # LM75B temperature sensor
107 SRCS += \
108 drivers/sensors/lm75b/lm75b.c
109
110 # ISL12022M RTC
111 SRCS += \
112 drivers/rtc/isl12022m/isl12022m.c
113
114 # TFT LCD support
115 SRCS += \
116 drivers/displays/tft/drawing.c \
117 drivers/displays/tft/touchscreen.c \
118 drivers/displays/tft/colors.c \
119 drivers/displays/tft/theme.c \
120 drivers/displays/tft/bmp.c
121
122 # GUI Controls
123 SRCS += \
124 drivers/displays/tft/controls/button.c \
125 drivers/displays/tft/controls/hsbchart.c \
126 drivers/displays/tft/controls/huechart.c \
127 drivers/displays/tft/controls/label.c \
128 drivers/displays/tft/controls/labelcentered.c \
129 drivers/displays/tft/controls/progressbar.c
130
131 # Bitmap (non-AA) fonts
132 SRCS += \
133 drivers/displays/tft/fonts.c \
134 drivers/displays/tft/fonts/dejavusans9.c \
135 drivers/displays/tft/fonts/dejavusansbold9.c \
136 drivers/displays/tft/fonts/dejavusanscondensed9.c \
137 drivers/displays/tft/fonts/dejavusansmono8.c \
138 drivers/displays/tft/fonts/dejavusansmonobold8.c \
139 drivers/displays/tft/fonts/verdana9.c \
140 drivers/displays/tft/fonts/verdana14.c \
141 drivers/displays/tft/fonts/verdanabold14.c
142
143 # Anti-aliased fonts
144 SRCS += \
145 drivers/displays/tft/aafonts.c \
146 drivers/displays/tft/aafonts/aa2/DejaVuSansCondensed14_AA2.c \
147 drivers/displays/tft/aafonts/aa2/DejaVuSansCondensedBold14_AA2.c \
148 drivers/displays/tft/aafonts/aa2/DejaVuSansMono10_AA2.c \
149 drivers/displays/tft/aafonts/aa2/DejaVuSansMono13_AA2.c \
150 drivers/displays/tft/aafonts/aa2/DejaVuSansMono14_AA2.c
151
152 # LCD Driver (Only one can be included at a time!)
153 # SRCS += drivers/displays/tft/hw/hx8340b.c
154 # SRCS += drivers/displays/tft/hw/hx8347d.c
155 # SRCS += drivers/displays/tft/hw/ILI9328.c
156 # SRCS += drivers/displays/tft/hw/ILI9325.c
157 # SRCS += drivers/displays/tft/hw/ssd1331.c
158 # SRCS += drivers/displays/tft/hw/ssd1351.c
159 # SRCS += drivers/displays/tft/hw/st7735.c
160 # SRCS += drivers/displays/tft/hw/st7783.c
161
162 # Bitmap/Monochrome LCD support (ST7565, SSD1306, etc.)
163 SRCS += \
164 drivers/displays/smallfonts.c \
165 drivers/displays/bitmap/sharpmem/sharpmem.c \
166 drivers/displays/bitmap/st7565/st7565.c \
167 drivers/displays/bitmap/ssd1306/ssd1306.c
168
169 #Character Displays (VFD text displays, etc.)
170 SRCS += \
171 drivers/displays/character/samsung_20T202DA2JA/samsung_20T202DA2JA.c
172
173 # ChaN FatFS and SD card support
174 SRCS += \
175 drivers/fatfs/ff.c
176 # drivers/fatfs/mmc.c
177
178 # Motors
179 SRCS += \
180 drivers/motor/stepper/stepper.c
181
182 # RSA Encryption/Descryption
183 SRCS += \
184 drivers/rsa/rsa.c
185
186 # DAC
187 SRCS += \
188 drivers/dac/mcp4725/mcp4725.c \
189 drivers/dac/mcp4901/mcp4901.c
190
191 # RFID/NFC
192 SRCS += \
193 drivers/rf/pn532/pn532.c \
194 drivers/rf/pn532/pn532_bus_i2c.c \
195 drivers/rf/pn532/pn532_bus_uart.c \
196 drivers/rf/pn532/helpers/pn532_mifare_classic.c \
197 drivers/rf/pn532/helpers/pn532_mifare_ultralight.c
198
199 # TAOS Light Sensors
200 SRCS += \
201 drivers/sensors/tcs3414/tcs3414.c \
202 drivers/sensors/tsl2561/tsl2561.c
203
204 # SPI Flash
205 SRCS += \
206 drivers/storage/spiflash/w25q16bv/w25q16bv.c
207
208 # FM Radio
209 SRCS += \
210 drivers/audio/tea5767/tea5767.c
211
212 # IN219 Current Sensor
213 SRCS += \
214 drivers/sensors/ina219/ina219.c
215
216 # MPL115A2 Barometric Pressure Sensor
217 SRCS += \
218 drivers/sensors/mpl115a2/mpl115a2.c
219
220 # ADS1015 12-bit ADC
221 SRCS += \
222 drivers/adc/ads1015/ads1015.c
223
224 ##########################################################################
225 # Library files
226 ##########################################################################
227
228 SRCS += \
229 core/adc/adc.c \
230 core/cmd/cmd.c \
231 core/cpu/cpu.c \
232 core/gpio/gpio.c \
233 core/i2c/i2c.c \
234 core/iap/iap.c \
235 core/libc/stdio.c \
236 core/libc/string.c \
237 core/pmu/pmu.c \
238 core/pwm/pwm.c \
239 core/ssp/ssp.c \
240 core/systick/systick.c \
241 core/timer16/timer16.c \
242 core/timer32/timer32.c \
243 core/uart/uart_buf.c \
244 core/uart/uart.c \
245 core/usbcdc/cdc_buf.c \
246 core/usbcdc/cdcuser.c \
247 core/usbcdc/usbcore.c \
248 core/usbcdc/usbdesc.c \
249 core/usbcdc/usbhw.c \
250 core/usbcdc/usbuser.c \
251 core/usbhid-rom/usbconfig.c \
252 core/usbhid-rom/usbhid.c \
253 core/usbhid-rom/usbmsc.c \
254 core/wdt/wdt.c
255
256 ##########################################################################
257 # GNU GCC compiler prefix and location
258 ##########################################################################
259
260 CROSS_COMPILE = arm-none-eabi-
261 AS = $(CROSS_COMPILE)gcc
262 CC = $(CROSS_COMPILE)gcc
263 LD = $(CROSS_COMPILE)gcc
264 SIZE = $(CROSS_COMPILE)size
265 OBJCOPY = $(CROSS_COMPILE)objcopy
266 OBJDUMP = $(CROSS_COMPILE)objdump
267 OUTFILE = firmware
268
269 CC_FOR_BUILD = gcc
270 LPCRC = ./lpcrc
271
272 ##########################################################################
273 # GNU GCC compiler flags
274 ##########################################################################
275 ROOT_PATH = .
276 INCLUDE_PATHS = -I$(ROOT_PATH) -I$(ROOT_PATH)/project
277
278 ##########################################################################
279 # Startup files
280 ##########################################################################
281
282 LD_PATH = lpc1xxx
283 LD_SCRIPT = $(LD_PATH)/linkscript.ld
284 LD_TEMP = $(LD_PATH)/memory.ld
285
286 ifeq (LPC11xx,$(TARGET))
287 CORTEX_TYPE=m0
288 else
289 CORTEX_TYPE=m3
290 endif
291
292 CPU_TYPE = cortex-$(CORTEX_TYPE)
293
294 SRCS += \
295 lpc1xxx/$(TARGET)_handlers.c \
296 lpc1xxx/LPC1xxx_startup.c
297
298 OBJS = $(SRCS:%.c=%.o)
299 DEPS = $(SRCS:%.c=%.dep)
300
301 ##########################################################################
302 # Compiler settings, parameters and flags
303 ##########################################################################
304 ifeq (TRUE,$(DEBUGBUILD))
305 CFLAGS = -c -g -O0 $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -fno-builtin $(OPTDEFINES) -std=c99
306 ASFLAGS = -c -g -O0 $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -D__ASSEMBLY__ -x assembler-with-cpp
307 else
308 CFLAGS = -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -fno-builtin $(OPTDEFINES) -std=c99
309 ASFLAGS = -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -D__ASSEMBLY__ -x assembler-with-cpp
310 endif
311
312 LDFLAGS = -nostartfiles -mthumb -mcpu=$(CPU_TYPE) -Wl,--gc-sections
313 LDLIBS = -lm
314 OCFLAGS = --strip-unneeded
315
316 all: dep size $(OUTFILE).bin $(OUTFILE).hex
317
318 dep: $(DEPS)
319
320 $(DEPS) : %.dep : %.c
321 $(CC) $(CPPFLAGS) $(CFLAGS) -MM $< -MT $@ -MT $(@:%.dep=%.o) -MF $@
322
323 sinclude $(DEPS)
324
325 $(LD_TEMP):
326 -@echo "MEMORY" > $(LD_TEMP)
327 -@echo "{" >> $(LD_TEMP)
328 -@echo " flash(rx): ORIGIN = 0x00000000, LENGTH = $(FLASH)" >> $(LD_TEMP)
329 -@echo " sram(rwx): ORIGIN = 0x10000000+$(SRAM_USB), LENGTH = $(SRAM)-$(SRAM_USB)" >> $(LD_TEMP)
330 -@echo "}" >> $(LD_TEMP)
331 -@echo "INCLUDE $(LD_SCRIPT)" >> $(LD_TEMP)
332
333 $(OUTFILE).elf: $(OBJS) $(LD_TEMP)
334 $(LD) $(LDFLAGS) -T $(LD_TEMP) -o $(OUTFILE).elf $(OBJS) $(LDLIBS)
335
336 $(OUTFILE).bin: $(OUTFILE).elf $(LPCRC)
337 $(OBJCOPY) $(OCFLAGS) -O binary $(OUTFILE).elf $(OUTFILE).bin
338 $(LPCRC) $(OUTFILE).bin
339
340 $(OUTFILE).hex: $(OUTFILE).elf
341 $(OBJCOPY) $(OCFLAGS) -O ihex $(OUTFILE).elf $(OUTFILE).hex
342
343 size: $(OUTFILE).elf
344 $(SIZE) $(OUTFILE).elf
345
346 clean:
347 rm -f $(OBJS) $(LD_TEMP) $(OUTFILE).elf $(OUTFILE).bin $(OUTFILE).hex
348
349 distclean: clean
350 rm -f $(DEPS) $(LPCRC)
351
352 .PHONY: all dep size clean distclean
353
354 CFLAGS_FOR_BUILD = -Wall -Wextra -std=c99 -O0 -g
355
356 LPCRC_SRCS = tools/lpcrc/lpcrc.c
357 LPCRC_OBJS = $(LPCRC_SRCS:%.c=%.o)
358 LPCRC_DEPS = $(LPCRC_SRCS:%.c=%.dep)
359
360 $(LPCRC_DEPS) : %.dep : %.c
361 $(CC_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) -MM $< -MT $@ -MT $(@:%.dep=%.o) -MF $@
362
363 $(LPCRC_OBJS): %.o : %.c
364 $(CC_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) -o $@ -c $<
365
366 $(LPCRC): $(LPCRC_OBJS)
367 $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ $+ $(LDLIBS_FOR_BUILD)
This page took 0.06342 seconds and 3 git commands to generate.