Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

Commit

Permalink
Added folder for testbenches and Makefile support to compile them. Ad…
Browse files Browse the repository at this point in the history
…ded acquisition testbench.
  • Loading branch information
fnoble committed Feb 1, 2012
1 parent de4eabe commit d27d3d2
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 8 deletions.
34 changes: 31 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
SWIFTNAV_ROOT := $(shell pwd)
MAKEFLAGS += SWIFTNAV_ROOT=$(SWIFTNAV_ROOT)

.PHONY: all firmware docs
# Be silent per default, but 'make V=1' will show all compiler calls.
ifneq ($(V),1)
Q := @
# Do not print "Entering directory ...".
MAKEFLAGS += --no-print-directory
endif

all: firmware docs
.PHONY: all tests firmware docs

all: firmware tests

firmware:
cd src; $(MAKE) $(MFLAGS)
@printf "BUILD src\n"; \
$(MAKE) -C src $(MAKEFLAGS)

tests:
$(Q)for i in tests/*; do \
if [ -d $$i ]; then \
printf "BUILD $$i\n"; \
$(MAKE) -C $$i $(MAKEFLAGS) || exit $?; \
fi; \
done

clean:
@printf "CLEAN src\n"; \
$(MAKE) -C src $(MAKEFLAGS) clean
$(Q)for i in tests/*; do \
if [ -d $$i ]; then \
printf "CLEAN $$i\n"; \
$(MAKE) -C $$i $(MAKEFLAGS) clean || exit $?; \
fi; \
done

docs:
doxygen docs/Doxyfile
Expand Down
8 changes: 3 additions & 5 deletions stm32/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@
## along with this program. If not, see <http://www.gnu.org/licenses/>.
##

SWIFTNAV_ROOT = ..
PREFIX ?= arm-none-eabi
GIT_VERSION := $(shell ../scripts/git-check.sh)
GIT_VERSION := $(shell $(SWIFTNAV_ROOT)/scripts/git-check.sh)
# PREFIX ?= arm-elf
CC = $(PREFIX)-gcc
LD = $(PREFIX)-gcc
OBJCOPY = $(PREFIX)-objcopy
OBJDUMP = $(PREFIX)-objdump
# Uncomment this line if you want to use the installed (not local) library.
#TOOLCHAIN_DIR := $(shell dirname `which $(CC)`)/../$(PREFIX)
TOOLCHAIN_DIR = $(SWIFTNAV_ROOT)/../libopencm3/
TOOLCHAIN_DIR = /home/fnoble/libopencm3/
CFLAGS += -O0 -g -Wall -Wextra -Werror -I$(TOOLCHAIN_DIR)/include \
-fno-common -mcpu=cortex-m3 -mthumb -msoft-float -MD -DSTM32F2 \
-DGIT_VERSION="\"$(GIT_VERSION)\"" -std=gnu99
Expand Down Expand Up @@ -79,7 +78,7 @@ flash: $(BINARY).flash
@printf " OBJDUMP $(*).list\n"
$(Q)$(OBJDUMP) -S $(*).elf > $(*).list

%.elf: $(OBJS) $(LDSCRIPT) $(TOOLCHAIN_DIR)/lib/stm32/f2/libopencm3_stm32f2.a
%.elf: $(OBJS)
@printf " LD $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(LD) -o $(*).elf $(OBJS) -lopencm3_stm32f2 -Xlinker -Map=$(*).map $(LDFLAGS)

Expand Down Expand Up @@ -122,5 +121,4 @@ ftdi_kextload:

.PHONY: images clean ftdi_kextload ftdi_kextunload

-include $(OBJS:.o=.d)

18 changes: 18 additions & 0 deletions tests/acq/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
BINARY = acq_test

OBJS = acq_test.o \
../../src/debug.o \
../../src/swift_nap_io.o \
../../src/acq.o \
../../src/track.o \
../../src/nav_msg.o \
../../src/hw/max2769.o \
../../src/hw/m25_flash.o \
../../src/hw/leds.o \
../../src/hw/spi.o \
../../src/hw/usart.o \

CFLAGS += -I../../src/

include ../../stm32/Makefile.include

85 changes: 85 additions & 0 deletions tests/acq/acq_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright (C) 2011 Fergus Noble <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdio.h>
#include <libopencm3/stm32/f2/rcc.h>
#include <libopencm3/stm32/f2/flash.h>
#include <libopencm3/stm32/f2/gpio.h>

#include "main.h"
#include "debug.h"
#include "swift_nap_io.h"
#include "acq.h"
#include "hw/leds.h"

const clock_scale_t hse_16_368MHz_in_65_472MHz_out_3v3 =
{ /* 65.472 MHz */
.pllm = 16,
.plln = 256,
.pllp = 4,
.pllq = 6,
.hpre = RCC_CFGR_HPRE_DIV_NONE,
.ppre1 = RCC_CFGR_PPRE_DIV_4,
.ppre2 = RCC_CFGR_PPRE_DIV_4,
.flash_config = FLASH_ICE | FLASH_DCE | FLASH_LATENCY_2WS,
.apb1_frequency = 16368000,
.apb2_frequency = 16368000,
};

int main(void)
{
for (u32 i = 0; i < 600000; i++)
__asm__("nop");

led_setup();

rcc_clock_setup_hse_3v3(&hse_16_368MHz_in_65_472MHz_out_3v3);

debug_setup();

printf("\n\nFirmware info - git: " GIT_VERSION ", built: " __DATE__ " " __TIME__ "\n");
printf("--- ACQ TEST ---\n");

swift_nap_setup();
swift_nap_reset();

float code_phase;
float carrier_freq;
float snr;

acq_set_load_enable_blocking();
timing_strobe(timing_count() + 1000);
wait_for_exti();
acq_clear_load_enable_blocking();

for (u8 prn=0; prn<32; prn++) {
do_acq(prn, 0, 1023, -7000, 7000, 300, &code_phase, &carrier_freq, &snr);

printf("PRN %2u - Code phase: %7.2f, Carrier Freq: % 7.1f, SNR: %5.2f", prn+1, code_phase, carrier_freq, snr);
if (snr > 8.0)
printf(" :D\n");
else
printf("\n");
}

printf("DONE!\n");
led_on(LED_GREEN);
while (1);

return 0;
}

0 comments on commit d27d3d2

Please sign in to comment.