rgb381.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  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. if(SensorGetID(CS->ID)==0xC2)// device id is 0xC2
  200. {
  201. SensorEnable();
  202. SensorMeasurementFactor(ALS_MeasRes_17B|ALS_MeasRate_50ms);
  203. SensorSetGain(ALS_Gain_9X);
  204. CS->TtMax=0.0;
  205. // CS->TtNow=0.0;
  206. // CS->ColDifInit=0.0;
  207. // CS->ColDifNow=0.0;
  208. // CS->ColDifMax=0.0;
  209. CS->Tt=30.0;
  210. CS->STD=0.0;
  211. CS->average=0.0;
  212. memset(CS->SAMP, 0, sizeof(CS->SAMP));
  213. CS->std_num=0;
  214. CS->gain=0;
  215. SensorGetRawData(CS);
  216. for(int i = 0; i < 10; i++)
  217. {
  218. if(CS->RDR > CS_RDR_MIN)
  219. return 0;
  220. HAL_Delay(100);
  221. SensorGetRawData(CS);
  222. }
  223. return 1;
  224. }
  225. else
  226. return 1;
  227. }
  228. int SensorSelfCheck(void)
  229. {
  230. SensorState1=SensorInit(&CS[0]);
  231. SensorState2=SensorInit(&CS[1]);
  232. SensorState3=SensorInit(&CS[2]);
  233. SensorState4=SensorInit(&CS[3]);
  234. SensorState5=SensorInit(&CS[4]);
  235. SensorState6=SensorInit(&CS[5]);
  236. SensorState7=SensorInit(&CS[6]);
  237. SensorState8=SensorInit(&CS[7]);
  238. SensorState9=SensorInit(&CS[8]);
  239. SensorState10=SensorInit(&CS[9]);
  240. if(SensorState1|SensorState2|SensorState3|SensorState4|SensorState5|SensorState6|SensorState7|SensorState8|SensorState9|SensorState10)
  241. return -1;
  242. else return 0;
  243. }
  244. void SensorGetCalData(ColorSensor *CS)
  245. {
  246. // SensorGetRawData(CS);
  247. //CS->AccArea+=CS->RtR;
  248. }
  249. void SensorInitial(void)
  250. {
  251. CS[0].ID = Sensor1;
  252. CS[1].ID = Sensor2;
  253. CS[2].ID = Sensor3;
  254. CS[3].ID = Sensor4;
  255. CS[4].ID = Sensor5;
  256. CS[5].ID = Sensor6;
  257. CS[6].ID = Sensor7;
  258. CS[7].ID = Sensor8;
  259. CS[8].ID = Sensor9;
  260. CS[9].ID = Sensor10;
  261. }
  262. int Returntozero(ColorSensor *CS) //lxx-add-2022.12.26
  263. {
  264. //lxx-add-2023.03.27
  265. SensorGetRawData(CS);
  266. CS->CDR = (float)CS->RDR;
  267. if(CS->RDR < CARD_NO_MIN){
  268. return 1;
  269. }
  270. if(CS->RDC/CS->RDR > CARD_NO_ALIGN){
  271. return 1;
  272. }
  273. return 0;
  274. }
  275. void Get_SAMP_DATA(ColorSensor *CS)
  276. {
  277. CS->SAMP[0] = CS->RtR;
  278. // CS->CALCU_SAMP[samp_num] = (uint16_t)CS->RtR;
  279. }
  280. void Get_Tt(ColorSensor *CS)
  281. {
  282. if(CS->Tt == 30.0)
  283. {
  284. if(CS->RtR>(10*fabs(CS->STD)+CS->average))
  285. {
  286. CS->std_num++;
  287. if(CS->std_num==5) //连续5次
  288. {
  289. // CS->Tt = (sampleTimes-(5-1))/6.0f; //每分钟6次;
  290. }
  291. }
  292. else
  293. {
  294. CS->std_num=0;
  295. }
  296. }
  297. }
  298. void Get_average(ColorSensor *CS)
  299. {
  300. float sum= 0;
  301. int i = 0;
  302. for(i=0;i<SAMP_SIZE;i++)
  303. {
  304. sum += CS->SAMP[i];
  305. }
  306. CS->average = sum/(SAMP_SIZE);
  307. }
  308. void Get_STD(ColorSensor *CS)
  309. {
  310. int i = 0;
  311. float sum = 0;
  312. for(i=0;i<SAMP_SIZE;i++)
  313. {
  314. sum += (CS->SAMP[i]-CS->average)*(CS->SAMP[i]-CS->average);
  315. }
  316. CS->STD = sqrtf(sum / (SAMP_SIZE - 1));
  317. }
  318. void Get_GAIN(ColorSensor *CS) //lxx_add_2023.07.27
  319. {
  320. SensorGetRawData(CS);
  321. CS->RDC = (float)CS->RDR;
  322. if(CS->RDC < CS_RDR_MIN)
  323. {
  324. // error_set(ERROR_SENSOR_SELF_CHECK);
  325. return;
  326. }
  327. CS->gain = 1000.0/(float)CS->RDC;
  328. }
  329. void Sensor_calibration_data(ColorSensor *CS) //lxx_add_2023.07.27
  330. {
  331. CS->RtR = (CS->CDR-CS->RDR)*CS->gain;
  332. }
  333. void sample_first_zero(void)
  334. {
  335. for (int i = 0; i < CS_MAX; i++)
  336. {
  337. Returntozero(&CS[i]);
  338. //从零点输出
  339. Sensor_calibration_data(&CS[i]);
  340. }
  341. }
  342. int check_first_zero(void)
  343. {
  344. int noAlignNum = 0;
  345. for (int i = 0; i < CS_MAX; i++)
  346. {
  347. if(Returntozero(&CS[i]) == 1){
  348. noAlignNum ++;
  349. }
  350. }
  351. if(noAlignNum == 0){
  352. error_clear();
  353. return 0;
  354. }else{
  355. error_set(ERROR_SENSOR_SELF_CHECK);
  356. return 1;
  357. }
  358. }
  359. void sample_calibrate_calc(uint32_t times)
  360. {
  361. for (int i = 0; i < CS_MAX; i++)
  362. {
  363. SensorGetRawData(&CS[i]); // get the original data every 1S
  364. if(CS->RDR == 0){
  365. // if(!(g_cfg.skip_CheckOrRun & SKIP_CHECK_CARDINSERT)){
  366. // error_set(ERROR_SENSOR_SELF_CHECK);
  367. // return;
  368. // }
  369. }
  370. Sensor_calibration_data(&CS[i]);
  371. }
  372. if (times < 19)
  373. {
  374. for (int i = 0; i < CS_MAX; i++)
  375. {
  376. Get_SAMP_DATA(&CS[i]);// save the returntozero data in 30minutes
  377. }
  378. // samp_num++;
  379. }
  380. }
  381. void sample_calc_avg_std(void)
  382. {
  383. for (int i = 0; i < CS_MAX; i++)
  384. {
  385. Get_average(&CS[i]);
  386. Get_STD(&CS[i]);
  387. }
  388. }
  389. void sample_calc_tt(void)
  390. {
  391. for (int i = 0; i < CS_MAX; i++)
  392. {
  393. Get_Tt(&CS[i]);
  394. }
  395. }
  396. void SingleChannelJudge(ColorSensor *CS)
  397. {
  398. if(CS->TtMin < CS->Tt && CS->Tt < CS->TtMax)
  399. {
  400. CS->Result=ResultPositive;
  401. }
  402. else
  403. {
  404. CS->Result=ResultNegative;
  405. }
  406. }
  407. void SystemResaultJudge(void)
  408. {
  409. int nc_index = 0; //内参
  410. uint8_t *p = &result.hole1_result; //孔结果
  411. result.Devicenum = 0;
  412. strcpy(result.card_num,sysinf.psmMaster.card_param_info.pid);
  413. // result.card_num = card_param_info.pid;
  414. result.hole1_item = sysinf.psmMaster.card_param_info.hole_info[0].item;
  415. result.hole2_item = sysinf.psmMaster.card_param_info.hole_info[1].item;
  416. result.hole3_item = sysinf.psmMaster.card_param_info.hole_info[2].item;
  417. result.hole4_item = sysinf.psmMaster.card_param_info.hole_info[3].item;
  418. result.hole5_item = sysinf.psmMaster.card_param_info.hole_info[4].item;
  419. result.hole6_item = sysinf.psmMaster.card_param_info.hole_info[5].item;
  420. result.hole7_item = sysinf.psmMaster.card_param_info.hole_info[6].item;
  421. result.hole8_item = sysinf.psmMaster.card_param_info.hole_info[7].item;
  422. result.hole9_item = sysinf.psmMaster.card_param_info.hole_info[8].item;
  423. result.hole10_item = sysinf.psmMaster.card_param_info.hole_info[9].item;
  424. result.hole1_Tt[0] = (uint8_t)CS[0].Tt;
  425. result.hole1_Tt[1] = (uint8_t)((CS[0].Tt-(uint8_t)CS[0].Tt)*100);
  426. result.hole2_Tt[0] = (uint8_t)CS[1].Tt;
  427. result.hole2_Tt[1] = (uint8_t)((CS[1].Tt-(uint8_t)CS[1].Tt)*100);
  428. result.hole3_Tt[0] = (uint8_t)CS[2].Tt;
  429. result.hole3_Tt[1] = (uint8_t)((CS[2].Tt-(uint8_t)CS[2].Tt)*100);
  430. result.hole4_Tt[0] = (uint8_t)CS[3].Tt;
  431. result.hole4_Tt[1] = (uint8_t)((CS[3].Tt-(uint8_t)CS[3].Tt)*100);
  432. result.hole5_Tt[0] = (uint8_t)CS[4].Tt;
  433. result.hole5_Tt[1] = (uint8_t)((CS[4].Tt-(uint8_t)CS[4].Tt)*100);
  434. result.hole6_Tt[0] = (uint8_t)CS[5].Tt;
  435. result.hole6_Tt[1] = (uint8_t)((CS[5].Tt-(uint8_t)CS[5].Tt)*100);
  436. result.hole7_Tt[0] = (uint8_t)CS[6].Tt;
  437. result.hole7_Tt[1] = (uint8_t)((CS[6].Tt-(uint8_t)CS[6].Tt)*100);
  438. result.hole8_Tt[0] = (uint8_t)CS[7].Tt;
  439. result.hole8_Tt[1] = (uint8_t)((CS[7].Tt-(uint8_t)CS[7].Tt)*100);
  440. result.hole9_Tt[0] = (uint8_t)CS[8].Tt;
  441. result.hole9_Tt[1] = (uint8_t)((CS[8].Tt-(uint8_t)CS[8].Tt)*100);
  442. result.hole10_Tt[0] = (uint8_t)CS[9].Tt;
  443. result.hole10_Tt[1] = (uint8_t)((CS[9].Tt-(uint8_t)CS[9].Tt)*100);
  444. //判断孔结果
  445. for (int i = 0; i < CS_MAX; i++)
  446. {
  447. SingleChannelJudge(&CS[i]);
  448. *p = CS[i].Result;
  449. p += 5;
  450. }
  451. //找id == -1
  452. for(nc_index = 0; nc_index < 10; nc_index++)
  453. {
  454. if(sysinf.psmMaster.card_param_info.hole_info[nc_index].item == 0xFF)
  455. break;
  456. }
  457. if(nc_index == 10)
  458. {
  459. nc_index = 0;
  460. }
  461. //判断最终检测结果
  462. p = &result.hole1_item_result; //检测结果
  463. if(CS[nc_index].Result == ResultPositive) //内参结果为阳
  464. {
  465. for (int i = 0; i < CS_MAX; i++)
  466. {
  467. if(CS[i].Result==ResultPositive) //孔结果为阳,最终结果为阳
  468. {
  469. *p = ResultPositive;
  470. }
  471. else //否则,最终结果为阴
  472. {
  473. *p = ResultNegative;
  474. }
  475. p += 5;
  476. }
  477. }
  478. else //内参结果为阴
  479. {
  480. for (int i = 0; i < CS_MAX; i++)
  481. {
  482. if(CS[i].Result==ResultPositive) //孔结果为阳,最终结果为阳
  483. {
  484. *p = ResultPositive;
  485. }
  486. else //否则,最终结果无效
  487. {
  488. *p = ResultInvalid;
  489. }
  490. p += 5;
  491. }
  492. }
  493. //内参自身检测结果,等于孔结果
  494. p = &result.hole1_item_result; //检测结果
  495. p += 5*nc_index;
  496. *p = CS[nc_index].Result;
  497. }
  498. void sample_calc_result(void)
  499. {
  500. for (int i = 0; i < CS_MAX; i++)
  501. {
  502. //从二维码获取Tt范围
  503. 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;
  504. 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;
  505. }
  506. SystemResaultJudge();
  507. }
  508. void calc_balance(void)
  509. {
  510. // 获取插卡前白平衡值
  511. for (int i = 0; i < CS_MAX; i++)
  512. {
  513. Get_GAIN(&CS[i]);
  514. }
  515. }