2 ******************************************************************************
3 * @file stm32f0xx_hal_uart_ex.c
4 * @author MCD Application Team
6 * @date 11-December-2014
7 * @brief Extended UART HAL module driver.
9 * This file provides firmware functions to manage the following extended
10 * functionalities of the Universal Asynchronous Receiver Transmitter Peripheral (UART).
11 * + Initialization and de-initialization functions
12 * + Peripheral Control functions
16 ===============================================================================
17 ##### How to use this driver #####
18 ===============================================================================
20 The Extended UART HAL driver can be used as follows:
22 (#) Declare a UART_HandleTypeDef handle structure.
24 (#) For the UART RS485 Driver Enabled mode, initialize the UART registers
25 by calling the HAL_RS485Ex_Init() API.
29 ******************************************************************************
32 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
34 * Redistribution and use in source and binary forms, with or without modification,
35 * are permitted provided that the following conditions are met:
36 * 1. Redistributions of source code must retain the above copyright notice,
37 * this list of conditions and the following disclaimer.
38 * 2. Redistributions in binary form must reproduce the above copyright notice,
39 * this list of conditions and the following disclaimer in the documentation
40 * and/or other materials provided with the distribution.
41 * 3. Neither the name of STMicroelectronics nor the names of its contributors
42 * may be used to endorse or promote products derived from this software
43 * without specific prior written permission.
45 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
46 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
51 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
52 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
53 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
54 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 ******************************************************************************
59 /* Includes ------------------------------------------------------------------*/
60 #include "stm32f0xx_hal.h"
62 /** @addtogroup STM32F0xx_HAL_Driver
66 /** @defgroup UARTEx UARTEx Extended HAL module driver
67 * @brief UART Extended HAL module driver
71 #ifdef HAL_UART_MODULE_ENABLED
73 /* Private typedef -----------------------------------------------------------*/
74 /* Private define ------------------------------------------------------------*/
75 /* Private macro -------------------------------------------------------------*/
76 /* Private variables ---------------------------------------------------------*/
77 /* Private function prototypes -----------------------------------------------*/
79 /** @defgroup UARTEx_Private_Functions UARTEx Private Functions
82 #if !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC)
83 static void UART_Wakeup_AddressConfig(UART_HandleTypeDef *huart, UART_WakeUpTypeDef WakeUpSelection);
84 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC) */
85 static HAL_StatusTypeDef UART_EndTransmit_IT(UART_HandleTypeDef *huart);
91 /* Exported functions ---------------------------------------------------------*/
93 /** @defgroup UARTEx_Exported_Functions UARTEx Exported Functions
97 /** @defgroup UARTEx_Exported_Functions_Group1 Extended Initialization/de-initialization functions
98 * @brief Extended Initialization and Configuration Functions
101 ===============================================================================
102 ##### Initialization and Configuration functions #####
103 ==============================================================================
105 This subsection provides a set of functions allowing to initialize the USARTx or the UARTy
106 in asynchronous mode.
107 (+) For the asynchronous mode only these parameters can be configured:
109 (++) Word Length (Fixed to 8-bits only for LIN mode)
111 (++) Parity: If the parity is enabled, then the MSB bit of the data written
112 in the data register is transmitted but is changed by the parity bit.
113 Depending on the frame length defined by the M bit (8-bits or 9-bits),
114 the possible UART frame formats are as listed in the following table:
115 |-----------|-----------|---------------------------------------|
116 | M1M0 bits | PCE bit | UART frame |
117 |-----------------------|---------------------------------------|
118 | 00 | 0 | | SB | 8-bit data | STB | |
119 |-----------|-----------|---------------------------------------|
120 | 00 | 1 | | SB | 7-bit data | PB | STB | |
121 |-----------|-----------|---------------------------------------|
122 | 01 | 0 | | SB | 9-bit data | STB | |
123 |-----------|-----------|---------------------------------------|
124 | 01 | 1 | | SB | 8-bit data | PB | STB | |
125 +---------------------------------------------------------------+
126 | 10 | 0 | | SB | 7-bit data | STB | |
127 |-----------|-----------|---------------------------------------|
128 | 10 | 1 | | SB | 6-bit data | PB | STB | |
129 +---------------------------------------------------------------+
130 (++) Hardware flow control
131 (++) Receiver/transmitter modes
132 (++) Over Sampling Method
133 (++) One-Bit Sampling Method
134 (+) For the asynchronous mode, the following advanced features can be configured as well:
135 (++) TX and/or RX pin level inversion
136 (++) data logical level inversion
137 (++) RX and TX pins swap
138 (++) RX overrun detection disabling
139 (++) DMA disabling on RX error
140 (++) MSB first on communication line
141 (++) auto Baud rate detection
143 The HAL_LIN_Init() and HAL_RS485Ex_Init() APIs follows respectively the LIN and
144 the UART RS485 mode configuration procedures (details for the procedures are
145 available in reference manual).
151 #if !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC)
153 * @brief Initializes the RS485 Driver enable feature according to the specified
154 * parameters in the UART_InitTypeDef and creates the associated handle .
155 * @param huart: uart handle
156 * @param UART_DEPolarity: select the driver enable polarity
157 * This parameter can be one of the following values:
158 * @arg UART_DE_POLARITY_HIGH: DE signal is active high
159 * @arg UART_DE_POLARITY_LOW: DE signal is active low
160 * @param UART_DEAssertionTime: Driver Enable assertion time
161 * 5-bit value defining the time between the activation of the DE (Driver Enable)
162 * signal and the beginning of the start bit. It is expressed in sample time
163 * units (1/8 or 1/16 bit time, depending on the oversampling rate)
164 * @param UART_DEDeassertionTime: Driver Enable deassertion time
165 * 5-bit value defining the time between the end of the last stop bit, in a
166 * transmitted message, and the de-activation of the DE (Driver Enable) signal.
167 * It is expressed in sample time units (1/8 or 1/16 bit time, depending on the
168 * oversampling rate).
171 HAL_StatusTypeDef HAL_RS485Ex_Init(UART_HandleTypeDef *huart, uint32_t UART_DEPolarity, uint32_t UART_DEAssertionTime, uint32_t UART_DEDeassertionTime)
175 /* Check the UART handle allocation */
180 /* Check the Driver Enable UART instance */
181 assert_param(IS_UART_DRIVER_ENABLE_INSTANCE(huart->Instance));
183 /* Check the Driver Enable polarity */
184 assert_param(IS_UART_DE_POLARITY(UART_DEPolarity));
186 /* Check the Driver Enable assertion time */
187 assert_param(IS_UART_ASSERTIONTIME(UART_DEAssertionTime));
189 /* Check the Driver Enable deassertion time */
190 assert_param(IS_UART_DEASSERTIONTIME(UART_DEDeassertionTime));
192 if(huart->State == HAL_UART_STATE_RESET)
194 /* Init the low level hardware : GPIO, CLOCK */
195 HAL_UART_MspInit(huart);
198 huart->State = HAL_UART_STATE_BUSY;
200 /* Disable the Peripheral */
201 __HAL_UART_DISABLE(huart);
203 /* Set the UART Communication parameters */
204 if (UART_SetConfig(huart) == HAL_ERROR)
209 if (huart->AdvancedInit.AdvFeatureInit != UART_ADVFEATURE_NO_INIT)
211 UART_AdvFeatureConfig(huart);
214 /* Enable the Driver Enable mode by setting the DEM bit in the CR3 register */
215 huart->Instance->CR3 |= USART_CR3_DEM;
217 /* Set the Driver Enable polarity */
218 MODIFY_REG(huart->Instance->CR3, USART_CR3_DEP, UART_DEPolarity);
220 /* Set the Driver Enable assertion and deassertion times */
221 temp = (UART_DEAssertionTime << UART_CR1_DEAT_ADDRESS_LSB_POS);
222 temp |= (UART_DEDeassertionTime << UART_CR1_DEDT_ADDRESS_LSB_POS);
223 MODIFY_REG(huart->Instance->CR1, (USART_CR1_DEDT|USART_CR1_DEAT), temp);
225 /* Enable the Peripheral */
226 __HAL_UART_ENABLE(huart);
228 /* TEACK and/or REACK to check before moving huart->State to Ready */
229 return (UART_CheckIdleState(huart));
231 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC)*/
233 #if !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC)
235 * @brief Initializes the LIN mode according to the specified
236 * parameters in the UART_InitTypeDef and creates the associated handle.
237 * @param huart: uart handle
238 * @param BreakDetectLength: specifies the LIN break detection length.
239 * This parameter can be one of the following values:
240 * @arg UART_LINBREAKDETECTLENGTH_10B: 10-bit break detection
241 * @arg UART_LINBREAKDETECTLENGTH_11B: 11-bit break detection
244 HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength)
246 /* Check the UART handle allocation */
252 /* Check the parameters */
253 assert_param(IS_UART_LIN_INSTANCE(huart->Instance));
254 assert_param(IS_UART_LIN_BREAK_DETECT_LENGTH(BreakDetectLength));
256 /* LIN mode limited to 16-bit oversampling only */
257 if(huart->Init.OverSampling == UART_OVERSAMPLING_8)
262 /* in LIN mode, data length is limited to 8-bit only */
263 if(huart->Init.WordLength!= UART_WORDLENGTH_8B)
268 /* Init the low level hardware : GPIO, CLOCK, CORTEX */
269 HAL_UART_MspInit(huart);
271 /* Disable the Peripheral */
272 __HAL_UART_DISABLE(huart);
274 /* Set the UART Communication parameters */
275 if (UART_SetConfig(huart) == HAL_ERROR)
280 if (huart->AdvancedInit.AdvFeatureInit != UART_ADVFEATURE_NO_INIT)
282 UART_AdvFeatureConfig(huart);
285 /* In LIN mode, the following bits must be kept cleared:
286 - LINEN and CLKEN bits in the USART_CR2 register,
287 - SCEN and IREN bits in the USART_CR3 register.*/
288 huart->Instance->CR2 &= ~(USART_CR2_CLKEN);
289 huart->Instance->CR3 &= ~(USART_CR3_HDSEL | USART_CR3_IREN | USART_CR3_SCEN);
291 /* Enable the LIN mode by setting the LINEN bit in the CR2 register */
292 huart->Instance->CR2 |= USART_CR2_LINEN;
294 /* Set the USART LIN Break detection length. */
295 MODIFY_REG(huart->Instance->CR2, USART_CR2_LBDL, BreakDetectLength);
297 /* Enable the Peripheral */
298 __HAL_UART_ENABLE(huart);
300 /* TEACK and/or REACK to check before moving huart->State to Ready */
301 return (UART_CheckIdleState(huart));
303 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC) */
308 /** @defgroup UARTEx_Exported_Functions_Group2 Extended IO operation function
309 * @brief Extended UART Interrupt handling function
312 ===============================================================================
313 ##### IO operation function #####
314 ===============================================================================
316 This subsection provides functions allowing to manage the UART interrupts
317 and to handle Wake up interrupt call-back.
319 (#) Non-Blocking mode API with Interrupt is :
320 (++) HAL_UART_IRQHandler()
322 (#) Callback provided in No_Blocking mode:
323 (++) HAL_UART_WakeupCallback()
331 * @brief This function handles UART interrupt request.
332 * @param huart: uart handle
335 void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
337 /* UART parity error interrupt occurred -------------------------------------*/
338 if((__HAL_UART_GET_IT(huart, UART_IT_PE) != RESET) && (__HAL_UART_GET_IT_SOURCE(huart, UART_IT_PE) != RESET))
340 __HAL_UART_CLEAR_IT(huart, UART_CLEAR_PEF);
342 huart->ErrorCode |= HAL_UART_ERROR_PE;
343 /* Set the UART state ready to be able to start again the process */
344 huart->State = HAL_UART_STATE_READY;
347 /* UART frame error interrupt occured --------------------------------------*/
348 if((__HAL_UART_GET_IT(huart, UART_IT_FE) != RESET) && (__HAL_UART_GET_IT_SOURCE(huart, UART_IT_ERR) != RESET))
350 __HAL_UART_CLEAR_IT(huart, UART_CLEAR_FEF);
352 huart->ErrorCode |= HAL_UART_ERROR_FE;
353 /* Set the UART state ready to be able to start again the process */
354 huart->State = HAL_UART_STATE_READY;
357 /* UART noise error interrupt occured --------------------------------------*/
358 if((__HAL_UART_GET_IT(huart, UART_IT_NE) != RESET) && (__HAL_UART_GET_IT_SOURCE(huart, UART_IT_ERR) != RESET))
360 __HAL_UART_CLEAR_IT(huart, UART_CLEAR_NEF);
362 huart->ErrorCode |= HAL_UART_ERROR_NE;
363 /* Set the UART state ready to be able to start again the process */
364 huart->State = HAL_UART_STATE_READY;
367 /* UART Over-Run interrupt occured -----------------------------------------*/
368 if((__HAL_UART_GET_IT(huart, UART_IT_ORE) != RESET) && (__HAL_UART_GET_IT_SOURCE(huart, UART_IT_ERR) != RESET))
370 __HAL_UART_CLEAR_IT(huart, UART_CLEAR_OREF);
372 huart->ErrorCode |= HAL_UART_ERROR_ORE;
373 /* Set the UART state ready to be able to start again the process */
374 huart->State = HAL_UART_STATE_READY;
377 /* Call UART Error Call back function if need be --------------------------*/
378 if(huart->ErrorCode != HAL_UART_ERROR_NONE)
380 HAL_UART_ErrorCallback(huart);
383 #if !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC)
384 /* UART wakeup from Stop mode interrupt occurred -------------------------------------*/
385 if((__HAL_UART_GET_IT(huart, UART_IT_WUF) != RESET) && (__HAL_UART_GET_IT_SOURCE(huart, UART_IT_WUF) != RESET))
387 __HAL_UART_CLEAR_IT(huart, UART_CLEAR_WUF);
388 /* Set the UART state ready to be able to start again the process */
389 huart->State = HAL_UART_STATE_READY;
390 HAL_UART_WakeupCallback(huart);
392 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC) */
394 /* UART in mode Receiver ---------------------------------------------------*/
395 if((__HAL_UART_GET_IT(huart, UART_IT_RXNE) != RESET) && (__HAL_UART_GET_IT_SOURCE(huart, UART_IT_RXNE) != RESET))
397 UART_Receive_IT(huart);
398 /* Clear RXNE interrupt flag */
399 __HAL_UART_SEND_REQ(huart, UART_RXDATA_FLUSH_REQUEST);
403 /* UART in mode Transmitter ------------------------------------------------*/
404 if((__HAL_UART_GET_IT(huart, UART_IT_TXE) != RESET) &&(__HAL_UART_GET_IT_SOURCE(huart, UART_IT_TXE) != RESET))
406 UART_Transmit_IT(huart);
409 /* UART in mode Transmitter ------------------------------------------------*/
410 if((__HAL_UART_GET_IT(huart, UART_IT_TC) != RESET) &&(__HAL_UART_GET_IT_SOURCE(huart, UART_IT_TC) != RESET))
412 UART_EndTransmit_IT(huart);
416 #if !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC)
418 * @brief UART wakeup from Stop mode callback
419 * @param huart: uart handle
422 __weak void HAL_UART_WakeupCallback(UART_HandleTypeDef *huart)
424 /* NOTE : This function should not be modified, when the callback is needed,
425 the HAL_UART_WakeupCallback can be implemented in the user file
428 #endif /*!defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC)*/
435 /** @defgroup UARTEx_Exported_Functions_Group3 Extended Peripheral Control functions
436 * @brief Extended Peripheral Control functions
439 ===============================================================================
440 ##### Peripheral Control function #####
441 ===============================================================================
443 This subsection provides extended functions allowing to control the UART.
444 (+) HAL_MultiProcessorEx_AddressLength_Set() API optionally sets the UART node address
445 detection length to more than 4 bits for multiprocessor address mark wake up.
446 (+) HAL_UARTEx_StopModeWakeUpSourceConfig() API sets Wakeup from Stop mode interrupt flag selection
447 (+) HAL_UARTEx_EnableStopMode() API allows the UART to wake up the MCU from Stop mode as
448 long as UART clock is HSI or LSE
449 (+) HAL_UARTEx_DisableStopMode() API disables the above feature
450 (+) HAL_LIN_SendBreak() API transmits the break characters
456 #if !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC)
458 * @brief Set Wakeup from Stop mode interrupt flag selection
459 * @param huart: uart handle,
460 * @param WakeUpSelection: address match, Start Bit detection or RXNE bit status.
461 * This parameter can be one of the following values:
462 * @arg UART_WAKEUP_ON_ADDRESS
463 * @arg UART_WAKEUP_ON_STARTBIT
464 * @arg UART_WAKEUP_ON_READDATA_NONEMPTY
467 HAL_StatusTypeDef HAL_UARTEx_StopModeWakeUpSourceConfig(UART_HandleTypeDef *huart, UART_WakeUpTypeDef WakeUpSelection)
469 /* Check parameters */
470 assert_param(IS_UART_WAKEUP_INSTANCE(huart->Instance));
471 assert_param(IS_UART_WAKEUP_SELECTION(WakeUpSelection.WakeUpEvent));
476 huart->State = HAL_UART_STATE_BUSY;
478 /* Disable the Peripheral */
479 __HAL_UART_DISABLE(huart);
481 /* Set the wake-up selection scheme */
482 MODIFY_REG(huart->Instance->CR3, USART_CR3_WUS, WakeUpSelection.WakeUpEvent);
484 if (WakeUpSelection.WakeUpEvent == UART_WAKEUP_ON_ADDRESS)
486 UART_Wakeup_AddressConfig(huart, WakeUpSelection);
489 /* Enable the Peripheral */
490 __HAL_UART_ENABLE(huart);
492 /* Wait until REACK flag is set */
493 if(UART_WaitOnFlagUntilTimeout(huart, USART_ISR_REACK, RESET, HAL_UART_TIMEOUT_VALUE) != HAL_OK)
499 /* Initialize the UART State */
500 huart->State= HAL_UART_STATE_READY;
501 /* Process Unlocked */
508 * @brief Enable UART Stop Mode
509 * The UART is able to wake up the MCU from Stop mode as long as UART clock is HSI or LSE
510 * @param huart: uart handle
513 HAL_StatusTypeDef HAL_UARTEx_EnableStopMode(UART_HandleTypeDef *huart)
515 /* Check parameter */
516 assert_param(IS_UART_WAKEUP_INSTANCE(huart->Instance));
521 huart->State = HAL_UART_STATE_BUSY;
523 /* Set the USART UESM bit */
524 huart->Instance->CR1 |= USART_CR1_UESM;
526 huart->State = HAL_UART_STATE_READY;
528 /* Process Unlocked */
535 * @brief Disable UART Stop Mode
536 * @param huart: uart handle
539 HAL_StatusTypeDef HAL_UARTEx_DisableStopMode(UART_HandleTypeDef *huart)
541 /* Check parameter */
542 assert_param(IS_UART_WAKEUP_INSTANCE(huart->Instance));
547 huart->State = HAL_UART_STATE_BUSY;
549 /* Clear USART UESM bit */
550 huart->Instance->CR1 &= ~(USART_CR1_UESM);
552 huart->State = HAL_UART_STATE_READY;
554 /* Process Unlocked */
560 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC) */
563 * @brief By default in multiprocessor mode, when the wake up method is set
564 * to address mark, the UART handles only 4-bit long addresses detection.
565 * This API allows to enable longer addresses detection (6-, 7- or 8-bit
567 * - 6-bit address detection in 7-bit data mode
568 * - 7-bit address detection in 8-bit data mode
569 * - 8-bit address detection in 9-bit data mode
570 * @param huart: UART handle
571 * @param AddressLength: this parameter can be one of the following values:
572 * @arg UART_ADDRESS_DETECT_4B: 4-bit long address
573 * @arg UART_ADDRESS_DETECT_7B: 6-, 7- or 8-bit long address
576 HAL_StatusTypeDef HAL_MultiProcessorEx_AddressLength_Set(UART_HandleTypeDef *huart, uint32_t AddressLength)
578 /* Check the UART handle allocation */
584 /* Check the address length parameter */
585 assert_param(IS_UART_ADDRESSLENGTH_DETECT(AddressLength));
587 huart->State = HAL_UART_STATE_BUSY;
589 /* Disable the Peripheral */
590 __HAL_UART_DISABLE(huart);
592 /* Set the address length */
593 MODIFY_REG(huart->Instance->CR2, USART_CR2_ADDM7, AddressLength);
595 /* Enable the Peripheral */
596 __HAL_UART_ENABLE(huart);
598 /* TEACK and/or REACK to check before moving huart->State to Ready */
599 return (UART_CheckIdleState(huart));
603 #if !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC)
605 * @brief Transmits break characters.
606 * @param huart: UART handle
609 HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart)
611 /* Check the parameters */
612 assert_param(IS_UART_INSTANCE(huart->Instance));
617 huart->State = HAL_UART_STATE_BUSY;
619 /* Send break characters */
620 huart->Instance->RQR |= UART_SENDBREAK_REQUEST;
622 huart->State = HAL_UART_STATE_READY;
624 /* Process Unlocked */
630 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC) */
640 /** @addtogroup UARTEx_Private_Functions
645 * @brief Wraps up transmission in non blocking mode.
646 * @param huart: pointer to a UART_HandleTypeDef structure that contains
647 * the configuration information for the specified UART module.
650 static HAL_StatusTypeDef UART_EndTransmit_IT(UART_HandleTypeDef *huart)
652 /* Disable the UART Transmit Complete Interrupt */
653 __HAL_UART_DISABLE_IT(huart, UART_IT_TC);
655 /* Check if a receive process is ongoing or not */
656 if(huart->State == HAL_UART_STATE_BUSY_TX_RX)
658 huart->State = HAL_UART_STATE_BUSY_RX;
662 /* Disable the UART Error Interrupt: (Frame error, noise error, overrun error) */
663 __HAL_UART_DISABLE_IT(huart, UART_IT_ERR);
665 huart->State = HAL_UART_STATE_READY;
668 HAL_UART_TxCpltCallback(huart);
673 #if !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC)
675 * @brief Initializes the UART wake-up from stop mode parameters when triggered by address detection.
676 * @param huart: uart handle
677 * @param WakeUpSelection: UART wake up from stop mode parameters
680 static void UART_Wakeup_AddressConfig(UART_HandleTypeDef *huart, UART_WakeUpTypeDef WakeUpSelection)
682 /* Check parmeters */
683 assert_param(IS_UART_WAKEUP_INSTANCE(huart->Instance));
684 assert_param(IS_UART_ADDRESSLENGTH_DETECT(WakeUpSelection.AddressLength));
686 /* Set the USART address length */
687 MODIFY_REG(huart->Instance->CR2, USART_CR2_ADDM7, WakeUpSelection.AddressLength);
689 /* Set the USART address node */
690 MODIFY_REG(huart->Instance->CR2, USART_CR2_ADD, ((uint32_t)WakeUpSelection.Address << UART_CR2_ADDRESS_LSB_POS));
692 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC) */
698 #endif /* HAL_UART_MODULE_ENABLED */
708 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/