app_1_0.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. /****************************************************************************
  2. *
  3. * Copy right: 2020-, Copyrigths of QIXIANG TECH Ltd.
  4. * File name: app.c
  5. * Description: QX app source file
  6. * History: Rev1.0 2020-10-16
  7. * Athuor: chenjie
  8. *
  9. ****************************************************************************/
  10. //include
  11. #include "bsp.h"
  12. #include "bsp_custom.h"
  13. #include "osasys.h"
  14. #include "ostask.h"
  15. #include "queue.h"
  16. #include "ps_event_callback.h"
  17. #include "app.h"
  18. #include "cmisim.h"
  19. #include "cmimm.h"
  20. #include "cmips.h"
  21. #include "sockets.h"
  22. #include "psifevent.h"
  23. #include "ps_lib_api.h"
  24. #include "lwip/netdb.h"
  25. #include <cis_def.h>
  26. #include "debug_log.h"
  27. #include "slpman_ec616.h"
  28. #include "plat_config.h"
  29. //define
  30. // app task static stack and control block
  31. #define PROC_TASK_STACK_SIZE (1024)
  32. //uart def
  33. #define Uart_Send_LEN (8)
  34. #define Uart_Rece_LEN (16)
  35. #define RTE_UART_RX_IO_MODE RTE_UART1_RX_IO_MODE
  36. //statement variable
  37. extern ARM_DRIVER_USART Driver_USART1;
  38. static ARM_DRIVER_USART *USARTdrv = &Driver_USART1;
  39. /** \brief usart receive buffer */
  40. uint8_t Uart_Data_buffer[8];
  41. /** \brief usart send buffer */
  42. /** \brief receive timeout flag */
  43. volatile bool isRecvTimeout = false;
  44. /** \brief receive complete flag */
  45. volatile bool isRecvComplete = false;
  46. uint8_t process0SlpHandler = 0xff;
  47. uint8_t process1SlpHandler = 0xff;
  48. uint8_t process2SlpHandler = 0xff;
  49. /** \brief 电压传输 */
  50. uint8_t Uart_Rece_BattCellU1_U4[8];
  51. uint8_t Uart_Rece_BattCellU5_U8[8];
  52. uint8_t Uart_Rece_BattCellU9_U12[8];
  53. uint8_t Uart_Rece_BattCellU13_U14[8];
  54. uint8_t Uart_Rece_BattT[8];
  55. int16_t Uart_Rece_BattI;
  56. uint8_t Uart_Rece_Batt_states[6];
  57. uint16_t Uart_Rece_BattU;
  58. uint16_t Uart_Rece_Batt_MaxcellU;
  59. uint16_t Uart_Rece_Batt_MincellU;
  60. typedef enum
  61. {
  62. PROCESS1_STATE_IDLE = 0,
  63. PROCESS1_STATE_WORK,
  64. PROCESS1_STATE_SLEEP
  65. }process1SM;
  66. typedef enum
  67. {
  68. PROCESS2_STATE_IDLE = 0,
  69. PROCESS2_STATE_WORK,
  70. PROCESS2_STATE_SLEEP
  71. }process2SM;
  72. static StaticTask_t gProcessTask0;
  73. static UINT8 gProcessTaskStack0[PROC_TASK_STACK_SIZE];
  74. static StaticTask_t gProcessTask1;
  75. static UINT8 gProcessTaskStack1[PROC_TASK_STACK_SIZE];
  76. static StaticTask_t gProcessTask2;
  77. static UINT8 gProcessTaskStack2[PROC_TASK_STACK_SIZE];
  78. process1SM gProc1State = PROCESS1_STATE_IDLE;
  79. process2SM gProc2State = PROCESS2_STATE_IDLE;
  80. #define PROC1_STATE_SWITCH(a) (gProc1State = a)
  81. #define PROC2_STATE_SWITCH(a) (gProc2State = a)
  82. unsigned int crc_chk(uint8_t* data, uint8_t length)
  83. {
  84. int j;
  85. uint16_t reg_crc=0xFFFF;
  86. while(length--)
  87. {
  88. reg_crc ^= *data++;
  89. for(j=0;j<8;j++)
  90. {
  91. if(reg_crc & 0x01)
  92. {
  93. reg_crc=(reg_crc>>1) ^ 0xA001;
  94. }
  95. else
  96. {
  97. reg_crc=reg_crc >>1;
  98. }
  99. }
  100. }
  101. return reg_crc;
  102. }
  103. uint8_t* Uart_Receive_func(Uart_Receive_Type Uart_Receive_Msg)
  104. {
  105. uint8_t Uart_Rece_buffer[Uart_Rece_LEN];
  106. uint16_t CRC_Reve_buffer;
  107. uint16_t CRC_chk_buffer;
  108. uint8_t Uart_Send_buffer[8];
  109. uint8_t Rece_Data_Len;
  110. Uart_Send_buffer[0] = Uart_Receive_Msg.Bms_Address;
  111. Uart_Send_buffer[1] = Uart_Receive_Msg.Bms_Read_Funcode;
  112. Uart_Send_buffer[2] = Uart_Receive_Msg.Reg_Begin_H;
  113. Uart_Send_buffer[3] = Uart_Receive_Msg.Reg_Begin_L;
  114. Uart_Send_buffer[4] = Uart_Receive_Msg.Reg_Num_H;
  115. Uart_Send_buffer[5] = Uart_Receive_Msg.Reg_Num_L;
  116. CRC_chk_buffer = crc_chk(Uart_Send_buffer,6);
  117. Uart_Send_buffer[6] = CRC_chk_buffer;
  118. Uart_Send_buffer[7] = CRC_chk_buffer>>8;
  119. Uart_Rece_buffer[0]=0xfe;
  120. uint32_t timeout=0;
  121. USARTdrv->Send(Uart_Send_buffer,8);
  122. USARTdrv->Receive(Uart_Rece_buffer,13);
  123. Rece_Data_Len = 11;
  124. while((isRecvTimeout == false) && (isRecvComplete == false))// 未收到数据不叫时间超时,收到数据但是不全叫时间超时
  125. {
  126. timeout++;
  127. if (timeout>7000000)
  128. {
  129. timeout =0;
  130. isRecvTimeout = true;
  131. break;
  132. }
  133. }
  134. if (isRecvComplete == true)
  135. {
  136. isRecvComplete = false;
  137. CRC_chk_buffer =Uart_Rece_buffer[12]<<8|Uart_Rece_buffer[11];
  138. CRC_Reve_buffer = crc_chk(Uart_Rece_buffer,11);
  139. if (CRC_Reve_buffer == CRC_chk_buffer)//满足校验
  140. {
  141. for (uint8_t i = 0; i < 8; i++)
  142. {
  143. Uart_Data_buffer[i]=Uart_Rece_buffer[i+3];
  144. }
  145. return Uart_Data_buffer;
  146. }
  147. else //接收数据的校验不过暂时屏蔽
  148. {
  149. for (uint8_t i = 0; i < 8; i++)
  150. {
  151. Uart_Data_buffer[i]=0xff;
  152. }
  153. return Uart_Data_buffer;
  154. }
  155. }
  156. if (isRecvTimeout == true)//没收到数据,全部为空值
  157. {
  158. Uart_Data_buffer[0] = 0x00;
  159. Uart_Data_buffer[1] = 0x00;
  160. Uart_Data_buffer[2] = 0x00;
  161. Uart_Data_buffer[3] = 0x00;
  162. Uart_Data_buffer[4] = 0x00;
  163. Uart_Data_buffer[5] = 0x00;
  164. Uart_Data_buffer[6] = 0x00;
  165. Uart_Data_buffer[7] = 0xff;
  166. isRecvTimeout = false;
  167. osDelay(1000);
  168. return Uart_Data_buffer;
  169. }
  170. }
  171. void USART_callback(uint32_t event)
  172. {
  173. if(event & ARM_USART_EVENT_RX_TIMEOUT)
  174. {
  175. isRecvTimeout = true;
  176. }
  177. if(event & ARM_USART_EVENT_RECEIVE_COMPLETE)
  178. {
  179. isRecvComplete = true;
  180. }
  181. }
  182. static void process0AppTask(void* arg)
  183. {
  184. uint32_t inParam = 0xAABBCCDD;
  185. uint32_t cnt;
  186. slpManSetPmuSleepMode(true,SLP_HIB_STATE,false);
  187. slpManApplyPlatVoteHandle("process0slp",&process0SlpHandler);
  188. slpManSlpState_t slpstate = slpManGetLastSlpState();
  189. UINT8 Can_index = 0;
  190. UINT8 Uart_index = 0;
  191. while(1)
  192. {
  193. osDelay(10);//10ms
  194. Can_index++;
  195. Uart_index++;
  196. if (Uart_index >10)//Uart 100ms 调用一次
  197. {
  198. PROC2_STATE_SWITCH(PROCESS2_STATE_WORK);
  199. Uart_index = 0;
  200. }
  201. if (Can_index >=100)//Can 100ms 调用一次
  202. {
  203. PROC1_STATE_SWITCH(PROCESS1_STATE_WORK);
  204. Can_index = 0;
  205. }
  206. }
  207. }
  208. static void process1AppTask(void* arg)
  209. {
  210. PROC1_STATE_SWITCH(PROCESS1_STATE_IDLE);
  211. uint32_t Can_ID;
  212. NVIC_EnableIRQ(PadWakeup1_IRQn);
  213. Can_InitType param;
  214. Can_TxMsgType Can_TxMsg;
  215. param.baudrate = CAN_500Kbps;
  216. param.mode = REQOP_NORMAL;
  217. param.TxStdIDH = 0x00;
  218. param.TxStdIDL = 0x00;
  219. param.RxStdIDH[0] = 0x00;
  220. param.RxStdIDL[0] = 0x00;
  221. /*stdid 0000 0000 001x*/
  222. param.RxStdIDH[1] = 0x00;
  223. param.RxStdIDL[1] = 0x20;
  224. /*stdid 0000 0000 010x */
  225. param.RxStdIDH[2] = 0x00;
  226. param.RxStdIDL[2] = 0x40;
  227. /*stdid 0000 0000 011x*/
  228. param.RxStdIDH[3] = 0x00;
  229. param.RxStdIDL[3] =0x60;
  230. /*stdid 0000 0000 100x */
  231. param.RxStdIDH[4] = 0x00;
  232. param.RxStdIDL[4] = 0x80;
  233. /*stdid 0000 0000 101x*/
  234. param.RxStdIDH[5] = 0x00;
  235. param.RxStdIDL[5] =0xa0;
  236. param.packType = STD_PACK;
  237. HAL_Can_Init(param);
  238. int send_index = 0;
  239. while(1)
  240. {
  241. switch(gProc1State)
  242. {
  243. case PROCESS1_STATE_IDLE:
  244. {
  245. send_index = 0;
  246. FaultDisplay(LED_TURN_OFF);
  247. break;
  248. }
  249. case PROCESS1_STATE_WORK:
  250. {
  251. switch(send_index)
  252. {
  253. case 0:
  254. {
  255. Can_ID = 0x001;
  256. for (int i = 0; i < 8; i++)
  257. {
  258. Can_TxMsg.Data[i] = Uart_Rece_BattCellU1_U4[i];
  259. }
  260. Can_TxMsg.stdIDH = Can_ID>>3;
  261. Can_TxMsg.stdIDL = Can_ID<<5;
  262. Can_TxMsg.DLC = 8;
  263. HAL_Can_Transmit(Can_TxMsg);
  264. break;
  265. }
  266. case 1:
  267. {
  268. Can_ID = 0x012;
  269. for (int i = 0; i < 8; i++)
  270. {
  271. Can_TxMsg.Data[i] = Uart_Rece_BattCellU5_U8[i];
  272. }
  273. Can_TxMsg.stdIDH = Can_ID>>3;
  274. Can_TxMsg.stdIDL = Can_ID<<5;
  275. Can_TxMsg.DLC = 8;
  276. HAL_Can_Transmit(Can_TxMsg);
  277. break;
  278. }
  279. case 2:
  280. {
  281. Can_ID = 0x021;
  282. for (int i = 0; i < 8; i++)
  283. {
  284. Can_TxMsg.Data[i] = Uart_Rece_BattCellU9_U12[i];
  285. }
  286. Can_TxMsg.stdIDH = Can_ID>>3;
  287. Can_TxMsg.stdIDL = Can_ID<<5;
  288. Can_TxMsg.DLC = 8;
  289. HAL_Can_Transmit(Can_TxMsg);
  290. break;
  291. }
  292. case 3:
  293. {
  294. Can_ID = 0x031;
  295. for (int i = 0; i < 4; i++)
  296. {
  297. Can_TxMsg.Data[i] = Uart_Rece_BattCellU13_U14[i];
  298. }
  299. Can_TxMsg.Data[4] = 0x00;
  300. Can_TxMsg.Data[5] = 0x00;
  301. Can_TxMsg.Data[6] = 0x00;
  302. Can_TxMsg.Data[7] = 0x00;
  303. Can_TxMsg.stdIDH = Can_ID>>3;
  304. Can_TxMsg.stdIDL = Can_ID<<5;
  305. Can_TxMsg.DLC = 8;
  306. HAL_Can_Transmit(Can_TxMsg);
  307. break;
  308. }
  309. case 4:
  310. {
  311. Can_ID = 0x101;
  312. for (int i = 0; i < 4; i++)
  313. {
  314. Can_TxMsg.Data[i] = Uart_Rece_BattT[i*2+1];
  315. }
  316. Can_TxMsg.stdIDH = Can_ID>>3;
  317. Can_TxMsg.stdIDL = Can_ID<<5;
  318. Can_TxMsg.DLC = 8;
  319. HAL_Can_Transmit(Can_TxMsg);
  320. break;
  321. }
  322. case 5:
  323. {
  324. Can_ID = 0x201;
  325. Can_TxMsg.Data[0] = Uart_Rece_BattU>>8;
  326. Can_TxMsg.Data[1] = Uart_Rece_BattU;
  327. Can_TxMsg.Data[2] = 0x00;
  328. Can_TxMsg.Data[3] = 0x00;//外电压
  329. Can_TxMsg.Data[4] = 0x00;
  330. Can_TxMsg.Data[5] = 0x00;//累加电压
  331. Can_TxMsg.Data[6] = Uart_Rece_BattI>>8;
  332. Can_TxMsg.Data[7] = Uart_Rece_BattI;
  333. Can_TxMsg.stdIDH = Can_ID>>3;
  334. Can_TxMsg.stdIDL = Can_ID<<5;
  335. Can_TxMsg.DLC = 8;
  336. HAL_Can_Transmit(Can_TxMsg);
  337. break;
  338. }
  339. default:
  340. {
  341. PROC1_STATE_SWITCH(PROCESS1_STATE_IDLE);
  342. }
  343. }
  344. send_index ++;
  345. FaultDisplay(LED_TURN_ON);
  346. break;
  347. }
  348. case PROCESS1_STATE_SLEEP:
  349. {
  350. break;
  351. }
  352. }
  353. }
  354. }
  355. static void process2AppTask(void* arg)
  356. {
  357. USARTdrv->Initialize(USART_callback);
  358. USARTdrv->PowerControl(ARM_POWER_FULL);
  359. USARTdrv->Control(ARM_USART_MODE_ASYNCHRONOUS |
  360. ARM_USART_DATA_BITS_8 |
  361. ARM_USART_PARITY_NONE |
  362. ARM_USART_STOP_BITS_1 |
  363. ARM_USART_FLOW_CONTROL_NONE, 9600);
  364. int Rece_index = 0;
  365. uint8_t *Uart_Reve_Point = NULL;
  366. Uart_Receive_Type Uart_Receive_Msg;
  367. PROC2_STATE_SWITCH(PROCESS2_STATE_IDLE);
  368. while(1)
  369. {
  370. switch(gProc2State)
  371. {
  372. case PROCESS2_STATE_IDLE:
  373. {
  374. Rece_index = 0;
  375. NetSocDisplay(3,LED_TURN_OFF);
  376. break;
  377. }
  378. case PROCESS2_STATE_WORK:
  379. {
  380. Uart_Receive_Msg.Bms_Address = 0x01;
  381. Uart_Receive_Msg.Bms_Read_Funcode = 0x03;
  382. switch(Rece_index)
  383. {
  384. case 0://读取电压1-4
  385. {
  386. Uart_Receive_Msg.Reg_Begin_H = 0x00;
  387. Uart_Receive_Msg.Reg_Begin_L = 0x02;
  388. Uart_Receive_Msg.Reg_Num_H = 0x00;
  389. Uart_Receive_Msg.Reg_Num_L = 0x04;
  390. Uart_Reve_Point = Uart_Receive_func(Uart_Receive_Msg);
  391. for(int i =0;i<8;i++)
  392. {
  393. Uart_Rece_BattCellU1_U4[i] = *(Uart_Reve_Point+i);
  394. }
  395. break;
  396. }
  397. case 1://读取电压5-8
  398. {
  399. Uart_Receive_Msg.Reg_Begin_H = 0x00;
  400. Uart_Receive_Msg.Reg_Begin_L= 0x06;
  401. Uart_Receive_Msg.Reg_Num_H = 0x00;
  402. Uart_Receive_Msg.Reg_Num_L = 0x04;
  403. Uart_Reve_Point = Uart_Receive_func(Uart_Receive_Msg);
  404. for(int i =0;i<8;i++)
  405. {
  406. Uart_Rece_BattCellU5_U8[i] = *(Uart_Reve_Point+i);
  407. }
  408. break;
  409. }
  410. case 2:
  411. {
  412. Uart_Receive_Msg.Reg_Begin_H = 0x00;
  413. Uart_Receive_Msg.Reg_Begin_L= 0x0A;
  414. Uart_Receive_Msg.Reg_Num_H = 0x00;
  415. Uart_Receive_Msg.Reg_Num_L = 0x04;
  416. Uart_Reve_Point = Uart_Receive_func(Uart_Receive_Msg);
  417. for(int i =0;i<8;i++)
  418. {
  419. Uart_Rece_BattCellU9_U12[i] = *(Uart_Reve_Point+i);
  420. }
  421. break;
  422. }
  423. case 3:
  424. {
  425. Uart_Receive_Msg.Reg_Begin_H = 0x00;
  426. Uart_Receive_Msg.Reg_Begin_L= 0x0E;
  427. Uart_Receive_Msg.Reg_Num_H = 0x00;
  428. Uart_Receive_Msg.Reg_Num_L = 0x04;
  429. Uart_Reve_Point = Uart_Receive_func(Uart_Receive_Msg);
  430. for(int i =0;i<8;i++)
  431. {
  432. Uart_Rece_BattCellU13_U14[i] = *(Uart_Reve_Point+i);
  433. }
  434. break;
  435. }
  436. case 4:
  437. {
  438. Uart_Receive_Msg.Reg_Begin_H = 0x00;
  439. Uart_Receive_Msg.Reg_Begin_L= 0x14;
  440. Uart_Receive_Msg.Reg_Num_H = 0x00;
  441. Uart_Receive_Msg.Reg_Num_L = 0x04;
  442. Uart_Reve_Point = Uart_Receive_func(Uart_Receive_Msg);
  443. for(int i =0;i<8;i++)
  444. {
  445. Uart_Rece_BattT[i] = *(Uart_Reve_Point+i);
  446. }
  447. break;
  448. }
  449. case 5:
  450. {
  451. Uart_Receive_Msg.Reg_Begin_H = 0x00;
  452. Uart_Receive_Msg.Reg_Begin_L= 0x10;
  453. Uart_Receive_Msg.Reg_Num_H = 0x00;
  454. Uart_Receive_Msg.Reg_Num_L = 0x04;
  455. Uart_Reve_Point = Uart_Receive_func(Uart_Receive_Msg);
  456. Uart_Rece_BattI = *(Uart_Reve_Point+0)<<8 | *(Uart_Reve_Point+1);
  457. for (int i = 0; i < 6; i++)
  458. {
  459. Uart_Rece_Batt_states[i] = *(Uart_Reve_Point+2+i);
  460. }
  461. break;
  462. }
  463. case 6:
  464. {
  465. Uart_Receive_Msg.Reg_Begin_H = 0x00;
  466. Uart_Receive_Msg.Reg_Begin_L= 0x2B;
  467. Uart_Receive_Msg.Reg_Num_H = 0x00;
  468. Uart_Receive_Msg.Reg_Num_L = 0x04;
  469. Uart_Reve_Point = Uart_Receive_func(Uart_Receive_Msg);
  470. Uart_Rece_BattU = *(Uart_Reve_Point+0)<<8 | *(Uart_Reve_Point+1);
  471. Uart_Rece_Batt_MaxcellU = *(Uart_Reve_Point+2)<<8 | *(Uart_Reve_Point+3);
  472. Uart_Rece_Batt_MincellU = *(Uart_Reve_Point+4)<<8 | *(Uart_Reve_Point+5);
  473. break;
  474. }
  475. default:
  476. {
  477. PROC2_STATE_SWITCH(PROCESS2_STATE_IDLE);
  478. break;
  479. }
  480. }
  481. Rece_index++;
  482. NetSocDisplay(3,LED_TURN_ON);
  483. break;
  484. }
  485. case PROCESS2_STATE_SLEEP:
  486. {
  487. //此处写休眠程序
  488. break;
  489. }
  490. }
  491. }
  492. }
  493. /**
  494. \fn process0Init(void)
  495. \brief process0Init function.
  496. \return
  497. */
  498. void process0Init(void)
  499. {
  500. osThreadAttr_t task_attr;
  501. #ifndef USING_PRINTF
  502. if(BSP_GetPlatConfigItemValue(PLAT_CONFIG_ITEM_LOG_CONTROL) != 0)
  503. {
  504. HAL_UART_RecvFlowControl(false);
  505. }
  506. #endif
  507. memset(&task_attr,0,sizeof(task_attr));
  508. memset(gProcessTaskStack0, 0xA5,PROC_TASK_STACK_SIZE);
  509. task_attr.name = "Process0AppTask";
  510. task_attr.stack_mem = gProcessTaskStack0;
  511. task_attr.stack_size = PROC_TASK_STACK_SIZE;
  512. task_attr.priority = osPriorityNormal;//osPriorityBelowNormal;
  513. task_attr.cb_mem = &gProcessTask0;//task control block
  514. task_attr.cb_size = sizeof(StaticTask_t);//size of task control block
  515. osThreadNew(process0AppTask, NULL, &task_attr);
  516. }
  517. /**
  518. \fn process1Init(void)
  519. \brief process1Init function.
  520. \return
  521. */
  522. void process1Init(void)
  523. {
  524. osThreadAttr_t task_attr;
  525. #ifndef USING_PRINTF
  526. if(BSP_GetPlatConfigItemValue(PLAT_CONFIG_ITEM_LOG_CONTROL) != 0)
  527. {
  528. HAL_UART_RecvFlowControl(false);
  529. }
  530. #endif
  531. memset(&task_attr,0,sizeof(task_attr));
  532. memset(gProcessTaskStack1, 0xA5,PROC_TASK_STACK_SIZE);
  533. task_attr.name = "Process1AppTask";
  534. task_attr.stack_mem = gProcessTaskStack1;
  535. task_attr.stack_size = PROC_TASK_STACK_SIZE;
  536. task_attr.priority = osPriorityNormal;//osPriorityBelowNormal;
  537. task_attr.cb_mem = &gProcessTask1;//task control block
  538. task_attr.cb_size = sizeof(StaticTask_t);//size of task control block
  539. osThreadNew(process1AppTask, NULL, &task_attr);
  540. }
  541. /**
  542. \fn process2Init(void)
  543. \brief process2Init function.
  544. \return
  545. */
  546. void process2Init(void)
  547. {
  548. osThreadAttr_t task_attr;
  549. memset(&task_attr,0,sizeof(task_attr));
  550. memset(gProcessTaskStack2, 0xA5,PROC_TASK_STACK_SIZE);
  551. task_attr.name = "Process2AppTask";
  552. task_attr.stack_mem = gProcessTaskStack2;
  553. task_attr.stack_size = PROC_TASK_STACK_SIZE;
  554. task_attr.priority = osPriorityNormal;//osPriorityBelowNormal;
  555. task_attr.cb_mem = &gProcessTask2;//task control block
  556. task_attr.cb_size = sizeof(StaticTask_t);//size of task control block
  557. osThreadNew(process2AppTask, NULL, &task_attr);
  558. }
  559. /**
  560. \fn appInit(void)
  561. \brief appInit function.
  562. \return
  563. */
  564. void appInit(void *arg)
  565. {
  566. process0Init();
  567. process1Init();
  568. process2Init();
  569. }
  570. /**
  571. \fn int main_entry(void)
  572. \brief main entry function.
  573. \return
  574. */
  575. void main_entry(void) {
  576. BSP_CommonInit();
  577. osKernelInitialize();
  578. registerAppEntry(appInit, NULL);
  579. if (osKernelGetState() == osKernelReady)
  580. {
  581. osKernelStart();
  582. }
  583. while(1);
  584. }