123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #include <stdarg.h>
- #include "yc11xx.h"
- #include "yc11xx_gpio.h"
- #include "yc11xx_uart.h"
- #include "yc_timer.h"
- #include "Drv_adc.h"
- #include "system.h"
- #include "btreg.h"
- //#define hvin_test
- void ADC_Configuration(void);
- void ADC_Test(void);
- /**
- * @brief ADC initialization function.
- * @param None
- * @retval None
- */
- void ADC_Configuration(void)
- {
- GPIO_SetGpioMultFunction(GPIO_23,GPCFG_NO_IE);
-
- ADC_InitTypeDef ADCInitStruct;
- ADCInitStruct.ADC_Channel = ADC_CHANNEL_5;
- ADCInitStruct.ADC_Mode = ADC_GPIO;
- #ifdef hvin_test
- ADCInitStruct.ADC_Mode = ADC_HVIN;
- #endif
- ADC_Init(&ADCInitStruct);
- #ifdef DEBUG_ADC
- // printf("adc_init suc, gpio mode test 0-1.2V!\n");
- MyPrintf("testing channel %d\n",ADCInitStruct.ADC_Channel);
- #endif
- }
- /**
- * @brief ADC test function.
- * @param None
- * @retval None
- */
- void ADC_Test(void)
- {
- int result=0;
- SYS_delay_ms(500);
- result=ADC_GetVoltage(ADC_CHANNEL_5);
- #ifdef DEBUG_ADC
- MyPrintf("ADC_Result: %d mV\n", result);
- #endif
- }
- int main(void)
- {
- #ifdef DEBUG_ADC
- printport_init();
- MyPrintf("This is YC11XX ADC gpio mode demo v1.0. \n");
- #endif
- SYS_TimerInit();
-
- ADC_Configuration();
- while(1)
- {
- SYS_delay_ms(500);
- ADC_Test();
- }
- }
|