annotate Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src/stm32f4xx_hal_irda.c @ 59:00e70b60c69f

language updates
author heinrichsweikamp
date Fri, 10 Aug 2018 19:22:12 +0200
parents 5f11787b4f42
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @file stm32f4xx_hal_irda.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @author MCD Application Team
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @version V1.2.0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @date 26-December-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @brief IRDA HAL module driver.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 * This file provides firmware functions to manage the following
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 * functionalities of the IrDA SIR ENDEC block (IrDA):
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 * + Initialization and de-initialization methods
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 * + IO operation methods
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 * + Peripheral Control methods
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 ##### How to use this driver #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 The IRDA HAL driver can be used as follows:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 (#) Declare a IRDA_HandleTypeDef handle structure.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 (#) Initialize the IRDA low level resources by implementing the HAL_IRDA_MspInit() API:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 (##) Enable the USARTx interface clock.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 (##) IRDA pins configuration:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 (+++) Enable the clock for the IRDA GPIOs.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 (+++) Configure these IRDA pins as alternate function pull-up.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 (##) NVIC configuration if you need to use interrupt process (HAL_IRDA_Transmit_IT()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 and HAL_IRDA_Receive_IT() APIs):
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 (+++) Configure the USARTx interrupt priority.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 (+++) Enable the NVIC USART IRQ handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 (##) DMA Configuration if you need to use DMA process (HAL_IRDA_Transmit_DMA()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 and HAL_IRDA_Receive_DMA() APIs):
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 (+++) Declare a DMA handle structure for the Tx/Rx stream.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 (+++) Enable the DMAx interface clock.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 (+++) Configure the declared DMA handle structure with the required Tx/Rx parameters.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 (+++) Configure the DMA Tx/Rx Stream.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 (+++) Associate the initialized DMA handle to the IRDA DMA Tx/Rx handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx/Rx Stream.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 (#) Program the Baud Rate, Word Length, Parity, IrDA Mode, Prescaler
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 and Mode(Receiver/Transmitter) in the hirda Init structure.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 (#) Initialize the IRDA registers by calling the HAL_IRDA_Init() API:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 (++) This API configures also the low level Hardware GPIO, CLOCK, CORTEX...etc)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 by calling the customized HAL_IRDA_MspInit() API.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 -@@- The specific IRDA interrupts (Transmission complete interrupt,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 RXNE interrupt and Error Interrupts) will be managed using the macros
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 __HAL_IRDA_ENABLE_IT() and __HAL_IRDA_DISABLE_IT() inside the transmit and receive process.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 (#) Three operation modes are available within this driver :
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 *** Polling mode IO operation ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 =================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 (+) Send an amount of data in blocking mode using HAL_IRDA_Transmit()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 (+) Receive an amount of data in blocking mode using HAL_IRDA_Receive()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 *** Interrupt mode IO operation ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 ===================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 (+) Send an amount of data in non blocking mode using HAL_IRDA_Transmit_IT()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 (+) At transmission end of transfer HAL_IRDA_TxCpltCallback is executed and user can
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 add his own code by customization of function pointer HAL_IRDA_TxCpltCallback
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 (+) Receive an amount of data in non blocking mode using HAL_IRDA_Receive_IT()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 (+) At reception end of transfer HAL_IRDA_RxCpltCallback is executed and user can
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 add his own code by customization of function pointer HAL_IRDA_RxCpltCallback
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 (+) In case of transfer Error, HAL_IRDA_ErrorCallback() function is executed and user can
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 add his own code by customization of function pointer HAL_IRDA_ErrorCallback
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 *** DMA mode IO operation ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 =============================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 (+) Send an amount of data in non blocking mode (DMA) using HAL_IRDA_Transmit_DMA()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 (+) At transmission end of transfer HAL_IRDA_TxCpltCallback is executed and user can
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 add his own code by customization of function pointer HAL_IRDA_TxCpltCallback
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 (+) Receive an amount of data in non blocking mode (DMA) using HAL_IRDA_Receive_DMA()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 (+) At reception end of transfer HAL_IRDA_RxCpltCallback is executed and user can
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 add his own code by customization of function pointer HAL_IRDA_RxCpltCallback
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 (+) In case of transfer Error, HAL_IRDA_ErrorCallback() function is executed and user can
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 add his own code by customization of function pointer HAL_IRDA_ErrorCallback
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 *** IRDA HAL driver macros list ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 ===================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 Below the list of most used macros in IRDA HAL driver.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 (+) __HAL_IRDA_ENABLE: Enable the IRDA peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 (+) __HAL_IRDA_DISABLE: Disable the IRDA peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 (+) __HAL_IRDA_GET_FLAG : Checks whether the specified IRDA flag is set or not
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 (+) __HAL_IRDA_CLEAR_FLAG : Clears the specified IRDA pending flag
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 (+) __HAL_IRDA_ENABLE_IT: Enables the specified IRDA interrupt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 (+) __HAL_IRDA_DISABLE_IT: Disables the specified IRDA interrupt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 (@) You can refer to the IRDA HAL driver header file for more useful macros
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 * Redistribution and use in source and binary forms, with or without modification,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 * are permitted provided that the following conditions are met:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 * 1. Redistributions of source code must retain the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 * this list of conditions and the following disclaimer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 * 2. Redistributions in binary form must reproduce the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 * this list of conditions and the following disclaimer in the documentation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 * and/or other materials provided with the distribution.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 * 3. Neither the name of STMicroelectronics nor the names of its contributors
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 * may be used to endorse or promote products derived from this software
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 * without specific prior written permission.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 /** @addtogroup STM32F4xx_HAL_Driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 /** @defgroup IRDA IRDA
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 * @brief HAL IRDA module driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 #ifdef HAL_IRDA_MODULE_ENABLED
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 /* Private typedef -----------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 /* Private define ------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 /** @addtogroup IRDA_Private_Constants
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 #define IRDA_TIMEOUT_VALUE 22000
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 /* Private macro -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 /** @addtogroup IRDA_Private_Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 static void IRDA_SetConfig (IRDA_HandleTypeDef *hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 static HAL_StatusTypeDef IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 static HAL_StatusTypeDef IRDA_EndTransmit_IT(IRDA_HandleTypeDef *hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 static HAL_StatusTypeDef IRDA_Receive_IT(IRDA_HandleTypeDef *hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 static void IRDA_DMATransmitCplt(DMA_HandleTypeDef *hdma);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 static void IRDA_DMATransmitHalfCplt(DMA_HandleTypeDef *hdma);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 static void IRDA_DMAReceiveCplt(DMA_HandleTypeDef *hdma);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 static void IRDA_DMAReceiveHalfCplt(DMA_HandleTypeDef *hdma);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 static void IRDA_DMAError(DMA_HandleTypeDef *hdma);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 static HAL_StatusTypeDef IRDA_WaitOnFlagUntilTimeout(IRDA_HandleTypeDef *hirda, uint32_t Flag, FlagStatus Status, uint32_t Timeout);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 /** @defgroup IRDA_Exported_Functions IrDA Exported Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 /** @defgroup IRDA_Exported_Functions_Group1 IrDA Initialization and de-initialization functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 * @brief Initialization and Configuration functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 ##### Initialization and Configuration functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 This subsection provides a set of functions allowing to initialize the USARTx or the UARTy
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 in IrDA mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 (+) For the asynchronous mode only these parameters can be configured:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 (++) BaudRate
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 (++) WordLength
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 (++) Parity: If the parity is enabled, then the MSB bit of the data written
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 in the data register is transmitted but is changed by the parity bit.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 Depending on the frame length defined by the M bit (8-bits or 9-bits),
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 please refer to Reference manual for possible IRDA frame formats.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 (++) Prescaler: A pulse of width less than two and greater than one PSC period(s) may or may
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 not be rejected. The receiver set up time should be managed by software. The IrDA physical layer
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 specification specifies a minimum of 10 ms delay between transmission and
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 reception (IrDA is a half duplex protocol).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 (++) Mode: Receiver/transmitter modes
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 (++) IrDAMode: the IrDA can operate in the Normal mode or in the Low power mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 The HAL_IRDA_Init() API follows IRDA configuration procedures (details for the procedures
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 are available in reference manual).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 * @brief Initializes the IRDA mode according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 * parameters in the IRDA_InitTypeDef and create the associated handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 /* Check the IRDA handle allocation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 if(hirda == NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 /* Check the IRDA instance parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 assert_param(IS_IRDA_INSTANCE(hirda->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 /* Check the IRDA mode parameter in the IRDA handle */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 assert_param(IS_IRDA_POWERMODE(hirda->Init.IrDAMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 if(hirda->State == HAL_IRDA_STATE_RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 /* Init the low level hardware : GPIO, CLOCK, CORTEX...etc */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 HAL_IRDA_MspInit(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 hirda->State = HAL_IRDA_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 /* Disable the IRDA peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 __HAL_IRDA_DISABLE(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 /* Set the IRDA communication parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 IRDA_SetConfig(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 /* In IrDA mode, the following bits must be kept cleared:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 - LINEN, STOP and CLKEN bits in the USART_CR2 register,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 - SCEN and HDSEL bits in the USART_CR3 register.*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 hirda->Instance->CR2 &= ~(USART_CR2_LINEN | USART_CR2_STOP | USART_CR2_CLKEN);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 hirda->Instance->CR3 &= ~(USART_CR3_SCEN | USART_CR3_HDSEL);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 /* Enable the IRDA peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 __HAL_IRDA_ENABLE(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 /* Set the prescaler */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 MODIFY_REG(hirda->Instance->GTPR, USART_GTPR_PSC, hirda->Init.Prescaler);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 /* Configure the IrDA mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 MODIFY_REG(hirda->Instance->CR3, USART_CR3_IRLP, hirda->Init.IrDAMode);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 /* Enable the IrDA mode by setting the IREN bit in the CR3 register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 hirda->Instance->CR3 |= USART_CR3_IREN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 /* Initialize the IRDA state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 hirda->ErrorCode = HAL_IRDA_ERROR_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 hirda->State= HAL_IRDA_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 * @brief DeInitializes the IRDA peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 /* Check the IRDA handle allocation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274 if(hirda == NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 assert_param(IS_IRDA_INSTANCE(hirda->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 hirda->State = HAL_IRDA_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 __HAL_IRDA_DISABLE(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 /* DeInit the low level hardware */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 HAL_IRDA_MspDeInit(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 hirda->ErrorCode = HAL_IRDA_ERROR_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 hirda->State = HAL_IRDA_STATE_RESET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 /* Release Lock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 __HAL_UNLOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 * @brief IRDA MSP Init.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 __weak void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 the HAL_IRDA_MspInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 * @brief IRDA MSP DeInit.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 __weak void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 the HAL_IRDA_MspDeInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 /** @defgroup IRDA_Exported_Functions_Group2 IO operation functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 * @brief IRDA Transmit/Receive functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 ##### IO operation functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 This subsection provides a set of functions allowing to manage the IRDA data transfers.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 IrDA is a half duplex communication protocol. If the Transmitter is busy, any data
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 on the IrDA receive line will be ignored by the IrDA decoder and if the Receiver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 is busy, data on the TX from the USART to IrDA will not be encoded by IrDA.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 While receiving data, transmission should be avoided as the data to be transmitted
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 could be corrupted.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 (#) There are two modes of transfer:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 (++) Blocking mode: The communication is performed in polling mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 The HAL status of all data processing is returned by the same function
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 after finishing transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 (++) No-Blocking mode: The communication is performed using Interrupts
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 or DMA, These APIs return the HAL status.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 The end of the data processing will be indicated through the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 dedicated IRDA IRQ when using Interrupt mode or the DMA IRQ when
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 using DMA mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 The HAL_IRDA_TxCpltCallback(), HAL_IRDA_RxCpltCallback() user callbacks
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355 will be executed respectively at the end of the transmit or Receive process
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 The HAL_IRDA_ErrorCallback() user callback will be executed when a communication error is detected
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 (#) Blocking mode API's are :
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 (++) HAL_IRDA_Transmit()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 (++) HAL_IRDA_Receive()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 (#) Non Blocking mode APIs with Interrupt are :
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 (++) HAL_IRDA_Transmit_IT()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 (++) HAL_IRDA_Receive_IT()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 (++) HAL_IRDA_IRQHandler()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 (#) Non Blocking mode functions with DMA are :
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 (++) HAL_IRDA_Transmit_DMA()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 (++) HAL_IRDA_Receive_DMA()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 (#) A set of Transfer Complete Callbacks are provided in non Blocking mode:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 (++) HAL_IRDA_TxCpltCallback()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 (++) HAL_IRDA_RxCpltCallback()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 (++) HAL_IRDA_ErrorCallback()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 * @brief Sends an amount of data in blocking mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 * @param pData: Pointer to data buffer
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 * @param Size: Amount of data to be sent
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 * @param Timeout: Specify timeout value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 uint16_t* tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 uint32_t tmp1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 tmp1 = hirda->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 if((tmp1 == HAL_IRDA_STATE_READY) || (tmp1 == HAL_IRDA_STATE_BUSY_RX))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 if((pData == NULL) || (Size == 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 __HAL_LOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 hirda->ErrorCode = HAL_IRDA_ERROR_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 if(hirda->State == HAL_IRDA_STATE_BUSY_RX)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 hirda->State = HAL_IRDA_STATE_BUSY_TX_RX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 hirda->State = HAL_IRDA_STATE_BUSY_TX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 hirda->TxXferSize = Size;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416 hirda->TxXferCount = Size;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 while(hirda->TxXferCount > 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 hirda->TxXferCount--;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 if(hirda->Init.WordLength == IRDA_WORDLENGTH_9B)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422 if(IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_TXE, RESET, Timeout) != HAL_OK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426 tmp = (uint16_t*) pData;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 hirda->Instance->DR = (*tmp & (uint16_t)0x01FF);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428 if(hirda->Init.Parity == IRDA_PARITY_NONE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 pData +=2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434 pData +=1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439 if(IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_TXE, RESET, Timeout) != HAL_OK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443 hirda->Instance->DR = (*pData++ & (uint8_t)0xFF);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447 if(IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_TC, RESET, Timeout) != HAL_OK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452 if(hirda->State == HAL_IRDA_STATE_BUSY_TX_RX)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454 hirda->State = HAL_IRDA_STATE_BUSY_RX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 hirda->State = HAL_IRDA_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462 __HAL_UNLOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468 return HAL_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 * @brief Receive an amount of data in blocking mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 * @param pData: Pointer to data buffer
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477 * @param Size: Amount of data to be received
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478 * @param Timeout: Specify timeout value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481 HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483 uint16_t* tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 uint32_t tmp1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486 tmp1 = hirda->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 if((tmp1 == HAL_IRDA_STATE_READY) || (tmp1 == HAL_IRDA_STATE_BUSY_TX))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489 if((pData == NULL) || (Size == 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495 __HAL_LOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497 hirda->ErrorCode = HAL_IRDA_ERROR_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498 if(hirda->State == HAL_IRDA_STATE_BUSY_TX)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500 hirda->State = HAL_IRDA_STATE_BUSY_TX_RX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504 hirda->State = HAL_IRDA_STATE_BUSY_RX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 hirda->RxXferSize = Size;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507 hirda->RxXferCount = Size;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508 /* Check the remain data to be received */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 while(hirda->RxXferCount > 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
511 hirda->RxXferCount--;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512 if(hirda->Init.WordLength == IRDA_WORDLENGTH_9B)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514 if(IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_RXNE, RESET, Timeout) != HAL_OK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518 tmp = (uint16_t*) pData ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519 if(hirda->Init.Parity == IRDA_PARITY_NONE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521 *tmp = (uint16_t)(hirda->Instance->DR & (uint16_t)0x01FF);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
522 pData +=2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526 *tmp = (uint16_t)(hirda->Instance->DR & (uint16_t)0x00FF);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527 pData +=1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
530 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
531 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
532 if(IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_RXNE, RESET, Timeout) != HAL_OK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
536 if(hirda->Init.Parity == IRDA_PARITY_NONE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 *pData++ = (uint8_t)(hirda->Instance->DR & (uint8_t)0x00FF);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
539 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
541 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
542 *pData++ = (uint8_t)(hirda->Instance->DR & (uint8_t)0x007F);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
543 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
546 if(hirda->State == HAL_IRDA_STATE_BUSY_TX_RX)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
547 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
548 hirda->State = HAL_IRDA_STATE_BUSY_TX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
550 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
551 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552 hirda->State = HAL_IRDA_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556 __HAL_UNLOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
558 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
559 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
560 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
561 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
562 return HAL_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
563 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
564 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
565
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
566 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
567 * @brief Send an amount of data in non blocking mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
568 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
569 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
570 * @param pData: Pointer to data buffer
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
571 * @param Size: Amount of data to be sent
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
572 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
573 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
574 HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
575 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
576 uint32_t tmp1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
577
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
578 tmp1 = hirda->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
579 if((tmp1 == HAL_IRDA_STATE_READY) || (tmp1 == HAL_IRDA_STATE_BUSY_RX))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
580 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
581 if((pData == NULL) || (Size == 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
582 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
583 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
584 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
585 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
586 __HAL_LOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
587
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
588 hirda->pTxBuffPtr = pData;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
589 hirda->TxXferSize = Size;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
590 hirda->TxXferCount = Size;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
591 hirda->ErrorCode = HAL_IRDA_ERROR_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
592 if(hirda->State == HAL_IRDA_STATE_BUSY_RX)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
593 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
594 hirda->State = HAL_IRDA_STATE_BUSY_TX_RX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
595 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
596 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
597 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
598 hirda->State = HAL_IRDA_STATE_BUSY_TX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
599 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
600
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
601 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
602 __HAL_UNLOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
603
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
604 /* Enable the IRDA Error Interrupt: (Frame error, noise error, overrun error) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
605 __HAL_IRDA_ENABLE_IT(hirda, IRDA_IT_ERR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
606
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
607 /* Enable the IRDA Transmit Data Register Empty Interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
608 __HAL_IRDA_ENABLE_IT(hirda, IRDA_IT_TXE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
609
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
610 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
611 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
612 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
613 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
614 return HAL_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
615 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
616 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
617
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
618 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
619 * @brief Receives an amount of data in non blocking mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
620 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
621 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
622 * @param pData: Pointer to data buffer
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
623 * @param Size: Amount of data to be received
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
624 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
625 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
626 HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
627 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
628 uint32_t tmp1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
629
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
630 tmp1 = hirda->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
631 if((tmp1 == HAL_IRDA_STATE_READY) || (tmp1 == HAL_IRDA_STATE_BUSY_TX))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
632 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
633 if((pData == NULL) || (Size == 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
634 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
635 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
636 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
637
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
638 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
639 __HAL_LOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
640
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
641 hirda->pRxBuffPtr = pData;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
642 hirda->RxXferSize = Size;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
643 hirda->RxXferCount = Size;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
644 hirda->ErrorCode = HAL_IRDA_ERROR_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
645 if(hirda->State == HAL_IRDA_STATE_BUSY_TX)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
646 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
647 hirda->State = HAL_IRDA_STATE_BUSY_TX_RX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
648 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
649 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
650 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
651 hirda->State = HAL_IRDA_STATE_BUSY_RX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
652 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
653
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
654 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
655 __HAL_UNLOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
656
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
657 /* Enable the IRDA Data Register not empty Interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
658 __HAL_IRDA_ENABLE_IT(hirda, IRDA_IT_RXNE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
659
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
660 /* Enable the IRDA Parity Error Interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
661 __HAL_IRDA_ENABLE_IT(hirda, IRDA_IT_PE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
662
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
663 /* Enable the IRDA Error Interrupt: (Frame error, noise error, overrun error) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
664 __HAL_IRDA_ENABLE_IT(hirda, IRDA_IT_ERR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
665
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
666 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
667 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
668 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
669 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
670 return HAL_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
671 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
672 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
673
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
674 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
675 * @brief Sends an amount of data in non blocking mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
676 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
677 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
678 * @param pData: Pointer to data buffer
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
679 * @param Size: Amount of data to be sent
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
680 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
681 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
682 HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
683 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
684 uint32_t *tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
685 uint32_t tmp1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
686
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
687 tmp1 = hirda->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
688 if((tmp1 == HAL_IRDA_STATE_READY) || (tmp1 == HAL_IRDA_STATE_BUSY_RX))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
689 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
690 if((pData == NULL) || (Size == 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
691 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
692 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
693 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
694
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
695 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
696 __HAL_LOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
697
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
698 hirda->pTxBuffPtr = pData;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
699 hirda->TxXferSize = Size;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
700 hirda->TxXferCount = Size;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
701 hirda->ErrorCode = HAL_IRDA_ERROR_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
702
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
703 if(hirda->State == HAL_IRDA_STATE_BUSY_RX)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
704 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
705 hirda->State = HAL_IRDA_STATE_BUSY_TX_RX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
706 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
707 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
708 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
709 hirda->State = HAL_IRDA_STATE_BUSY_TX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
710 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
711
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
712 /* Set the IRDA DMA transfer complete callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
713 hirda->hdmatx->XferCpltCallback = IRDA_DMATransmitCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
714
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
715 /* Set the IRDA DMA half transfer complete callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
716 hirda->hdmatx->XferHalfCpltCallback = IRDA_DMATransmitHalfCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
717
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
718 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
719 hirda->hdmatx->XferErrorCallback = IRDA_DMAError;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
720
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
721 /* Enable the IRDA transmit DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
722 tmp = (uint32_t*)&pData;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
723 HAL_DMA_Start_IT(hirda->hdmatx, *(uint32_t*)tmp, (uint32_t)&hirda->Instance->DR, Size);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
724
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
725 /* Clear the TC flag in the SR register by writing 0 to it */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
726 __HAL_IRDA_CLEAR_FLAG(hirda, IRDA_FLAG_TC);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
727
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
728 /* Enable the DMA transfer for transmit request by setting the DMAT bit
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
729 in the USART CR3 register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
730 hirda->Instance->CR3 |= USART_CR3_DMAT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
731
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
732 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
733 __HAL_UNLOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
734
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
735 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
736 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
737 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
738 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
739 return HAL_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
740 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
741 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
742
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
743 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
744 * @brief Receives an amount of data in non blocking mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
745 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
746 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
747 * @param pData: Pointer to data buffer
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
748 * @param Size: Amount of data to be received
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
749 * @note When the IRDA parity is enabled (PCE = 1) the data received contain the parity bit.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
750 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
751 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
752 HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
753 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
754 uint32_t *tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
755 uint32_t tmp1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
756
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
757 tmp1 = hirda->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
758 if((tmp1 == HAL_IRDA_STATE_READY) || (tmp1 == HAL_IRDA_STATE_BUSY_TX))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
759 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
760 if((pData == NULL) || (Size == 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
761 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
762 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
763 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
764
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
765 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
766 __HAL_LOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
767
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
768 hirda->pRxBuffPtr = pData;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
769 hirda->RxXferSize = Size;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
770 hirda->ErrorCode = HAL_IRDA_ERROR_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
771 if(hirda->State == HAL_IRDA_STATE_BUSY_TX)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
772 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
773 hirda->State = HAL_IRDA_STATE_BUSY_TX_RX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
774 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
775 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
776 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
777 hirda->State = HAL_IRDA_STATE_BUSY_RX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
778 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
779
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
780 /* Set the IRDA DMA transfer complete callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
781 hirda->hdmarx->XferCpltCallback = IRDA_DMAReceiveCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
782
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
783 /* Set the IRDA DMA half transfer complete callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
784 hirda->hdmarx->XferHalfCpltCallback = IRDA_DMAReceiveHalfCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
785
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
786 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
787 hirda->hdmarx->XferErrorCallback = IRDA_DMAError;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
788
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
789 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
790 tmp = (uint32_t*)&pData;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
791 HAL_DMA_Start_IT(hirda->hdmarx, (uint32_t)&hirda->Instance->DR, *(uint32_t*)tmp, Size);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
792
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
793 /* Enable the DMA transfer for the receiver request by setting the DMAR bit
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
794 in the USART CR3 register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
795 hirda->Instance->CR3 |= USART_CR3_DMAR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
796
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
797 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
798 __HAL_UNLOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
799
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
800 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
801 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
802 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
803 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
804 return HAL_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
805 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
806 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
807
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
808 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
809 * @brief Pauses the DMA Transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
810 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
811 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
812 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
813 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
814 HAL_StatusTypeDef HAL_IRDA_DMAPause(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
815 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
816 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
817 __HAL_LOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
818
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
819 if(hirda->State == HAL_IRDA_STATE_BUSY_TX)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
820 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
821 /* Disable the UART DMA Tx request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
822 hirda->Instance->CR3 &= (uint32_t)(~USART_CR3_DMAT);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
823 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
824 else if(hirda->State == HAL_IRDA_STATE_BUSY_RX)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
825 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
826 /* Disable the UART DMA Rx request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
827 hirda->Instance->CR3 &= (uint32_t)(~USART_CR3_DMAR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
828 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
829 else if (hirda->State == HAL_IRDA_STATE_BUSY_TX_RX)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
830 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
831 /* Disable the UART DMA Tx & Rx requests */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
832 hirda->Instance->CR3 &= (uint32_t)(~USART_CR3_DMAT);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
833 hirda->Instance->CR3 &= (uint32_t)(~USART_CR3_DMAR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
834 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
835 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
836 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
837 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
838 __HAL_UNLOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
839
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
840 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
841 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
842
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
843 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
844 __HAL_UNLOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
845
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
846 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
847 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
848
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
849 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
850 * @brief Resumes the DMA Transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
851 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
852 * the configuration information for the specified UART module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
853 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
854 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
855 HAL_StatusTypeDef HAL_IRDA_DMAResume(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
856 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
857 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
858 __HAL_LOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
859
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
860 if(hirda->State == HAL_IRDA_STATE_BUSY_TX)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
861 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
862 /* Enable the UART DMA Tx request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
863 hirda->Instance->CR3 |= USART_CR3_DMAT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
864 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
865 else if(hirda->State == HAL_IRDA_STATE_BUSY_RX)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
866 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
867 /* Clear the Overrun flag before resuming the Rx transfer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
868 __HAL_IRDA_CLEAR_OREFLAG(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
869 /* Enable the UART DMA Rx request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
870 hirda->Instance->CR3 |= USART_CR3_DMAR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
871 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
872 else if(hirda->State == HAL_IRDA_STATE_BUSY_TX_RX)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
873 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
874 /* Clear the Overrun flag before resuming the Rx transfer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
875 __HAL_IRDA_CLEAR_OREFLAG(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
876 /* Enable the UART DMA Tx & Rx request */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
877 hirda->Instance->CR3 |= USART_CR3_DMAT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
878 hirda->Instance->CR3 |= USART_CR3_DMAR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
879 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
880 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
881 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
882 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
883 __HAL_UNLOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
884
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
885 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
886 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
887
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
888 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
889 __HAL_UNLOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
890
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
891 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
892 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
893
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
894 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
895 * @brief Stops the DMA Transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
896 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
897 * the configuration information for the specified UART module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
898 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
899 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
900 HAL_StatusTypeDef HAL_IRDA_DMAStop(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
901 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
902 /* The Lock is not implemented on this API to allow the user application
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
903 to call the HAL UART API under callbacks HAL_UART_TxCpltCallback() / HAL_UART_RxCpltCallback():
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
904 when calling HAL_DMA_Abort() API the DMA TX/RX Transfer complete interrupt is generated
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
905 and the correspond call back is executed HAL_UART_TxCpltCallback() / HAL_UART_RxCpltCallback()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
906 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
907
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
908 /* Disable the UART Tx/Rx DMA requests */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
909 hirda->Instance->CR3 &= ~USART_CR3_DMAT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
910 hirda->Instance->CR3 &= ~USART_CR3_DMAR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
911
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
912 /* Abort the UART DMA tx Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
913 if(hirda->hdmatx != NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
914 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
915 HAL_DMA_Abort(hirda->hdmatx);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
916 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
917 /* Abort the UART DMA rx Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
918 if(hirda->hdmarx != NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
919 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
920 HAL_DMA_Abort(hirda->hdmarx);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
921 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
922
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
923 hirda->State = HAL_IRDA_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
924
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
925 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
926 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
927
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
928 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
929 * @brief This function handles IRDA interrupt request.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
930 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
931 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
932 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
933 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
934 void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
935 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
936 uint32_t tmp1 = 0, tmp2 =0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
937
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
938 tmp1 = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_PE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
939 tmp2 = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_PE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
940 /* IRDA parity error interrupt occurred -------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
941 if((tmp1 != RESET) && (tmp2 != RESET))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
942 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
943 __HAL_IRDA_CLEAR_PEFLAG(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
944 hirda->ErrorCode |= HAL_IRDA_ERROR_PE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
945 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
946
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
947 tmp1 = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_FE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
948 tmp2 = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_ERR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
949 /* IRDA frame error interrupt occurred --------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
950 if((tmp1 != RESET) && (tmp2 != RESET))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
951 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
952 __HAL_IRDA_CLEAR_FEFLAG(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
953 hirda->ErrorCode |= HAL_IRDA_ERROR_FE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
954 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
955
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
956 tmp1 = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_NE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
957 tmp2 = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_ERR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
958 /* IRDA noise error interrupt occurred --------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
959 if((tmp1 != RESET) && (tmp2 != RESET))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
960 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
961 __HAL_IRDA_CLEAR_NEFLAG(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
962 hirda->ErrorCode |= HAL_IRDA_ERROR_NE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
963 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
964
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
965 tmp1 = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_ORE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
966 tmp2 = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_ERR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
967 /* IRDA Over-Run interrupt occurred -----------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
968 if((tmp1 != RESET) && (tmp2 != RESET))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
969 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
970 __HAL_IRDA_CLEAR_OREFLAG(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
971 hirda->ErrorCode |= HAL_IRDA_ERROR_ORE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
972 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
973
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
974 /* Call the Error call Back in case of Errors */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
975 if(hirda->ErrorCode != HAL_IRDA_ERROR_NONE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
976 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
977 /* Set the IRDA state ready to be able to start again the process */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
978 hirda->State = HAL_IRDA_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
979 HAL_IRDA_ErrorCallback(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
980 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
981
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
982 tmp1 = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_RXNE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
983 tmp2 = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_RXNE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
984 /* IRDA in mode Receiver ---------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
985 if((tmp1 != RESET) && (tmp2 != RESET))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
986 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
987 IRDA_Receive_IT(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
988 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
989
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
990 tmp1 = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_TXE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
991 tmp2 = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_TXE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
992 /* IRDA in mode Transmitter ------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
993 if((tmp1 != RESET) &&(tmp2 != RESET))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
994 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
995 IRDA_Transmit_IT(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
996 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
997
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
998 tmp1 = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_TC);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
999 tmp2 = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_TC);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1000 /* IRDA in mode Transmitter (transmission end) -----------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1001 if((tmp1 != RESET) && (tmp2 != RESET))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1002 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1003 IRDA_EndTransmit_IT(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1004 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1005 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1006
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1007 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1008 * @brief Tx Transfer complete callbacks.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1009 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1010 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1011 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1012 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1013 __weak void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1014 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1015 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1016 the HAL_IRDA_TxCpltCallback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1017 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1018 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1019
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1020 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1021 * @brief Tx Half Transfer completed callbacks.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1022 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1023 * the configuration information for the specified USART module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1024 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1025 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1026 __weak void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1027 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1028 /* NOTE: This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1029 the HAL_IRDA_TxHalfCpltCallback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1030 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1031 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1032
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1033 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1034 * @brief Rx Transfer complete callbacks.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1035 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1036 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1037 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1038 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1039 __weak void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1040 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1041 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1042 the HAL_IRDA_RxCpltCallback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1043 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1044 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1045
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1046 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1047 * @brief Rx Half Transfer complete callbacks.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1048 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1049 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1050 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1051 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1052 __weak void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1053 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1054 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1055 the HAL_IRDA_RxHalfCpltCallback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1056 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1057 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1058
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1059 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1060 * @brief IRDA error callbacks.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1061 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1062 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1063 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1064 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1065 __weak void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1066 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1067 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1068 the HAL_IRDA_ErrorCallback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1069 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1070 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1071
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1072 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1073 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1074 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1075
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1076 /** @defgroup IRDA_Exported_Functions_Group3 Peripheral State and Errors functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1077 * @brief IRDA State and Errors functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1078 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1079 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1080 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1081 ##### Peripheral State and Errors functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1082 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1083 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1084 This subsection provides a set of functions allowing to return the State of IrDA
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1085 communication process and also return Peripheral Errors occurred during communication process
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1086 (+) HAL_IRDA_GetState() API can be helpful to check in run-time the state of the IrDA peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1087 (+) HAL_IRDA_GetError() check in run-time errors that could be occurred during communication.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1088
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1089 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1090 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1091 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1092
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1093 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1094 * @brief Returns the IRDA state.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1095 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1096 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1097 * @retval HAL state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1098 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1099 HAL_IRDA_StateTypeDef HAL_IRDA_GetState(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1100 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1101 return hirda->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1102 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1103
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1104 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1105 * @brief Return the IARDA error code
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1106 * @param hirda : pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1107 * the configuration information for the specified IRDA.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1108 * @retval IRDA Error Code
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1109 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1110 uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1111 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1112 return hirda->ErrorCode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1113 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1114
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1115 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1116 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1117 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1118
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1119 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1120 * @brief DMA IRDA transmit process complete callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1121 * @param hdma : DMA handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1122 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1123 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1124 static void IRDA_DMATransmitCplt(DMA_HandleTypeDef *hdma)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1125 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1126 IRDA_HandleTypeDef* hirda = ( IRDA_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1127 /* DMA Normal mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1128 if((hdma->Instance->CR & DMA_SxCR_CIRC) == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1129 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1130 hirda->TxXferCount = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1131
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1132 /* Disable the DMA transfer for transmit request by setting the DMAT bit
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1133 in the IRDA CR3 register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1134 hirda->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_DMAT);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1135
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1136 /* Enable the IRDA Transmit Complete Interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1137 __HAL_IRDA_ENABLE_IT(hirda, IRDA_IT_TC);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1138 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1139 /* DMA Circular mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1140 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1141 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1142 HAL_IRDA_TxCpltCallback(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1143 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1144 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1145
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1146 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1147 * @brief DMA IRDA receive process half complete callback
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1148 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1149 * the configuration information for the specified DMA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1150 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1151 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1152 static void IRDA_DMATransmitHalfCplt(DMA_HandleTypeDef *hdma)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1153 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1154 IRDA_HandleTypeDef* hirda = ( IRDA_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1155
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1156 HAL_IRDA_TxHalfCpltCallback(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1157 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1158
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1159 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1160 * @brief DMA IRDA receive process complete callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1161 * @param hdma: DMA handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1162 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1163 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1164 static void IRDA_DMAReceiveCplt(DMA_HandleTypeDef *hdma)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1165 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1166 IRDA_HandleTypeDef* hirda = ( IRDA_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1167 /* DMA Normal mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1168 if((hdma->Instance->CR & DMA_SxCR_CIRC) == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1169 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1170 hirda->RxXferCount = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1171
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1172 /* Disable the DMA transfer for the receiver request by setting the DMAR bit
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1173 in the IRDA CR3 register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1174 hirda->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_DMAR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1175
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1176 if(hirda->State == HAL_IRDA_STATE_BUSY_TX_RX)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1177 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1178 hirda->State = HAL_IRDA_STATE_BUSY_TX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1179 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1180 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1181 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1182 hirda->State = HAL_IRDA_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1183 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1184 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1185
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1186 HAL_IRDA_RxCpltCallback(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1187 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1188
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1189 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1190 * @brief DMA IRDA receive process half complete callback
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1191 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1192 * the configuration information for the specified DMA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1193 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1194 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1195 static void IRDA_DMAReceiveHalfCplt(DMA_HandleTypeDef *hdma)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1196 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1197 IRDA_HandleTypeDef* hirda = ( IRDA_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1198
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1199 HAL_IRDA_RxHalfCpltCallback(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1200 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1201
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1202 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1203 * @brief DMA IRDA communication error callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1204 * @param hdma: DMA handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1205 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1206 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1207 static void IRDA_DMAError(DMA_HandleTypeDef *hdma)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1208 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1209 IRDA_HandleTypeDef* hirda = ( IRDA_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1210
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1211 hirda->RxXferCount = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1212 hirda->TxXferCount = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1213 hirda->ErrorCode |= HAL_IRDA_ERROR_DMA;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1214 hirda->State= HAL_IRDA_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1215
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1216 HAL_IRDA_ErrorCallback(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1217 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1218
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1219 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1220 * @brief This function handles IRDA Communication Timeout.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1221 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1222 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1223 * @param Flag: specifies the IRDA flag to check.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1224 * @param Status: The new Flag status (SET or RESET).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1225 * @param Timeout: Timeout duration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1226 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1227 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1228 static HAL_StatusTypeDef IRDA_WaitOnFlagUntilTimeout(IRDA_HandleTypeDef *hirda, uint32_t Flag, FlagStatus Status, uint32_t Timeout)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1229 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1230 uint32_t tickstart = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1231
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1232 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1233 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1234
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1235 /* Wait until flag is set */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1236 if(Status == RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1237 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1238 while(__HAL_IRDA_GET_FLAG(hirda, Flag) == RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1239 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1240 /* Check for the Timeout */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1241 if(Timeout != HAL_MAX_DELAY)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1242 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1243 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1244 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1245 /* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts for the interrupt process */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1246 __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_TXE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1247 __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_RXNE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1248 __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_PE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1249 __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_ERR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1250
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1251 hirda->State= HAL_IRDA_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1252
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1253 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1254 __HAL_UNLOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1255
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1256 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1257 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1258 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1259 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1260 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1261 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1262 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1263 while(__HAL_IRDA_GET_FLAG(hirda, Flag) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1264 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1265 /* Check for the Timeout */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1266 if(Timeout != HAL_MAX_DELAY)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1267 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1268 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1269 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1270 /* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts for the interrupt process */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1271 __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_TXE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1272 __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_RXNE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1273 __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_PE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1274 __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_ERR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1275
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1276 hirda->State= HAL_IRDA_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1277
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1278 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1279 __HAL_UNLOCK(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1280
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1281 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1282 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1283 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1284 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1285 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1286 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1287 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1288
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1289 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1290 * @brief Send an amount of data in non blocking mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1291 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1292 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1293 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1294 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1295 static HAL_StatusTypeDef IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1296 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1297 uint16_t* tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1298 uint32_t tmp1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1299
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1300 tmp1 = hirda->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1301 if((tmp1 == HAL_IRDA_STATE_BUSY_TX) || (tmp1 == HAL_IRDA_STATE_BUSY_TX_RX))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1302 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1303 if(hirda->Init.WordLength == IRDA_WORDLENGTH_9B)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1304 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1305 tmp = (uint16_t*) hirda->pTxBuffPtr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1306 hirda->Instance->DR = (uint16_t)(*tmp & (uint16_t)0x01FF);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1307 if(hirda->Init.Parity == IRDA_PARITY_NONE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1308 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1309 hirda->pTxBuffPtr += 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1310 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1311 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1312 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1313 hirda->pTxBuffPtr += 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1314 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1315 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1316 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1317 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1318 hirda->Instance->DR = (uint8_t)(*hirda->pTxBuffPtr++ & (uint8_t)0x00FF);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1319 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1320
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1321 if(--hirda->TxXferCount == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1322 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1323 /* Disable the IRDA Transmit Data Register Empty Interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1324 __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_TXE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1325
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1326 /* Enable the IRDA Transmit Complete Interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1327 __HAL_IRDA_ENABLE_IT(hirda, IRDA_IT_TC);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1328 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1329
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1330 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1331 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1332 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1333 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1334 return HAL_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1335 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1336 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1337
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1338 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1339 * @brief Wraps up transmission in non blocking mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1340 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1341 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1342 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1343 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1344 static HAL_StatusTypeDef IRDA_EndTransmit_IT(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1345 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1346 /* Disable the IRDA Transmit Complete Interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1347 __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_TC);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1348
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1349 /* Check if a receive process is ongoing or not */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1350 if(hirda->State == HAL_IRDA_STATE_BUSY_TX_RX)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1351 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1352 hirda->State = HAL_IRDA_STATE_BUSY_RX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1353 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1354 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1355 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1356 /* Disable the IRDA Error Interrupt: (Frame error, noise error, overrun error) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1357 __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_ERR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1358
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1359 hirda->State = HAL_IRDA_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1360 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1361
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1362 HAL_IRDA_TxCpltCallback(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1363
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1364 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1365 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1366
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1367 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1368 * @brief Receives an amount of data in non blocking mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1369 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1370 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1371 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1372 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1373 static HAL_StatusTypeDef IRDA_Receive_IT(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1374 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1375 uint16_t* tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1376 uint32_t tmp1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1377
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1378 tmp1 = hirda->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1379 if((tmp1 == HAL_IRDA_STATE_BUSY_RX) || (tmp1 == HAL_IRDA_STATE_BUSY_TX_RX))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1380 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1381 if(hirda->Init.WordLength == IRDA_WORDLENGTH_9B)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1382 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1383 tmp = (uint16_t*) hirda->pRxBuffPtr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1384 if(hirda->Init.Parity == IRDA_PARITY_NONE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1385 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1386 *tmp = (uint16_t)(hirda->Instance->DR & (uint16_t)0x01FF);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1387 hirda->pRxBuffPtr += 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1388 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1389 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1390 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1391 *tmp = (uint16_t)(hirda->Instance->DR & (uint16_t)0x00FF);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1392 hirda->pRxBuffPtr += 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1393 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1394 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1395 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1396 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1397 if(hirda->Init.Parity == IRDA_PARITY_NONE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1398 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1399 *hirda->pRxBuffPtr++ = (uint8_t)(hirda->Instance->DR & (uint8_t)0x00FF);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1400 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1401 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1402 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1403 *hirda->pRxBuffPtr++ = (uint8_t)(hirda->Instance->DR & (uint8_t)0x007F);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1404 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1405 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1406
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1407 if(--hirda->RxXferCount == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1408 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1409
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1410 __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_RXNE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1411
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1412 if(hirda->State == HAL_IRDA_STATE_BUSY_TX_RX)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1413 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1414 hirda->State = HAL_IRDA_STATE_BUSY_TX;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1415 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1416 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1417 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1418 /* Disable the IRDA Parity Error Interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1419 __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_PE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1420
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1421 /* Disable the IRDA Error Interrupt: (Frame error, noise error, overrun error) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1422 __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_ERR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1423
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1424 hirda->State = HAL_IRDA_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1425 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1426 HAL_IRDA_RxCpltCallback(hirda);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1427
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1428 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1429 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1430 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1431 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1432 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1433 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1434 return HAL_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1435 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1436 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1437
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1438 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1439 * @brief Configures the IRDA peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1440 * @param hirda: pointer to a IRDA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1441 * the configuration information for the specified IRDA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1442 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1443 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1444 static void IRDA_SetConfig(IRDA_HandleTypeDef *hirda)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1445 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1446 uint32_t tmpreg = 0x00;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1447
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1448 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1449 assert_param(IS_IRDA_INSTANCE(hirda->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1450 assert_param(IS_IRDA_BAUDRATE(hirda->Init.BaudRate));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1451 assert_param(IS_IRDA_WORD_LENGTH(hirda->Init.WordLength));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1452 assert_param(IS_IRDA_PARITY(hirda->Init.Parity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1453 assert_param(IS_IRDA_MODE(hirda->Init.Mode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1454
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1455 /*-------------------------- IRDA CR2 Configuration ------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1456 /* Clear STOP[13:12] bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1457 hirda->Instance->CR2 &= (uint32_t)~((uint32_t)USART_CR2_STOP);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1458
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1459 /*-------------------------- USART CR1 Configuration -----------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1460 tmpreg = hirda->Instance->CR1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1461
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1462 /* Clear M, PCE, PS, TE and RE bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1463 tmpreg &= (uint32_t)~((uint32_t)(USART_CR1_M | USART_CR1_PCE | USART_CR1_PS | USART_CR1_TE | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1464 USART_CR1_RE));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1465
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1466 /* Configure the USART Word Length, Parity and mode:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1467 Set the M bits according to hirda->Init.WordLength value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1468 Set PCE and PS bits according to hirda->Init.Parity value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1469 Set TE and RE bits according to hirda->Init.Mode value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1470 tmpreg |= (uint32_t)hirda->Init.WordLength | hirda->Init.Parity | hirda->Init.Mode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1471
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1472 /* Write to USART CR1 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1473 hirda->Instance->CR1 = (uint32_t)tmpreg;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1474
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1475 /*-------------------------- USART CR3 Configuration -----------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1476 /* Clear CTSE and RTSE bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1477 hirda->Instance->CR3 &= (uint32_t)~((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1478
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1479 /*-------------------------- USART BRR Configuration -----------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1480 if((hirda->Instance == USART1) || (hirda->Instance == USART6))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1481 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1482 hirda->Instance->BRR = IRDA_BRR(HAL_RCC_GetPCLK2Freq(), hirda->Init.BaudRate);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1483 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1484 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1485 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1486 hirda->Instance->BRR = IRDA_BRR(HAL_RCC_GetPCLK1Freq(), hirda->Init.BaudRate);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1487 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1488 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1489 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1490 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1491 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1492
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1493 #endif /* HAL_IRDA_MODULE_ENABLED */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1494 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1495 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1496 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1497
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1498 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1499 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1500 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1501
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1502 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/