summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--openocd/openocd.common.cfg10
-rw-r--r--openocd/openocd.stm32f072disco.cfg (renamed from tests/adc-power/openocd.stm32f4-disco.cfg)10
-rw-r--r--openocd/openocd.stm32f072disco.local.cfg2
-rw-r--r--openocd/openocd.stm32f4-disco.cfg8
-rw-r--r--openocd/openocd.stm32f4-disco.local.cfg2
-rw-r--r--openocd/openocd.stm32l1-generic.cfg15
-rw-r--r--tests/adc-power/Makefile.stm32l053-disco43
-rw-r--r--tests/adc-power/Makefile.stm32l1-generic18
-rw-r--r--tests/adc-power/main-stm32l1-generic.c53
-rw-r--r--tests/adc-power/openocd.stm32f103-generic.cfg17
-rw-r--r--tests/adc-power/openocd.stm32f3-disco.cfg12
-rw-r--r--tests/adc-power/openocd.stm32l1-generic.cfg15
12 files changed, 185 insertions, 20 deletions
diff --git a/openocd/openocd.common.cfg b/openocd/openocd.common.cfg
new file mode 100644
index 0000000..b601cde
--- /dev/null
+++ b/openocd/openocd.common.cfg
@@ -0,0 +1,10 @@
+# Shared openocd script helpers
+
+# put things like "hla_serial 'asdfadfa'" in openocd.<board>.local.cfg to support
+# multiple simultaneously connected boards.
+proc optional_local { LOCAL_FILE } {
+ if { [ file exists $LOCAL_FILE ] } {
+ puts "Loading custom local settings from $LOCAL_FILE"
+ source $LOCAL_FILE
+ }
+}
diff --git a/tests/adc-power/openocd.stm32f4-disco.cfg b/openocd/openocd.stm32f072disco.cfg
index d1d19ea..b7cc25b 100644
--- a/tests/adc-power/openocd.stm32f4-disco.cfg
+++ b/openocd/openocd.stm32f072disco.cfg
@@ -1,12 +1,14 @@
source [find interface/stlink-v2.cfg]
set WORKAREASIZE 0x4000
-source [find target/stm32f4x.cfg]
+source [find target/stm32f0x.cfg]
-# My board
-hla_serial "W?k\x06IgHV0H\x10?"
+source openocd.common.cfg
+optional_local "openocd.stm32f072disco.local.cfg"
-tpiu config internal swodump.stm32f4-disco.log uart off 168000000
+# no trace on cm0
+#tpiu config internal swodump.stm32f4disco.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/openocd/openocd.stm32f072disco.local.cfg b/openocd/openocd.stm32f072disco.local.cfg
new file mode 100644
index 0000000..f81e2a3
--- /dev/null
+++ b/openocd/openocd.stm32f072disco.local.cfg
@@ -0,0 +1,2 @@
+# serial of my f072 disco board.
+hla_serial "Q?o\x06PgHW#$\x16?"
diff --git a/openocd/openocd.stm32f4-disco.cfg b/openocd/openocd.stm32f4-disco.cfg
index 478fe30..a93997c 100644
--- a/openocd/openocd.stm32f4-disco.cfg
+++ b/openocd/openocd.stm32f4-disco.cfg
@@ -2,12 +2,12 @@ source [find interface/stlink-v2.cfg]
set WORKAREASIZE 0x4000
source [find target/stm32f4x.cfg]
-# serial of my f4 disco board.
-hla_serial "W?k\x06IgHV0H\x10?"
+source openocd.common.cfg
+optional_local "openocd.stm32f4-disco.local.cfg"
tpiu config internal swodump.stm32f4disco.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
+#reset_config srst_only srst_nogate
+reset_config srst_only srst_nogate connect_assert_srst
diff --git a/openocd/openocd.stm32f4-disco.local.cfg b/openocd/openocd.stm32f4-disco.local.cfg
new file mode 100644
index 0000000..8cace82
--- /dev/null
+++ b/openocd/openocd.stm32f4-disco.local.cfg
@@ -0,0 +1,2 @@
+# serial of my f4 disco board.
+hla_serial "W?k\x06IgHV0H\x10?"
diff --git a/openocd/openocd.stm32l1-generic.cfg b/openocd/openocd.stm32l1-generic.cfg
new file mode 100644
index 0000000..6b39750
--- /dev/null
+++ b/openocd/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
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 <http://www.gnu.org/licenses/>.
+##
+
+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 <karlp@tweak.net.au>
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <libopencm3/cm3/nvic.h>
+#include <libopencm3/stm32/adc.h>
+#include <libopencm3/stm32/flash.h>
+#include <libopencm3/stm32/gpio.h>
+#include <libopencm3/stm32/rcc.h>
+#include <libopencm3/stm32/usart.h>
+
+#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.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