summaryrefslogtreecommitdiffstats
path: root/app/adc.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/adc.c')
-rw-r--r--app/adc.c51
1 files changed, 0 insertions, 51 deletions
diff --git a/app/adc.c b/app/adc.c
deleted file mode 100644
index 1565af5..0000000
--- a/app/adc.c
+++ /dev/null
@@ -1,51 +0,0 @@
-#include "project.h"
-
-int host_has_power;
-
-void
-adc_tick (void)
-{
- uint16_t v;
-
- if (adc_eoc (ADC1))
- {
- v = adc_read_regular (ADC1);
-
- host_has_power = ! !(v > 1000);
-
- }
-
- adc_start_conversion_direct (ADC1);
-}
-
-
-
-static uint8_t channels[] = { ADC_CHANNEL0 };
-
-#define n_channels (sizeof(channels)/sizeof(channels[0]))
-
-void
-adc_init (void)
-{
-
- rcc_periph_clock_enable (RCC_ADC1);
-
- //gpio_mode_setup(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_DOWN, GPIO0);
- gpio_set_mode (GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_ANALOG, GPIO0);
-
- adc_off (ADC1);
- adc_disable_scan_mode (ADC1);
- adc_set_single_conversion_mode (ADC1);
- adc_disable_external_trigger_regular (ADC1);
- adc_set_right_aligned (ADC1);
- adc_set_sample_time_on_all_channels (ADC1, ADC_SMPR_SMP_28DOT5CYC);
-
- adc_power_on (ADC1);
-
- adc_reset_calibration (ADC1);
- adc_calibration (ADC1);
- adc_set_regular_sequence (ADC1, n_channels, channels);
- adc_start_conversion_direct (ADC1);
-
- host_has_power = 0;
-}