From 8d538b3935842204c7a545184df302958fc2015d Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Fri, 16 Oct 2015 21:56:42 +0000 Subject: stub adc on/off test code. Needs a pot on PA0, should get the temperature input working as well. --- tests/adc-power/main-stm32f4-disco.c | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/adc-power/main-stm32f4-disco.c (limited to 'tests/adc-power/main-stm32f4-disco.c') diff --git a/tests/adc-power/main-stm32f4-disco.c b/tests/adc-power/main-stm32f4-disco.c new file mode 100644 index 0000000..f02e610 --- /dev/null +++ b/tests/adc-power/main-stm32f4-disco.c @@ -0,0 +1,52 @@ +/* + * Oct 2015 Karl Palsson + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "trace.h" +#include "adc-power.h" + +#define LED_DISCO_GREEN_PORT GPIOD +#define LED_DISCO_GREEN_PIN GPIO12 + +int main(void) +{ + int i; + int j = 0; + rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]); + rcc_periph_clock_enable(RCC_GPIOD); + 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, GPIO0); + gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO1); + + adc_power_init(); + while (1) { + adc_power_task_up(); + gpio_toggle(LED_DISCO_GREEN_PORT, LED_DISCO_GREEN_PIN); + + for (i = 0; i < 0x1000000; i++) { /* Wait a bit. */ + __asm__("NOP"); + } + adc_power_task_down(); + gpio_toggle(LED_DISCO_GREEN_PORT, LED_DISCO_GREEN_PIN); + for (i = 0; i < 0x1000000; i++) { /* Wait a bit. */ + __asm__("NOP"); + } + } + + return 0; +} -- cgit