forked from TZlindra/ELEC291Project2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.mk
83 lines (62 loc) · 2.53 KB
/
main.mk
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
82
83
SHELL=cmd
CC=arm-none-eabi-gcc # Need Added to Path
AS=arm-none-eabi-as # Need Added to Path
LD=arm-none-eabi-ld # Need Added to Path
CCFLAGS=-mcpu=cortex-m0 -mthumb -g
# Search for the path of the right libraries. Works only on Windows.
GCCPATH=$(subst \bin\arm-none-eabi-gcc.exe,\,$(shell where $(CC)))
LIBPATH1=$(subst \libgcc.a,,$(shell dir /s /b "$(GCCPATH)*libgcc.a" | find "v6-m"))
LIBPATH2=$(subst \libc_nano.a,,$(shell dir /s /b "$(GCCPATH)*libc_nano.a" | find "v6-m"))
LIBSPEC=-L"$(LIBPATH1)" -L"$(LIBPATH2)"
OBJS=main.o startup.o serial.o global.o UART2.o JDY40.o lcd.o adc.o speaker.o frequency_calc.o passcode.o movement.o newlib_stubs.o
# Notice that floating point is enabled with printf (-u _printf_float)
main.hex: $(OBJS)
$(LD) $(OBJS) $(LIBSPEC) -Os -u _printf_float -nostdlib -lnosys -lgcc -T ../Common/LDscripts/stm32l051xx.ld --cref -Map main.map -o main.elf
arm-none-eabi-objcopy -O ihex main.elf main.hex
@echo Success!
main.o: main.c
$(CC) -c $(CCFLAGS) main.c -o main.o
global.o: global.c
$(CC) -c $(CCFLAGS) global.c -o global.o
adc.o: adc.c
$(CC) -c $(CCFLAGS) adc.c -o adc.o
passcode.o: passcode.c
$(CC) -c $(CCFLAGS) passcode.c -o passcode.o
lcd.o: lcd.c
$(CC) -c $(CCFLAGS) lcd.c -o lcd.o
JDY40.o: JDY40.c
$(CC) -c $(CCFLAGS) JDY40.c -o JDY40.o
speaker.o: speaker.c
$(CC) -c $(CCFLAGS) speaker.c -o speaker.o
frequency_calc.o: frequency_calc.c
$(CC) -c $(CCFLAGS) frequency_calc.c -o frequency_calc.o
movement.o: movement.c
$(CC) -c $(CCFLAGS) movement.c -o movement.o
UART2.o: UART2.c
$(CC) -c $(CCFLAGS) UART2.c -o UART2.o
startup.o: ../Common/Source/startup.c
$(CC) -c $(CCFLAGS) -DUSE_USART1 ../Common/Source/startup.c -o startup.o
serial.o: ../Common/Source/serial.c
$(CC) -c $(CCFLAGS) ../Common/Source/serial.c -o serial.o
newlib_stubs.o: ../Common/Source/newlib_stubs.c
$(CC) -c $(CCFLAGS) ../Common/Source/newlib_stubs.c -o newlib_stubs.o
clean:
@del $(OBJS) 2>NUL
@del main.elf main.hex main.map 2>NUL
Load_Flash: main.hex
@taskkill /f /im putty.exe /t /fi "status eq running" > NUL
@echo ..\stm32flash\stm32flash -w main.hex -v -g 0x0 ^^>loadf.bat
@..\stm32flash\BO230\BO230 -b >>loadf.bat
@loadf
@echo cmd /c start putty.exe -sercfg 115200,8,n,1,N -serial ^^>sputty.bat
@..\stm32flash\BO230\BO230 -r >>sputty.bat
@sputty
putty:
@taskkill /f /im putty.exe /t /fi "status eq running" > NUL
@echo cmd /c start putty.exe -sercfg 115200,8,n,1,N -serial ^^>sputty.bat
@..\stm32flash\BO230\BO230 -r >>sputty.bat
@sputty
explorer:
@explorer .
dummy: main.map main.hex
@echo Hello from 'dummy' target...