基于STM32F4的ADC128S052驱动程序
STM32F446验证通过。数据采集和数据获取分开,所有通道一起采集,使用的时候直接读通道数据。
一、BspAdc128s052.h
DataType.h
#ifndef _DATA_TYPE_DEF_H_
#define _DATA_TYPE_DEF_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifndef VOID
#define VOID void
#endif
#ifndef CHAR
typedef signed char CHAR;
#endif
#ifndef UCHAR
typedef unsigned char UCHAR;
#endif
#ifndef UINT8
typedef unsigned char UINT8;
#endif
#ifndef INT8U
typedef unsigned char INT8U;
#endif
#ifndef INT8
typedef signed char INT8;
#endif
#ifndef UINT16
typedef unsigned short UINT16;
#endif
#ifndef INT16U
typedef unsigned short INT16U;
#endif
#ifndef INT16
typedef signed short INT16;
#endif
#ifndef UINT32
//typedef unsigned long UINT32;
typedef unsigned int UINT32;
#endif
#ifndef INT32U
//typedef unsigned long UINT32;
typedef unsigned int INT32U;
#endif
#ifndef INT32
//typedef signed long INT32;
typedef signed int INT32;
#endif
#ifndef INT
typedef int INT;
#endif
#ifndef UINT
typedef unsigned int UINT;
#endif
#ifndef INT64U
#if !defined(WIN32)
typedef unsigned long long UINT64;
#else
typedef unsigned __int64 UINT64;
#endif
#endif
#ifndef INT64
#if !defined(WIN32)
typedef signed long long INT64;
#else
typedef __int64 INT64;
#endif
#endif
#ifndef FLOAT32
typedef float FLOAT32;
#endif
#ifndef FLOAT64
typedef double FLOAT64;
#endif
#ifndef BOOL
#define BOOL int
#endif
#ifndef CM_FILE
#define CM_FILE int
#endif
#ifndef NULL
#ifdef __cplusplus
#define NULL (0)
#else
#define NULL ((void *)0)
#endif
#endif
#ifndef FALSE
#define FALSE 0U
#endif
#ifndef TRUE
#define TRUE 1U
#endif
#ifndef WIN32
#define _PACKED __attribute__ ((packed))
#endif
#ifndef ENA
#define ENA 1U
#endif
#ifndef DIS
#define DIS 0U
#endif
#ifndef CM_HDL_INVALIA // BspOpen返回的无效值
#define CM_HDL_INVALIA ((INT)(-1))
#endif
#ifndef CM_EOF
#define CM_EOF ((INT)(-1))
#endif
#ifndef EM_COM_FD_REAL
#define EM_COM_FD_REAL ((FILE*)(-2))
#endif
#ifndef EM_VCOM_FD_REAL
#define EM_VCOM_FD_REAL ((FILE*)(-3))
#endif
#ifndef SHIFT_BIT
#define SHIFT_BIT(x) ((UINT32)(1Ul<<(x)))
#endif
#ifndef ADD_ONE //将一个变量加1
#define ADD_ONE(Type,Val) if((Type)((Val) + 1) > 0){(Val)++;}
#endif
#ifndef DEC_ONE //将一个变量减1
#define DEC_ONE(Type,Val) if((Type)((Val) - 1) > 0){(Val)--;}
#endif
/* 时间类型 add by LDM 2019-12-10
年用2 字节表示实际年份,而非2000年为基准,可以表示早于2000 年的年份*/
#pragma pack(1)
typedef struct {
UINT8 u8Second;
UINT8 u8Minute;
UINT8 u8Hour;
UINT8 u8Day;
UINT8 u8Month;
UINT16 u16Year;
} DATE_TIME;
#pragma pack()
//#define McuPrintf(...) printf(##__VA_ARGS__)
#ifndef MCUPRINTF_EX
#define McuPrintf(format,...)printf("File:"__FILE__",Line:%05d:"format"\n",__LINE__,##__VA_ARGS__)
#else
#define McuPrintf(format,...)
#endif
#ifdef _MSC_VER
#if _MSC_VER < 1900
#ifndef snprintf
#define snprintf(...) _snprintf(__VA_ARGS__)
#endif
#endif
#endif
#define IF_CMBASE
#define MUTEX_LOCK_INIT(...)
#define AP_MUTEX_UNLOCK(...)
#define AP_MUTEX_LOCK(...)
#define MUTEX_LOCK_DESTROY(...)
#define assert(...)
#ifdef __cplusplus
}
#endif
#endif
BspAdc128s052.h
#ifndef _ADC128S052_H
#define _ADC128S052_H
#include "DataType.h"
//外扩ADC128S052模块
enum
{
EM_ADC128S052D0_ID0 = 0,
EM_ADC128S052D0_ID_MAX,
};
enum
{
EM_ADC128S052D0_CH_ID0 = 0,
EM_ADC128S052D0_CH_ID1,
EM_ADC128S052D0_CH_ID2,
EM_ADC128S052D0_CH_ID3,
EM_ADC128S052D0_CH_ID4,
EM_ADC128S052D0_CH_ID5,
EM_ADC128S052D0_CH_ID6,
EM_ADC128S052D0_CH_ID7,
EM_ADC128S052D0_CH_MAX
在这里增减使用的通道
};
typedef struct ADC128S052_READ_STRU
{
UINT8 u8Ch;
INT16 s16Adc;
}ADC128S052_READ;
//======================================================
/// \fn void InitADC128S052(void)
/// \brief ADC128S052 初始化
/// \detils xxx
/// \param [in] xxx
/// \param [in] xxx
/// \param [out] xxx
/// \return [xxx] xxx
/// \note xxx
//====================================================
extern void InitADC128S052(void);
//======================================================
/// \fn INT OpenAdcEx(UINT32 u32Idx)
/// \brief 打开Adc设备驱动
/// \detils xxx
/// \param [in] u32Idx 设备驱动号
/// \param [in] xxx
/// \param [out] xxx
/// \return [xxx] xxx
/// \note xxx
//====================================================
extern INT OpenAdc128S052(UINT32 u32Idx);
//======================================================
/// \fn void CloseAdcEx(UINT32 u32Idx)
/// \brief 关闭Adc128S052设备驱动
/// \detils xxx
/// \param [in] u32Idx 设备驱动号
/// \param [in] xxx
/// \param [out] xxx
/// \return [xxx] xxx
/// \note xxx
//====================================================
extern void CloseAdc128S052(UINT32 u32Idx);
//======================================================
/// \fn void ScanADC128S052(const UINT32 u32Idx)
/// \brief 采集ADC128S052所有通道电压
/// \detils xxx
/// \param [in] u32Idx adc设备号
/// \param [out] xxx
/// \return [xxx] xxx
/// \note xxx
//======================================================
extern void ScanADC128S052(const UINT32 u32Idx);
//======================================================
/// \fn INT32 ReadAdc128S052(const INT pHdl,INT16 *pBuffer,const UINT32 u32Len)
/// \brief xxx
/// \detils xxx
/// \param [in] pHdl 句柄
/// \param [in] pBuffer 写入的数据
/// \param [in] u32Len 写入的长度
/// \param [out] xxx
/// \return [xxx] u32Len 写入的长度
/// \note xxx
//======================================================
extern INT32 ReadAdc128S052(const INT pHdl,INT16 *pBuffer,const UINT32 u32Len);
extern void ADC128S052_Test(void);
#endif
二、BspAdc128s052.c
#include <stdio.h>
#include <math.h>
#include <string.h>
#include "BspAdc128S052.h"
#include "stm32f4xx_spi.h"
/*
12bit的ADC 发送16bits数据,NC为任意数,ADD2 ADD1 ADD0决定选通通道
NC NC ADD2 ADD1 ADD0 NC NC NC NC NC NC NC NC NC NC NC
IN0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
IN1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
IN2 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
IN3 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0
IN4 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
IN5 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0
IN6 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0
IN7 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0
注意:使用两个通道以上时,发送指令读取另一通道数据需要发送两次才能获取当前想要读取的另一通道的电压值,只发送一次还是上一次读到的通道的电压值。
*/
//#define VOLTAGE_IN0 0x0000
//#define VOLTAGE_IN1 0x0800
//#define VOLTAGE_IN2 0x1000
//#define VOLTAGE_IN3 0x1800
//#define VOLTAGE_IN4 0x2000
//#define VOLTAGE_IN5 0x2800
//#define VOLTAGE_IN6 0x3000
//#define VOLTAGE_IN7 0x3800
#define ADC128S052_SPI SPI3
#define ADC128S052_CS_DISABLE() GPIO_SetBits(GPIOA, GPIO_Pin_15)
#define ADC128S052_CS_ENABLE() GPIO_ResetBits(GPIOA, GPIO_Pin_15)
#define ADC128S052_VREF 3295U //外部参考电压,实测值(MV)
#define ADC128S052_AD_MAX 4096U //ADC128S052 最大AD值
#define ADC_HAS_NO_DATA 0 //ADC没有数据
#define ADCEX0_BATCH_NUM 10 //ADC平均个数
static INT16 s16Adcx0Buf[ADCEX0_BATCH_NUM][EM_ADC128S052D0_CH_MAX];
static UINT16 u16AdcxState[EM_ADC128S052D0_ID_MAX];//步骤
typedef struct ADC_MEM_PRIV_STRU
{
INT16 s16Aver;// 平均值结果
INT16 s16Max; // 最大值
INT16 s16Min; // 最小值
}ADC_MEM_PRIV;
typedef struct ADC_X_PRIV_STRU
{
INT16* pAdcBuff; // 结果
UINT16* pState; //指向ADC的转换状态
UINT8 u8ChannMax; //该ADC有多少个通道
UINT16 u16AdcBatchNum; //平均个数
ADC_MEM_PRIV* pAdcVal; //处理结果得到的数据
}ADC_EX_PRIV;
static ADC_MEM_PRIV stAdc0Val[EM_ADC128S052D0_ID_MAX];
//私有数据
const static ADC_EX_PRIV stAdcExPrivData[EM_ADC128S052D0_ID_MAX] =
{
{
(INT16*)s16Adcx0Buf,
&u16AdcxState[0],
EM_ADC128S052D0_CH_MAX,//设置读取通道数
ADCEX0_BATCH_NUM, //电压数据取平均值个数
stAdc0Val,
},
// {
// (INT16*)s16AdcxBuf,
// u16AdcxState[1],
// EM_ADC128S052D1_ID_MAX,
// ADCEX1_BATCH_NUM,
// stAdc1Val,
// }
};
//======================================================
/// \fn static void InitADC128S052Gpio(void)
/// \brief ADC128S052 GPIO初始化
/// \detils xxx
/// \param [in] xxx
/// \param [out] xxx
/// \return [xxx] xxx
/// \note xxx
//====================================================
static void InitADC128S052Gpio(void)
{
SPI_InitTypeDef SPI_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC,ENABLE);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC,&GPIO_InitStructure);
GPIO_PinAFConfig(GPIOC,GPIO_PinSource10,GPIO_AF_SPI3);
GPIO_PinAFConfig(GPIOC,GPIO_PinSource11,GPIO_AF_SPI3);
GPIO_PinAFConfig(GPIOC,GPIO_PinSource12,GPIO_AF_SPI3);
//CS
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_SetBits(GPIOA, GPIO_Pin_15); //CS默认高
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3,ENABLE);
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_16b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; //第二个上升沿开始转化
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256; //F446 APB1 SPI3时钟为45M spi_clock:45/256=175.78KHz
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(ADC128S052_SPI,&SPI_InitStructure);
SPI_Cmd(ADC128S052_SPI,ENABLE);
ADC128S052_CS_DISABLE();
}
//======================================================
/// \fn static UINT16 SpiReadWriteByte(SPI_TypeDef *pSpi,const UINT16 U16Data)
/// \brief ADC128S052 读写
/// \detils xxx
/// \param [in] pSpi 对应spi号
/// \param [in] U16Data 要发送的数据
/// \param [out] xxx
/// \return [xxx] xxx
/// \note xxx
//====================================================
static UINT16 SpiReadWriteByte(SPI_TypeDef *pSpi,const UINT16 U16Data)
{
SPI_TypeDef *pRWSpi = pSpi;
UINT16 u16SpiData = U16Data;
while (SPI_I2S_GetFlagStatus(pRWSpi, SPI_I2S_FLAG_TXE) == RESET);
SPI_I2S_SendData(pRWSpi, u16SpiData);
while (SPI_I2S_GetFlagStatus(pRWSpi, SPI_I2S_FLAG_RXNE) == RESET);
return (SPI_I2S_ReceiveData(pRWSpi));
}
//======================================================
/// \fn static INT32 GetAdc128S052(const INT pHdl,const UINT8 u8ch)
/// \brief 采集adc128S052通道电压
/// \detils xxx
/// \param [in] pHdl 句柄
/// \param [in] u8ch 通道
/// \param [out] xxx
/// \return [xxx] s16AdcVal adc值
/// \note xxx
//======================================================
static INT16 GetAdc128S052(const INT pHdl,const UINT8 u8Ch)
{
INT16 s16AdcVal = 0;
if(CM_HDL_INVALIA == pHdl || EM_ADC128S052D0_CH_MAX < u8Ch)
{
return -1;
}
ADC128S052_CS_ENABLE();
s16AdcVal = SpiReadWriteByte(ADC128S052_SPI,u8Ch << 11);
ADC128S052_CS_DISABLE();
return s16AdcVal;
}
//======================================================
/// \fn void InitADC128S052(void)
/// \brief ADC128S052 初始化
/// \detils xxx
/// \param [in] xxx
/// \param [in] xxx
/// \param [out] xxx
/// \return [xxx] xxx
/// \note xxx
//====================================================
void InitADC128S052(void)
{
INT i = 0;
INT j = 0;
InitADC128S052Gpio();
for(i = 0; i < EM_ADC128S052D0_ID_MAX; i++)
{
for(j = 0; j < stAdcExPrivData[i].u8ChannMax; j++)
{
memset(stAdcExPrivData[i].pAdcBuff,0,stAdcExPrivData[i].u8ChannMax*sizeof(stAdcExPrivData[i].pAdcBuff[0]));
}
*(stAdcExPrivData[i].pState) = 0;
}
}
//======================================================
/// \fn INT OpenAdcEx(UINT32 u32Idx)
/// \brief 打开Adc设备驱动
/// \detils xxx
/// \param [in] u32Idx 设备驱动号
/// \param [in] xxx
/// \param [out] xxx
/// \return [xxx] xxx
/// \note xxx
//====================================================
INT OpenAdc128S052(UINT32 u32Idx)
{
INT fd = u32Idx;
return (INT)fd;
}
//======================================================
/// \fn void CloseAdcEx(UINT32 u32Idx)
/// \brief 关闭Adc设备驱动
/// \detils xxx
/// \param [in] u32Idx 设备驱动号
/// \param [in] xxx
/// \param [out] xxx
/// \return [xxx] xxx
/// \note xxx
//====================================================
void CloseAdc128S052(UINT32 u32Idx)
{
}
//======================================================
/// \fn void ScanADC128S052(const UINT32 u32Idx)
/// \brief 采集ADC128S052所有通道电压
/// \detils xxx
/// \param [in] u32Idx adc设备号
/// \param [out] xxx
/// \return [xxx] xxx
/// \note xxx
//======================================================
void ScanADC128S052(const UINT32 u32Idx)
{
UINT16 u16ChIdx = 0;
UINT16 u16TrunIdx = 0;
UINT16 u16DataVol = 0;
INT16 s16Min = 0;
INT16 s16Max = 0;
INT64 s64Sum = 0;
const ADC_EX_PRIV* pstAdcExPrivData = NULL;
pstAdcExPrivData = &stAdcExPrivData[u32Idx];
if(*(pstAdcExPrivData->pState) < (pstAdcExPrivData->u16AdcBatchNum*pstAdcExPrivData->u8ChannMax + ADC_HAS_NO_DATA +1))
{
u16ChIdx = (*(pstAdcExPrivData->pState) - ADC_HAS_NO_DATA - 1) % (INT32)pstAdcExPrivData->u8ChannMax; //获得第几个通道
u16TrunIdx = (*(pstAdcExPrivData->pState) - ADC_HAS_NO_DATA - 1) / pstAdcExPrivData->u8ChannMax; //获得第几个扫描周期
if(ADC_HAS_NO_DATA == *(pstAdcExPrivData->pState))
{
GetAdc128S052(u32Idx,0);//初始化
}
else
{
u16DataVol = GetAdc128S052(u32Idx,u16ChIdx) * ADC128S052_VREF/ADC128S052_AD_MAX;
if( 1 <= u16ChIdx )
{
pstAdcExPrivData->pAdcBuff[u16TrunIdx * pstAdcExPrivData->u8ChannMax + u16ChIdx -1] = u16DataVol;
}
else
{
pstAdcExPrivData->pAdcBuff[u16TrunIdx * pstAdcExPrivData->u8ChannMax + pstAdcExPrivData->u8ChannMax - 1] = u16DataVol;
}
u16ChIdx = (u16ChIdx + 1) % (INT32)pstAdcExPrivData->u8ChannMax;//启动下一个通道
}
(*(pstAdcExPrivData->pState))++;
}
if(*(pstAdcExPrivData->pState) > (pstAdcExPrivData->u16AdcBatchNum * pstAdcExPrivData->u8ChannMax + ADC_HAS_NO_DATA))
{
for(u16ChIdx = 0; u16ChIdx < pstAdcExPrivData->u8ChannMax; u16ChIdx++)
{
s64Sum = 0;
for(u16TrunIdx = 0; u16TrunIdx < pstAdcExPrivData->u16AdcBatchNum; u16TrunIdx++)
{
if( 0 == u16TrunIdx )
{
s16Min = s16Max = pstAdcExPrivData->pAdcBuff[u16TrunIdx * pstAdcExPrivData->u8ChannMax + u16ChIdx];
}
// printf("通道:%d,次数:%d,电压:%d\r\n",u16ChIdx,u16TrunIdx,pstAdcExPrivData->pAdcBuff[u16TrunIdx * pstAdcExPrivData->u8ChannMax + u16ChIdx]);
if(pstAdcExPrivData->pAdcBuff[u16TrunIdx * pstAdcExPrivData->u8ChannMax + u16ChIdx] > s16Max)
{
s16Max = pstAdcExPrivData->pAdcBuff[u16TrunIdx * pstAdcExPrivData->u8ChannMax + u16ChIdx];
}
s64Sum += (pstAdcExPrivData->pAdcBuff[u16TrunIdx * pstAdcExPrivData->u8ChannMax + u16ChIdx]);
}//end for(u16TrunIdx = 0; u16TrunIdx < pstAdcExPrivData->u16AdcBatchNum; u16TrunIdx++)
s64Sum = s64Sum - s16Max - s16Min;
pstAdcExPrivData->pAdcVal[u16ChIdx].s16Aver = (s64Sum/(pstAdcExPrivData->u16AdcBatchNum-2));
pstAdcExPrivData->pAdcVal[u16ChIdx].s16Max = s16Max;
pstAdcExPrivData->pAdcVal[u16ChIdx].s16Min = s16Min;
}//end for(u16ChIdx = 0; u16ChIdx < pstAdcExPrivData->u8ChannMax; u16ChIdx++)
*(pstAdcExPrivData->pState) = ADC_HAS_NO_DATA + 1;//重新开始
}
}
//======================================================
/// \fn INT32 ReadAdc128S052(const INT pHdl,INT16 *pBuffer,const UINT32 u32Len)
/// \brief 读Adc128S052所有通道电压数据
/// \detils xxx
/// \param [in] pHdl 句柄
/// \param [in] pBuffer 写入的数据
/// \param [in] u32Len 写入的长度
/// \param [out] xxx
/// \return [xxx] u32Len 写入的长度
/// \note xxx
//======================================================
INT32 ReadAdc128S052(const INT pHdl,INT16 *pBuffer,const UINT32 u32Len)
{
ADC128S052_READ *pAdcRead = (ADC128S052_READ *)pBuffer;
const ADC_EX_PRIV* pstAdcExPrivData = NULL;
UINT32 u32Idx = (INT32)pHdl;
// UINT32 u32BufferLen = u32Len;
if( (CM_HDL_INVALIA == pHdl)||(NULL == pBuffer)||(0 == u32Len)
||(EM_ADC128S052D0_CH_MAX <= u32Idx)||(u32Len < sizeof(ADC128S052_READ)) )
{
return -1;
}
pstAdcExPrivData = &stAdcExPrivData[u32Idx];
pAdcRead->s16Adc = pstAdcExPrivData->pAdcVal[pAdcRead->u8Ch].s16Aver;
return u32Len;
}
三、应用
代码如下(示例):
1、初始化io
InitADC128S052Gpio();
2、采集数据(这个函数可以放到单独线程里,至少10ms执行一次)
ScanADC128S052(EM_ADC128S052D0_ID0);
3、读取数据
void ADC128S052_Test(void)
{
ADC128S052_READ stAdcRead = {0,0};
INT fd = OpenAdc128S052(EM_ADC128S052D0_ID0);
stAdcRead.u8Ch = EM_ADC128S052D0_CH_ID0;
ReadAdc128S052(fd,(INT16*)&stAdcRead,sizeof(ADC128S052_READ));
printf("ADC128S052_Ch0:%dmV\r\n",stAdcRead.s16Adc);
stAdcRead.u8Ch = EM_ADC128S052D0_CH_ID1;
ReadAdc128S052(fd,(INT16*)&stAdcRead,sizeof(ADC128S052_READ));
printf("ADC128S052_Ch1:%dmV\r\n",stAdcRead.s16Adc);
stAdcRead.u8Ch = EM_ADC128S052D0_CH_ID2;
ReadAdc128S052(fd,(INT16*)&stAdcRead,sizeof(ADC128S052_READ));
printf("ADC128S052_Ch2:%dmV\r\n",stAdcRead.s16Adc);
stAdcRead.u8Ch = EM_ADC128S052D0_CH_ID3;
ReadAdc128S052(fd,(INT16*)&stAdcRead,sizeof(ADC128S052_READ));
printf("ADC128S052_Ch3:%dmV\r\n",stAdcRead.s16Adc);
stAdcRead.u8Ch = EM_ADC128S052D0_CH_ID4;
ReadAdc128S052(fd,(INT16*)&stAdcRead,sizeof(ADC128S052_READ));
printf("ADC128S052_Ch4:%dmV\r\n",stAdcRead.s16Adc);
CloseAdc128S052(EM_ADC128S052D0_ID0);
}