You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

159 lines
6.9 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f7xx_hal_usart_ex.h
  4. * @author MCD Application Team
  5. * @version V1.1.2
  6. * @date 23-September-2016
  7. * @brief Header file of USART HAL Extension module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32F7xx_HAL_USART_EX_H
  39. #define __STM32F7xx_HAL_USART_EX_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32f7xx_hal_def.h"
  45. /** @addtogroup STM32F7xx_HAL_Driver
  46. * @{
  47. */
  48. /** @addtogroup USARTEx
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /* Exported constants --------------------------------------------------------*/
  53. /** @defgroup USARTEx_Exported_Constants USARTEx Exported Constants
  54. * @{
  55. */
  56. /** @defgroup USARTEx_Word_Length USARTEx Word Length
  57. * @{
  58. */
  59. #define USART_WORDLENGTH_7B ((uint32_t)USART_CR1_M_1)
  60. #define USART_WORDLENGTH_8B ((uint32_t)0x00000000U)
  61. #define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M_0)
  62. /**
  63. * @}
  64. */
  65. /**
  66. * @}
  67. */
  68. /* Exported functions --------------------------------------------------------*/
  69. /* Private macros ------------------------------------------------------------*/
  70. /** @defgroup USARTEx_Private_Macros USARTEx Private Macros
  71. * @{
  72. */
  73. /** @brief Computes the USART mask to apply to retrieve the received data
  74. * according to the word length and to the parity bits activation.
  75. * If PCE = 1, the parity bit is not included in the data extracted
  76. * by the reception API().
  77. * This masking operation is not carried out in the case of
  78. * DMA transfers.
  79. * @param __HANDLE__: specifies the USART Handle
  80. * @retval none
  81. */
  82. #define __HAL_USART_MASK_COMPUTATION(__HANDLE__) \
  83. do { \
  84. if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_9B) \
  85. { \
  86. if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
  87. { \
  88. (__HANDLE__)->Mask = 0x01FF ; \
  89. } \
  90. else \
  91. { \
  92. (__HANDLE__)->Mask = 0x00FF ; \
  93. } \
  94. } \
  95. else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_8B) \
  96. { \
  97. if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
  98. { \
  99. (__HANDLE__)->Mask = 0x00FF ; \
  100. } \
  101. else \
  102. { \
  103. (__HANDLE__)->Mask = 0x007F ; \
  104. } \
  105. } \
  106. else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_7B) \
  107. { \
  108. if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
  109. { \
  110. (__HANDLE__)->Mask = 0x007F ; \
  111. } \
  112. else \
  113. { \
  114. (__HANDLE__)->Mask = 0x003F ; \
  115. } \
  116. } \
  117. } while(0)
  118. #define IS_USART_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == USART_WORDLENGTH_7B) || \
  119. ((__LENGTH__) == USART_WORDLENGTH_8B) || \
  120. ((__LENGTH__) == USART_WORDLENGTH_9B))
  121. /**
  122. * @}
  123. */
  124. /* Exported functions --------------------------------------------------------*/
  125. /* Initialization/de-initialization methods **********************************/
  126. /* IO operation methods *******************************************************/
  127. /* Peripheral Control methods ************************************************/
  128. /* Peripheral State methods **************************************************/
  129. /**
  130. * @}
  131. */
  132. /**
  133. * @}
  134. */
  135. #ifdef __cplusplus
  136. }
  137. #endif
  138. #endif /* __STM32F7xx_HAL_USART_EX_H */
  139. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/