SP8EBC-ParaTNC/system/src/aprs/adc.c

63 wiersze
1.5 KiB
C
Czysty Zwykły widok Historia

2017-08-20 12:41:17 +00:00
#include "adc.h"
2021-06-04 04:54:02 +00:00
#ifdef STM32F10X_MD_VL
#include <stm32f10x.h>
#endif
#ifdef STM32L471xx
#include <stm32l4xx.h>
#include <stm32l4xx_ll_tim.h>
#endif
2017-08-20 12:41:17 +00:00
#include <stdlib.h>
#include <stdio.h>
Afsk *adc_afsk;
uint16_t max_value;
uint32_t samplecount;
/*********************************************************************************************************************/
void AD_Restart(void) {
2017-08-20 12:41:17 +00:00
/*********************************************************************************************************************/
#ifdef STM32L471xx
// check if conversion is done or not
if ((ADC1->ISR & ADC_ISR_EOC) == 0) {
// stop adc conversion
ADC1->CR |= ADC_CR_ADSTP;
// wait for conversion to shutdown
while((ADC1->ISR & ADC_CR_ADSTART) == ADC_CR_ADSTART);
2017-08-20 12:41:17 +00:00
// start ADC back again
ADC1->CR |= ADC_CR_ADSTART;
}
#endif
2017-08-20 12:41:17 +00:00
}
/*********************************************************************************************************************/
void AD_Start() {
/*********************************************************************************************************************/
// samplecount = 0;
// max_value = 0;
//Timer3 ENABLE
TIM2->CR1 |= TIM_CR1_CEN;
}
/*********************************************************************************************************************/
void AD_Stop() {
/*********************************************************************************************************************/
//Timer3 DISABLE
TIM2->CR1 &= ~TIM_CR1_CEN;
// AD_Reset();
}