source: rtems/c/src/lib/libbsp/arm/stm32f7x/hal/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_irda_ex.h @ c20847a5

5
Last change on this file since c20847a5 was c20847a5, checked in by Isaac Gutekunst <isaac.gutekunst@…>, on 09/16/15 at 13:16:02

Add STM32F7 HAL Files

These files originated as:

+ STC32CubeF7 V1.1.0 from http://www.st.com/web/en/catalog/tools/PF261909

  • Property mode set to 100644
File size: 11.7 KB
Line 
1/**
2  ******************************************************************************
3  * @file    stm32f7xx_hal_irda_ex.h
4  * @author  MCD Application Team
5  * @version V1.0.1
6  * @date    25-June-2015
7  * @brief   Header file of IRDA HAL Extension module.
8  ******************************************************************************
9  * @attention
10  *
11  * <h2><center>&copy; COPYRIGHT(c) 2015 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
38/* Define to prevent recursive inclusion -------------------------------------*/
39#ifndef __STM32F7xx_HAL_IRDA_EX_H
40#define __STM32F7xx_HAL_IRDA_EX_H
41
42#ifdef __cplusplus
43 extern "C" {
44#endif
45
46/* Includes ------------------------------------------------------------------*/
47#include "stm32f7xx_hal_def.h"
48
49/** @addtogroup STM32F7xx_HAL_Driver
50  * @{
51  */
52
53/** @addtogroup IRDAEx
54  * @{
55  */
56
57/* Exported types ------------------------------------------------------------*/
58/* Exported constants --------------------------------------------------------*/
59/** @defgroup IRDAEx_Extended_Exported_Constants IRDAEx Extended Exported Constants
60  * @{
61  */
62
63/** @defgroup IRDAEx_Word_Length IRDAEx Word Length
64  * @{
65  */
66#define IRDA_WORDLENGTH_7B                  ((uint32_t)USART_CR1_M_1)
67#define IRDA_WORDLENGTH_8B                  ((uint32_t)0x00000000)
68#define IRDA_WORDLENGTH_9B                  ((uint32_t)USART_CR1_M_0)
69/**
70  * @}
71  */
72
73
74/**
75  * @}
76  */
77
78/* Exported macro ------------------------------------------------------------*/
79
80/* Private macros ------------------------------------------------------------*/
81
82/** @defgroup IRDAEx_Private_Macros IRDAEx Private Macros
83  * @{
84  */
85/** @brief  Reports the IRDA clock source.
86  * @param  __HANDLE__: specifies the IRDA Handle
87  * @param  __CLOCKSOURCE__ : output variable
88  * @retval IRDA clocking source, written in __CLOCKSOURCE__.
89  */
90#define IRDA_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__)       \
91  do {                                                        \
92    if((__HANDLE__)->Instance == USART1)                      \
93    {                                                         \
94       switch(__HAL_RCC_GET_USART1_SOURCE())                  \
95       {                                                      \
96        case RCC_USART1CLKSOURCE_PCLK2:                       \
97          (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK2;         \
98          break;                                              \
99        case RCC_USART1CLKSOURCE_HSI:                         \
100          (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;           \
101          break;                                              \
102        case RCC_USART1CLKSOURCE_SYSCLK:                      \
103          (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK;        \
104          break;                                              \
105        case RCC_USART1CLKSOURCE_LSE:                         \
106          (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;           \
107          break;                                              \
108        default:                                              \
109          break;                                              \
110       }                                                      \
111    }                                                         \
112    else if((__HANDLE__)->Instance == USART2)                 \
113    {                                                         \
114       switch(__HAL_RCC_GET_USART2_SOURCE())                  \
115       {                                                      \
116        case RCC_USART2CLKSOURCE_PCLK1:                       \
117          (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1;         \
118          break;                                              \
119        case RCC_USART2CLKSOURCE_HSI:                         \
120          (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;           \
121          break;                                              \
122        case RCC_USART2CLKSOURCE_SYSCLK:                      \
123          (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK;        \
124          break;                                              \
125        case RCC_USART2CLKSOURCE_LSE:                         \
126          (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;           \
127          break;                                              \
128        default:                                              \
129          break;                                              \
130       }                                                      \
131    }                                                         \
132    else if((__HANDLE__)->Instance == USART3)                 \
133    {                                                         \
134       switch(__HAL_RCC_GET_USART3_SOURCE())                  \
135       {                                                      \
136        case RCC_USART3CLKSOURCE_PCLK1:                       \
137          (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK1;         \
138          break;                                              \
139        case RCC_USART3CLKSOURCE_HSI:                         \
140          (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;           \
141          break;                                              \
142        case RCC_USART3CLKSOURCE_SYSCLK:                      \
143          (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK;        \
144          break;                                              \
145        case RCC_USART3CLKSOURCE_LSE:                         \
146          (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;           \
147          break;                                              \
148        default:                                              \
149          break;                                              \
150       }                                                      \
151    }                                                         \
152    else if((__HANDLE__)->Instance == USART6)                 \
153    {                                                         \
154       switch(__HAL_RCC_GET_USART6_SOURCE())                  \
155       {                                                      \
156        case RCC_USART6CLKSOURCE_PCLK2:                       \
157          (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PCLK2;         \
158          break;                                              \
159        case RCC_USART6CLKSOURCE_HSI:                         \
160          (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI;           \
161          break;                                              \
162        case RCC_USART6CLKSOURCE_SYSCLK:                      \
163          (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_SYSCLK;        \
164          break;                                              \
165        case RCC_USART6CLKSOURCE_LSE:                         \
166          (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE;           \
167          break;                                              \
168        default:                                              \
169          break;                                              \
170       }                                                      \
171    }                                                         \
172        } while(0)
173
174/** @brief  Reports the mask to apply to retrieve the received data
175  *         according to the word length and to the parity bits activation.
176  * @param  __HANDLE__: specifies the IRDA Handle
177  * @retval mask to apply to USART RDR register value.
178  */
179#define IRDA_MASK_COMPUTATION(__HANDLE__)                       \
180  do {                                                                \
181  if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_9B)            \
182  {                                                                   \
183     if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE)               \
184     {                                                                \
185        (__HANDLE__)->Mask = 0x01FF ;                                 \
186     }                                                                \
187     else                                                             \
188     {                                                                \
189        (__HANDLE__)->Mask = 0x00FF ;                                 \
190     }                                                                \
191  }                                                                   \
192  else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_8B)       \
193  {                                                                   \
194     if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE)               \
195     {                                                                \
196        (__HANDLE__)->Mask = 0x00FF ;                                 \
197     }                                                                \
198     else                                                             \
199     {                                                                \
200        (__HANDLE__)->Mask = 0x007F ;                                 \
201     }                                                                \
202  }                                                                   \
203  else if ((__HANDLE__)->Init.WordLength == IRDA_WORDLENGTH_7B)       \
204  {                                                                   \
205     if ((__HANDLE__)->Init.Parity == IRDA_PARITY_NONE)               \
206     {                                                                \
207        (__HANDLE__)->Mask = 0x007F ;                                 \
208     }                                                                \
209     else                                                             \
210     {                                                                \
211        (__HANDLE__)->Mask = 0x003F ;                                 \
212     }                                                                \
213  }                                                                   \
214} while(0)
215
216#define IS_IRDA_WORD_LENGTH(LENGTH) (((LENGTH) == IRDA_WORDLENGTH_7B) || \
217                                     ((LENGTH) == IRDA_WORDLENGTH_8B) || \
218                                     ((LENGTH) == IRDA_WORDLENGTH_9B))
219/**
220  * @}
221  */
222
223/* Exported functions --------------------------------------------------------*/
224
225/**
226  * @}
227  */
228
229/**
230  * @}
231  */
232
233#ifdef __cplusplus
234}
235#endif
236
237#endif /* __STM32F7xx_HAL_IRDA_EX_H */
238
239/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Note: See TracBrowser for help on using the repository browser.