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