From 19d3225fd66573a2a62ece83158cd5551255f2ad Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Mon, 26 Sep 2016 20:57:10 +0000 Subject: adc-power: update makefiles with work lying around --- tests/adc-power/Makefile.stm32l053-disco | 43 ++++++++++++++++++++++ tests/adc-power/Makefile.stm32l1-generic | 18 +++++++++ tests/adc-power/main-stm32l1-generic.c | 53 +++++++++++++++++++++++++++ tests/adc-power/openocd.stm32f103-generic.cfg | 17 +++++++++ tests/adc-power/openocd.stm32f3-disco.cfg | 12 ------ tests/adc-power/openocd.stm32f4-disco.cfg | 12 ------ tests/adc-power/openocd.stm32l1-generic.cfg | 15 ++++++++ 7 files changed, 146 insertions(+), 24 deletions(-) create mode 100644 tests/adc-power/Makefile.stm32l053-disco create mode 100644 tests/adc-power/Makefile.stm32l1-generic create mode 100644 tests/adc-power/main-stm32l1-generic.c create mode 100644 tests/adc-power/openocd.stm32f103-generic.cfg delete mode 100644 tests/adc-power/openocd.stm32f3-disco.cfg delete mode 100644 tests/adc-power/openocd.stm32f4-disco.cfg create mode 100644 tests/adc-power/openocd.stm32l1-generic.cfg (limited to 'tests') diff --git a/tests/adc-power/Makefile.stm32l053-disco b/tests/adc-power/Makefile.stm32l053-disco new file mode 100644 index 0000000..1957e65 --- /dev/null +++ b/tests/adc-power/Makefile.stm32l053-disco @@ -0,0 +1,43 @@ +## +## This file is part of the libopencm3 project. +## +## This library is free software: you can redistribute it and/or modify +## it under the terms of the GNU Lesser General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## This library 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 Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public License +## along with this library. If not, see . +## + +BOARD = stm32l053disco +PROJECT = usb-gadget0-$(BOARD) +BUILD_DIR = bin-$(BOARD) + +SHARED_DIR = ../shared + +CFILES = main-$(BOARD).c +CFILES += usb-gadget0.c + +VPATH += $(SHARED_DIR) + +INCLUDES += $(patsubst %,-I%, . $(SHARED_DIR)) + +OPENCM3_DIR=../.. + +### This section can go to an arch shared rules eventually... +LDSCRIPT = ../../lib/stm32/l0/stm32l0xx8.ld +OPENCM3_LIB = opencm3_stm32l0 +OPENCM3_DEFS = -DSTM32L0 +#FP_FLAGS ?= -mfloat-abi=hard -mfpu=fpv4-sp-d16 +ARCH_FLAGS = -mthumb -mcpu=cortex-m0plus $(FP_FLAGS) +#OOCD_INTERFACE = stlink-v2-1 +#OOCD_TARGET = stm32l0 +OOCD_FILE = ../../openocd/openocd.stm32l053disco.cfg + +include ../rules.mk diff --git a/tests/adc-power/Makefile.stm32l1-generic b/tests/adc-power/Makefile.stm32l1-generic new file mode 100644 index 0000000..cc8de84 --- /dev/null +++ b/tests/adc-power/Makefile.stm32l1-generic @@ -0,0 +1,18 @@ +BOARD = stm32l1-generic +PROJECT = adc-power-$(BOARD) +BUILD_DIR = bin-$(BOARD) + +SHARED_DIR = ../../shared + +CFILES = main-$(BOARD).c +CFILES += adc-power.c +CFILES += trace.c trace_stdio.c + +VPATH += $(SHARED_DIR) + +INCLUDES += $(patsubst %,-I%, . $(SHARED_DIR)) + +OPENCM3_DIR=../../libopencm3 +DEVICE=stm32l151xb +OOCD_FILE = openocd.stm32l1-generic.cfg +include ../../rules.mk diff --git a/tests/adc-power/main-stm32l1-generic.c b/tests/adc-power/main-stm32l1-generic.c new file mode 100644 index 0000000..9f80be0 --- /dev/null +++ b/tests/adc-power/main-stm32l1-generic.c @@ -0,0 +1,53 @@ +/* + * Oct 2015 Karl Palsson + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "trace.h" +#include "adc-power.h" + +#define LED_DISCO_GREEN_PORT GPIOB +#define LED_DISCO_GREEN_PIN GPIO7 + + +int main(void) +{ + int i; + int j = 0; + rcc_clock_setup_pll(&rcc_clock_config[RCC_CLOCK_VRANGE1_HSI_PLL_32MHZ]); + rcc_periph_clock_enable(RCC_GPIOB); + printf("hi guys!\n"); + /* green led for ticking */ + gpio_mode_setup(LED_DISCO_GREEN_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, + LED_DISCO_GREEN_PIN); + + rcc_periph_clock_enable(RCC_GPIOA); + gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1); + gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO5); + + adc_power_init(); + while (1) { + adc_power_task_up(); + gpio_toggle(LED_DISCO_GREEN_PORT, LED_DISCO_GREEN_PIN); + + for (i = 0; i < 0x100000; i++) { /* Wait a bit. */ + __asm__("NOP"); + } + adc_power_task_down(); + gpio_toggle(LED_DISCO_GREEN_PORT, LED_DISCO_GREEN_PIN); + for (i = 0; i < 0x100000; i++) { /* Wait a bit. */ + __asm__("NOP"); + } + } + + return 0; +} diff --git a/tests/adc-power/openocd.stm32f103-generic.cfg b/tests/adc-power/openocd.stm32f103-generic.cfg new file mode 100644 index 0000000..f2da08c --- /dev/null +++ b/tests/adc-power/openocd.stm32f103-generic.cfg @@ -0,0 +1,17 @@ +# Unfortunately, with no f103 disco, we're currently +# using a separate disco board +source [find interface/stlink-v2.cfg] +set WORKAREASIZE 0x2000 +source [find target/stm32f1x.cfg] + +# Serial of my l1 disco used as stlink here. +#hla_serial "S?l\x06H?WQ%\x10\x18?" +# if f4 disco +hla_serial "W?k\x06IgHV0H\x10?" + +tpiu config internal swodump.stm32f103-generic.log uart off 72000000 + +# Uncomment to reset on connect, for grabbing under WFI et al +reset_config srst_only srst_nogate +# reset_config srst_only srst_nogate connect_assert_srst + diff --git a/tests/adc-power/openocd.stm32f3-disco.cfg b/tests/adc-power/openocd.stm32f3-disco.cfg deleted file mode 100644 index 6c91eb7..0000000 --- a/tests/adc-power/openocd.stm32f3-disco.cfg +++ /dev/null @@ -1,12 +0,0 @@ -source [find interface/stlink-v2.cfg] -set WORKAREASIZE 0x4000 -source [find target/stm32f3x.cfg] - -# my board -hla_serial "S?n\x06gePQ6G%g" - -tpiu config internal swodump.stm32f4-disco.log uart off 72000000 - -# Uncomment to reset on connect, for grabbing under WFI et al -reset_config srst_only srst_nogate -# reset_config srst_only srst_nogate connect_assert_srst diff --git a/tests/adc-power/openocd.stm32f4-disco.cfg b/tests/adc-power/openocd.stm32f4-disco.cfg deleted file mode 100644 index d1d19ea..0000000 --- a/tests/adc-power/openocd.stm32f4-disco.cfg +++ /dev/null @@ -1,12 +0,0 @@ -source [find interface/stlink-v2.cfg] -set WORKAREASIZE 0x4000 -source [find target/stm32f4x.cfg] - -# My board -hla_serial "W?k\x06IgHV0H\x10?" - -tpiu config internal swodump.stm32f4-disco.log uart off 168000000 - -# Uncomment to reset on connect, for grabbing under WFI et al -reset_config srst_only srst_nogate -# reset_config srst_only srst_nogate connect_assert_srst diff --git a/tests/adc-power/openocd.stm32l1-generic.cfg b/tests/adc-power/openocd.stm32l1-generic.cfg new file mode 100644 index 0000000..6b39750 --- /dev/null +++ b/tests/adc-power/openocd.stm32l1-generic.cfg @@ -0,0 +1,15 @@ +# l1 generic, using a l4 disco board +#source [find interface/stlink-v2-1.cfg] +# l1 disco itself or similar +source [find interface/stlink-v2.cfg] +set WORKAREASIZE 0x2000 +source [find target/stm32l1.cfg] + +#hla_serial "066DFF495351885087171826" # My l4 disco +hla_serial "S?l\x06H?WQ%\x10\x18?" # My l1 disco + +tpiu config internal swodump.stm32l1-generic.log uart off 32000000 + +# Uncomment to reset on connect, for grabbing under WFI et al +reset_config srst_only srst_nogate +# reset_config srst_only srst_nogate connect_assert_srst -- cgit