Bluecell_operate.c 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. #include <stdio.h>
  2. #include "main.h"
  3. #include "Bluecell_operate.h"
  4. #include "PE43711.h"
  5. extern volatile uint32_t LedTimerCnt;
  6. uint8_t Alarm_Status[MAX_ALARM_Len] = {0,};
  7. uint8_t ResultData[1024] = {0,};
  8. void Boot_LED_Toggle(void){
  9. if(LedTimerCnt > 500){
  10. HAL_GPIO_TogglePin(GPIOG,GPIO_PIN_14);
  11. LedTimerCnt = 0;
  12. // printf("LED OF OFF\r\n");
  13. }
  14. }
  15. uint8_t* MBIC_HeaderDataSetting(uint8_t* data){
  16. ResultData[MBIC_PREAMBLE_0] = MBIC_PREAMBLE0;
  17. ResultData[MBIC_PREAMBLE_1] = MBIC_PREAMBLE1;
  18. ResultData[MBIC_PREAMBLE_2] = MBIC_PREAMBLE2;
  19. ResultData[MBIC_PREAMBLE_3] = MBIC_PREAMBLE3;
  20. ResultData[MBIC_SUBUID_0] = MBIC_SUBUID0;
  21. ResultData[MBIC_SUBUID_1] = MBIC_SUBUID1;
  22. ResultData[MBIC_RCODE_0] = data[MBIC_RCODE_0];
  23. ResultData[MBIC_TRID_0] = data[MBIC_TRID_0];
  24. ResultData[MBIC_TRID_1] = data[MBIC_TRID_1];
  25. ResultData[MBIC_SEQSUM_0] = data[MBIC_SEQSUM_0];
  26. ResultData[MBIC_TTL_0] = data[MBIC_TTL_0];
  27. ResultData[MBIC_TIME_0] = data[MBIC_TIME_0];
  28. ResultData[MBIC_TIME_1] = data[MBIC_TIME_1];
  29. ResultData[MBIC_TIME_2] = data[MBIC_TIME_2];
  30. ResultData[MBIC_TIME_3] = data[MBIC_TIME_3];
  31. ResultData[MBIC_TIME_4] = data[MBIC_TIME_4];
  32. ResultData[MBIC_TIME_5] = data[MBIC_TIME_5];
  33. return ResultData;
  34. }
  35. typedef enum{
  36. BLUECELL_DL_PATH1 = 0x01,
  37. BLUECELL_UL_PATH1,
  38. BLUECELL_DL_PATH2,
  39. BLUECELL_UL_PATH2,
  40. BLUECELL_DL_PATH3,
  41. BLUECELL_UL_PATH3,
  42. BLUECELL_DL_PATH4,
  43. BLUECELL_UL_PATH4,
  44. };
  45. typedef enum{
  46. BLUECELL_HEADER,
  47. BLUECELL_TYPE,
  48. BLUECELL_LENGTH,
  49. BLUECELL_CRCINDEX,
  50. BLUECELL_DATA,
  51. };
  52. extern ALL_PE43711_st ALL_ATT;
  53. bool Bluecell_Operate(uint8_t* data){
  54. uint8_t datatype = data[BLUECELL_TYPE];
  55. uint16_t tmp_h = 0,tmp_l = 0;
  56. double ret = 0 ,tmp = 0.1;
  57. uint8_t val = 0;
  58. switch(datatype){
  59. case ATTDL1 :
  60. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  61. tmp_h = data[BLUECELL_DATA];
  62. tmp_l = data[BLUECELL_DATA + 1];
  63. ret += ((tmp_h << 8) & 0xFF00);
  64. ret += (tmp_l & 0x00FF);
  65. ret /= 100;
  66. val = PE43711_DataToHexConvert(ret);
  67. PE43711_atten_ctrl(ALL_ATT.ATT_DL1,val);
  68. printf("ret : %f ,tmp %f \r\n",ret,tmp );
  69. break;
  70. case ATT_DL1_PATH_OFF :
  71. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  72. break;
  73. case ATT_DL1_PATH_ON :
  74. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  75. break;
  76. case ATTUL1 :
  77. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  78. tmp_h = data[BLUECELL_DATA];
  79. tmp_l = data[BLUECELL_DATA + 1];
  80. ret += ((tmp_h << 8) & 0xFF00);
  81. ret += (tmp_l & 0x00FF);
  82. ret /= 100;
  83. val = PE43711_DataToHexConvert(ret);
  84. PE43711_atten_ctrl(ALL_ATT.ATT_UL1,val);
  85. printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
  86. break;
  87. case ATT_UL1_PATH_OFF :
  88. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  89. break;
  90. case ATT_UL1_PATH_ON :
  91. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  92. break;
  93. case ATT_SelfTest1_OFF :
  94. HAL_GPIO_WritePin(_PATH_SW1_GPIO_Port,_PATH_SW1_Pin,GPIO_PIN_RESET);//CLOCK
  95. HAL_GPIO_WritePin(PATH_SW1_GPIO_Port,PATH_SW1_Pin,GPIO_PIN_SET);//CLOCK
  96. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  97. break;
  98. case ATT_SelfTest1_ON :
  99. HAL_GPIO_WritePin(_PATH_SW1_GPIO_Port,_PATH_SW1_Pin,GPIO_PIN_SET);//CLOCK
  100. HAL_GPIO_WritePin(PATH_SW1_GPIO_Port,PATH_SW1_Pin,GPIO_PIN_RESET);//CLOCK
  101. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  102. break;
  103. case ATTDL2 :
  104. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  105. tmp_h = data[BLUECELL_DATA];
  106. tmp_l = data[BLUECELL_DATA + 1];
  107. ret += ((tmp_h << 8) & 0xFF00);
  108. ret += (tmp_l & 0x00FF);
  109. ret /= 100;
  110. val = PE43711_DataToHexConvert(ret);
  111. PE43711_atten_ctrl(ALL_ATT.ATT_DL2,val);
  112. printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
  113. break;
  114. case ATT_DL2_PATH_OFF :
  115. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  116. break;
  117. case ATT_DL2_PATH_ON :
  118. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  119. break;
  120. case ATTUL2 :
  121. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  122. tmp_h = data[BLUECELL_DATA];
  123. tmp_l = data[BLUECELL_DATA + 1];
  124. ret += ((tmp_h << 8) & 0xFF00);
  125. ret += (tmp_l & 0x00FF);
  126. ret /= 100;
  127. val = PE43711_DataToHexConvert(ret);
  128. PE43711_atten_ctrl(ALL_ATT.ATT_UL2,val);
  129. printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
  130. break;
  131. case ATT_UL2_PATH_OFF :
  132. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  133. break;
  134. case ATT_UL2_PATH_ON :
  135. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  136. break;
  137. case ATT_SelfTest2_OFF :
  138. HAL_GPIO_WritePin(_PATH_SW2_GPIO_Port,_PATH_SW2_Pin,GPIO_PIN_RESET);//CLOCK
  139. HAL_GPIO_WritePin(PATH_SW2_GPIO_Port,PATH_SW2_Pin,GPIO_PIN_SET);//CLOCK
  140. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  141. break;
  142. case ATT_SelfTest2_ON :
  143. HAL_GPIO_WritePin(PATH_SW2_GPIO_Port,PATH_SW2_Pin,GPIO_PIN_RESET);//CLOCK
  144. HAL_GPIO_WritePin(_PATH_SW2_GPIO_Port,_PATH_SW2_Pin,GPIO_PIN_SET);//CLOCK
  145. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  146. break;
  147. case ATTDL3 :
  148. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  149. tmp_h = data[BLUECELL_DATA];
  150. tmp_l = data[BLUECELL_DATA + 1];
  151. ret += ((tmp_h << 8) & 0xFF00);
  152. ret += (tmp_l & 0x00FF);
  153. ret /= 100;
  154. val = PE43711_DataToHexConvert(ret);
  155. PE43711_atten_ctrl(ALL_ATT.ATT_DL3,val);
  156. printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
  157. break;
  158. case ATT_DL3_PATH_OFF :
  159. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  160. break;
  161. case ATT_DL3_PATH_ON :
  162. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  163. break;
  164. case ATTUL3 :
  165. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  166. tmp_h = data[BLUECELL_DATA];
  167. tmp_l = data[BLUECELL_DATA + 1];
  168. ret += ((tmp_h << 8) & 0xFF00);
  169. ret += (tmp_l & 0x00FF);
  170. ret /= 100;
  171. val = PE43711_DataToHexConvert(ret);
  172. PE43711_atten_ctrl(ALL_ATT.ATT_UL3,val);
  173. printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
  174. break;
  175. case ATT_UL3_PATH_OFF :
  176. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  177. break;
  178. case ATT_UL3_PATH_ON :
  179. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  180. break;
  181. case ATT_SelfTest3_OFF :
  182. HAL_GPIO_WritePin(_PATH_SW3_GPIO_Port,_PATH_SW3_Pin,GPIO_PIN_RESET);//CLOCK
  183. HAL_GPIO_WritePin(PATH_SW3_GPIO_Port,PATH_SW3_Pin,GPIO_PIN_SET);//CLOCK
  184. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  185. break;
  186. case ATT_SelfTest3_ON :
  187. HAL_GPIO_WritePin(PATH_SW3_GPIO_Port,PATH_SW3_Pin,GPIO_PIN_RESET);//CLOCK
  188. HAL_GPIO_WritePin(_PATH_SW3_GPIO_Port,_PATH_SW3_Pin,GPIO_PIN_SET);//CLOCK
  189. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  190. break;
  191. case ATTDL4 :
  192. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  193. tmp_h = data[BLUECELL_DATA];
  194. tmp_l = data[BLUECELL_DATA + 1];
  195. ret += ((tmp_h << 8) & 0xFF00);
  196. ret += (tmp_l & 0x00FF);
  197. ret /= 100;
  198. val = PE43711_DataToHexConvert(ret);
  199. PE43711_atten_ctrl(ALL_ATT.ATT_DL4,val);
  200. printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
  201. break;
  202. case ATT_DL4_PATH_OFF :
  203. HAL_GPIO_WritePin(_PATH_SW4_GPIO_Port,_PATH_SW4_Pin,GPIO_PIN_RESET);//CLOCK
  204. HAL_GPIO_WritePin(PATH_SW4_GPIO_Port,PATH_SW4_Pin,GPIO_PIN_SET);//CLOCK
  205. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  206. break;
  207. case ATT_DL4_PATH_ON :
  208. HAL_GPIO_WritePin(_PATH_SW4_GPIO_Port,_PATH_SW4_Pin,GPIO_PIN_SET);//CLOCK
  209. HAL_GPIO_WritePin(PATH_SW4_GPIO_Port,PATH_SW4_Pin,GPIO_PIN_RESET);//CLOCK
  210. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  211. break;
  212. case ATTUL4 :
  213. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  214. tmp_h = data[BLUECELL_DATA];
  215. tmp_l = data[BLUECELL_DATA + 1];
  216. ret += ((tmp_h << 8) & 0xFF00);
  217. ret += (tmp_l & 0x00FF);
  218. ret /= 100;
  219. val = PE43711_DataToHexConvert(ret);
  220. PE43711_atten_ctrl(ALL_ATT.ATT_UL4,val);
  221. printf("tmp_h : %x tmp_l : %x , ret : %x ,%f ,tmp %f \r\n",tmp_h,tmp_l,ret,tmp );
  222. break;
  223. case ATT_UL4_PATH_OFF:
  224. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  225. break;
  226. case ATT_UL4_PATH_ON :
  227. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  228. break;
  229. case ATT_SelfTest4_OFF :
  230. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  231. break;
  232. case ATT_SelfTest4_ON :
  233. printf("Function : %s Line %d \r\n",__func__,__LINE__);
  234. break;
  235. }
  236. return true;
  237. }
  238. bool MBIC_Operate(uint8_t* data){
  239. uint16_t datatype = 0;
  240. switch(datatype){
  241. case Alarm_Bit_List:
  242. // �븣由� 鍮꾪듃
  243. Uart1_Data_Send(&Alarm_Status[0],MAX_ALARM_Len);
  244. break;
  245. case Alarm_Mask:
  246. break;
  247. case Alarm_Test_Mode:
  248. break;
  249. case Alarm_Test_Dummy:
  250. break;
  251. case CPU_Version:
  252. break;
  253. case ModuleINFORMATION_null1:
  254. break;
  255. case CPU_Current_Bank:
  256. break;
  257. case CPU_Bank_Select_Reboot_by:
  258. break;
  259. case CPU_Bank1_Image_Version:
  260. break;
  261. case CPU_Bank1_Image_BuildTime:
  262. break;
  263. case CPU_Bank1_Image_Name:
  264. break;
  265. case CPU_Bank2_Image_Version:
  266. break;
  267. case CPU_Bank2_Image_BuildTime:
  268. break;
  269. case CPU_Bank2_Image_Name:
  270. break;
  271. case SW_Reset:
  272. break;
  273. case Factory_Set_Initialization:
  274. break;
  275. case Temperature:
  276. break;
  277. case Temperature_Offset:
  278. break;
  279. case Temp_High_Threshold:
  280. break;
  281. case Temp_High_Threshold_Default:
  282. break;
  283. case Temp_High_Alarm:
  284. break;
  285. case LED_TEST:
  286. break;
  287. case Node:
  288. break;
  289. case Type:
  290. break;
  291. case PCB_Version:
  292. break;
  293. case Serial_Number:
  294. break;
  295. case Manufacture:
  296. break;
  297. case Manufacture_Date:
  298. break;
  299. case ENVIRONMENT_INVENTORY_null1:
  300. printf("Function : %s .... Line : %d\r\n",__func__,__LINE__);
  301. break;
  302. case Freq_ID:
  303. break;
  304. case Carrier_ID:
  305. break;
  306. case Carrier_ON_OFF:
  307. break;
  308. }
  309. return true;
  310. }