summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKarl Palsson <karlp@tweak.net.au>2015-11-03 23:53:42 +0000
committerKarl Palsson <karlp@tweak.net.au>2016-03-04 00:43:21 +0000
commit19a85ae45beb97d5b260e80320e233f95c0e302b (patch)
treea4686cd846ae987a0e355ab7d2d047c9653982ca /tests
parentc522c29dcab2be8c8ee629e22a3f632d8c614282 (diff)
downloadolsndot-19a85ae45beb97d5b260e80320e233f95c0e302b.tar.gz
olsndot-19a85ae45beb97d5b260e80320e233f95c0e302b.tar.bz2
olsndot-19a85ae45beb97d5b260e80320e233f95c0e302b.zip
f0 working (one fixme)
need scan mode upstream?
Diffstat (limited to 'tests')
-rw-r--r--tests/adc-power/Makefile.stm32f072-disco19
-rw-r--r--tests/adc-power/adc-power.c6
-rw-r--r--tests/adc-power/main-stm32f072-disco.c67
3 files changed, 89 insertions, 3 deletions
diff --git a/tests/adc-power/Makefile.stm32f072-disco b/tests/adc-power/Makefile.stm32f072-disco
new file mode 100644
index 0000000..99eade8
--- /dev/null
+++ b/tests/adc-power/Makefile.stm32f072-disco
@@ -0,0 +1,19 @@
+BOARD = stm32f072-disco
+PROJECT = adc-power-$(BOARD)
+BUILD_DIR = bin-$(BOARD)
+
+SHARED_DIR = ../../shared
+
+CFILES = main-$(BOARD).c
+CFILES += adc-power.c
+# No trace on cm0!
+#CFILES += trace.c trace_stdio.c
+CFILES += usart_stdio.c
+
+VPATH += $(SHARED_DIR)
+
+INCLUDES += $(patsubst %,-I%, . $(SHARED_DIR))
+
+OPENCM3_DIR=../../libopencm3
+include ../../rules.stm32f0.mk
+include ../../rules.mk
diff --git a/tests/adc-power/adc-power.c b/tests/adc-power/adc-power.c
index 734e3af..c673666 100644
--- a/tests/adc-power/adc-power.c
+++ b/tests/adc-power/adc-power.c
@@ -22,7 +22,7 @@
// Still have some bad shit to deal with...
#if defined(STM32F0)
#define SEPARATE_ADC_SAMPLING 0
-#define SAMPLE_TIME_BASIC ADC_SMPR_SMP_239DOT5
+#define SAMPLE_TIME_BASIC ADC_SMPR_SMP_239DOT5 // 4usec or more for tempsensor
#elif defined(STM32F3)
#define SAMPLE_TIME_BASIC ADC_SMPR1_SMP_181DOT5CYC
#define SAMPLE_TIME_TEMP ADC_SMPR1_SMP_601DOT5CYC // 2.2usecs or more
@@ -67,7 +67,7 @@ void adc_power_init(void)
adc_enable_scan_mode(ADC1);
ADC_CR2 |= ADC_CR2_EOCS; // FIXME
#else
- adc_disable_scan_mode(ADC1);
+ // FIXME - f0! adc_disable_scan_mode(ADC1);
#endif
#endif
@@ -150,4 +150,4 @@ void adc_power_task_down()
adc_power_off(ADC1);
unsigned int td = TIM_CNT(TIMER);
printf("toff in: %u\n", td);
-} \ No newline at end of file
+}
diff --git a/tests/adc-power/main-stm32f072-disco.c b/tests/adc-power/main-stm32f072-disco.c
new file mode 100644
index 0000000..4a960e1
--- /dev/null
+++ b/tests/adc-power/main-stm32f072-disco.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2015 Karl Palsson <karlp@tweak.net.au>
+ */
+
+#include <libopencm3/cm3/nvic.h>
+#include <libopencm3/stm32/crs.h>
+#include <libopencm3/stm32/gpio.h>
+#include <libopencm3/stm32/rcc.h>
+#include <libopencm3/stm32/usart.h>
+
+#include <stdio.h>
+#include "adc-power.h"
+
+static
+void setup_usart(void)
+{
+ uint32_t dev = USART1;
+ rcc_periph_clock_enable(RCC_USART1);
+ rcc_periph_clock_enable(RCC_GPIOA);
+ gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9);
+ gpio_set_af(GPIOA, GPIO_AF1, GPIO9);
+
+ usart_set_baudrate(dev, 115200);
+ usart_set_databits(dev, 8);
+ usart_set_parity(dev, USART_PARITY_NONE);
+ usart_set_stopbits(dev, USART_CR2_STOP_1_0BIT);
+ usart_set_mode(dev, USART_MODE_TX);
+ usart_set_flow_control(dev, USART_FLOWCONTROL_NONE);
+
+ /* Finally enable the USART. */
+ usart_enable(dev);
+}
+
+int main(void)
+{
+ int i;
+ rcc_clock_setup_in_hsi48_out_48mhz();
+ setup_usart();
+
+ /* LED on for boot progress */
+ rcc_periph_clock_enable(RCC_GPIOC);
+ gpio_mode_setup(GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO7);
+ gpio_set(GPIOC, GPIO7);
+
+ printf("hi guys!\n");
+
+ 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(GPIOC, GPIO7);
+
+ for (i = 0; i < 0x100000; i++) { /* Wait a bit. */
+ __asm__("NOP");
+ }
+ printf("tick...\n");
+ adc_power_task_down();
+ gpio_toggle(GPIOC, GPIO7);
+ for (i = 0; i < 0x100000; i++) { /* Wait a bit. */
+ __asm__("NOP");
+ }
+ }
+
+}
+