summaryrefslogtreecommitdiff
path: root/tests/adc-power
diff options
context:
space:
mode:
Diffstat (limited to 'tests/adc-power')
-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.stm32f4-disco.cfg12
-rw-r--r--tests/adc-power/openocd.stm32l1-generic.cfg15
7 files changed, 146 insertions, 24 deletions
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.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