diff options
author | Karl Palsson <karlp@tweak.net.au> | 2016-03-04 00:40:08 +0000 |
---|---|---|
committer | Karl Palsson <karlp@tweak.net.au> | 2016-03-04 00:43:41 +0000 |
commit | f4ebd4a603a3a0b903424bb35ef68e9844a7dbe9 (patch) | |
tree | b561cb0a31bd1fb96e7a73b7d185b13a7d839f91 /tests | |
parent | 2a05ac39426c5bfc8dda9c0f54b6ff69ef0b57bd (diff) | |
download | olsndot-f4ebd4a603a3a0b903424bb35ef68e9844a7dbe9.tar.gz olsndot-f4ebd4a603a3a0b903424bb35ef68e9844a7dbe9.tar.bz2 olsndot-f4ebd4a603a3a0b903424bb35ef68e9844a7dbe9.zip |
attempt actual adc on l4
(insufficient,needs clocks yet)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/adc-power/Makefile.stm32l4-disco | 5 | ||||
-rw-r--r-- | tests/adc-power/adc-power.c | 6 | ||||
-rw-r--r-- | tests/adc-power/main-stm32l4-disco.c | 17 |
3 files changed, 23 insertions, 5 deletions
diff --git a/tests/adc-power/Makefile.stm32l4-disco b/tests/adc-power/Makefile.stm32l4-disco index 99fc9e2..7957e9d 100644 --- a/tests/adc-power/Makefile.stm32l4-disco +++ b/tests/adc-power/Makefile.stm32l4-disco @@ -6,9 +6,8 @@ BUILD_DIR = bin-$(BOARD) SHARED_DIR = ../../shared CFILES = main-$(BOARD).c -# hah, not yet! -#CFILES += adc-power.c -#CFILES += trace.c trace_stdio.c +CFILES += adc-power.c +CFILES += trace.c trace_stdio.c VPATH += $(SHARED_DIR) diff --git a/tests/adc-power/adc-power.c b/tests/adc-power/adc-power.c index bb70aa7..a188649 100644 --- a/tests/adc-power/adc-power.c +++ b/tests/adc-power/adc-power.c @@ -62,6 +62,12 @@ void adc_power_init(void) rcc_periph_clock_enable(RCC_ADC12); rcc_adc_prescale(RCC_CFGR2_ADCxPRES_PLL_CLK_DIV_1, RCC_CFGR2_ADCxPRES_PLL_CLK_DIV_1); adc_enable_regulator(ADC1); +#elif defined (STM32L4) + /* same same but different */ + rcc_periph_clock_enable(RCC_ADC1); + ADC_CR(ADC1) &= ~ADC_CR_DEEPPWD; + adc_enable_regulator(ADC1); + #else rcc_periph_clock_enable(RCC_ADC1); #if 0 diff --git a/tests/adc-power/main-stm32l4-disco.c b/tests/adc-power/main-stm32l4-disco.c index 4b8ca43..a23266f 100644 --- a/tests/adc-power/main-stm32l4-disco.c +++ b/tests/adc-power/main-stm32l4-disco.c @@ -10,6 +10,9 @@ #include <libopencm3/stm32/gpio.h> #include <libopencm3/stm32/rcc.h> +#include "trace.h" +#include "adc-power.h" + #define LED_DISCO_RED_PORT GPIOB #define LED_DISCO_RED_PIN GPIO2 #define LED_DISCO_GREEN_PORT GPIOE @@ -20,20 +23,30 @@ int main(void) { int i; int j = 0; - rcc_periph_clock_enable(RCC_GPIOB); - rcc_periph_clock_enable(RCC_GPIOE); + rcc_periph_clock_enable(RCC_GPIOB); // led + rcc_periph_clock_enable(RCC_GPIOE); // led + rcc_periph_clock_enable(RCC_GPIOA); // adcs + rcc_periph_clock_enable(RCC_GPIOC); // adcs + 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); gpio_mode_setup(LED_DISCO_RED_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LED_DISCO_RED_PIN); + /* ADC 1 channels 1 and 5 */ + gpio_mode_setup(GPIOC, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO0); + 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 < 0x10000; i++) { /* Wait a bit. */ __asm__("NOP"); } + adc_power_task_down(); gpio_toggle(LED_DISCO_RED_PORT, LED_DISCO_RED_PIN); for (i = 0; i < 0x10000; i++) { /* Wait a bit. */ __asm__("NOP"); |