collab/pb-hal
git clone https://git.julia.blue/collab/pb-hal
1dbe808
control
1# Makefile for PWM-Test 2TARGET = PWM-Test.axf 3 4# Library Locations 5RASLIB = ../RASLib 6STELLARIS = /usr/local/lib/StellarisWare 7CORTEXM4 = /usr/local/lib/CortexM4Libs 8ARMCLIB = $( dir $( shell which $( CC ) )) .. 9GDBSCRIPT = $( RASLIB ) /gdb-script 10 11# Board device path 12DETECT_SCRIPT = $( RASLIB ) /detect-board 13 14# Command Definitions 15PREFIX = arm-none-eabi- 16 17CC := $( PREFIX ) gcc 18LD := $( PREFIX ) ld 19AR := $( PREFIX ) ar 20OBJCOPY := $( PREFIX ) objcopy 21SIZE := $( PREFIX ) size 22GDB := $( PREFIX ) gdb 23 24OPENOCDCFG := $( shell find /usr-path */scripts/board/*tm4c123*2 > /dev/null) 25OPENOCD = openocd -f$( OPENOCDCFG ) 26SCREEN := screen 27 28# File Definitions 29SRC := $( wildcard src/*.c *.c) 30INC = inc$( RASLIB ) /..$( STELLARIS ) /..$( STELLARIS ) 31LIB = ras driver-cm4f m c gcc 32LDS = lm4f.ld 33 34OBJ := $( SRC:.c=.o) 35ASM := $( SRC:.c=.s) 36 37# Flag Definitions 38CFLAGS += -mthumb 39CFLAGS += -mcpu=cortex-m4 40 41ifneq ($( filter MINGW%,$( shell uname )) ,) 42lib-search-dirs = $( shell ${ CC } ${ CFLAGS } -print-search-dirs | grep libraries| sed -e "s/libraries:\ =/-L'/" -e "s/ /\\\ /" -e "s/;/' -L'/g" -e "s/ $ $/'/" ) 43else 44lib-search-dirs = $( shell ${ CC } ${ CFLAGS } -print-search-dirs | grep libraries| sed -e "s/libraries:\ =/-L'/" -e "s/ /\\\ /" -e "s/:/' -L'/g" -e "s/ $ $/'/" ) 45endif 46 47$( info $( lib-search-dirs )) 48 49LDDIR += $( RASLIB ) /output 50LDDIR += $( STELLARIS ) /driverlib/gcc-cm4f 51LDDIR += $( CORTEXM4 ) 52 53$( info $( LDDIR )) 54 55CFLAGS += -g 56CFLAGS += -mfpu=fpv4-sp-d16 57CFLAGS += -mfloat-abi=softfp 58CFLAGS += -O0 59CFLAGS += -ffunction-sections 60CFLAGS += -fdata-sections 61CFLAGS += -MD 62CFLAGS += -std=c99 63CFLAGS += -Dgcc 64CFLAGS += -DPART_LM4F120H5QR 65CFLAGS += -DTARGET_IS_BLIZZARD_RA1 66 67LDFLAGS += --entry ResetHandler 68LDFLAGS += --gc-sections 69 70CFLAGS += $( addprefix -I,$( INC )) 71LDFLAGS += $( addprefix -L,$( LDDIR )) 72LDFLAGS += ${ lib-search-dirs } 73LDFLAGS += $( addprefix -l,$( LIB )) 74 75# Rules 76all : $( TARGET ) 77 78-include$( OBJECTS:.o=.d) 79 80asm : $( ASM ) 81 82size : $( TARGET ) 83$( SIZE ) $ < 84 85flash2 : $( TARGET ) 86$( OPENOCD ) -c "init" \ 87-c "halt" \ 88-c "flash write_image erase $( TARGET ) " \ 89-c "verify_image $( TARGET ) " \ 90-c "halt" \ 91-c "shutdown" 92 93flash : $( TARGET ) 94lm4flash $ < 95 96debug : $( TARGET ) 97$( GDB ) $ < -x$( RASLIB ) /gdb-script 98 99uart : 100$( SCREEN ) $( shell $( DETECT_SCRIPT ) ) 115200 101 102run : flash 103$( SCREEN ) $( shell $( DETECT_SCRIPT ) ) 115200 104 105clean : 106 -rm $( TARGET ) 107 -rm $( TARGET:.axf=.out ) 108 -rm $( ASM ) 109 -rm $( OBJ:.o=.d ) 110 111 112%.a : $( OBJ ) 113$( AR ) rcs$ @ $ ^ 114 115%.axf : %.out 116$( OBJCOPY ) -O binary$ < $ @ 117 118%.out : $( OBJ ) 119$( LD ) -T $( LDS ) -o $ @ $( OBJ ) $( LDFLAGS ) 120 121%.o : %.c 122$( CC ) -c $( CFLAGS ) -o $ @ $ < 123 124%.s : %.c 125$( CC ) -S $( CFLAGS ) -o $ @ $ <