summaryrefslogtreecommitdiff
path: root/tests/adc-power
diff options
context:
space:
mode:
authorKarl Palsson <karlp@tweak.net.au>2016-03-14 21:34:18 +0000
committerKarl Palsson <karlp@tweak.net.au>2016-03-14 21:34:18 +0000
commit9b371b5189c368932d4dd15ca6904212cd59e83b (patch)
treeb3a89fea11e327dee2bd8b753c5fb9320ae5e057 /tests/adc-power
parent39467f34cbff0b1e21e6ea75b9359fd42321a416 (diff)
downloadolsndot-9b371b5189c368932d4dd15ca6904212cd59e83b.tar.gz
olsndot-9b371b5189c368932d4dd15ca6904212cd59e83b.tar.bz2
olsndot-9b371b5189c368932d4dd15ca6904212cd59e83b.zip
fix l4 to run at 48Mhz and with a clock
Diffstat (limited to 'tests/adc-power')
-rw-r--r--tests/adc-power/adc-power.c1
-rw-r--r--tests/adc-power/main-stm32l4-disco.c10
2 files changed, 11 insertions, 0 deletions
diff --git a/tests/adc-power/adc-power.c b/tests/adc-power/adc-power.c
index a188649..97a083a 100644
--- a/tests/adc-power/adc-power.c
+++ b/tests/adc-power/adc-power.c
@@ -66,6 +66,7 @@ void adc_power_init(void)
/* same same but different */
rcc_periph_clock_enable(RCC_ADC1);
ADC_CR(ADC1) &= ~ADC_CR_DEEPPWD;
+ RCC_CCIPR |= 3 << 28; // system clock as adc clock. (with CKMODE == 0)
adc_enable_regulator(ADC1);
#else
diff --git a/tests/adc-power/main-stm32l4-disco.c b/tests/adc-power/main-stm32l4-disco.c
index a23266f..ad21fcb 100644
--- a/tests/adc-power/main-stm32l4-disco.c
+++ b/tests/adc-power/main-stm32l4-disco.c
@@ -7,7 +7,9 @@
#include <stdio.h>
#include <unistd.h>
#include <libopencm3/cm3/nvic.h>
+#include <libopencm3/stm32/flash.h>
#include <libopencm3/stm32/gpio.h>
+#include <libopencm3/stm32/pwr.h>
#include <libopencm3/stm32/rcc.h>
#include "trace.h"
@@ -18,6 +20,12 @@
#define LED_DISCO_GREEN_PORT GPIOE
#define LED_DISCO_GREEN_PIN GPIO8
+int hack(void) {
+ pwr_set_vos_scale(PWR_SCALE1);
+ flash_set_ws(FLASH_ACR_LATENCY_2WS);
+ rcc_set_msi_range(RCC_CR_MSIRANGE_48MHZ);
+ return 0;
+}
int main(void)
{
@@ -27,6 +35,8 @@ int main(void)
rcc_periph_clock_enable(RCC_GPIOE); // led
rcc_periph_clock_enable(RCC_GPIOA); // adcs
rcc_periph_clock_enable(RCC_GPIOC); // adcs
+ rcc_periph_clock_enable(RCC_PWR);
+ hack();
printf("hi guys!\n");
/* green led for ticking */
gpio_mode_setup(LED_DISCO_GREEN_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE,