forked from trocache/RefKEIL
35 lines
630 B
C
35 lines
630 B
C
#include "stm32f10x.h"
|
|
#include "../../Drivers/gpiodriver.h"
|
|
#include "../../Drivers/adcdriver.h"
|
|
|
|
#define ADCPRE 14
|
|
#define SQ1 0
|
|
|
|
#define ADON 0
|
|
|
|
int main (void)
|
|
{
|
|
MyGPIO_Struct_TypeDef led = {GPIOA,5,Out_PullUp}; //led
|
|
MyADC_Struct_TypeDef adcStruct = {ADC1,10,cycles41d5,0};
|
|
MyGPIO_Struct_TypeDef adc = {GPIOC,0,In_Analog};
|
|
char voltageOverflow = 0;
|
|
|
|
MyGPIO_Init(&led);
|
|
MyADC_Init(&adcStruct);
|
|
MyGPIO_Init(&adc);
|
|
|
|
while(1){
|
|
ADC1->CR2 |= (0x1<<ADON);
|
|
if(ADC1->DR >= 3102)
|
|
{
|
|
MyGPIO_Set(GPIOA,5);
|
|
voltageOverflow = 1;
|
|
}
|
|
else{
|
|
if(!voltageOverflow)
|
|
{
|
|
MyGPIO_Reset(GPIOA,5);
|
|
}
|
|
}
|
|
};
|
|
}
|