Mercurial > public > ostc4
comparison Common/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c @ 918:f72613a152dd Evo_2_23
Switch external interface tx communication to DMA:
In the previous version the transmitting of data was done in polling mode. With the introduction of new sensors the length of commands send to the sensor may increase and have a impact to the runtim behavior of the SW. To avoid this the DMA transfers for TX has been activated.
author | Ideenmodellierer |
---|---|
date | Sun, 03 Nov 2024 15:40:55 +0100 |
parents | c78bcbd5deda |
children |
comparison
equal
deleted
inserted
replaced
917:0d6c4b40fae4 | 918:f72613a152dd |
---|---|
180 */ | 180 */ |
181 static void UART_EndTxTransfer(UART_HandleTypeDef *huart); | 181 static void UART_EndTxTransfer(UART_HandleTypeDef *huart); |
182 static void UART_EndRxTransfer(UART_HandleTypeDef *huart); | 182 static void UART_EndRxTransfer(UART_HandleTypeDef *huart); |
183 static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma); | 183 static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma); |
184 static void UART_DMAReceiveCplt(DMA_HandleTypeDef *hdma); | 184 static void UART_DMAReceiveCplt(DMA_HandleTypeDef *hdma); |
185 static void UART_DMATxHalfCplt(DMA_HandleTypeDef *hdma); | |
186 static void UART_DMARxHalfCplt(DMA_HandleTypeDef *hdma); | |
187 static void UART_DMAError(DMA_HandleTypeDef *hdma); | 185 static void UART_DMAError(DMA_HandleTypeDef *hdma); |
188 static void UART_DMAAbortOnError(DMA_HandleTypeDef *hdma); | 186 static void UART_DMAAbortOnError(DMA_HandleTypeDef *hdma); |
189 static void UART_DMATxAbortCallback(DMA_HandleTypeDef *hdma); | 187 static void UART_DMATxAbortCallback(DMA_HandleTypeDef *hdma); |
190 static void UART_DMARxAbortCallback(DMA_HandleTypeDef *hdma); | 188 static void UART_DMARxAbortCallback(DMA_HandleTypeDef *hdma); |
191 static void UART_DMATxOnlyAbortCallback(DMA_HandleTypeDef *hdma); | 189 static void UART_DMATxOnlyAbortCallback(DMA_HandleTypeDef *hdma); |
894 | 892 |
895 /* Set the UART DMA transfer complete callback */ | 893 /* Set the UART DMA transfer complete callback */ |
896 huart->hdmatx->XferCpltCallback = UART_DMATransmitCplt; | 894 huart->hdmatx->XferCpltCallback = UART_DMATransmitCplt; |
897 | 895 |
898 /* Set the UART DMA Half transfer complete callback */ | 896 /* Set the UART DMA Half transfer complete callback */ |
899 huart->hdmatx->XferHalfCpltCallback = UART_DMATxHalfCplt; | 897 huart->hdmatx->XferHalfCpltCallback = NULL; |
900 | 898 |
901 /* Set the DMA error callback */ | 899 /* Set the DMA error callback */ |
902 huart->hdmatx->XferErrorCallback = UART_DMAError; | 900 huart->hdmatx->XferErrorCallback = UART_DMAError; |
903 | 901 |
904 /* Set the DMA abort callback */ | 902 /* Set the DMA abort callback */ |
958 | 956 |
959 /* Set the UART DMA transfer complete callback */ | 957 /* Set the UART DMA transfer complete callback */ |
960 huart->hdmarx->XferCpltCallback = UART_DMAReceiveCplt; | 958 huart->hdmarx->XferCpltCallback = UART_DMAReceiveCplt; |
961 | 959 |
962 /* Set the UART DMA Half transfer complete callback */ | 960 /* Set the UART DMA Half transfer complete callback */ |
963 huart->hdmarx->XferHalfCpltCallback = UART_DMARxHalfCplt; | 961 huart->hdmarx->XferHalfCpltCallback = NULL; |
964 | 962 |
965 /* Set the DMA error callback */ | 963 /* Set the DMA error callback */ |
966 huart->hdmarx->XferErrorCallback = UART_DMAError; | 964 huart->hdmarx->XferErrorCallback = UART_DMAError; |
967 | 965 |
968 /* Set the DMA abort callback */ | 966 /* Set the DMA abort callback */ |
2010 { | 2008 { |
2011 HAL_UART_TxCpltCallback(huart); | 2009 HAL_UART_TxCpltCallback(huart); |
2012 } | 2010 } |
2013 } | 2011 } |
2014 | 2012 |
2013 #ifdef HALF_COMPLETE_NEEDED | |
2015 /** | 2014 /** |
2016 * @brief DMA UART transmit process half complete callback | 2015 * @brief DMA UART transmit process half complete callback |
2017 * @param hdma pointer to a DMA_HandleTypeDef structure that contains | 2016 * @param hdma pointer to a DMA_HandleTypeDef structure that contains |
2018 * the configuration information for the specified DMA module. | 2017 * the configuration information for the specified DMA module. |
2019 * @retval None | 2018 * @retval None |
2022 { | 2021 { |
2023 UART_HandleTypeDef* huart = (UART_HandleTypeDef*)((DMA_HandleTypeDef*)hdma)->Parent; | 2022 UART_HandleTypeDef* huart = (UART_HandleTypeDef*)((DMA_HandleTypeDef*)hdma)->Parent; |
2024 | 2023 |
2025 HAL_UART_TxHalfCpltCallback(huart); | 2024 HAL_UART_TxHalfCpltCallback(huart); |
2026 } | 2025 } |
2027 | 2026 #endif |
2028 /** | 2027 /** |
2029 * @brief DMA UART receive process complete callback. | 2028 * @brief DMA UART receive process complete callback. |
2030 * @param hdma DMA handle | 2029 * @param hdma DMA handle |
2031 * @retval None | 2030 * @retval None |
2032 */ | 2031 */ |
2056 * @brief DMA UART receive process half complete callback | 2055 * @brief DMA UART receive process half complete callback |
2057 * @param hdma pointer to a DMA_HandleTypeDef structure that contains | 2056 * @param hdma pointer to a DMA_HandleTypeDef structure that contains |
2058 * the configuration information for the specified DMA module. | 2057 * the configuration information for the specified DMA module. |
2059 * @retval None | 2058 * @retval None |
2060 */ | 2059 */ |
2060 #if 0 | |
2061 static void UART_DMARxHalfCplt(DMA_HandleTypeDef *hdma) | 2061 static void UART_DMARxHalfCplt(DMA_HandleTypeDef *hdma) |
2062 { | 2062 { |
2063 UART_HandleTypeDef* huart = (UART_HandleTypeDef*)((DMA_HandleTypeDef*)hdma)->Parent; | 2063 UART_HandleTypeDef* huart = (UART_HandleTypeDef*)((DMA_HandleTypeDef*)hdma)->Parent; |
2064 | 2064 |
2065 HAL_UART_RxHalfCpltCallback(huart); | 2065 HAL_UART_RxHalfCpltCallback(huart); |
2066 } | 2066 } |
2067 #endif | |
2067 | 2068 |
2068 /** | 2069 /** |
2069 * @brief DMA UART communication error callback. | 2070 * @brief DMA UART communication error callback. |
2070 * @param hdma DMA handle | 2071 * @param hdma DMA handle |
2071 * @retval None | 2072 * @retval None |