#include "AD1.h" #define IDLE 0x00U /* IDLE state */ #define SINGLE 0x01U /* SINGLE state */ #define MEASURE 0x02U /* MESURE state */ #define CONTINUOUS 0x04U /* CONTINUOUS state */ #define CMD_EOL 0xC0000000U /* Command End of list used as the last command in CSL */ #define CMD_EOL_CONTINUOUS 0x80000000U /* Command End of list with continuous measurement of the whole list used as the last command in CSL */ #define CLEAR_CMD_EOL 0x3FFFFFFFU /* Constant for clearing the EOL command - for channel methods */ static const word Table[] = { /* Table of mask constants */ 0x01U,0x02U,0x04U,0x08U,0x10U,0x20U,0x40U,0x80U,0x0100U}; #pragma DATA_SEG DEFAULT /* Select data segment "DEFAULT" */ static volatile dword CSL[10] __attribute__ ((aligned (4))) = { /* Channel/Sample settings */ 0x00D90000U,0x00D80000U,0x00D70000U,0x00D60000U,0x00D50000U,0x00D40000U,0x00D30000U,0x00D20000U,0xC0D10000U,CMD_EOL}; static volatile word RVL[18] __attribute__ ((aligned (4))); /* HW DMA result buffer */ static volatile word OutFlg; /* Measurement finish flag */ static volatile byte SumChan; /* Number of the measured channels */ static volatile word ModeFlg; /* Current state of device */ word AD1_OutV[9]; #define CMD_LAST_SAMPLE_PLUS_EOL 0xC0D10000U /* Last sample with command End of list */ #define CMD_LAST_SAMPLE_PLUS_EOL_CONTINUOUS 0x80D10000U /* Last sample with command End of list */ //word ADCVALUE[9]={0,0,0,0,0,0,0,0,0}; byte ADC_convert_over_flag=0;//AD转换完成标志 //AD转换完成中断函数 void AD1_OnEnd() { ADC_convert_over_flag=1;//AD转换完成 /*ADCVALUE[0]=AD1_OutV[0];// ADCVALUE[1]=AD1_OutV[1];// ADCVALUE[2]=AD1_OutV[2];// ADCVALUE[3]=AD1_OutV[3];// ADCVALUE[4]=AD1_OutV[4];// ADCVALUE[5]=AD1_OutV[5];// ADCVALUE[6]=AD1_OutV[6];// ADCVALUE[7]=AD1_OutV[7];// ADCVALUE[8]=AD1_OutV[8];*/ } //AD转换错误中断 void AD1_OnError() { } //AD转换终止中断 void AD1_OnAbort() { } //Get AD average value word AD_Average_Calculate(word *AD_Array,byte Arrsize) { byte AD_i=0; word AD_Sum=0; for(AD_i=0;AD_i