diff options
| author | Keith Packard <keithp@keithp.com> | 2019-02-18 12:59:05 -0800 |
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2019-02-18 13:08:23 -0800 |
| commit | 7a89aa1ea7e1b02b5cd310986adf4239ec0ce91d (patch) | |
| tree | 74e5fe54f95ab21e513a1c9a14b8a02c1c8cffea /src/lpc | |
| parent | 889518aeee080b0f8bb954db86d08105898d8161 (diff) | |
altos: Move common build definitions to src/Makefile.defs
This cleans up the build process for all architectures, providing a
common place to specify vpath, cflags and build rules for various
common files.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/lpc')
| -rw-r--r-- | src/lpc/Makefile-flash.defs | 7 | ||||
| -rw-r--r-- | src/lpc/Makefile-lpc.defs | 52 | ||||
| -rw-r--r-- | src/lpc/Makefile.defs | 3 | ||||
| -rw-r--r-- | src/lpc/clock_figure.5c | 113 |
4 files changed, 119 insertions, 56 deletions
diff --git a/src/lpc/Makefile-flash.defs b/src/lpc/Makefile-flash.defs index 4a245d10..44b43bfe 100644 --- a/src/lpc/Makefile-flash.defs +++ b/src/lpc/Makefile-flash.defs @@ -33,7 +33,7 @@ PRODUCT=AltosFlash PRODUCT_DEF=-DALTOS_FLASH IDPRODUCT=0x000a -CFLAGS = $(PRODUCT_DEF) $(LPC_CFLAGS) -g -Os +CFLAGS = $(PRODUCT_DEF) $(LPC_CFLAGS) LDFLAGS=$(CFLAGS) -L$(TOPDIR)/lpc -Wl,-Taltos-loader.ld @@ -41,10 +41,7 @@ PROGNAME=altos-flash PROG=$(HARDWARE)-$(PROGNAME)-$(VERSION).elf $(PROG): Makefile $(OBJ) altos-loader.ld - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS) - -ao_product.h: ao-make-product.5c $(TOPDIR)/Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ + $(call quiet,CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(LIBS) $(OBJ): $(INC) diff --git a/src/lpc/Makefile-lpc.defs b/src/lpc/Makefile-lpc.defs index 16da583f..8b297351 100644 --- a/src/lpc/Makefile-lpc.defs +++ b/src/lpc/Makefile-lpc.defs @@ -2,57 +2,13 @@ ifndef TOPDIR TOPDIR=.. endif -include $(TOPDIR)/Makedefs +include $(TOPDIR)/Makefile.defs -vpath % $(TOPDIR)/lpc:$(TOPDIR)/product:$(TOPDIR)/drivers:$(TOPDIR)/kernel:$(TOPDIR)/util:$(TOPDIR)/kalman:$(TOPDIR)/aes:$(TOPDIR):$(TOPDIR)/math -vpath make-altitude $(TOPDIR)/util -vpath make-kalman $(TOPDIR)/util -vpath kalman.5c $(TOPDIR)/kalman -vpath kalman_filter.5c $(TOPDIR)/kalman -vpath load_csv.5c $(TOPDIR)/kalman -vpath matrix.5c $(TOPDIR)/kalman -vpath ao-make-product.5c $(TOPDIR)/util +vpath % $(TOPDIR)/lpc:$(AO_VPATH) -.SUFFIXES: .elf .ihx - -.elf.ihx: - $(ELFTOHEX) --output=$@ $*.elf - - -ifndef VERSION -include $(TOPDIR)/Version -endif - -ELFTOHEX=$(TOPDIR)/../ao-tools/ao-elftohex/ao-elftohex CC=$(ARM_CC) -WARN_FLAGS=-Wall -Wextra -Werror -Wcast-align \ - -Wpointer-arith \ - -Wstrict-prototypes \ - -Wmissing-prototypes \ - -Wmissing-declarations \ - -Wnested-externs \ - -Wshadow - -AO_CFLAGS=-I. -I$(TOPDIR)/lpc -I$(TOPDIR)/kernel -I$(TOPDIR)/drivers \ - -DNEWLIB_INTEGER_PRINTF_SCANF \ - -I$(TOPDIR)/product -I$(TOPDIR) -I$(TOPDIR)/math -I$(TOPDIR) \ - -isystem $(NEWLIB_NANO)/arm-none-eabi/include - -LPC_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m0 -mthumb\ - -ffreestanding -nostdlib $(AO_CFLAGS) $(WARN_FLAGS) - -NICKLE=nickle - LIBS=-L$(NEWLIB_NANO)/arm-none-eabi/lib/thumb/v6-m -lc -lm -lgcc -V=0 -# The user has explicitly enabled quiet compilation. -ifeq ($(V),0) -quiet = @printf " $1 $2 $@\n"; $($1) -endif -# Otherwise, print the full command line. -quiet ?= $($1) - -.c.o: - $(call quiet,CC) -c $(CFLAGS) -o $@ $< +LPC_CFLAGS=-mlittle-endian -mcpu=cortex-m0 -mthumb\ + -I$(TOPDIR)/lpc $(AO_CFLAGS) $(NEWLIB_CFLAGS) diff --git a/src/lpc/Makefile.defs b/src/lpc/Makefile.defs index 5bb8133d..7fdcf0dc 100644 --- a/src/lpc/Makefile.defs +++ b/src/lpc/Makefile.defs @@ -3,7 +3,6 @@ TOPDIR=.. endif include $(TOPDIR)/lpc/Makefile-lpc.defs -include $(TOPDIR)/Makedefs LDFLAGS=$(CFLAGS) -L$(TOPDIR)/lpc -Wl,-Taltos.ld -n @@ -11,5 +10,3 @@ ao_serial_lpc.h: $(TOPDIR)/lpc/baud_rate ao_pins.h nickle $(TOPDIR)/lpc/baud_rate `awk '/AO_LPC_CLKOUT/{print $$3}' ao_pins.h` > $@ ao_serial_lpc.o: ao_serial_lpc.h - -.DEFAULT_GOAL=all diff --git a/src/lpc/clock_figure.5c b/src/lpc/clock_figure.5c new file mode 100644 index 00000000..d2f632a0 --- /dev/null +++ b/src/lpc/clock_figure.5c @@ -0,0 +1,113 @@ +#!/usr/bin/nickle + +real +pll_out(real clock_in, int mul, int div) +{ + return clock_in * mul / div; +} + +real +pll_in(real pll_out, int mul, int div) +{ + return pll_out * div / mul; +} + +real +fcco_out(real clock_in, int mul, int div) +{ + real out = pll_out(clock_in, mul, div); + return out * div; +} + +bool +valid_clock_in(real clock_in) +{ + return 10 <= clock_in && clock_in < 25; +} + +bool +valid_fcco(real clock_in, int mul, int div) +{ + real fcco = fcco_out (clock_in, mul, div); + return 156 <= fcco && fcco <= 320; +} + +void +all_clocks(real clock_in) { + for (int mul = 1; mul <= 32; mul++) { + for (int div = 2; div <= 16; div *= 2) { + if (!valid_fcco(clock_in, mul, div)) + printf ("clock_in %f mul %d div %d invalid fcco %f\n", + clock_in, mul, div, fcco_out(clock_in, mul, div)); + else + printf ("clock_in %f mul %d div %d pll_out %f\n", + clock_in, mul, div, pll_out(clock_in, mul, div)); + } + } +} + +typedef struct { + real clock_in; + int mul; + int div; + real pll_out; +} clock; + +clock[] +all_ins(real pll_out) +{ + clock[...] clocks = {}; + for (int mul = 1; mul <= 32; mul++) { + for (int div = 2; div <= 16; div *= 2) { + real clock_in = pll_in(pll_out, mul, div); + if (valid_clock_in(clock_in) && valid_fcco(clock_in, mul, div)) { + clocks[dim(clocks)] = (clock) { + .clock_in = clock_in, + .mul = mul, + .div = div, + .pll_out = pll_out + }; + } + } + } + return clocks; +} + +#all_clocks(12.0); + +autoload Sort; + +void +dump_clocks(clock[] clocks) +{ + printf ("Clocks for %f\n", clocks[0].pll_out); + Sort::qsort(&clocks, bool func(clock a, clock b) { return a.clock_in > b.clock_in; }); + for (int i = 0; i < dim (clocks); i++) { + printf("\tclock_in %f mul %d div %d\n", + clocks[i].clock_in, + clocks[i].mul, + clocks[i].div); + } +} + +void +find_clocks() { + clock[] c40 = all_ins(40.0); + clock[] c48 = all_ins(48.0); + + dump_clocks(c40); + dump_clocks(c48); + for (int i40 = 0; i40 < dim(c40); i40++) { + for (int i48 = 0; i48 < dim(c48); i48++) { + if (c40[i40].clock_in == c48[i48].clock_in) + printf ("clock_in %f mul_40 %d div_40 %d mul_48 %d div_48 %d\n", + c40[i40].clock_in, + c40[i40].mul, + c40[i40].div, + c48[i48].mul, + c48[i48].div); + } + } +} + +find_clocks(); |
