hal_adapter.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990
  1. /*
  2. * hal_adapter.c
  3. *中间层函数调用库
  4. * Created on: 2022年1月18日
  5. * Author: QiXiang_CHENJIE
  6. */
  7. #include "hal_adapter.h"
  8. #include "AppGlobalVar.h"
  9. #include "stdio.h"
  10. #include "stdarg.h"
  11. /********************************/
  12. #include "Icu.h"
  13. #include "Gpt.h"
  14. uint8_t __attribute__((section(".non_cacheable_data"))) RX_Buffer[3][BUFFER_SIZE];
  15. uint32_t bufferIdx[3] = {0};
  16. volatile uint32 VarNotification_0 = 0;
  17. volatile uint32 VarNotification_1 = 0;
  18. TP_Value_Type ConvertedBuffer[NUM_RESULTS];
  19. Adc_ValueGroupType ResultBuffer[NUM_RESULTS];
  20. volatile Uart_StatusType Uart_TransmitStatus[3] = {UART_STATUS_TIMEOUT,UART_STATUS_TIMEOUT,UART_STATUS_TIMEOUT};
  21. QueueHandle_t UartRecvQueue[3];
  22. QueueHandle_t TcpRecvQueue;
  23. QueueHandle_t UartSendQueue[3];
  24. QueueHandle_t UartHalQueueHandle;
  25. Std_ReturnType UartStartRecvFunc(uint8 channel);
  26. Std_ReturnType ADC_Converter(Adc_ValueGroupType *Buffer, TP_Value_Type *ConvertedValueR);
  27. void create_ringBuffer(ringbuffer_t *ringBuf, uint8_t *buf, uint32_t buf_len);
  28. void clear_ringBuffer(ringbuffer_t *ringBuf);
  29. uint32_t write_ringBuffer(uint8_t *buffer, uint16_t size, ringbuffer_t *ringBuf,uint32 *uartDataAddr);
  30. uint32_t read_ringBuffer(uint8_t *buffer, uint32_t size, ringbuffer_t *ringBuf);
  31. uint8 ringBufferforUart[3][BUFFER_SIZE];
  32. ringbuffer_t uartRingBuffer[3];
  33. sint8 AtcmdDelayRecvFunc(uint8 recvChannel,char *ResultStrPtr,uint16 delayTime)
  34. {
  35. sint8 outValue = -1;
  36. uint8 delayCnt = 0;
  37. uint8 UartData[256];
  38. uint16 ReadLen = 0;
  39. char *retptr = NULL;
  40. while (delayCnt<(delayTime/1000)&&outValue!=0)
  41. {
  42. UART_Receive_Data(recvChannel,UartData, &ReadLen,1000);
  43. if(ReadLen>0)
  44. {
  45. retptr = (char *)strstr((char *)UartData, ResultStrPtr);
  46. if (retptr)
  47. {
  48. outValue = 0;
  49. break;
  50. }
  51. }
  52. else
  53. {
  54. delayCnt++;
  55. }
  56. }
  57. return outValue;
  58. }
  59. void create_ringBuffer(ringbuffer_t *ringBuf, uint8_t *buf, uint32_t buf_len)
  60. {
  61. ringBuf->br = 0;
  62. ringBuf->bw = 0;
  63. ringBuf->btoRead = 0;
  64. ringBuf->source = buf;
  65. ringBuf->length = buf_len;
  66. }
  67. void clear_ringBuffer(ringbuffer_t *ringBuf)
  68. {
  69. ringBuf->br = 0;
  70. ringBuf->bw = 0;
  71. ringBuf->btoRead = 0;
  72. }
  73. uint32_t write_ringBuffer(uint8_t *buffer, uint16_t size, ringbuffer_t *ringBuf,uint32 *uartDataAddr)
  74. {
  75. volatile uint32_t ringBuf_bw = ringBuf->bw;
  76. uint32_t ringBuf_len = ringBuf->length;
  77. uint8_t *ringBuf_source = ringBuf->source;
  78. if( (ringBuf_bw + size + 1) > ringBuf_len )
  79. {
  80. ringBuf_bw = 0;
  81. }
  82. memcpy(ringBuf_source + ringBuf_bw, buffer, size);
  83. memset(ringBuf_source + ringBuf_bw + size + 1,0x00,1);//环形buffer 插入分隔符截断字符串
  84. ringBuf->bw = (ringBuf_bw + size + 1) % ringBuf_len;//数据长度不变,起始地址移位1
  85. ringBuf->btoRead += size;
  86. *uartDataAddr = (uint32)(ringBuf->source + ringBuf->bw - size - 1);
  87. return size;
  88. }
  89. uint32_t read_ringBuffer(uint8_t *buffer, uint32_t size, ringbuffer_t *ringBuf)
  90. {
  91. uint32_t len = 0;
  92. volatile uint32_t ringBuf_br = ringBuf->br;
  93. uint32_t ringBuf_len = ringBuf->length;
  94. uint8_t *ringBuf_source = ringBuf->source;
  95. memcpy(buffer, ringBuf_source, size);
  96. ringBuf->br = size;
  97. return size;
  98. }
  99. Std_ReturnType UART_Query_Data(uint8 transChannel, uint8 recvChannel, uint8 *txBuffer, uint16 sendLength, uint8 *rxBuffer, uint16 *rxlen, uint32 T_timeout)
  100. {
  101. UartMsg_t UartRecvMsg;
  102. UartMsg_t UartSendMsg;
  103. BaseType_t Sendret = pdFALSE;
  104. BaseType_t Recvret = pdFALSE;
  105. uint32 retVal = E_NOT_OK;
  106. UartSendMsg.DataLen = sendLength;
  107. UartSendMsg.dataPtr = txBuffer;
  108. *rxlen = 0;
  109. Sendret = xQueueSend(UartSendQueue[transChannel],&UartSendMsg,50);
  110. if(Sendret == pdTRUE)
  111. {
  112. Recvret = xQueueReceive(UartRecvQueue[recvChannel],&UartRecvMsg,T_timeout);
  113. if(Recvret == pdTRUE)
  114. {
  115. *rxlen = UartRecvMsg.DataLen;
  116. memcpy(rxBuffer,(uint8 *)(UartRecvMsg.dataAddr),UartRecvMsg.DataLen);
  117. retVal = E_OK;
  118. }
  119. else
  120. {
  121. retVal = 3;
  122. }
  123. }
  124. else
  125. {
  126. retVal = 2;
  127. }
  128. return retVal;
  129. }
  130. Std_ReturnType UART_Receive_Data(uint8 recvChannel, uint8 *rxBuffer, uint16 *rxlen, uint32 T_timeout)
  131. {
  132. UartMsg_t UartRecvMsg;
  133. BaseType_t ret = pdFALSE;
  134. uint32 retVal = E_NOT_OK;
  135. *rxlen = 0;
  136. ret = xQueueReceive(UartRecvQueue[recvChannel],&UartRecvMsg,T_timeout);
  137. if(ret == pdTRUE)
  138. {
  139. *rxlen = UartRecvMsg.DataLen;
  140. memcpy(rxBuffer,(uint8 *)UartRecvMsg.dataAddr,UartRecvMsg.DataLen);
  141. retVal = E_OK;
  142. }
  143. return retVal;
  144. }
  145. Std_ReturnType Tcp_Receive_Data(uint8 *rxBuffer, uint16 *rxlen, uint32 T_timeout)
  146. {
  147. UartMsg_t UartRecvMsg;
  148. BaseType_t ret = pdFALSE;
  149. uint32 retVal = E_NOT_OK;
  150. *rxlen = 0;
  151. ret = xQueueReceive(TcpRecvQueue,&UartRecvMsg,T_timeout);
  152. if(ret == pdTRUE)
  153. {
  154. *rxlen = UartRecvMsg.DataLen;
  155. memcpy(rxBuffer,(uint8 *)UartRecvMsg.dataAddr,UartRecvMsg.DataLen);
  156. retVal = E_OK;
  157. }
  158. return retVal;
  159. }
  160. Std_ReturnType UART_Reset(uint8 recvChannel)
  161. {
  162. uint32 retVal = E_NOT_OK;
  163. retVal = xQueueReset(UartRecvQueue[recvChannel]);
  164. return retVal;
  165. }
  166. Std_ReturnType UART_Send_Data(uint8 transChannel, const uint8 *txBuffer, uint32 sendLength, uint32 T_timeout)
  167. {
  168. UartMsg_t UartSendMsg;
  169. BaseType_t ret = pdFALSE;
  170. uint32 retVal = E_NOT_OK;
  171. UartSendMsg.DataLen = sendLength;
  172. UartSendMsg.dataPtr = txBuffer;
  173. ret = xQueueSend(UartSendQueue[transChannel],&UartSendMsg,T_timeout);
  174. if(ret == pdTRUE)
  175. {
  176. retVal = E_OK;
  177. }
  178. return retVal;
  179. }
  180. void UartInit(void)
  181. {
  182. create_ringBuffer(&uartRingBuffer[0],ringBufferforUart[0],sizeof(ringBufferforUart[0]));
  183. create_ringBuffer(&uartRingBuffer[1],ringBufferforUart[1],sizeof(ringBufferforUart[1]));
  184. create_ringBuffer(&uartRingBuffer[2],ringBufferforUart[2],sizeof(ringBufferforUart[2]));
  185. UartRecvQueue[0] = xQueueCreate(6, sizeof(UartMsg_t));
  186. UartRecvQueue[1] = xQueueCreate(6, sizeof(UartMsg_t));
  187. UartRecvQueue[2] = xQueueCreate(6, sizeof(UartMsg_t));
  188. TcpRecvQueue = xQueueCreate(2, sizeof(UartMsg_t));
  189. UartSendQueue[0] = xQueueCreate(3, sizeof(UartMsg_t));
  190. UartSendQueue[1] = xQueueCreate(1, sizeof(UartMsg_t));
  191. UartSendQueue[2] = xQueueCreate(1, sizeof(UartMsg_t));
  192. UartHalQueueHandle = xQueueCreate(9, sizeof(UartHalMsg_t));
  193. xTaskCreate(Uart_Hal_RecvTask, (const char *const)"UartRecv", 256, (void *)0, main_TASK_PRIORITY + 5, &Uart_Hal_RecvTask_Handle);
  194. xTaskCreate(Uart_Hal_SendTask, (const char *const)"UartSend", 256, (void *)0, main_TASK_PRIORITY + 4, &Uart_Hal_SendTask_Handle);
  195. }
  196. Std_ReturnType UartStartRecvFunc(uint8 channel)
  197. {
  198. sint8 out = 0;
  199. volatile Std_ReturnType R_Uart_Status=E_NOT_OK;
  200. bufferIdx[channel]=0;
  201. memset(RX_Buffer[channel],0x00,BUFFER_SIZE);
  202. switch(channel)
  203. {
  204. case 0:
  205. IP_LPUART0->CTRL |= LPUART_CTRL_ILIE(1);
  206. break;
  207. case 1:
  208. IP_LPUART1->CTRL |= LPUART_CTRL_ILIE(1);
  209. break;
  210. case 2:
  211. IP_LPUART2->CTRL |= LPUART_CTRL_ILIE(1);
  212. break;
  213. default:
  214. break;
  215. }
  216. Uart_SetBuffer(channel, RX_Buffer[channel], DMA_SIZE, UART_RECEIVE);
  217. R_Uart_Status = Uart_AsyncReceive(channel, RX_Buffer[channel], DMA_SIZE);
  218. if (E_OK != R_Uart_Status)
  219. {
  220. Uart_Abort(channel, UART_RECEIVE);
  221. out = E_NOT_OK;
  222. }
  223. return out;
  224. }
  225. void Uart_Hal_RecvTask(void *pvParameters)
  226. {
  227. UartHalMsg_t UartHalMsgRecv;
  228. UartMsg_t UartRecvMsg;
  229. uint16 recvSize = 0;
  230. BaseType_t ret = pdFALSE;
  231. BaseType_t ret_send = pdFALSE;
  232. uint32 T_bytesRemaining[3] = {0};
  233. uint16 T_timeout[3] = {0};
  234. volatile Uart_StatusType Uart_ReceiveStatus[3] = {UART_STATUS_TIMEOUT,UART_STATUS_TIMEOUT,UART_STATUS_TIMEOUT};
  235. uint8 UartIdx = UART_LPUART0;
  236. uint8 UartState[3] = {UartAbortRecv,UartAbortRecv,UartAbortRecv};
  237. while(1)
  238. {
  239. if((T_timeout[UartIdx]>1000) && (Uart_ReceiveStatus[UartIdx] != UART_STATUS_NO_ERROR) )
  240. {
  241. Uart_Abort(UartIdx, UART_RECEIVE);
  242. UartState[UartIdx] = UartAbortRecv;
  243. T_timeout[UartIdx] = 0;
  244. }
  245. else if(Uart_ReceiveStatus[UartIdx] == UART_STATUS_NO_ERROR)
  246. {
  247. UartState[UartIdx] = UartRecvComplete;
  248. }
  249. if((UartState[UartIdx] == UartAbortRecv) || (UartState[UartIdx] == UartRecvComplete))
  250. {
  251. if(E_OK == UartStartRecvFunc(UartIdx))
  252. {
  253. UartState[UartIdx] = UartStartRecv;
  254. }
  255. }
  256. Uart_ReceiveStatus[UartIdx] = Uart_GetStatus(UartIdx, &T_bytesRemaining[UartIdx], UART_RECEIVE);
  257. T_timeout[UartIdx]++;
  258. UartIdx = (UartIdx + 1) > 2 ? 1 : (UartIdx + 1);
  259. ret = xQueueReceive(UartHalQueueHandle,&UartHalMsgRecv,1);
  260. if(ret==pdTRUE)
  261. {
  262. if(UartHalMsgRecv.event==LPUART_UART_IP_EVENT_RECV_IDLE)
  263. {
  264. if(UartHalMsgRecv.value>0)
  265. {
  266. recvSize = write_ringBuffer(RX_Buffer[UartHalMsgRecv.Channel],UartHalMsgRecv.value,&uartRingBuffer[UartHalMsgRecv.Channel],&(UartRecvMsg.dataAddr));
  267. UartRecvMsg.DataLen = UartHalMsgRecv.value;
  268. if(UartHalMsgRecv.Channel==1 && strstr((char *)UartRecvMsg.dataAddr, (char *)("RECV FROM")))//网络接收数据放入其他队列
  269. {
  270. ret_send = xQueueSend(TcpRecvQueue,&UartRecvMsg,10);
  271. }
  272. else
  273. {
  274. ret_send = xQueueSend(UartRecvQueue[UartHalMsgRecv.Channel],&UartRecvMsg,10);
  275. }
  276. T_timeout[UartHalMsgRecv.Channel] = 0;
  277. UartState[UartHalMsgRecv.Channel] = UartRecvComplete;
  278. }
  279. }
  280. }
  281. }
  282. }
  283. void Uart_Hal_SendTask(void *pvParameters)
  284. {
  285. UartMsg_t UartSendMsg;
  286. BaseType_t ret = pdFALSE;
  287. uint32 T_bytesRemaining[3] = {0};
  288. uint16 T_timeout[3] = {0};
  289. volatile Std_ReturnType T_Uart_Status[3];
  290. uint8 UartIdx = UART_LPUART0;
  291. uint8 UartSendState[3] = {UartNoDataSend,UartNoDataSend,UartNoDataSend};
  292. while(1)
  293. {
  294. ret = xQueueReceive(UartSendQueue[UartIdx],&UartSendMsg,1);
  295. if(ret==pdTRUE)
  296. {
  297. T_Uart_Status[UartIdx] = Uart_AsyncSend(UartIdx, UartSendMsg.dataPtr, UartSendMsg.DataLen);
  298. if (E_OK != T_Uart_Status[UartIdx])
  299. {
  300. Uart_Abort(UartIdx, UART_SEND);
  301. UartSendState[UartIdx] = UartAbortSend;
  302. }
  303. else
  304. {
  305. UartSendState[UartIdx] = UartStartSend;
  306. }
  307. }
  308. /*开始发送后的判定*/
  309. if(UartSendState[UartIdx] == UartStartSend)
  310. {
  311. Uart_TransmitStatus[UartIdx] = Uart_GetStatus(UartIdx, &T_bytesRemaining[UartIdx], UART_SEND);
  312. T_timeout[UartIdx]++;
  313. }
  314. if(T_timeout[UartIdx]>=1000 || ((Uart_TransmitStatus[UartIdx] != UART_STATUS_OPERATION_ONGOING) && (UartSendState[UartIdx] == UartStartSend)))
  315. {
  316. if(T_timeout[UartIdx]>=1000)
  317. {
  318. Uart_Abort(UartIdx, UART_SEND);
  319. UartSendState[UartIdx] = UartAbortSend;
  320. }
  321. else if(Uart_TransmitStatus[UartIdx] == UART_STATUS_NO_ERROR)
  322. {
  323. UartSendState[UartIdx] = UartSendComplete;
  324. }
  325. T_timeout[UartIdx] = 0;
  326. }
  327. UartIdx = (UartIdx + 1) > 2 ? 0 : (UartIdx + 1);
  328. }
  329. }
  330. extern Lpuart_Uart_Ip_StateStructureType *Lpuart_Uart_Ip_apStateStructuresArray[LPUART_UART_IP_NUMBER_OF_INSTANCES];
  331. void UART_Callback(uint32 hwInstance, Lpuart_Uart_Ip_EventType event)
  332. {
  333. // (void)userData;
  334. Lpuart_Uart_Ip_StateStructureType * UartState;
  335. UartState = (Lpuart_Uart_Ip_StateStructureType *)Lpuart_Uart_Ip_apStateStructuresArray[hwInstance];
  336. /* Check the event type */
  337. if (event == LPUART_UART_IP_EVENT_RX_FULL)
  338. {
  339. /* The reception stops when receiving idle is detected or the buffer is full */
  340. if (bufferIdx[hwInstance] <= (BUFFER_SIZE - DMA_SIZE))
  341. {
  342. /* Update the buffer index and the rx buffer */
  343. bufferIdx[hwInstance] += DMA_SIZE;
  344. Uart_SetBuffer(hwInstance, &RX_Buffer[hwInstance][bufferIdx[hwInstance]], DMA_SIZE, UART_RECEIVE);
  345. // Lpuart_Uart_Ip_SetRxBuffer(hwInstance, &RX_Buffer[bufferIdx], DMA_SIZE);
  346. }
  347. }
  348. if (event == LPUART_UART_IP_EVENT_ERROR)
  349. {
  350. // /*Get the transfered data size. DMA Channel 1 is used for LPUART DMA receiving, please modify accordingly.*/
  351. // temp = DMA_SIZE - (uint32_t)IP_DMA->TCD->CITER.ELINKNO;
  352. // /*Add the remaining data size to the sum of the received size*/
  353. // bufferIdx[hwInstance] += temp;
  354. /*Abort the receiving after detecting IDLE receiving*/
  355. Lpuart_Uart_Ip_AbortReceivingData(hwInstance);
  356. Lpuart_Uart_Ip_AbortSendingData(hwInstance);
  357. // bufferIdx = 0;
  358. }
  359. if (event == LPUART_UART_IP_EVENT_RECV_IDLE)
  360. {
  361. uint32_t temp;
  362. UartHalMsg_t UartHalMsg;
  363. UartHalMsg.Channel = hwInstance;
  364. UartHalMsg.event = event;
  365. /*Get the transfered data size. DMA Channel 1 is used for LPUART DMA receiving, please modify accordingly.*/
  366. temp = DMA_SIZE - (uint32_t)IP_DMA->TCD[hwInstance].CITER.ELINKNO;
  367. /*Add the remaining data size to the sum of the received size*/
  368. bufferIdx[hwInstance] += temp;
  369. /*Abort the receiving after detecting IDLE receiving*/
  370. UartHalMsg.value = bufferIdx[hwInstance];
  371. xQueueSendFromISR(UartHalQueueHandle,&UartHalMsg,pdFALSE);
  372. }
  373. }
  374. /*CAN*/
  375. Can_PduType Can_CreatePduInfo(Can_IdType id, CAN_IdFrameType idFrame, PduIdType swPduHandle, uint8 length, uint8 *sdu)
  376. {
  377. Can_PduType PduInfo;
  378. switch (idFrame)
  379. {
  380. case CAN_STANDARD_ID_TYPE:
  381. id = id & 0x7FF;
  382. break;
  383. case CANFD_STANDARD_ID_TYPE:
  384. id = (id & 0x7FF) | 0x40000000;
  385. break;
  386. case CAN_EXTENDED_ID_TYPE:
  387. id = id | 0x80000000;
  388. break;
  389. case CANFD_EXTENDED_ID_TYPE:
  390. id = id | 0xC0000000;
  391. break;
  392. default:
  393. id = id & 0x7FF;
  394. break;
  395. }
  396. PduInfo.id = id;
  397. PduInfo.swPduHandle = swPduHandle;
  398. PduInfo.length = length;
  399. PduInfo.sdu = sdu;
  400. return PduInfo;
  401. }
  402. Std_ReturnType CanIf_SendMessage(uint8 ControllerId, Can_Msg_Type CanMsg)
  403. {
  404. volatile Can_PduType Can_PduInfo;
  405. volatile Std_ReturnType CAN_Write_Status;
  406. Std_ReturnType retVal = E_NOT_OK;
  407. uint32 u8TimeOut = 100 * 100;
  408. Can_HwHandleType Hth = Can0HardwareObject_TX + (Can_HwHandleType)ControllerId; // controller 0 --> Can0HardwareObject_TX
  409. Can_PduInfo = Can_CreatePduInfo(CanMsg.id, CanMsg.idFrame, 0, CanMsg.length, CanMsg.sdu);
  410. CAN_Write_Status = Can_Write(Hth, &Can_PduInfo);
  411. CanIf_bTxFlag = FALSE;
  412. if (CAN_Write_Status == E_OK)
  413. {
  414. while ((!CanIf_bTxFlag) && (u8TimeOut != 0U))
  415. {
  416. Can_MainFunction_Write();
  417. u8TimeOut--;
  418. }
  419. }
  420. if (CanIf_bTxFlag == TRUE)
  421. {
  422. retVal = E_OK;
  423. }
  424. else
  425. {
  426. retVal = E_NOT_OK;
  427. }
  428. return retVal;
  429. }
  430. Can_Msg_Type Can_GetMsgInfo(Can_IdType id, uint8 length, uint8 *sdu)
  431. {
  432. Can_Msg_Type CanMsgInfo;
  433. CanMsgInfo.idFrame = (CAN_IdFrameType)((id >> 30) & 0x03);
  434. if (CanMsgInfo.idFrame & 0x01)
  435. {
  436. CanMsgInfo.id = id & 0x7FF;
  437. }
  438. else
  439. {
  440. CanMsgInfo.id = id & 0x1FFFFFFF;
  441. }
  442. CanMsgInfo.length = length;
  443. CanMsgInfo.sdu = sdu;
  444. return CanMsgInfo;
  445. }
  446. void CanIf_ControllerBusOff(uint8 ControllerId)
  447. {
  448. (void)ControllerId;
  449. }
  450. void CanIf_ControllerModeIndication(uint8 ControllerId, Can_ControllerStateType ControllerMode)
  451. {
  452. (void)ControllerId;
  453. (void)ControllerMode;
  454. }
  455. void CanIf_TxConfirmation(PduIdType CanTxPduId)
  456. {
  457. CanIf_u8TxConfirmCnt++;
  458. CanIf_bTxFlag = TRUE;
  459. (void)CanTxPduId;
  460. }
  461. void CanIf_RxIndication(const Can_HwType *Mailbox, const PduInfoType *PduInfoPtr)
  462. {
  463. Can_Msg_Type canRxMsg_Buff;
  464. Can_Msg_Type_Data canRxMsgQueueData;
  465. CanIf_bRxFlag = TRUE; // should not be delete
  466. // should put the msg into message queue
  467. canRxMsg_Buff = Can_GetMsgInfo(Mailbox->CanId, PduInfoPtr->SduLength, PduInfoPtr->SduDataPtr);
  468. canRxMsgQueueData.id = canRxMsg_Buff.id;
  469. canRxMsgQueueData.length = canRxMsg_Buff.length;
  470. memcpy(canRxMsgQueueData.data, canRxMsg_Buff.sdu, canRxMsgQueueData.length);
  471. switch(Mailbox->Hoh)
  472. {
  473. case 0:
  474. xQueueSend(CanRecvQueueHandle0, &canRxMsgQueueData, 0);
  475. break;
  476. case 1:
  477. xQueueSend(CanRecvQueueHandle1, &canRxMsgQueueData, 0);
  478. break;
  479. case 2:
  480. xQueueSend(CanRecvQueueHandle2, &canRxMsgQueueData, 0);
  481. break;
  482. }
  483. }
  484. void CanIf_CurrentIcomConfiguration(uint8 ControllerId, IcomConfigIdType ConfigurationId, IcomSwitch_ErrorType Error)
  485. {
  486. (void)ControllerId;
  487. (void)ConfigurationId;
  488. (void)Error;
  489. }
  490. void Notification_0(void)
  491. {
  492. ADC_Converter(ResultBuffer, ConvertedBuffer);
  493. memcpy(BattTempR, &ConvertedBuffer[3], 4 * sizeof(uint32));
  494. }
  495. void Notification_1(void)
  496. {
  497. VarNotification_1++;
  498. }
  499. Std_ReturnType ADC_Converter(Adc_ValueGroupType *Buffer, TP_Value_Type *ConvertedValueR)
  500. {
  501. Adc_ValueGroupType REFH, REFL;
  502. REFH = Buffer[0];
  503. REFL = Buffer[2];
  504. for (int i = 3; i < NUM_RESULTS; i++)
  505. {
  506. if (Buffer[i] >= REFH)
  507. {
  508. ConvertedValueR[i] = 40930000;
  509. }
  510. else if (Buffer[i] <= REFL)
  511. {
  512. ConvertedValueR[i] = 0x00;
  513. }
  514. else
  515. {
  516. ConvertedValueR[i] = (TP_Value_Type)((float)(10000 * (Buffer[i] - REFL) / (float)(REFH - REFL)) / (1 - (float)((Buffer[i] - REFL) / (float)(REFH - REFL))));
  517. }
  518. }
  519. return 0;
  520. }
  521. Std_ReturnType ADC_ReadValue()
  522. {
  523. Std_ReturnType ret = E_NOT_OK;
  524. for (uint8 i = 0; i < NUM_RESULTS; i++)
  525. {
  526. ResultBuffer[i] = 0xFFFF;
  527. ConvertedBuffer[i] = 0x00;
  528. }
  529. Adc_SetupResultBuffer(AdcGroupSoftwareOneShot, ResultBuffer);
  530. Adc_EnableGroupNotification(AdcGroupSoftwareOneShot);
  531. VarNotification_0 = 0;
  532. Adc_StartGroupConversion(AdcGroupSoftwareOneShot);
  533. return ret;
  534. }
  535. /*EEP*/
  536. static Std_ReturnType TestEep_FlexNvmProgramPartCmd(
  537. VAR(TestEep_CsecKeySize, AUTOMATIC) eepKeysize,
  538. VAR(TestEep_SfeType, AUTOMATIC) eepSecurityFlagExtension,
  539. VAR(TestEep_LoadFlexRamType, AUTOMATIC) eepLoadFlexRamAtReset,
  540. VAR(TestEep_Eeprom_FlexRamPartitionType, AUTOMATIC) eepFlexRamPartition,
  541. VAR(TestEep_Eeprom_FlexNvmPartitionType, AUTOMATIC) eepFlexNvmPartition)
  542. {
  543. Std_ReturnType u8RetVal = (Std_ReturnType)E_OK;
  544. uint32 u32FlexNvmPartSize = 0;
  545. uint32 u32RegSimFcfg1 = 0UL;
  546. u32RegSimFcfg1 = IP_SIM->FCFG1;
  547. /*get DEPART value */
  548. u32FlexNvmPartSize = (uint32)((u32RegSimFcfg1 & SIM_FCFG1_DEPART_MASK) >> SIM_FCFG1_DEPART_SHIFT);
  549. /* check that it was not partitioned before */
  550. if (u32FlexNvmPartSize == 0xF)
  551. {
  552. // /* if error flags are set the cmd is not executed */
  553. // REG_WRITE8(TEST_EEP_EEPROM_FSTAT_ADDR32, TEST_EEP_EEPROM_FSTAT_ACCERR_U8 | TEST_EEP_EEPROM_FSTAT_FPVIOL_U8);
  554. //
  555. // /*erase DF 0 sector*/
  556. // u32Addr=(TEST_EEP_DEEPROM_SECTOR_0_ADDR32 - D_EEPROM_BASE_ADDR) + 0x800000UL;
  557. //
  558. // REG_WRITE8(TEST_EEP_EEPROM_FCCOB0_ADDR32, TEST_EEP_EEPROM_CMD_ERASE_SECTOR);
  559. // REG_WRITE8(TEST_EEP_EEPROM_FCCOB1_ADDR32, (uint8)(u32Addr >> 16UL));
  560. // REG_WRITE8(TEST_EEP_EEPROM_FCCOB2_ADDR32, (uint8)(u32Addr >> 8UL));
  561. // REG_WRITE8(TEST_EEP_EEPROM_FCCOB3_ADDR32, (uint8)(u32Addr >> 0UL));
  562. // REG_WRITE8(TEST_EEP_EEPROM_FSTAT_ADDR32 , TEST_EEP_EEPROM_FSTAT_CCIF_U8);
  563. // while((0U == REG_BIT_GET8(TEST_EEP_EEPROM_FSTAT_ADDR32, TEST_EEP_EEPROM_FSTAT_CCIF_U8)))
  564. // {
  565. // }
  566. //
  567. if (0U == REG_BIT_GET8(TEST_EEP_EEPROM_FSTAT_ADDR32, TEST_EEP_EEPROM_FSTAT_ACCERR_U8 | TEST_EEP_EEPROM_FSTAT_FPVIOL_U8))
  568. {
  569. /* run program partition command */
  570. REG_WRITE8(TEST_EEP_EEPROM_FCCOB0_ADDR32, EEPROM_CMD_PROGRAM_PARTITION);
  571. REG_WRITE8(TEST_EEP_EEPROM_FCCOB1_ADDR32, (uint8)eepKeysize);
  572. REG_WRITE8(TEST_EEP_EEPROM_FCCOB2_ADDR32, (uint8)eepSecurityFlagExtension);
  573. REG_WRITE8(TEST_EEP_EEPROM_FCCOB3_ADDR32, (uint8)eepLoadFlexRamAtReset);
  574. REG_WRITE8(TEST_EEP_EEPROM_FCCOB4_ADDR32, (uint8)eepFlexRamPartition);
  575. REG_WRITE8(TEST_EEP_EEPROM_FCCOB5_ADDR32, (uint8)eepFlexNvmPartition);
  576. REG_WRITE8(TEST_EEP_EEPROM_FSTAT_ADDR32, TEST_EEP_EEPROM_FSTAT_CCIF_U8);
  577. while ((0U == REG_BIT_GET8(TEST_EEP_EEPROM_FSTAT_ADDR32, TEST_EEP_EEPROM_FSTAT_CCIF_U8)))
  578. {
  579. /* wait for operation to finish */
  580. }
  581. /* check if errors occured */
  582. if (REG_BIT_GET8(TEST_EEP_EEPROM_FSTAT_ADDR32, TEST_EEP_EEPROM_FSTAT_ACCERR_U8 | TEST_EEP_EEPROM_FSTAT_FPVIOL_U8))
  583. {
  584. /* NOK, error flags are set */
  585. u8RetVal = (Std_ReturnType)E_NOT_OK;
  586. }
  587. }
  588. else
  589. {
  590. /* NOK, error flags are set */
  591. u8RetVal = (Std_ReturnType)E_NOT_OK;
  592. }
  593. }
  594. else
  595. {
  596. /* NOK, partitioned already */
  597. u8RetVal = (Std_ReturnType)E_NOT_OK;
  598. }
  599. return u8RetVal;
  600. }
  601. void Eep_DepartParitition(TestEep_Eeprom_FlexNvmPartitionType T_EEP_SIZE)
  602. {
  603. uint32 u32FlexNvmPartSize = 0;
  604. uint32 u32RegSimFcfg1 = 0UL;
  605. u32RegSimFcfg1 = IP_SIM->FCFG1;
  606. /*get DEPART value */
  607. u32FlexNvmPartSize = (uint32)((u32RegSimFcfg1 & SIM_FCFG1_DEPART_MASK) >> SIM_FCFG1_DEPART_SHIFT);
  608. if (u32FlexNvmPartSize == 0xF) /* We just partition again if curent size different with expected */
  609. {
  610. /* partition for EERAM 64K with NOT loading EERAM at reset in hardware */
  611. TestEep_FlexNvmProgramPartCmd(EEP_FTFC_KEY_SIZE_0_BYTES, EEP_FTFC_VERIFY_ONLY_DISABLED,
  612. EEP_FTFC_LOAD_AT_RESET_ENABLED, EEP_FTFC_EERAM_SIZE_4K, T_EEP_SIZE);
  613. }
  614. }
  615. /* Erase memory by writing erase value */
  616. Std_ReturnType HAL_EEP_Erase(uint32 eepEraseStartAddr, uint32 eepEraseSize)
  617. {
  618. Std_ReturnType retReturnType = E_OK;
  619. MemIf_JobResultType retJobResultType;
  620. retReturnType = Eep_Erase(eepEraseStartAddr, eepEraseSize);
  621. if (E_OK != retReturnType)
  622. {
  623. return E_NOT_OK;
  624. }
  625. while (MEMIF_IDLE != Eep_GetStatus())
  626. {
  627. Eep_MainFunction();
  628. }
  629. retJobResultType = Eep_GetJobResult();
  630. if (MEMIF_JOB_OK != retJobResultType)
  631. {
  632. return E_NOT_OK;
  633. }
  634. return E_OK;
  635. }
  636. /* Write one or more complete eeprom pages to the eeprom device */
  637. Std_ReturnType HAL_EEP_Write(uint32 eepWriteStartAddr, uint8 *pDataNeedtoWrite, uint32 dataSize)
  638. {
  639. Std_ReturnType retReturnType = E_OK;
  640. MemIf_JobResultType retJobResultType;
  641. /*Erase the EEP before write*/
  642. retReturnType = HAL_EEP_Erase(eepWriteStartAddr, dataSize);
  643. if (E_OK != retReturnType)
  644. {
  645. return E_NOT_OK;
  646. }
  647. retReturnType = Eep_Write(eepWriteStartAddr, pDataNeedtoWrite, dataSize);
  648. if (E_OK != retReturnType)
  649. {
  650. return E_NOT_OK;
  651. }
  652. while (MEMIF_IDLE != Eep_GetStatus())
  653. {
  654. Eep_MainFunction();
  655. }
  656. retJobResultType = Eep_GetJobResult();
  657. if (MEMIF_JOB_OK != retJobResultType)
  658. {
  659. return E_NOT_OK;
  660. }
  661. return E_OK;
  662. }
  663. /* Reads from eeprom memory */
  664. Std_ReturnType HAL_EEP_Read(uint32 eepReadStartAddr, uint8 *pDataBuffer, uint32 dataSize)
  665. {
  666. Std_ReturnType retReturnType = E_OK;
  667. MemIf_JobResultType retJobResultType;
  668. retReturnType = Eep_Read(eepReadStartAddr, pDataBuffer, dataSize);
  669. if (E_OK != retReturnType)
  670. {
  671. return E_NOT_OK;
  672. }
  673. while (MEMIF_IDLE != Eep_GetStatus())
  674. {
  675. Eep_MainFunction();
  676. }
  677. retJobResultType = Eep_GetJobResult();
  678. if (MEMIF_JOB_OK != retJobResultType)
  679. {
  680. return E_NOT_OK;
  681. }
  682. return E_OK;
  683. }
  684. /* Compares a eeprom memory area with an application data buffer */
  685. Std_ReturnType HAL_EEP_Compare(uint32 eepCompareStartAddr, uint8 *pDataNeedtoCompare, uint32 dataSize)
  686. {
  687. Std_ReturnType retReturnType = E_OK;
  688. MemIf_JobResultType retJobResultType;
  689. retReturnType = Eep_Compare(eepCompareStartAddr, pDataNeedtoCompare, dataSize);
  690. if (E_OK != retReturnType)
  691. {
  692. return E_NOT_OK;
  693. }
  694. while (MEMIF_IDLE != Eep_GetStatus())
  695. {
  696. Eep_MainFunction();
  697. }
  698. retJobResultType = Eep_GetJobResult();
  699. if (MEMIF_JOB_OK != retJobResultType)
  700. {
  701. return E_NOT_OK;
  702. }
  703. return E_OK;
  704. }
  705. /* @brief VECTKEY value so that AIRCR register write is not ignored. */
  706. #define FEATURE_SCB_VECTKEY (0x05FAU)
  707. void SystemSoftwareReset(void)
  708. {
  709. uint32_t regValue;
  710. /* Read Application Interrupt and Reset Control Register */
  711. regValue = S32_SCB->AIRCR;
  712. /* Clear register key */
  713. regValue &= ~( S32_SCB_AIRCR_VECTKEY_MASK);
  714. /* Configure System reset request bit and Register Key */
  715. regValue |= S32_SCB_AIRCR_VECTKEY(FEATURE_SCB_VECTKEY);
  716. regValue |= S32_SCB_AIRCR_SYSRESETREQ(0x1u);
  717. /* Write computed register value */
  718. S32_SCB->AIRCR = regValue;
  719. }
  720. void MCUSleep(void)
  721. {
  722. #if (ICU_PRECOMPILE_SUPPORT == STD_ON)
  723. Icu_Init(NULL_PTR);
  724. #elif (ICU_PRECOMPILE_SUPPORT == STD_OFF)
  725. Icu_Init(&Icu_Config_VS_0);
  726. #endif
  727. Mcu_SetMode(McuModeSettingConf_VLPS);
  728. // typedef void (*AppAddr)(void);
  729. // AppAddr resetHandle = (AppAddr)(0x14601);
  730. // OsIf_SuspendAllInterrupts();
  731. // (resetHandle)();
  732. SystemSoftwareReset();
  733. // coreInit();
  734. }
  735. void SystemDeinit(void)
  736. {
  737. Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_OFF);
  738. vTaskDelay(pdMS_TO_TICKS(3000));
  739. Dio_WriteChannel(DioConf_DioChannel_PTA6_GPIO_OUT_MCU_4G_POW_EN, STD_OFF);
  740. Dio_WriteChannel(DioConf_DioChannel_PTD1_GPIO_OUT_MCU_GPS_POW_EN, STD_OFF);//GPS ShutDown
  741. Dio_WriteChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1, STD_ON);
  742. Dio_WriteChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2, STD_ON);
  743. Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_ON);
  744. Dio_WriteChannel(DioConf_DioChannel_PTE8_GPIO_OUT_MCU_LED4, STD_ON);
  745. Dio_WriteChannel(DioConf_DioChannel_PTE9_GPIO_OUT_MCU_LED5, STD_ON);
  746. Uart_Deinit();
  747. Can_SetControllerMode(CanController_0, CAN_CS_STOPPED);
  748. Can_SetControllerMode(CanController_1, CAN_CS_STOPPED);
  749. // Can_SetControllerMode(CanController_2, CAN_CS_STOPPED);
  750. Can_DeInit();
  751. Adc_DeInit();
  752. Gpt_DisableNotification(GptConf_GptChannelConfiguration_GptChannelConfiguration_0);
  753. Gpt_DeInit();
  754. Spi_DeInit();
  755. Mcl_DeInit();
  756. //port DeInit
  757. for(int pinIndex = 0; pinIndex <PortConfigSet_PortContainer_GPIO_PTB4_GPIO_OUT_MCU_RS485_EN; pinIndex++)
  758. {
  759. if(pinIndex == PortConfigSet_PortContainer_CAN_PTA12_CAN1_RX_MCU_CAN1_RX /*|| pinIndex == PortConfigSet_PortContainer_INT_PTB0_LPTMR0_ATL3_MCU_CC1_INT || pinIndex == PortConfigSet_PortContainer_INT_PTE11_LPTMR0_ALT1_MCU_3D_INT1 || pinIndex == PortConfigSet_PortContainer_INT_PTD5_LPTMR0_ATL2_MCU_3D_INT2*/)
  760. {
  761. continue;
  762. }
  763. else
  764. {
  765. Port_SetAsUnusedPin(pinIndex);
  766. }
  767. }
  768. Port_SetPinMode(PortConfigSet_PortContainer_CAN_PTA12_CAN1_RX_MCU_CAN1_RX,PORT_GPIO_MODE);
  769. // systemInitFlag = false;
  770. }
  771. void MCUEnterSleep(void)
  772. {
  773. if(pdTRUE == xSemaphoreTake(sleep_mutex,1) && Fota_Process_Going == false)
  774. {
  775. extern boolean Uart_4G_Task_Sleep_FLag;
  776. WdgDeInit();
  777. Std_ReturnType Ret = E_NOT_OK;
  778. uint8 appConfigWriteTimes = 0;
  779. do
  780. {
  781. waitForSleepFlag = true;
  782. //save the app configure before power off
  783. if(Ret == E_NOT_OK)
  784. {
  785. AppConfigInfo.appSaveFlg = false;
  786. Ret = HAL_EEP_Write(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
  787. appConfigWriteTimes++;
  788. }
  789. vTaskDelay(pdMS_TO_TICKS(10));
  790. }while(Uart_4G_Task_Sleep_FLag == false || (Ret == E_NOT_OK && appConfigWriteTimes<5) );
  791. vTaskDelete(Uart_Hal_RecvTask_Handle);
  792. vTaskDelete(Uart_Hal_SendTask_Handle);
  793. vTaskDelete(CanTask_Handle);
  794. vTaskDelete(GpsTask_Handle);
  795. vTaskDelete(Uart_4G_Task_Handle);
  796. SystemDeinit();
  797. MCUSleep();
  798. // WdgInit();
  799. // DoResetECUWithWdg();
  800. }
  801. }
  802. void coreInit(void)
  803. {
  804. /* Initialize the Mcu driver */
  805. #if (MCU_PRECOMPILE_SUPPORT == STD_ON)
  806. Mcu_Init(NULL_PTR);
  807. #elif (MCU_PRECOMPILE_SUPPORT == STD_OFF)
  808. Mcu_Init(&Mcu_Config_VS_0);
  809. #endif /* (MCU_PRECOMPILE_SUPPORT == STD_ON) */
  810. Mcu_InitClock(McuClockSettingConfig_0);
  811. /* Wait until PLL is locked */
  812. while (MCU_PLL_LOCKED != Mcu_GetPllStatus())
  813. {
  814. /* Busy wait until the System PLL is locked */
  815. }
  816. Mcu_DistributePllClock();
  817. OsIf_Init(NULL_PTR);
  818. Platform_Init(NULL_PTR);
  819. /* Initialize all pins*/
  820. #if (PORT_PRECOMPILE_SUPPORT == STD_ON)
  821. Port_Init(NULL_PTR);
  822. #elif (PORT_PRECOMPILE_SUPPORT == STD_OFF)
  823. Port_Init(&Port_Config_VS_0);
  824. #endif
  825. }
  826. void SystemModulesInit(void)
  827. {
  828. /* Initialize Mcl module */
  829. Mcl_Init(NULL_PTR);
  830. SEGGER_RTT_Init();
  831. /* Initializes an UART driver*/
  832. #if (UART_PRECOMPILE_SUPPORT == STD_ON)
  833. Uart_Init(NULL_PTR);
  834. #elif (UART_PRECOMPILE_SUPPORT == STD_OFF)
  835. Uart_Init(&Uart_xConfig_VS_0);
  836. #endif
  837. IP_LPUART0->CTRL |= LPUART_CTRL_ILT(1);
  838. IP_LPUART1->CTRL |= LPUART_CTRL_ILT(1);
  839. IP_LPUART2->CTRL |= LPUART_CTRL_ILT(1);
  840. IP_LPUART0->CTRL |= LPUART_CTRL_IDLECFG(3);
  841. IP_LPUART1->CTRL |= LPUART_CTRL_IDLECFG(3);
  842. IP_LPUART2->CTRL |= LPUART_CTRL_IDLECFG(3);
  843. #if 1 /* Initialize Platform driver */
  844. #if (CAN_PRECOMPILE_SUPPORT == STD_ON)
  845. Can_Init(NULL_PTR);
  846. #elif (CAN_PRECOMPILE_SUPPORT == STD_OFF)
  847. Can_Init(&Can_Config_VS_0);
  848. #endif
  849. Can_SetControllerMode(CanController_0, CAN_CS_STARTED);
  850. Can_SetControllerMode(CanController_1, CAN_CS_STARTED);
  851. // Can_SetControllerMode(CanController_2, CAN_CS_STARTED);
  852. #endif
  853. #if (ADC_PRECOMPILE_SUPPORT == STD_ON)
  854. Adc_Init(NULL_PTR);
  855. #else
  856. Adc_Init(&Adc_Config_VS_0);
  857. #endif /* ADC_PRECOMPILE_SUPPORT == STD_ON */
  858. /* Partition only if it was not partitioned before for EERAM with code 0x4 */
  859. // Eep_DepartParitition(T_EEEPROM_SIZE);
  860. /* Initialize Eep driver */
  861. #if defined (EEP_PRECOMPILE_SUPPORT)
  862. Eep_Init(NULL_PTR);
  863. #else
  864. Eep_Init(&Eep_Config_VS_0);
  865. #endif
  866. //Init Flash Driver
  867. #if defined (FLS_PRECOMPILE_SUPPORT)
  868. Fls_Init(NULL_PTR);
  869. #else
  870. Fls_Init(&Fls_Config_VS_0);
  871. while(MEMIF_IDLE == Fls_GetStatus())
  872. {
  873. ;
  874. }
  875. #endif
  876. Spi_Init(NULL_PTR);
  877. /* Initialize the Gpt driver */
  878. Gpt_Init(&Gpt_Config_VS_0);
  879. /* Enable the Gpt notification to periodically service the Wdg */
  880. Gpt_EnableNotification(GptConf_GptChannelConfiguration_GptChannelConfiguration_0);
  881. Icu_DeInit();
  882. WdgInit();
  883. IsFeedWdg = true;
  884. }
  885. void displayResetReasonWithLED(void)
  886. {
  887. Mcu_ResetType bootreason;
  888. bootreason = Mcu_GetResetReason();
  889. }
  890. #define APPNAME "S32K146_4G"
  891. #define HARDWARE_VERSION "V1.0.0"
  892. #define SOFTWARE_VERSION "V0.0.1"
  893. #include "SEGGER_SYSVIEW.h"
  894. #include "cm_backtrace.h"
  895. void debugInit(void)
  896. {
  897. #ifdef SEGGER_SYSTEMVIEW
  898. SEGGER_SYSVIEW_Conf();
  899. SEGGER_SYSVIEW_Start();
  900. #endif
  901. #ifdef SEGGER_RTT_PRINTF
  902. SEGGER_RTT_Init();
  903. cm_backtrace_init(APPNAME, HARDWARE_VERSION, SOFTWARE_VERSION);
  904. SEGGER_RTT_printf("boot\n");
  905. #endif
  906. }