usart.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. /**
  2. ******************************************************************************
  3. * File Name : USART.c
  4. * Description : This file provides code for the configuration
  5. * of the USART instances.
  6. ******************************************************************************
  7. * This notice applies to any and all portions of this file
  8. * that are not between comment pairs USER CODE BEGIN and
  9. * USER CODE END. Other portions of this file, whether
  10. * inserted by the user or by software development tools
  11. * are owned by their respective copyright owners.
  12. *
  13. * Copyright (c) 2019 STMicroelectronics International N.V.
  14. * All rights reserved.
  15. *
  16. * Redistribution and use in source and binary forms, with or without
  17. * modification, are permitted, provided that the following conditions are met:
  18. *
  19. * 1. Redistribution of source code must retain the above copyright notice,
  20. * this list of conditions and the following disclaimer.
  21. * 2. Redistributions in binary form must reproduce the above copyright notice,
  22. * this list of conditions and the following disclaimer in the documentation
  23. * and/or other materials provided with the distribution.
  24. * 3. Neither the name of STMicroelectronics nor the names of other
  25. * contributors to this software may be used to endorse or promote products
  26. * derived from this software without specific written permission.
  27. * 4. This software, including modifications and/or derivative works of this
  28. * software, must execute solely and exclusively on microcontroller or
  29. * microprocessor devices manufactured by or for STMicroelectronics.
  30. * 5. Redistribution and use of this software other than as permitted under
  31. * this license is void and will automatically terminate your rights under
  32. * this license.
  33. *
  34. * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
  35. * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
  36. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  37. * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
  38. * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
  39. * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  40. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  42. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  43. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  44. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  45. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  46. *
  47. ******************************************************************************
  48. */
  49. /* Includes ------------------------------------------------------------------*/
  50. #include "usart.h"
  51. //#include "Dwin.h"
  52. /* USER CODE BEGIN 0 */
  53. #include <stdio.h>
  54. #include <string.h>
  55. //#include "TerminalSlave485.h"
  56. //#include "KeySlave485.h"
  57. //#include "CollectMaster485.h"
  58. //#include "ScreenMaster485.h"
  59. uint8_t usart1_rx_flag;
  60. uint8_t usart2_rx_flag;
  61. uint8_t usart3_rx_flag;
  62. uint8_t usart4_rx_flag;
  63. uint16_t rx1_len;
  64. uint16_t rx2_len;
  65. uint16_t rx3_len;
  66. uint16_t rx3_len;
  67. uint16_t rx4_len;
  68. static uint8_t USART_RX_BUF_U1[Uart1_BUF_SIZE]; /*为UART专门开一个DMA接收存储区 2021-2-23 by Daiyf*/
  69. //static uint8_t USART_RX_BUF_U2[Uart2_BUF_SIZE]; /*为UART2、3专门开一个DMA接收存储区 2021-4-12 by Daiyf*/
  70. static uint8_t USART_RX_BUF_U3[Uart3_BUF_SIZE];
  71. uint8_t USART_RX_BUF[Uart1_BUF_SIZE];
  72. static const char LIB_CRC_MODBUS_HI[] =
  73. {
  74. 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
  75. 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
  76. 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
  77. 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
  78. 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
  79. 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
  80. 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
  81. 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
  82. 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
  83. 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
  84. 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
  85. 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
  86. 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
  87. 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
  88. 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
  89. 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
  90. 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
  91. 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
  92. 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
  93. 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
  94. 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
  95. 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
  96. 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
  97. 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
  98. 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
  99. 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40
  100. };
  101. static const char LIB_CRC_MODBUS_LO[] =
  102. {
  103. 0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06,
  104. 0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD,
  105. 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09,
  106. 0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A,
  107. 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, 0x14, 0xD4,
  108. 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3,
  109. 0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3,
  110. 0xF2, 0x32, 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4,
  111. 0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A,
  112. 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29,
  113. 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED,
  114. 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26,
  115. 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60,
  116. 0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67,
  117. 0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F,
  118. 0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68,
  119. 0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA, 0xBE, 0x7E,
  120. 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5,
  121. 0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71,
  122. 0x70, 0xB0, 0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92,
  123. 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C,
  124. 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B,
  125. 0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B,
  126. 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C,
  127. 0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42,
  128. 0x43, 0x83, 0x41, 0x81, 0x80, 0x40
  129. };
  130. uint8_t USART_TX_BUF[Uart1_BUF_SIZE];
  131. uint8_t USART1_RX_BUF[Uart1_BUF_SIZE];
  132. uint8_t USART1_RX_BUF002[Uart1_BUF_SIZE];
  133. uint8_t USART1_TX_BUF[Uart1_BUF_SIZE];
  134. uint8_t USART2_RX_BUF[Uart2_BUF_SIZE];
  135. uint8_t USART2_TX_BUF[Uart2_BUF_SIZE];
  136. uint8_t USART2_RX_BUF002[Uart2_BUF_SIZE];
  137. uint8_t USART3_RX_BUF[Uart3_BUF_SIZE];
  138. uint8_t USART3_RX_BUF002[Uart3_BUF_SIZE];
  139. uint8_t USART3_RX_BUF002_print[Uart3_BUF_SIZE];
  140. uint8_t USART3_TX_BUF[Uart3_BUF_SIZE];
  141. //uint8_t UART4_RX_BUF[BUF_SIZE];
  142. //uint8_t UART4_TX_BUF[BUF_SIZE];
  143. /* USER CODE END 0 */
  144. //UART_HandleTypeDef huart4;
  145. extern UART_HandleTypeDef huart1;
  146. extern UART_HandleTypeDef huart2;
  147. extern UART_HandleTypeDef huart3;
  148. //DMA_HandleTypeDef hdma_uart4_rx;
  149. extern DMA_HandleTypeDef hdma_usart1_rx;
  150. extern DMA_HandleTypeDef hdma_usart2_rx;
  151. extern DMA_HandleTypeDef hdma_usart3_rx;
  152. UART_HandleTypeDef huart4;
  153. /* USER CODE BEGIN 1 */
  154. uint16_t ErrorLength;
  155. void UsartReceive_IDLE(UART_HandleTypeDef *huart)
  156. {
  157. uint32_t i = 0;
  158. if((__HAL_UART_GET_FLAG(huart, UART_FLAG_IDLE) != RESET))
  159. {
  160. if(huart->Instance == USART1)
  161. {
  162. __HAL_UART_CLEAR_IDLEFLAG(huart);
  163. // i = huart->Instance->ISR; //清除状态寄存器SR,读取SR寄存器可以实现清除SR寄存器的功能 /*这三行不要。 2021-2-23 by Daiyf*/
  164. // i = huart->Instance->RDR; //读取数据寄存器中的数据
  165. // i = hdma_usart1_rx.Instance->NDTR;
  166. // __HAL_UART_DISABLE_IT(&huart1, UART_IT_RXNE);
  167. HAL_UART_DMAStop(huart);
  168. i = __HAL_DMA_GET_COUNTER(&hdma_usart1_rx);// 获取DMA中未传输的数据个数
  169. // HAL_UART_Receive_DMA(&huart1, USART_RX_BUF,Uart1_BUF_SIZE);//重新打开DMA接收
  170. /* 此处处理数据,主要是拷贝和置位标志位 */
  171. memcpy(USART1_RX_BUF, USART_RX_BUF_U1, (Uart1_BUF_SIZE - i)); /*为UART专门开一个DMA接收存储区 2021-2-23 by Daiyf*/
  172. usart1_rx_flag = 1;
  173. rx1_len = Uart1_BUF_SIZE - i-2;//实际接收到的有用数据,总计数减去未传输的数据个数,得到已经接收的数据个数(0x0D,0x0A)
  174. /* 清空缓存,重新接收 */
  175. ErrorLength=Uart1_BUF_SIZE;//DMA缺陷处理不定长数据时,连续数据太快导致长度异常,处理方法不用RTOS,或者不用DMA.
  176. // printf("%d:%s\r\n",rx1_len,USART_RX_BUF);
  177. // KeySlave485_Send_Data(USART_RX_BUF,rx1_len);
  178. // SendChar4(rx1_len);
  179. //memset(USART_RX_BUF_U1, 0x00, Uart1_BUF_SIZE); /*这二行不要。 2021-2-23 by Daiyf*/
  180. //__HAL_DMA_SET_COUNTER(&hdma_usart1_rx, 0); //清除DMA 计数
  181. HAL_UART_Receive_DMA(&huart1, USART_RX_BUF_U1,Uart1_BUF_SIZE);//重新打开DMA接收
  182. if((__HAL_UART_GET_FLAG(&huart1, UART_FLAG_ORE) != RESET))
  183. {
  184. // i = huart->Instance->ISR; //清除状态寄存器SR,读取SR寄存器可以实现清除SR寄存器的功能
  185. // i = huart->Instance->RDR; //读取数据寄存器中的数据
  186. // i = hdma_usart1_rx.Instance->NDTR;
  187. __HAL_UART_CLEAR_OREFLAG(&huart1);
  188. HAL_DMA_DeInit(&hdma_usart1_rx);
  189. }
  190. }
  191. // else if(huart->Instance == USART2)
  192. // {
  193. // __HAL_UART_CLEAR_IDLEFLAG(huart);
  194. //// i = huart->Instance->ISR;
  195. //// i = huart->Instance->RDR;
  196. //// i = hdma_usart2_rx.Instance->NDTR;
  197. // HAL_UART_DMAStop(huart);
  198. // HAL_UART_Receive_DMA(&huart2, USART_RX_BUF_U2,Uart2_BUF_SIZE);
  199. // /* 此处处理数据,主要是拷贝和置位标志位 */
  200. //
  201. //
  202. //
  203. // //memcpy(USART2_RX_BUF, USART_RX_BUF, rx2_len);
  204. // memcpy(USART2_RX_BUF, USART_RX_BUF_U2, Uart2_BUF_SIZE - i); //这里原来可能有点问题,改了一下与其他串口方式相同处理
  205. // __nop();
  206. // memcpy(USART2_RX_BUF, USART_RX_BUF_U2, 32);
  207. // __nop();
  208. //
  209. //
  210. //
  211. // usart2_rx_flag = 1;
  212. // rx2_len = Uart2_BUF_SIZE - i;//实际接收到的有用数据
  213. // // memset(USART_RX_BUF_U2, 0x00, Uart2_BUF_SIZE);
  214. // }
  215. else if(huart->Instance == USART3)
  216. {
  217. __HAL_UART_CLEAR_IDLEFLAG(huart);
  218. #if 1
  219. HAL_UART_DMAStop(huart);
  220. i = __HAL_DMA_GET_COUNTER(&hdma_usart3_rx);// 获取DMA中未传输的数据个数
  221. memcpy(USART3_RX_BUF, USART_RX_BUF_U3, (Uart3_BUF_SIZE - i));
  222. usart3_rx_flag = 1;
  223. rx3_len = Uart3_BUF_SIZE - i;
  224. ErrorLength=Uart3_BUF_SIZE;
  225. HAL_UART_Receive_DMA(&huart3, USART_RX_BUF_U3,Uart3_BUF_SIZE);//重新打开DMA接收
  226. if((__HAL_UART_GET_FLAG(&huart3, UART_FLAG_ORE) != RESET))
  227. {
  228. // i = huart->Instance->ISR; //清除状态寄存器SR,读取SR寄存器可以实现清除SR寄存器的功能
  229. // i = huart->Instance->RDR; //读取数据寄存器中的数据
  230. // i = hdma_usart3_rx.Instance->NDTR;
  231. __HAL_UART_CLEAR_OREFLAG(&huart3);
  232. HAL_DMA_DeInit(&hdma_usart3_rx);
  233. }
  234. #else
  235. i = huart->Instance->ISR;
  236. i = huart->Instance->RDR;
  237. i = hdma_usart3_rx.Instance->NDTR;
  238. HAL_UART_DMAStop(huart);
  239. HAL_UART_Receive_DMA(&huart3, USART_RX_BUF_U3,Uart3_BUF_SIZE); /*为UART3专门开一个DMA接收存储区 2021-4-12 by Daiyf*/
  240. /* 此处处理数据,主要是拷贝和置位标志位 */
  241. memcpy(USART3_RX_BUF, USART_RX_BUF_U3, (Uart3_BUF_SIZE - i));
  242. usart3_rx_flag = 1;
  243. rx3_len = Uart3_BUF_SIZE - i;//实际接收到的有用数据
  244. #endif
  245. memset(USART_RX_BUF, 0x00, BUF_SIZE);
  246. }
  247. /*
  248. else if(huart->Instance == UART4)
  249. {
  250. __HAL_UART_CLEAR_IDLEFLAG(huart);
  251. i = huart->Instance->ISR;
  252. i = huart->Instance->RDR;
  253. i = hdma_uart4_rx.Instance->NDTR;
  254. HAL_UART_DMAStop(huart);
  255. HAL_UART_Receive_DMA(&huart4, USART_RX_BUF,BUF_SIZE);
  256. //此处处理数据,主要是拷贝和置位标志位 //
  257. memcpy(UART4_RX_BUF, USART_RX_BUF, (BUF_SIZE - i));
  258. usart4_rx_flag = 1;
  259. rx4_len = BUF_SIZE - i;//实际接收到的有用数据
  260. memset(USART_RX_BUF, 0x00, BUF_SIZE);
  261. if((__HAL_UART_GET_FLAG(&huart4, UART_FLAG_ORE) != RESET))
  262. {
  263. i = huart->Instance->ISR; //清除状态寄存器SR,读取SR寄存器可以实现清除SR寄存器的功能
  264. i = huart->Instance->RDR; //读取数据寄存器中的数据
  265. i = hdma_uart4_rx.Instance->NDTR;
  266. __HAL_UART_CLEAR_OREFLAG(&huart4);
  267. HAL_DMA_DeInit(&hdma_uart4_rx);
  268. HAL_UART_MspInit(&huart4);
  269. HAL_UART_Receive_DMA(&huart4, USART_RX_BUF,BUF_SIZE);
  270. }
  271. }
  272. */
  273. }
  274. // HAL_DMA_DeInit(&hdma_usart1_rx);
  275. }
  276. void Uart_Mode_Init(void)
  277. {
  278. __HAL_UART_ENABLE_IT(&huart1, UART_IT_IDLE);
  279. __HAL_UART_ENABLE_IT(&huart1, UART_IT_RXNE);
  280. __HAL_UART_ENABLE_IT(&huart2, UART_IT_IDLE);
  281. __HAL_UART_ENABLE_IT(&huart2, UART_IT_RXNE);
  282. __HAL_UART_ENABLE_IT(&huart3, UART_IT_IDLE);
  283. __HAL_UART_ENABLE_IT(&huart3, UART_IT_RXNE);
  284. __HAL_UART_ENABLE_IT(&huart4, UART_IT_IDLE);
  285. __HAL_UART_ENABLE_IT(&huart4, UART_IT_RXNE);
  286. }
  287. /*****************************************************************
  288. * 串口2发送函数KeySlave485_Send_Data(uint8_t *buf,uint8_t len)
  289. ******************************************************************/
  290. void SendChar2 (uint8_t ch)
  291. {
  292. HAL_UART_Transmit(&huart2, &ch, 1, 0xffff);
  293. }
  294. void SendChar4 (uint8_t ch)
  295. {
  296. //KeySlave485_TX_Set(1);
  297. HAL_UART_Transmit(&huart4, &ch, 1, 1000);
  298. //KeySlave485_TX_Set(0);
  299. }
  300. /*****************************************************************
  301. * 串口发送数组函数
  302. ******************************************************************/
  303. void UartWrite(UART_HandleTypeDef *uartHandle, uint8_t *buf , uint8_t len)
  304. {
  305. uint8_t i;
  306. for(i = 0; i < len; i++)
  307. {
  308. HAL_UART_Transmit(uartHandle, &buf[i], 1, 0xFFFF);
  309. }
  310. }
  311. // 重定向函数1
  312. int fputc(int ch,FILE *f)
  313. {
  314. uint8_t temp[1]={ch};
  315. HAL_UART_Transmit(&huart4,temp,1,2); //
  316. return 0;
  317. }
  318. //16位modbusCRC校验
  319. uint16_t LIB_CRC_MODBUS(uint8_t* Buf, uint16_t srLen)
  320. {
  321. uint32_t srIndex;
  322. char ucHI = 0xFF;
  323. char ucLO = 0xFF;
  324. while(srLen--)
  325. {
  326. srIndex = ucHI ^ *Buf++;
  327. ucHI = ucLO ^ LIB_CRC_MODBUS_HI[srIndex];
  328. ucLO = LIB_CRC_MODBUS_LO[srIndex];
  329. }
  330. return ((uint16_t)ucHI<<8) + ucLO;
  331. }
  332. /* USER CODE END 1 */
  333. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/