aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/adc.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmaple/adc.c')
-rw-r--r--libmaple/adc.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/libmaple/adc.c b/libmaple/adc.c
index 7169824..d584dba 100644
--- a/libmaple/adc.c
+++ b/libmaple/adc.c
@@ -23,10 +23,9 @@
* @brief Analog to digital converter routines
*/
-#include "stm32f10x_rcc.h"
+#include "libmaple.h"
+#include "rcc.h"
#include "adc.h"
-#include <stdio.h>
-#include <inttypes.h>
/* The ADC input clock is generated from PCLK2/APB2 divided by a prescaler
* and it must not exceed 14MHz.
@@ -59,15 +58,9 @@
* At 55.5 cycles/sample, the external input impedance < 50kOhms*/
void adc_init(void) {
- /* PCLK2 is the APB2 clock */
- RCC_ADCCLKConfig(RCC_PCLK2_Div6);
-
- /* Enable ADC1 clock so that we can talk to it */
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
-
- /* Put everything back to power-on defaults */
- RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC1, ENABLE);
- RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC1, DISABLE);
+ rcc_set_adc_prescaler(PCLK2_DIV_2);
+ rcc_enable_clk_adc1();
+ rcc_reset_adc1();
ADC_CR1 = 0;
ADC_CR2 = CR2_EXTSEL_SWSTART | CR2_EXTTRIG; // Software triggers conversions