ad7616.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /******************************************************************************
  2. 版权所有:
  3. 文件名称: ad7606.h
  4. 文件版本: 01.01
  5. 创建作者: xxxxxx
  6. 创建日期: 2014-11-24
  7. 功能说明: AD7606采样驱动头文件
  8. 其它说明:
  9. 修改记录:
  10. */
  11. #ifndef _AD7616_H_
  12. #define _AD7616_H_
  13. #include <sys/types.h>
  14. #include <sys/stat.h>
  15. #include <fcntl.h>
  16. #include <sys/mman.h>
  17. #include <sys/time.h>
  18. #include <unistd.h>
  19. #include <pthread.h>
  20. #include <sys/time.h>
  21. #include "bspconfig.h"
  22. //裸核版本信息
  23. typedef struct SHM_VER_T
  24. {
  25. uint16_t A;
  26. uint16_t B;
  27. uint16_t ver;
  28. uint16_t v_crc;
  29. uint8_t time[24];//时间
  30. uint16_t crc;
  31. }SHM_VER_T;
  32. //Ad7616采样点写指针结构体
  33. typedef struct WP_T
  34. {
  35. uint16_t A;
  36. uint16_t B;
  37. uint16_t write_flag_A;
  38. uint16_t write_flag_B;
  39. uint16_t crc;
  40. }WP_T;
  41. //Ad7616采样点结构定义
  42. typedef struct SHM_SAMPLE_T
  43. {
  44. uint16_t sample_buf[16];
  45. uint32_t yx_buf[2]; //预留64个遥信
  46. struct timespec ts;//时间戳
  47. }SHM_SAMPLE_T;
  48. #define SHM_ADC_WR_NUM (SHM_ADC_SIZE/sizeof(SHM_SAMPLE_T))
  49. //7616电压参数读写结构体
  50. typedef struct SHM_RFV_T
  51. {
  52. uint16_t A;
  53. uint16_t B;
  54. uint32_t rc;
  55. uint16_t crc;
  56. }SHM_RFV_T;
  57. //直流数据结构体
  58. typedef struct SHM_DC_T
  59. {
  60. uint16_t A;
  61. uint16_t B;
  62. struct timespec ts;//时间戳
  63. uint16_t adc[2]; //ad值
  64. uint16_t crc;
  65. }SHM_DC_T;
  66. extern s16 (*g_adc_dots)[CFG_ADC_DOTS_PER_CHANNEL*2];
  67. extern s16 (*g_adc_dots_rec)[CFG_ADC_CHANNEL];
  68. extern struct timespec ts_adc_dots[CFG_ADC_DOTS_PER_CHANNEL];
  69. #define ADC_REC_SAMPLE 128 // 录波每周采样点数
  70. #define ADC_REC_SAMPLE_RATE 4 // 录波128点,计算32点,比率为4
  71. #define ADC_REC_LEN 64 // 录波记录长度,以周波为单位,64周波约1.28s。
  72. #define ADC_REC_DOTS_CHANNEL (ADC_REC_SAMPLE*ADC_REC_LEN)// 每通道点数
  73. #define ADC_REC_DOTS_MASK (ADC_REC_DOTS_CHANNEL - 1) // 录波索引屏蔽字
  74. #define AD7616_DC0_CHANNEL 14
  75. #define AD7616_DC1_CHANNEL -1
  76. extern volatile unsigned long g_adc_dots_count;
  77. #define g_adc_dots_index (g_adc_dots_count&CFG_ADC_DOTS_MASK)
  78. #define g_adc_dots_index_rec (g_adc_dots_data_count&ADC_REC_DOTS_MASK)
  79. extern int g_adc_sync;
  80. extern float g_freq;
  81. extern volatile unsigned long g_adc_dots_data_count;
  82. extern bool prt_flag;
  83. extern SHM_VER_T LuoHe_version;
  84. /******************************************************************************
  85. 函数名称: adc_init
  86. 函数版本: 01.01
  87. 创建作者: xxxxxx
  88. 创建日期: 2014-11-24
  89. 函数说明: AD7606初始化.
  90. 参数说明:
  91. 返回值: 成功返回0, 失败返回-1
  92. 修改记录:
  93. */
  94. int adc_init(void);
  95. /******************************************************************************
  96. 函数名称: adc_exit
  97. 函数版本: 01.01
  98. 创建作者: xxxxxx
  99. 创建日期: 2014-11-24
  100. 函数说明: AD7606反初始化.
  101. 参数说明:
  102. 返回值: 总是返回0.
  103. 修改记录:
  104. */
  105. int adc_exit(void);
  106. /******************************************************************************
  107. 函数名称: adc_slot_is_ok
  108. 函数版本: 01.01
  109. 创建作者: sunxi
  110. 创建日期: 2016-02-01
  111. 函数说明: 检查对应槽的ADC芯片是否安装或损坏。
  112. 参数说明:
  113. slot: 0~3;从g_ac_slot_begin开始
  114. 返回值: 成功返回0.
  115. 修改记录:
  116. */
  117. int adc_slot_is_ok(int slot);
  118. /******************************************************************************
  119. 函数名称: adc_isr
  120. 函数版本: 01.01
  121. 创建作者: xxxxxx
  122. 创建日期: 2014-11-24
  123. 函数说明: AD7606转换处理(此函数在156us中断中处理).
  124. 参数说明:
  125. 返回值: 无
  126. 修改记录:
  127. */
  128. int adc_isr(int mod);
  129. /******************************************************************************
  130. 函数名称: adc_stat_reset
  131. 函数版本: 01.01
  132. 创建作者: sunxi
  133. 创建日期: 2008-06-26
  134. 函数说明: 复位统计信息
  135. 参数说明:无
  136. 返回值: 无
  137. 修改记录:
  138. */
  139. int adc_stat_reset(void);
  140. /******************************************************************************
  141. 函数名称: adc_stat_printf
  142. 函数版本: 01.01
  143. 创建作者: sunxi
  144. 创建日期: 2008-06-26
  145. 函数说明: 频率跟踪统计信息
  146. 参数说明:无
  147. 返回值: 无
  148. 修改记录:
  149. */
  150. int adc_stat_printf(void);
  151. /******************************************************************************
  152. 函数名称: adc_fourier_address
  153. 函数版本: 01.01
  154. 创建作者: sunxi
  155. 创建日期: 2008-06-26
  156. 函数说明: 返回指定的通道进行傅立叶计算的首地址。首地址保证4bytes对齐。
  157. 参数说明:
  158. channel:ADC的通道,取值0~7。
  159. index: 要进行傅立叶计算的32点中的最后一个点的索引。这么设置是为了和
  160. g_adc_dots_index匹配。保证g_adc_dots_index可以直接作为参数传进来。
  161. 返回值: 成功返回0.
  162. 修改记录:
  163. */
  164. short * adc_fourier_address(int channel,int index);
  165. float dc_get(unsigned int index);
  166. #endif
  167. /*------------------------------ 文件结束 -------------------------------------
  168. */