140 lines
4.4 KiB
C
140 lines
4.4 KiB
C
|
/*******************************************************************************
|
|||
|
* @Copyright (c) :(C)2020, Qingdao ieslab Co., Ltd
|
|||
|
* @FileName :hc32_adc_driver.h
|
|||
|
* @Author :Kv-L
|
|||
|
* @Version :V1.0
|
|||
|
* @Date :2020<EFBFBD><EFBFBD>7<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD> 17:57:05
|
|||
|
* @Description :<EFBFBD><EFBFBD>ѹת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD><EFBFBD>0~2.5V; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>80<EFBFBD><EFBFBD>
|
|||
|
*******************************************************************************/
|
|||
|
|
|||
|
/*********************************VREFINT***************************************
|
|||
|
* typ voltage :1.212V
|
|||
|
* Min ADC sampling time : 4us
|
|||
|
*
|
|||
|
*******************************************************************************/
|
|||
|
/*************************external channels*************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>CADC = 5pF<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>裺RAIN = 50K<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>裺RADC = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* ȡ60RC = 15us<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㹻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>硣
|
|||
|
* <EFBFBD>ⲿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>15us<EFBFBD><EFBFBD><EFBFBD>㡣
|
|||
|
*******************************************************************************/
|
|||
|
|
|||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
|||
|
#ifndef __UWater_ADC_DRIVER_H
|
|||
|
#define __UWater_ADC_DRIVER_H
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
extern "C" {
|
|||
|
#endif
|
|||
|
|
|||
|
/* Includes ------------------------------------------------------------------*/
|
|||
|
#include "sys_config.h"
|
|||
|
#include "ddl.h"
|
|||
|
#include "type.h"
|
|||
|
|
|||
|
/* Exported types ------------------------------------------------------------*/
|
|||
|
|
|||
|
/* Exported constants --------------------------------------------------------*/
|
|||
|
|
|||
|
/* Exported macro ------------------------------------------------------------*/
|
|||
|
/*ADCs to use*/
|
|||
|
|
|||
|
/*External analog input channel selection*/
|
|||
|
#if (HARDWARE_VERSION==0x14)//<2F><><EFBFBD>DZ<EFBFBD>
|
|||
|
#define ADC_IN0 0 //PA00 //use:1 ;not use:0
|
|||
|
#define ADC_IN1 0 //PA01
|
|||
|
#define ADC_IN2 0 //PA02
|
|||
|
#define ADC_IN3 0 //PA03
|
|||
|
#define ADC_IN4 0 //PA04
|
|||
|
#define ADC_IN5 1 //PA05
|
|||
|
#define ADC_IN6 0 //PA06
|
|||
|
#define ADC_IN7 0 //PA07
|
|||
|
#define ADC_IN8 0 //PB00
|
|||
|
#define ADC_IN9 0 //PB01
|
|||
|
#define ADC_IN10 1 //PC00
|
|||
|
#define ADC_IN11 0 //PC01
|
|||
|
#define ADC_IN12 1 //PC02
|
|||
|
#define ADC_IN13 1 //PC03
|
|||
|
#define ADC_IN14 0 //PC04
|
|||
|
#define ADC_IN15 0 //PC05
|
|||
|
#define ADC_IN16 0 //PB02
|
|||
|
#define ADC_IN17 0 //PB10
|
|||
|
#define ADC_IN18 0 //PB11
|
|||
|
#define ADC_IN19 0 //PB12
|
|||
|
#define ADC_IN20 0 //PB13
|
|||
|
#define ADC_IN21 0 //PB14
|
|||
|
#define ADC_IN22 0 //PB15
|
|||
|
#define ADC_IN23 0 //PE15
|
|||
|
#define ADC_IN24 0 //PE14
|
|||
|
#define ADC_IN25 0 //PE13
|
|||
|
|
|||
|
#elif (HARDWARE_VERSION==0x18)//Բ<>DZ<EFBFBD>
|
|||
|
#define ADC_IN0 0 //PA00 //use:1 ;not use:0
|
|||
|
#define ADC_IN1 0 //PA01
|
|||
|
#define ADC_IN2 0 //PA02
|
|||
|
#define ADC_IN3 0 //PA03
|
|||
|
#define ADC_IN4 0 //PA04
|
|||
|
#define ADC_IN5 0 //PA05//T1_ADC_MCU
|
|||
|
#define ADC_IN6 0 //PA06
|
|||
|
#define ADC_IN7 1 //PA07
|
|||
|
#define ADC_IN8 0 //PB00
|
|||
|
#define ADC_IN9 0 //PB01
|
|||
|
#define ADC_IN10 1 //PC00//BAT_CHECK_MCU
|
|||
|
#define ADC_IN11 0 //PC01
|
|||
|
#define ADC_IN12 1 //PC02//NB_PSM_CHECK
|
|||
|
#define ADC_IN13 1 //PC03//VALVE_ADC_V_MCU
|
|||
|
#define ADC_IN14 0 //PC04
|
|||
|
#define ADC_IN15 0 //PC05
|
|||
|
#define ADC_IN16 0 //PB02
|
|||
|
#define ADC_IN17 0 //PB10
|
|||
|
#define ADC_IN18 0 //PB11
|
|||
|
#define ADC_IN19 0 //PB12
|
|||
|
#define ADC_IN20 0 //PB13
|
|||
|
#define ADC_IN21 0 //PB14
|
|||
|
#define ADC_IN22 0 //PB15
|
|||
|
#define ADC_IN23 0 //PE15
|
|||
|
#define ADC_IN24 0 //PE14
|
|||
|
#define ADC_IN25 0 //PE13
|
|||
|
#endif
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
/*Main machine states*/
|
|||
|
#define ADC_IDLE 0
|
|||
|
#define ADC_CFGADC 1
|
|||
|
#define ADC_START 2
|
|||
|
#define ADC_CONV 3
|
|||
|
#define ADC_END 4
|
|||
|
|
|||
|
/*states*/
|
|||
|
#define ADC_OK 0x00
|
|||
|
#define ADC_START_ERROR 0x01
|
|||
|
#define ADC_CONV_TIMEOUT 0x02
|
|||
|
|
|||
|
/*convert result array*/
|
|||
|
#define MIN 0
|
|||
|
#define SUM 1
|
|||
|
#define MAX 2
|
|||
|
#define MINCONVNUM 3
|
|||
|
/*Max conv num*/
|
|||
|
#define MAXCONVNUM 80 //max:86!
|
|||
|
/*adc_timeout*/
|
|||
|
#define ADC_TIMEOUT 100 //<2F><>λ<EFBFBD><CEBB>us
|
|||
|
/* Exported functions ------------------------------------------------------- */
|
|||
|
void AdcStartConvert( u8 AdcChannel, u32 ConvNum, u32 TimeInterval, u32 *ConvResult, u8 *ConvIfDone);
|
|||
|
void AdcMachineDriver(void);
|
|||
|
u8 AdcIfIdle(void);
|
|||
|
u8 AdcGetStatus(void);
|
|||
|
u8 AdcIfSleep(void);
|
|||
|
void AdcPreSleep(void);
|
|||
|
void AdcWakeSleep(void);
|
|||
|
#ifdef __cplusplus
|
|||
|
}
|
|||
|
#endif
|
|||
|
|
|||
|
#endif /* __UWater_ADC_DRIVER_H */
|
|||
|
|
|||
|
/***************************************************************END OF FILE****/
|