voilier/Drivers/adc.c
2025-12-03 08:19:23 +01:00

19 lines
No EOL
470 B
C

#include "adc.h"
#include "stm32f10x.h"
void ADC_Base_Init(ADC_TypeDef * ADC, char channel)
{
RCC->CFGR |= RCC_CFGR_ADCPRE_DIV6;//divise par 6 freq adcs
ADC->SQR3 |= channel;
ADC->CR2 |= ADC_CR2_ADON;//ADON
ADC->CR2 |= ADC_CR2_EXTTRIG;//Extrig
ADC->CR2 &= ~(0x1<<1);//discoutinuous
ADC->CR1 |= ADC_CR1_EOCIE;//interrupt enable
ADC->CR2 |= ADC_CR2_EXTSEL_0 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_2;//SWSTART
}
void ADC_Read(ADC_TypeDef * ADC);