rgb381.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. /*
  2. * ALS308.c
  3. *
  4. * Created on: 2022年4月11日
  5. * Author: amos
  6. */
  7. #include "rgb381.h"
  8. #include "TCA9548A.h"
  9. #include <string.h>
  10. #define I2C_TIMEOUT_1000MS 16000000 // 定义超时时间(毫秒)
  11. #define CARD_NO_ALIGN 3
  12. #define CARD_NO_MIN 10
  13. /****************Result define*******************/
  14. #define ResultInvalid 0 //无效
  15. #define ResultNegative 1 //阴
  16. #define ResultPositive 2 //阳
  17. ColorSensor CS[CS_MAX] = {0}; //检测孔
  18. uint8_t SensorState1=0,SensorState2=0,SensorState3=0,SensorState4=0,SensorState5=0,
  19. SensorState6=0,SensorState7=0,SensorState8=0,SensorState9=0,SensorState10=0;
  20. //extern uint8_t I2C_data;
  21. int8_t I2CWriteOneByte(I2C_HandleTypeDef *hi2c, uint8_t u8SlaveAddr, uint8_t u8DataAddr, uint8_t data)
  22. {
  23. // HAL 库返回值:HAL_OK 表示成功
  24. HAL_StatusTypeDef status = HAL_I2C_Mem_Write(hi2c,
  25. (uint16_t)(u8SlaveAddr << 1), // 7位地址左移1位,HAL内部会处理读写位
  26. (uint16_t)u8DataAddr, // 寄存器地址(8位)
  27. I2C_MEMADD_SIZE_8BIT, // 寄存器地址宽度 8 位
  28. &data, // 要写入的数据
  29. 1, // 数据长度(字节)
  30. 100); // 超时时间 ms
  31. if (status == HAL_OK)
  32. return 0; // 成功
  33. else
  34. return 3; // 统一返回 3(或按原函数错误码细化)
  35. }
  36. uint8_t I2CReadOneByte(I2C_HandleTypeDef *hi2c, uint8_t u8SlaveAddr, uint8_t u8DataAddr)
  37. {
  38. uint8_t rdata = 0;
  39. HAL_StatusTypeDef status = HAL_I2C_Mem_Read(hi2c,
  40. (uint16_t)(u8SlaveAddr << 1),
  41. (uint16_t)u8DataAddr,
  42. I2C_MEMADD_SIZE_8BIT,
  43. &rdata,
  44. 1,
  45. 100);
  46. if (status == HAL_OK)
  47. return rdata;
  48. else
  49. return 0; // 失败返回 0(与原函数一致)
  50. }
  51. uint8_t I2C_data = 0;
  52. void TCA9548A_SetChannel(uint8_t ID)
  53. {
  54. /********************************************************/
  55. /**************background light--PA0*********************/
  56. /*********************WIFI_EN--PA12**********************/
  57. /**********************I2C_S0--PB3***********************/
  58. /***********************I2C_S1--PB2**********************/
  59. /**********************I2C_S2--PB1***********************/
  60. /**********************I2C_S3--PB0***********************/
  61. /**********************I2C_S4--PF5***********************/
  62. /******************Device_num1--PB15*********************/
  63. /******************Device_num2--PB14*********************/
  64. /******************Device_num3--PB13*********************/
  65. /******************Device_num4--PB12*********************/
  66. /***********************LED--PF4*************************/
  67. /***********************DEC--PB15************************/
  68. switch(ID)
  69. {
  70. case 0:
  71. I2C_data = TCA9548A_CHANNEL_0;
  72. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,ID);
  73. break;
  74. case 1:
  75. I2C_data = TCA9548A_CHANNEL_0;
  76. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,I2C_data);
  77. HAL_Delay(50);
  78. I2C_data = TCA9548A_CHANNEL_2;
  79. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,I2C_data);
  80. break;
  81. case 2:
  82. I2C_data = TCA9548A_CHANNEL_3;
  83. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,I2C_data);
  84. break;
  85. case 3:
  86. I2C_data = TCA9548A_CHANNEL_4;
  87. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,I2C_data);
  88. break;
  89. case 4:
  90. I2C_data = TCA9548A_CHANNEL_5;
  91. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,I2C_data);
  92. break;
  93. case 5:
  94. I2C_data = TCA9548A_CHANNEL_6;
  95. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,I2C_data);
  96. break;
  97. case 6:
  98. I2C_data = TCA9548A_CHANNEL_7;
  99. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,I2C_data);
  100. break;
  101. case 7:
  102. I2C_data = TCA9548A_CHANNEL_8;
  103. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,I2C_data);
  104. break;
  105. case 8:
  106. I2C_data = TCA9548A_CHANNEL_1;
  107. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR,I2C_data,I2C_data);
  108. HAL_Delay(50);
  109. I2C_data = TCA9548A_CHANNEL_0;
  110. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR1,I2C_data,I2C_data);
  111. HAL_Delay(50);
  112. I2C_data = TCA9548A_CHANNEL_2;
  113. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR1,I2C_data,I2C_data);
  114. break;
  115. case 9:
  116. // I2C_data = TCA9548A_CHANNEL_0;
  117. // I2CWriteOneByte(I2C0,TCA9548A_SLAVE_ADDR1,I2C_data,I2C_data);
  118. // DelayMS(100);
  119. I2C_data = TCA9548A_CHANNEL_3;
  120. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR1,I2C_data,I2C_data);
  121. break;
  122. case 10:
  123. // I2C_data = TCA9548A_CHANNEL_0;
  124. // I2CWriteOneByte(I2C0,TCA9548A_SLAVE_ADDR1,I2C_data,I2C_data);
  125. // DelayMS(100);
  126. I2C_data = TCA9548A_CHANNEL_4;
  127. I2CWriteOneByte(&hi2c1,TCA9548A_SLAVE_ADDR1,I2C_data,I2C_data);
  128. break;
  129. default:
  130. break;
  131. }
  132. }
  133. void SensorMeasurementFactor(uint8_t measfactor)
  134. {
  135. I2CWriteOneByte(&hi2c1,RGB381_ADDR,RGB381_MeasRate,measfactor);
  136. }
  137. void SensorSetGain(uint8_t gain)
  138. {
  139. I2CWriteOneByte(&hi2c1,RGB381_ADDR,RGB381_Gain,gain);
  140. }
  141. uint8_t SensorGetID(uint8_t ID)
  142. {
  143. TCA9548A_SetChannel(ID);
  144. HAL_Delay(100);
  145. return I2CReadOneByte(&hi2c1,RGB381_ADDR,RGB381_PartID);
  146. // return I2CReadOneByte(I2C0,RGB381_ADDR,RGB381_PartID);
  147. }
  148. void SensorGetRawData(ColorSensor *CS)
  149. {
  150. uint32_t u32Timeout = I2C_TIMEOUT_1000MS; // 转换为时钟周期数
  151. uint32_t u32StartTick = sysinf.ms_conter;
  152. uint32_t u32LastTick;
  153. uint32_t time;
  154. TCA9548A_SetChannel(CS->ID);
  155. HAL_Delay(40);
  156. u32LastTick = sysinf.ms_conter;
  157. time = u32LastTick - u32StartTick;
  158. while((I2CReadOneByte(&hi2c1,RGB381_ADDR,RGB381_MainState)&0x08)==0x08){
  159. // 超时检测
  160. u32LastTick = sysinf.ms_conter;
  161. time = u32LastTick - u32StartTick;
  162. if(u32LastTick < u32StartTick){
  163. time = u32LastTick + 0x1000000 - u32StartTick;
  164. }
  165. if ((time) > u32Timeout) {
  166. CS->RDR = 0;
  167. Van_Device_Printf(VAN_LOG_ERROR, "error_state :%d\n",time);
  168. return; // 返回超时错误码
  169. }
  170. };
  171. HAL_Delay(10);
  172. // LOG_E("error_state :%d\n",time);
  173. CS->RDR=(I2CReadOneByte(&hi2c1,RGB381_ADDR,RGB381_R_DataLow)|
  174. (I2CReadOneByte(&hi2c1,RGB381_ADDR,RGB381_R_DataMid)<<8)|
  175. (I2CReadOneByte(&hi2c1,RGB381_ADDR,RGB381_R_DataHIG)<<16));
  176. if(CS->RDR == 0){
  177. HAL_Delay(10);
  178. CS->RDR=(I2CReadOneByte(&hi2c1,RGB381_ADDR,RGB381_R_DataLow)|
  179. (I2CReadOneByte(&hi2c1,RGB381_ADDR,RGB381_R_DataMid)<<8)|
  180. (I2CReadOneByte(&hi2c1,RGB381_ADDR,RGB381_R_DataHIG)<<16));
  181. if(CS->RDR == 0){
  182. Van_Device_Printf(VAN_LOG_ERROR, "error_Data\n");
  183. }
  184. }
  185. // CS->RDG=(I2CReadOneByte(I2C0,RGB381_ADDR,RGB381_G_DataLow)|
  186. // (I2CReadOneByte(I2C0,RGB381_ADDR,RGB381_G_DataMid)<<8)|
  187. // (I2CReadOneByte(I2C0,RGB381_ADDR,RGB381_G_DataHIG)<<16));
  188. // CS->RDB=(I2CReadOneByte(I2C0,RGB381_ADDR,RGB381_B_DataLow)|
  189. // (I2CReadOneByte(I2C0,RGB381_ADDR,RGB381_B_DataMid)<<8)|
  190. // (I2CReadOneByte(I2C0,RGB381_ADDR,RGB381_B_DataHIG)<<16));
  191. }
  192. void SensorEnable(void)
  193. {
  194. I2CWriteOneByte(&hi2c1,RGB381_ADDR,RGB381_MainCtrl,CS_Modle|ALS_Active);
  195. HAL_Delay(10);
  196. }
  197. uint8_t SensorInit(ColorSensor *CS)
  198. {
  199. Refresh_IWDG();
  200. if(SensorGetID(CS->ID)==0xC2)// device id is 0xC2
  201. {
  202. SensorEnable();
  203. SensorMeasurementFactor(ALS_MeasRes_17B|ALS_MeasRate_50ms);
  204. SensorSetGain(ALS_Gain_9X);
  205. CS->TtMax=0.0;
  206. // CS->TtNow=0.0;
  207. // CS->ColDifInit=0.0;
  208. // CS->ColDifNow=0.0;
  209. // CS->ColDifMax=0.0;
  210. CS->Tt=30.0;
  211. CS->STD=0.0;
  212. CS->average=0.0;
  213. memset(CS->SAMP, 0, sizeof(CS->SAMP));
  214. CS->std_num=0;
  215. CS->gain=0;
  216. SensorGetRawData(CS);
  217. for(int i = 0; i < 10; i++)
  218. {
  219. if(CS->RDR > CS_RDR_MIN)
  220. return 0;
  221. HAL_Delay(100);
  222. SensorGetRawData(CS);
  223. }
  224. return 1;
  225. }
  226. else
  227. return 1;
  228. }
  229. int SensorSelfCheckPass(void)
  230. {
  231. SensorState1=SensorInit(&CS[0]);
  232. SensorState2=SensorInit(&CS[1]);
  233. SensorState3=SensorInit(&CS[2]);
  234. SensorState4=SensorInit(&CS[3]);
  235. SensorState5=SensorInit(&CS[4]);
  236. SensorState6=SensorInit(&CS[5]);
  237. SensorState7=SensorInit(&CS[6]);
  238. SensorState8=SensorInit(&CS[7]);
  239. SensorState9=SensorInit(&CS[8]);
  240. SensorState10=SensorInit(&CS[9]);
  241. if(SensorState1|SensorState2|SensorState3|SensorState4|SensorState5|SensorState6|SensorState7|SensorState8|SensorState9|SensorState10)
  242. return 0;
  243. else return 1;
  244. }
  245. void SensorGetCalData(ColorSensor *CS)
  246. {
  247. // SensorGetRawData(CS);
  248. //CS->AccArea+=CS->RtR;
  249. }
  250. void SensorInitial(void)
  251. {
  252. CS[0].ID = Sensor1;
  253. CS[1].ID = Sensor2;
  254. CS[2].ID = Sensor3;
  255. CS[3].ID = Sensor4;
  256. CS[4].ID = Sensor5;
  257. CS[5].ID = Sensor6;
  258. CS[6].ID = Sensor7;
  259. CS[7].ID = Sensor8;
  260. CS[8].ID = Sensor9;
  261. CS[9].ID = Sensor10;
  262. }
  263. int Returntozero(ColorSensor *CS) //lxx-add-2022.12.26
  264. {
  265. //lxx-add-2023.03.27
  266. SensorGetRawData(CS);
  267. CS->CDR = (float)CS->RDR;
  268. if(CS->RDR < CARD_NO_MIN){
  269. return 1;
  270. }
  271. if(CS->RDC/CS->RDR > CARD_NO_ALIGN){
  272. return 1;
  273. }
  274. return 0;
  275. }
  276. void Get_SAMP_DATA(ColorSensor *CS)
  277. {
  278. CS->SAMP[0] = CS->RtR;
  279. // CS->CALCU_SAMP[samp_num] = (uint16_t)CS->RtR;
  280. }
  281. void Get_Tt(ColorSensor *CS)
  282. {
  283. if(CS->Tt == 30.0)
  284. {
  285. if(CS->RtR>(10*fabs(CS->STD)+CS->average))
  286. {
  287. CS->std_num++;
  288. if(CS->std_num==5) //连续5次
  289. {
  290. // CS->Tt = (sampleTimes-(5-1))/6.0f; //每分钟6次;
  291. }
  292. }
  293. else
  294. {
  295. CS->std_num=0;
  296. }
  297. }
  298. }
  299. void Get_average(ColorSensor *CS)
  300. {
  301. float sum= 0;
  302. int i = 0;
  303. for(i=0;i<SAMP_SIZE;i++)
  304. {
  305. sum += CS->SAMP[i];
  306. }
  307. CS->average = sum/(SAMP_SIZE);
  308. }
  309. void Get_STD(ColorSensor *CS)
  310. {
  311. int i = 0;
  312. float sum = 0;
  313. for(i=0;i<SAMP_SIZE;i++)
  314. {
  315. sum += (CS->SAMP[i]-CS->average)*(CS->SAMP[i]-CS->average);
  316. }
  317. CS->STD = sqrtf(sum / (SAMP_SIZE - 1));
  318. }
  319. void Get_GAIN(ColorSensor *CS) //lxx_add_2023.07.27
  320. {
  321. SensorGetRawData(CS);
  322. CS->RDC = (float)CS->RDR;
  323. if(CS->RDC < CS_RDR_MIN)
  324. {
  325. // error_set(ERROR_SENSOR_SELF_CHECK);
  326. return;
  327. }
  328. CS->gain = 1000.0/(float)CS->RDC;
  329. }
  330. void Sensor_calibration_data(ColorSensor *CS) //lxx_add_2023.07.27
  331. {
  332. CS->RtR = (CS->CDR-CS->RDR)*CS->gain;
  333. }
  334. void sample_first_zero(void)
  335. {
  336. for (int i = 0; i < CS_MAX; i++)
  337. {
  338. Returntozero(&CS[i]);
  339. //从零点输出
  340. Sensor_calibration_data(&CS[i]);
  341. }
  342. }
  343. int check_first_zero(void)
  344. {
  345. int noAlignNum = 0;
  346. for (int i = 0; i < CS_MAX; i++)
  347. {
  348. if(Returntozero(&CS[i]) == 1){
  349. noAlignNum ++;
  350. }
  351. }
  352. if(noAlignNum == 0){
  353. error_clear();
  354. return 0;
  355. }else{
  356. error_set(ERROR_SENSOR_SELF_CHECK);
  357. return 1;
  358. }
  359. }
  360. void sample_calibrate_calc(uint32_t times)
  361. {
  362. for (int i = 0; i < CS_MAX; i++)
  363. {
  364. SensorGetRawData(&CS[i]); // get the original data every 1S
  365. if(CS->RDR == 0){
  366. // if(!(g_cfg.skip_CheckOrRun & SKIP_CHECK_CARDINSERT)){
  367. // error_set(ERROR_SENSOR_SELF_CHECK);
  368. // return;
  369. // }
  370. }
  371. Sensor_calibration_data(&CS[i]);
  372. }
  373. if (times < 19)
  374. {
  375. for (int i = 0; i < CS_MAX; i++)
  376. {
  377. Get_SAMP_DATA(&CS[i]);// save the returntozero data in 30minutes
  378. }
  379. // samp_num++;
  380. }
  381. }
  382. void sample_calc_avg_std(void)
  383. {
  384. for (int i = 0; i < CS_MAX; i++)
  385. {
  386. Get_average(&CS[i]);
  387. Get_STD(&CS[i]);
  388. }
  389. }
  390. void sample_calc_tt(void)
  391. {
  392. for (int i = 0; i < CS_MAX; i++)
  393. {
  394. Get_Tt(&CS[i]);
  395. }
  396. }
  397. void SingleChannelJudge(ColorSensor *CS)
  398. {
  399. if(CS->TtMin < CS->Tt && CS->Tt < CS->TtMax)
  400. {
  401. CS->Result=ResultPositive;
  402. }
  403. else
  404. {
  405. CS->Result=ResultNegative;
  406. }
  407. }
  408. void SystemResaultJudge(void)
  409. {
  410. int nc_index = 0; //内参
  411. uint8_t *p = &result.hole1_result; //孔结果
  412. result.Devicenum = 0;
  413. strcpy(result.card_num,sysinf.psmMaster.card_param_info.pid);
  414. // result.card_num = card_param_info.pid;
  415. result.hole1_item = sysinf.psmMaster.card_param_info.hole_info[0].item;
  416. result.hole2_item = sysinf.psmMaster.card_param_info.hole_info[1].item;
  417. result.hole3_item = sysinf.psmMaster.card_param_info.hole_info[2].item;
  418. result.hole4_item = sysinf.psmMaster.card_param_info.hole_info[3].item;
  419. result.hole5_item = sysinf.psmMaster.card_param_info.hole_info[4].item;
  420. result.hole6_item = sysinf.psmMaster.card_param_info.hole_info[5].item;
  421. result.hole7_item = sysinf.psmMaster.card_param_info.hole_info[6].item;
  422. result.hole8_item = sysinf.psmMaster.card_param_info.hole_info[7].item;
  423. result.hole9_item = sysinf.psmMaster.card_param_info.hole_info[8].item;
  424. result.hole10_item = sysinf.psmMaster.card_param_info.hole_info[9].item;
  425. result.hole1_Tt[0] = (uint8_t)CS[0].Tt;
  426. result.hole1_Tt[1] = (uint8_t)((CS[0].Tt-(uint8_t)CS[0].Tt)*100);
  427. result.hole2_Tt[0] = (uint8_t)CS[1].Tt;
  428. result.hole2_Tt[1] = (uint8_t)((CS[1].Tt-(uint8_t)CS[1].Tt)*100);
  429. result.hole3_Tt[0] = (uint8_t)CS[2].Tt;
  430. result.hole3_Tt[1] = (uint8_t)((CS[2].Tt-(uint8_t)CS[2].Tt)*100);
  431. result.hole4_Tt[0] = (uint8_t)CS[3].Tt;
  432. result.hole4_Tt[1] = (uint8_t)((CS[3].Tt-(uint8_t)CS[3].Tt)*100);
  433. result.hole5_Tt[0] = (uint8_t)CS[4].Tt;
  434. result.hole5_Tt[1] = (uint8_t)((CS[4].Tt-(uint8_t)CS[4].Tt)*100);
  435. result.hole6_Tt[0] = (uint8_t)CS[5].Tt;
  436. result.hole6_Tt[1] = (uint8_t)((CS[5].Tt-(uint8_t)CS[5].Tt)*100);
  437. result.hole7_Tt[0] = (uint8_t)CS[6].Tt;
  438. result.hole7_Tt[1] = (uint8_t)((CS[6].Tt-(uint8_t)CS[6].Tt)*100);
  439. result.hole8_Tt[0] = (uint8_t)CS[7].Tt;
  440. result.hole8_Tt[1] = (uint8_t)((CS[7].Tt-(uint8_t)CS[7].Tt)*100);
  441. result.hole9_Tt[0] = (uint8_t)CS[8].Tt;
  442. result.hole9_Tt[1] = (uint8_t)((CS[8].Tt-(uint8_t)CS[8].Tt)*100);
  443. result.hole10_Tt[0] = (uint8_t)CS[9].Tt;
  444. result.hole10_Tt[1] = (uint8_t)((CS[9].Tt-(uint8_t)CS[9].Tt)*100);
  445. //判断孔结果
  446. for (int i = 0; i < CS_MAX; i++)
  447. {
  448. SingleChannelJudge(&CS[i]);
  449. *p = CS[i].Result;
  450. p += 5;
  451. }
  452. //找id == -1
  453. for(nc_index = 0; nc_index < 10; nc_index++)
  454. {
  455. if(sysinf.psmMaster.card_param_info.hole_info[nc_index].item == 0xFF)
  456. break;
  457. }
  458. if(nc_index == 10)
  459. {
  460. nc_index = 0;
  461. }
  462. //判断最终检测结果
  463. p = &result.hole1_item_result; //检测结果
  464. if(CS[nc_index].Result == ResultPositive) //内参结果为阳
  465. {
  466. for (int i = 0; i < CS_MAX; i++)
  467. {
  468. if(CS[i].Result==ResultPositive) //孔结果为阳,最终结果为阳
  469. {
  470. *p = ResultPositive;
  471. }
  472. else //否则,最终结果为阴
  473. {
  474. *p = ResultNegative;
  475. }
  476. p += 5;
  477. }
  478. }
  479. else //内参结果为阴
  480. {
  481. for (int i = 0; i < CS_MAX; i++)
  482. {
  483. if(CS[i].Result==ResultPositive) //孔结果为阳,最终结果为阳
  484. {
  485. *p = ResultPositive;
  486. }
  487. else //否则,最终结果无效
  488. {
  489. *p = ResultInvalid;
  490. }
  491. p += 5;
  492. }
  493. }
  494. //内参自身检测结果,等于孔结果
  495. p = &result.hole1_item_result; //检测结果
  496. p += 5*nc_index;
  497. *p = CS[nc_index].Result;
  498. }
  499. void sample_calc_result(void)
  500. {
  501. for (int i = 0; i < CS_MAX; i++)
  502. {
  503. //从二维码获取Tt范围
  504. CS[i].TtMax = sysinf.psmMaster.card_param_info.hole_info[i].TtMax[0] + sysinf.psmMaster.card_param_info.hole_info[i].TtMax[1] / 100.0f;
  505. CS[i].TtMin = sysinf.psmMaster.card_param_info.hole_info[i].TtMin[0] + sysinf.psmMaster.card_param_info.hole_info[i].TtMin[1] / 100.0f;
  506. }
  507. SystemResaultJudge();
  508. }
  509. void calc_balance(void)
  510. {
  511. // 获取插卡前白平衡值
  512. for (int i = 0; i < CS_MAX; i++)
  513. {
  514. Get_GAIN(&CS[i]);
  515. }
  516. }