/****************************************************************************** 版权所有: 文件名称: ad7606.h 文件版本: 01.01 创建作者: xxxxxx 创建日期: 2014-11-24 功能说明: AD7606采样驱动头文件 其它说明: 修改记录: */ #ifndef _AD7616_H_ #define _AD7616_H_ #include #include #include #include #include #include #include #include #include "bspconfig.h" //裸核版本信息 typedef struct SHM_VER_T { uint16_t A; uint16_t B; uint16_t ver; uint16_t v_crc; uint8_t time[24];//时间 uint16_t crc; }SHM_VER_T; //Ad7616采样点写指针结构体 typedef struct WP_T { uint16_t A; uint16_t B; uint16_t write_flag_A; uint16_t write_flag_B; uint16_t crc; }WP_T; //AD7616采样点结构定义 typedef struct SHM_SAMPLE_T { uint16_t sample_buf[16]; uint32_t yx_buf[2]; //预留64个遥信 struct timespec ts;//时间戳 }SHM_SAMPLE_T; #define SHM_ADC_WR_NUM (SHM_ADC_SIZE/sizeof(SHM_SAMPLE_T)) //7616电压参数读写结构体 typedef struct SHM_RFV_T { uint16_t A; uint16_t B; uint32_t rc; uint16_t crc; }SHM_RFV_T; //直流数据结构体 typedef struct SHM_DC_T { uint16_t A; uint16_t B; struct timespec ts;//时间戳 uint16_t adc[2]; //ad值 uint16_t crc; }SHM_DC_T; extern s16 (*g_adc_dots)[CFG_ADC_DOTS_PER_CHANNEL*2]; extern s16 (*g_adc_dots_rec)[CFG_ADC_CHANNEL]; extern struct timespec ts_adc_dots[CFG_ADC_DOTS_PER_CHANNEL]; #define ADC_REC_SAMPLE 128 // 录波每周采样点数 #define ADC_REC_SAMPLE_RATE 4 // 录波128点,计算32点,比率为4 #define ADC_REC_LEN 64 // 录波记录长度,以周波为单位,64周波约1.28s。 #define ADC_REC_DOTS_CHANNEL (ADC_REC_SAMPLE*ADC_REC_LEN)// 每通道点数 #define ADC_REC_DOTS_MASK (ADC_REC_DOTS_CHANNEL - 1) // 录波索引屏蔽字 #define AD7616_DC0_CHANNEL 14 #define AD7616_DC1_CHANNEL -1 extern volatile unsigned long g_adc_dots_count; #define g_adc_dots_index (g_adc_dots_count&CFG_ADC_DOTS_MASK) #define g_adc_dots_index_rec (g_adc_dots_data_count&ADC_REC_DOTS_MASK) extern int g_adc_sync; extern float g_freq; extern volatile unsigned long g_adc_dots_data_count; extern bool prt_flag; extern SHM_VER_T LuoHe_version; /****************************************************************************** 函数名称: adc_init 函数版本: 01.01 创建作者: xxxxxx 创建日期: 2014-11-24 函数说明: AD7606初始化. 参数说明: 无 返回值: 成功返回0, 失败返回-1 修改记录: */ int adc_init(void); /****************************************************************************** 函数名称: adc_exit 函数版本: 01.01 创建作者: xxxxxx 创建日期: 2014-11-24 函数说明: AD7606反初始化. 参数说明: 无 返回值: 总是返回0. 修改记录: */ int adc_exit(void); /****************************************************************************** 函数名称: adc_slot_is_ok 函数版本: 01.01 创建作者: sunxi 创建日期: 2016-02-01 函数说明: 检查对应槽的ADC芯片是否安装或损坏。 参数说明: slot: 0~3;从g_ac_slot_begin开始 返回值: 成功返回0. 修改记录: */ int adc_slot_is_ok(int slot); /****************************************************************************** 函数名称: adc_isr 函数版本: 01.01 创建作者: xxxxxx 创建日期: 2014-11-24 函数说明: AD7606转换处理(此函数在156us中断中处理). 参数说明: 无 返回值: 无 修改记录: */ int adc_isr(int mod); /****************************************************************************** 函数名称: adc_stat_reset 函数版本: 01.01 创建作者: sunxi 创建日期: 2008-06-26 函数说明: 复位统计信息 参数说明:无 返回值: 无 修改记录: */ int adc_stat_reset(void); /****************************************************************************** 函数名称: adc_stat_printf 函数版本: 01.01 创建作者: sunxi 创建日期: 2008-06-26 函数说明: 频率跟踪统计信息 参数说明:无 返回值: 无 修改记录: */ int adc_stat_printf(void); /****************************************************************************** 函数名称: adc_fourier_address 函数版本: 01.01 创建作者: sunxi 创建日期: 2008-06-26 函数说明: 返回指定的通道进行傅立叶计算的首地址。首地址保证4bytes对齐。 参数说明: channel:ADC的通道,取值0~7。 index: 要进行傅立叶计算的32点中的最后一个点的索引。这么设置是为了和 g_adc_dots_index匹配。保证g_adc_dots_index可以直接作为参数传进来。 返回值: 成功返回0. 修改记录: */ short * adc_fourier_address(int channel,int index); float dc_get(unsigned int index); #endif /*------------------------------ 文件结束 ------------------------------------- */