mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F072RB/stm32f0xx_hal_irda.c@323:9e901b0a5aa1, 2014-09-13 (annotated)
- Committer:
- shaoziyang
- Date:
- Sat Sep 13 14:25:46 2014 +0000
- Revision:
- 323:9e901b0a5aa1
- Parent:
- 218:44081b78fdc2
test with CLOCK_SETUP = 0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 205:c41fc65bcfb4 | 1 | /** |
mbed_official | 205:c41fc65bcfb4 | 2 | ****************************************************************************** |
mbed_official | 205:c41fc65bcfb4 | 3 | * @file stm32f0xx_hal_irda.c |
mbed_official | 205:c41fc65bcfb4 | 4 | * @author MCD Application Team |
mbed_official | 205:c41fc65bcfb4 | 5 | * @version V1.0.0 |
mbed_official | 218:44081b78fdc2 | 6 | * @date 28-May-2014 |
mbed_official | 205:c41fc65bcfb4 | 7 | * @brief IRDA HAL module driver. |
mbed_official | 205:c41fc65bcfb4 | 8 | * |
mbed_official | 205:c41fc65bcfb4 | 9 | * This file provides firmware functions to manage the following |
mbed_official | 205:c41fc65bcfb4 | 10 | * functionalities of the IrDA (Infrared Data Association) Peripheral |
mbed_official | 205:c41fc65bcfb4 | 11 | * (IRDA) |
mbed_official | 205:c41fc65bcfb4 | 12 | * + Initialization and de-initialization function |
mbed_official | 205:c41fc65bcfb4 | 13 | * + IO operation function |
mbed_official | 205:c41fc65bcfb4 | 14 | * + Peripheral Control function |
mbed_official | 205:c41fc65bcfb4 | 15 | * |
mbed_official | 205:c41fc65bcfb4 | 16 | * |
mbed_official | 205:c41fc65bcfb4 | 17 | @verbatim |
mbed_official | 205:c41fc65bcfb4 | 18 | =============================================================================== |
mbed_official | 205:c41fc65bcfb4 | 19 | ##### How to use this driver ##### |
mbed_official | 205:c41fc65bcfb4 | 20 | =============================================================================== |
mbed_official | 205:c41fc65bcfb4 | 21 | [..] |
mbed_official | 205:c41fc65bcfb4 | 22 | The IRDA HAL driver can be used as follows: |
mbed_official | 205:c41fc65bcfb4 | 23 | |
mbed_official | 205:c41fc65bcfb4 | 24 | (#) Declare a IRDA_HandleTypeDef handle structure. |
mbed_official | 205:c41fc65bcfb4 | 25 | (#) Initialize the IRDA low level resources by implementing the HAL_IRDA_MspInit() API |
mbed_official | 205:c41fc65bcfb4 | 26 | in setting the associated USART or UART in IRDA mode: |
mbed_official | 205:c41fc65bcfb4 | 27 | (##) Enable the USARTx/UARTx interface clock. |
mbed_official | 205:c41fc65bcfb4 | 28 | (##) USARTx/UARTx pins configuration: |
mbed_official | 205:c41fc65bcfb4 | 29 | (+) Enable the clock for the USARTx/UARTx GPIOs. |
mbed_official | 205:c41fc65bcfb4 | 30 | (+) Configure these USARTx/UARTx pins as alternate function pull-up. |
mbed_official | 205:c41fc65bcfb4 | 31 | (##) NVIC configuration if you need to use interrupt process (HAL_IRDA_Transmit_IT() |
mbed_official | 205:c41fc65bcfb4 | 32 | and HAL_IRDA_Receive_IT() APIs): |
mbed_official | 205:c41fc65bcfb4 | 33 | (+) Configure the USARTx/UARTx interrupt priority. |
mbed_official | 205:c41fc65bcfb4 | 34 | (+) Enable the NVIC IRDA IRQ handle. |
mbed_official | 205:c41fc65bcfb4 | 35 | (@) The specific IRDA interrupts (Transmission complete interrupt, |
mbed_official | 205:c41fc65bcfb4 | 36 | RXNE interrupt and Error Interrupts) will be managed using the macros |
mbed_official | 205:c41fc65bcfb4 | 37 | __HAL_IRDA_ENABLE_IT() and __HAL_IRDA_DISABLE_IT() inside the transmit and receive process. |
mbed_official | 205:c41fc65bcfb4 | 38 | (##) DMA Configuration if you need to use DMA process (HAL_IRDA_Transmit_DMA() |
mbed_official | 205:c41fc65bcfb4 | 39 | and HAL_IRDA_Receive_DMA() APIs): |
mbed_official | 205:c41fc65bcfb4 | 40 | (+) Declare a DMA handle structure for the Tx/Rx stream. |
mbed_official | 205:c41fc65bcfb4 | 41 | (+) Enable the DMAx interface clock. |
mbed_official | 205:c41fc65bcfb4 | 42 | (+) Configure the declared DMA handle structure with the required Tx/Rx parameters. |
mbed_official | 205:c41fc65bcfb4 | 43 | (+) Configure the DMA Tx/Rx Stream. |
mbed_official | 205:c41fc65bcfb4 | 44 | (+) Associate the initilalized DMA handle to the IRDA DMA Tx/Rx handle. |
mbed_official | 205:c41fc65bcfb4 | 45 | (+) Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx/Rx Stream. |
mbed_official | 205:c41fc65bcfb4 | 46 | |
mbed_official | 205:c41fc65bcfb4 | 47 | (#) Program the Baud Rate, Word Length and Parity and Mode(Receiver/Transmitter), |
mbed_official | 205:c41fc65bcfb4 | 48 | the normal or low power mode and the clock prescaler in the hirda Init structure. |
mbed_official | 205:c41fc65bcfb4 | 49 | |
mbed_official | 205:c41fc65bcfb4 | 50 | (#) Initialize the IRDA registers by calling |
mbed_official | 205:c41fc65bcfb4 | 51 | the HAL_IRDA_Init() API. |
mbed_official | 205:c41fc65bcfb4 | 52 | |
mbed_official | 205:c41fc65bcfb4 | 53 | (@) This API (HAL_IRDA_Init()) configures also the low level Hardware (GPIO, CLOCK, CORTEX...etc) |
mbed_official | 205:c41fc65bcfb4 | 54 | by calling the customized HAL_IRDA_MspInit() API. |
mbed_official | 205:c41fc65bcfb4 | 55 | |
mbed_official | 205:c41fc65bcfb4 | 56 | @endverbatim |
mbed_official | 205:c41fc65bcfb4 | 57 | ****************************************************************************** |
mbed_official | 205:c41fc65bcfb4 | 58 | * @attention |
mbed_official | 205:c41fc65bcfb4 | 59 | * |
mbed_official | 205:c41fc65bcfb4 | 60 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 205:c41fc65bcfb4 | 61 | * |
mbed_official | 205:c41fc65bcfb4 | 62 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 205:c41fc65bcfb4 | 63 | * are permitted provided that the following conditions are met: |
mbed_official | 205:c41fc65bcfb4 | 64 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 205:c41fc65bcfb4 | 65 | * this list of conditions and the following disclaimer. |
mbed_official | 205:c41fc65bcfb4 | 66 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 205:c41fc65bcfb4 | 67 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 205:c41fc65bcfb4 | 68 | * and/or other materials provided with the distribution. |
mbed_official | 205:c41fc65bcfb4 | 69 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 205:c41fc65bcfb4 | 70 | * may be used to endorse or promote products derived from this software |
mbed_official | 205:c41fc65bcfb4 | 71 | * without specific prior written permission. |
mbed_official | 205:c41fc65bcfb4 | 72 | * |
mbed_official | 205:c41fc65bcfb4 | 73 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 205:c41fc65bcfb4 | 74 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 205:c41fc65bcfb4 | 75 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 205:c41fc65bcfb4 | 76 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 205:c41fc65bcfb4 | 77 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 205:c41fc65bcfb4 | 78 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 205:c41fc65bcfb4 | 79 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 205:c41fc65bcfb4 | 80 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 205:c41fc65bcfb4 | 81 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 205:c41fc65bcfb4 | 82 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 205:c41fc65bcfb4 | 83 | * |
mbed_official | 205:c41fc65bcfb4 | 84 | ****************************************************************************** |
mbed_official | 205:c41fc65bcfb4 | 85 | */ |
mbed_official | 205:c41fc65bcfb4 | 86 | |
mbed_official | 205:c41fc65bcfb4 | 87 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 88 | #include "stm32f0xx_hal.h" |
mbed_official | 205:c41fc65bcfb4 | 89 | |
mbed_official | 205:c41fc65bcfb4 | 90 | /** @addtogroup STM32F0xx_HAL_Driver |
mbed_official | 205:c41fc65bcfb4 | 91 | * @{ |
mbed_official | 205:c41fc65bcfb4 | 92 | */ |
mbed_official | 205:c41fc65bcfb4 | 93 | |
mbed_official | 205:c41fc65bcfb4 | 94 | /** @defgroup IRDA |
mbed_official | 205:c41fc65bcfb4 | 95 | * @brief HAL IRDA module driver |
mbed_official | 205:c41fc65bcfb4 | 96 | * @{ |
mbed_official | 205:c41fc65bcfb4 | 97 | */ |
mbed_official | 205:c41fc65bcfb4 | 98 | #ifdef HAL_IRDA_MODULE_ENABLED |
mbed_official | 205:c41fc65bcfb4 | 99 | |
mbed_official | 205:c41fc65bcfb4 | 100 | #if !defined(STM32F030x6) && !defined(STM32F030x8) |
mbed_official | 205:c41fc65bcfb4 | 101 | |
mbed_official | 205:c41fc65bcfb4 | 102 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 103 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 104 | #define TEACK_REACK_TIMEOUT 1000 |
mbed_official | 205:c41fc65bcfb4 | 105 | #define HAL_IRDA_TXDMA_TIMEOUTVALUE 22000 |
mbed_official | 205:c41fc65bcfb4 | 106 | #define IRDA_CR1_FIELDS ((uint32_t)(USART_CR1_M | USART_CR1_PCE \ |
mbed_official | 205:c41fc65bcfb4 | 107 | | USART_CR1_PS | USART_CR1_TE | USART_CR1_RE)) |
mbed_official | 205:c41fc65bcfb4 | 108 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 109 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 110 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 111 | static void IRDA_DMATransmitCplt(DMA_HandleTypeDef *hdma); |
mbed_official | 205:c41fc65bcfb4 | 112 | static void IRDA_DMAReceiveCplt(DMA_HandleTypeDef *hdma); |
mbed_official | 205:c41fc65bcfb4 | 113 | static void IRDA_DMAError(DMA_HandleTypeDef *hdma); |
mbed_official | 205:c41fc65bcfb4 | 114 | static HAL_StatusTypeDef IRDA_SetConfig(IRDA_HandleTypeDef *hirda); |
mbed_official | 205:c41fc65bcfb4 | 115 | static HAL_StatusTypeDef IRDA_CheckIdleState(IRDA_HandleTypeDef *hirda); |
mbed_official | 205:c41fc65bcfb4 | 116 | static HAL_StatusTypeDef IRDA_WaitOnFlagUntilTimeout(IRDA_HandleTypeDef *hirda, uint32_t Flag, FlagStatus Status, uint32_t Timeout); |
mbed_official | 205:c41fc65bcfb4 | 117 | static HAL_StatusTypeDef IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda); |
mbed_official | 205:c41fc65bcfb4 | 118 | static HAL_StatusTypeDef IRDA_Receive_IT(IRDA_HandleTypeDef *hirda); |
mbed_official | 205:c41fc65bcfb4 | 119 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 120 | |
mbed_official | 205:c41fc65bcfb4 | 121 | /** @defgroup IRDA_Private_Functions |
mbed_official | 205:c41fc65bcfb4 | 122 | * @{ |
mbed_official | 205:c41fc65bcfb4 | 123 | */ |
mbed_official | 205:c41fc65bcfb4 | 124 | |
mbed_official | 205:c41fc65bcfb4 | 125 | /** @defgroup HAL_IRDA_Group1 Initialization/de-initialization functions |
mbed_official | 205:c41fc65bcfb4 | 126 | * @brief Initialization and Configuration functions |
mbed_official | 205:c41fc65bcfb4 | 127 | * |
mbed_official | 205:c41fc65bcfb4 | 128 | @verbatim |
mbed_official | 205:c41fc65bcfb4 | 129 | =============================================================================== |
mbed_official | 205:c41fc65bcfb4 | 130 | ##### Initialization and Configuration functions ##### |
mbed_official | 205:c41fc65bcfb4 | 131 | =============================================================================== |
mbed_official | 205:c41fc65bcfb4 | 132 | [..] |
mbed_official | 205:c41fc65bcfb4 | 133 | This subsection provides a set of functions allowing to initialize the USARTx |
mbed_official | 205:c41fc65bcfb4 | 134 | in asynchronous IRDA mode. |
mbed_official | 205:c41fc65bcfb4 | 135 | (+) For the asynchronous mode only these parameters can be configured: |
mbed_official | 205:c41fc65bcfb4 | 136 | (++) Baud Rate |
mbed_official | 205:c41fc65bcfb4 | 137 | (++) Word Length |
mbed_official | 205:c41fc65bcfb4 | 138 | (++) Parity: If the parity is enabled, then the MSB bit of the data written |
mbed_official | 205:c41fc65bcfb4 | 139 | in the data register is transmitted but is changed by the parity bit. |
mbed_official | 205:c41fc65bcfb4 | 140 | Depending on the frame length defined by the M bit (8-bits or 9-bits) |
mbed_official | 205:c41fc65bcfb4 | 141 | or by the M1 and M0 bits (7-bit, 8-bit or 9-bit), |
mbed_official | 205:c41fc65bcfb4 | 142 | the possible IRDA frame formats are as listed in the following table: |
mbed_official | 205:c41fc65bcfb4 | 143 | +---------------------------------------------------------------+ |
mbed_official | 205:c41fc65bcfb4 | 144 | | M bit | PCE bit | IRDA frame | |
mbed_official | 205:c41fc65bcfb4 | 145 | |-----------|-----------|---------------------------------------| |
mbed_official | 205:c41fc65bcfb4 | 146 | | 0 | 0 | | SB | 8-bit data | STB | | |
mbed_official | 205:c41fc65bcfb4 | 147 | |-----------|-----------|---------------------------------------| |
mbed_official | 205:c41fc65bcfb4 | 148 | | 0 | 1 | | SB | 7-bit data | PB | STB | | |
mbed_official | 205:c41fc65bcfb4 | 149 | |-----------|-----------|---------------------------------------| |
mbed_official | 205:c41fc65bcfb4 | 150 | | 1 | 0 | | SB | 9-bit data | STB | | |
mbed_official | 205:c41fc65bcfb4 | 151 | |-----------|-----------|---------------------------------------| |
mbed_official | 205:c41fc65bcfb4 | 152 | | 1 | 1 | | SB | 8-bit data | PB | STB | | |
mbed_official | 205:c41fc65bcfb4 | 153 | +---------------------------------------------------------------+ |
mbed_official | 205:c41fc65bcfb4 | 154 | | M1M0 bits | PCE bit | IRDA frame | |
mbed_official | 205:c41fc65bcfb4 | 155 | |-----------------------|---------------------------------------| |
mbed_official | 205:c41fc65bcfb4 | 156 | | 10 | 0 | | SB | 7-bit data | STB | | |
mbed_official | 205:c41fc65bcfb4 | 157 | |-----------|-----------|---------------------------------------| |
mbed_official | 205:c41fc65bcfb4 | 158 | | 10 | 1 | | SB | 6-bit data | PB | STB | | |
mbed_official | 205:c41fc65bcfb4 | 159 | +---------------------------------------------------------------+ |
mbed_official | 205:c41fc65bcfb4 | 160 | |
mbed_official | 205:c41fc65bcfb4 | 161 | (++) Power mode |
mbed_official | 205:c41fc65bcfb4 | 162 | (++) Prescaler setting |
mbed_official | 205:c41fc65bcfb4 | 163 | (++) Receiver/transmitter modes |
mbed_official | 205:c41fc65bcfb4 | 164 | |
mbed_official | 205:c41fc65bcfb4 | 165 | [..] |
mbed_official | 205:c41fc65bcfb4 | 166 | The HAL_IRDA_Init() API follows the USART asynchronous configuration procedures |
mbed_official | 205:c41fc65bcfb4 | 167 | (details for the procedures are available in reference manual). |
mbed_official | 205:c41fc65bcfb4 | 168 | |
mbed_official | 205:c41fc65bcfb4 | 169 | @endverbatim |
mbed_official | 205:c41fc65bcfb4 | 170 | * @{ |
mbed_official | 205:c41fc65bcfb4 | 171 | */ |
mbed_official | 205:c41fc65bcfb4 | 172 | |
mbed_official | 205:c41fc65bcfb4 | 173 | /** |
mbed_official | 205:c41fc65bcfb4 | 174 | * @brief Initializes the IRDA mode according to the specified |
mbed_official | 205:c41fc65bcfb4 | 175 | * parameters in the IRDA_InitTypeDef and creates the associated handle . |
mbed_official | 205:c41fc65bcfb4 | 176 | * @param hirda: IRDA handle |
mbed_official | 205:c41fc65bcfb4 | 177 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 178 | */ |
mbed_official | 205:c41fc65bcfb4 | 179 | HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda) |
mbed_official | 205:c41fc65bcfb4 | 180 | { |
mbed_official | 205:c41fc65bcfb4 | 181 | /* Check the IRDA handle allocation */ |
mbed_official | 205:c41fc65bcfb4 | 182 | if(hirda == NULL) |
mbed_official | 205:c41fc65bcfb4 | 183 | { |
mbed_official | 205:c41fc65bcfb4 | 184 | return HAL_ERROR; |
mbed_official | 205:c41fc65bcfb4 | 185 | } |
mbed_official | 205:c41fc65bcfb4 | 186 | |
mbed_official | 205:c41fc65bcfb4 | 187 | /* Check the USART/UART associated to the IRDA handle */ |
mbed_official | 205:c41fc65bcfb4 | 188 | assert_param(IS_IRDA_INSTANCE(hirda->Instance)); |
mbed_official | 205:c41fc65bcfb4 | 189 | |
mbed_official | 205:c41fc65bcfb4 | 190 | if(hirda->State == HAL_IRDA_STATE_RESET) |
mbed_official | 205:c41fc65bcfb4 | 191 | { |
mbed_official | 205:c41fc65bcfb4 | 192 | /* Init the low level hardware : GPIO, CLOCK */ |
mbed_official | 205:c41fc65bcfb4 | 193 | HAL_IRDA_MspInit(hirda); |
mbed_official | 205:c41fc65bcfb4 | 194 | } |
mbed_official | 205:c41fc65bcfb4 | 195 | |
mbed_official | 205:c41fc65bcfb4 | 196 | hirda->State = HAL_IRDA_STATE_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 197 | |
mbed_official | 205:c41fc65bcfb4 | 198 | /* Disable the Peripheral to update the configuration registers */ |
mbed_official | 205:c41fc65bcfb4 | 199 | __HAL_IRDA_DISABLE(hirda); |
mbed_official | 205:c41fc65bcfb4 | 200 | |
mbed_official | 205:c41fc65bcfb4 | 201 | /* Set the IRDA Communication parameters */ |
mbed_official | 205:c41fc65bcfb4 | 202 | if (IRDA_SetConfig(hirda) == HAL_ERROR) |
mbed_official | 205:c41fc65bcfb4 | 203 | { |
mbed_official | 205:c41fc65bcfb4 | 204 | return HAL_ERROR; |
mbed_official | 205:c41fc65bcfb4 | 205 | } |
mbed_official | 205:c41fc65bcfb4 | 206 | |
mbed_official | 205:c41fc65bcfb4 | 207 | /* In IRDA mode, the following bits must be kept cleared: |
mbed_official | 205:c41fc65bcfb4 | 208 | - LINEN, STOP and CLKEN bits in the USART_CR2 register, |
mbed_official | 205:c41fc65bcfb4 | 209 | - SCEN and HDSEL bits in the USART_CR3 register.*/ |
mbed_official | 205:c41fc65bcfb4 | 210 | hirda->Instance->CR2 &= ~(USART_CR2_LINEN | USART_CR2_CLKEN | USART_CR2_STOP); |
mbed_official | 205:c41fc65bcfb4 | 211 | hirda->Instance->CR3 &= ~(USART_CR3_SCEN | USART_CR3_HDSEL); |
mbed_official | 205:c41fc65bcfb4 | 212 | |
mbed_official | 205:c41fc65bcfb4 | 213 | /* set the UART/USART in IRDA mode */ |
mbed_official | 205:c41fc65bcfb4 | 214 | hirda->Instance->CR3 |= USART_CR3_IREN; |
mbed_official | 205:c41fc65bcfb4 | 215 | |
mbed_official | 205:c41fc65bcfb4 | 216 | /* Enable the Peripheral */ |
mbed_official | 205:c41fc65bcfb4 | 217 | __HAL_IRDA_ENABLE(hirda); |
mbed_official | 205:c41fc65bcfb4 | 218 | |
mbed_official | 205:c41fc65bcfb4 | 219 | /* TEACK and/or REACK to check before moving hirda->State to Ready */ |
mbed_official | 205:c41fc65bcfb4 | 220 | return (IRDA_CheckIdleState(hirda)); |
mbed_official | 205:c41fc65bcfb4 | 221 | } |
mbed_official | 205:c41fc65bcfb4 | 222 | |
mbed_official | 205:c41fc65bcfb4 | 223 | |
mbed_official | 205:c41fc65bcfb4 | 224 | |
mbed_official | 205:c41fc65bcfb4 | 225 | |
mbed_official | 205:c41fc65bcfb4 | 226 | |
mbed_official | 205:c41fc65bcfb4 | 227 | |
mbed_official | 205:c41fc65bcfb4 | 228 | /** |
mbed_official | 205:c41fc65bcfb4 | 229 | * @brief DeInitializes the IRDA peripheral |
mbed_official | 205:c41fc65bcfb4 | 230 | * @param hirda: IRDA handle |
mbed_official | 205:c41fc65bcfb4 | 231 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 232 | */ |
mbed_official | 205:c41fc65bcfb4 | 233 | HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda) |
mbed_official | 205:c41fc65bcfb4 | 234 | { |
mbed_official | 205:c41fc65bcfb4 | 235 | /* Check the IRDA handle allocation */ |
mbed_official | 205:c41fc65bcfb4 | 236 | if(hirda == NULL) |
mbed_official | 205:c41fc65bcfb4 | 237 | { |
mbed_official | 205:c41fc65bcfb4 | 238 | return HAL_ERROR; |
mbed_official | 205:c41fc65bcfb4 | 239 | } |
mbed_official | 205:c41fc65bcfb4 | 240 | |
mbed_official | 205:c41fc65bcfb4 | 241 | /* Check the USART/UART associated to the IRDA handle */ |
mbed_official | 205:c41fc65bcfb4 | 242 | assert_param(IS_IRDA_INSTANCE(hirda->Instance)); |
mbed_official | 205:c41fc65bcfb4 | 243 | |
mbed_official | 205:c41fc65bcfb4 | 244 | hirda->State = HAL_IRDA_STATE_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 245 | |
mbed_official | 205:c41fc65bcfb4 | 246 | /* DeInit the low level hardware */ |
mbed_official | 205:c41fc65bcfb4 | 247 | HAL_IRDA_MspDeInit(hirda); |
mbed_official | 205:c41fc65bcfb4 | 248 | /* Disable the Peripheral */ |
mbed_official | 205:c41fc65bcfb4 | 249 | __HAL_IRDA_DISABLE(hirda); |
mbed_official | 205:c41fc65bcfb4 | 250 | |
mbed_official | 205:c41fc65bcfb4 | 251 | hirda->ErrorCode = HAL_IRDA_ERROR_NONE; |
mbed_official | 205:c41fc65bcfb4 | 252 | hirda->State = HAL_IRDA_STATE_RESET; |
mbed_official | 205:c41fc65bcfb4 | 253 | |
mbed_official | 205:c41fc65bcfb4 | 254 | /* Process Unlock */ |
mbed_official | 205:c41fc65bcfb4 | 255 | __HAL_UNLOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 256 | |
mbed_official | 205:c41fc65bcfb4 | 257 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 258 | } |
mbed_official | 205:c41fc65bcfb4 | 259 | |
mbed_official | 205:c41fc65bcfb4 | 260 | /** |
mbed_official | 205:c41fc65bcfb4 | 261 | * @brief IRDA MSP Init |
mbed_official | 205:c41fc65bcfb4 | 262 | * @param hirda: IRDA handle |
mbed_official | 205:c41fc65bcfb4 | 263 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 264 | */ |
mbed_official | 205:c41fc65bcfb4 | 265 | __weak void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda) |
mbed_official | 205:c41fc65bcfb4 | 266 | { |
mbed_official | 205:c41fc65bcfb4 | 267 | /* NOTE : This function should not be modified, when the callback is needed, |
mbed_official | 205:c41fc65bcfb4 | 268 | the HAL_IRDA_MspInit can be implemented in the user file |
mbed_official | 205:c41fc65bcfb4 | 269 | */ |
mbed_official | 205:c41fc65bcfb4 | 270 | } |
mbed_official | 205:c41fc65bcfb4 | 271 | |
mbed_official | 205:c41fc65bcfb4 | 272 | /** |
mbed_official | 205:c41fc65bcfb4 | 273 | * @brief IRDA MSP DeInit |
mbed_official | 205:c41fc65bcfb4 | 274 | * @param hirda: IRDA handle |
mbed_official | 205:c41fc65bcfb4 | 275 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 276 | */ |
mbed_official | 205:c41fc65bcfb4 | 277 | __weak void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda) |
mbed_official | 205:c41fc65bcfb4 | 278 | { |
mbed_official | 205:c41fc65bcfb4 | 279 | /* NOTE : This function should not be modified, when the callback is needed, |
mbed_official | 205:c41fc65bcfb4 | 280 | the HAL_IRDA_MspDeInit can be implemented in the user file |
mbed_official | 205:c41fc65bcfb4 | 281 | */ |
mbed_official | 205:c41fc65bcfb4 | 282 | } |
mbed_official | 205:c41fc65bcfb4 | 283 | |
mbed_official | 205:c41fc65bcfb4 | 284 | /** |
mbed_official | 205:c41fc65bcfb4 | 285 | * @} |
mbed_official | 205:c41fc65bcfb4 | 286 | */ |
mbed_official | 205:c41fc65bcfb4 | 287 | |
mbed_official | 205:c41fc65bcfb4 | 288 | /** @defgroup HAL_IRDA_Group2 IO operation functions |
mbed_official | 205:c41fc65bcfb4 | 289 | * @brief IRDA Transmit/Receive functions |
mbed_official | 205:c41fc65bcfb4 | 290 | * |
mbed_official | 205:c41fc65bcfb4 | 291 | @verbatim |
mbed_official | 205:c41fc65bcfb4 | 292 | =============================================================================== |
mbed_official | 205:c41fc65bcfb4 | 293 | ##### I/O operation functions ##### |
mbed_official | 205:c41fc65bcfb4 | 294 | =============================================================================== |
mbed_official | 205:c41fc65bcfb4 | 295 | This subsection provides a set of functions allowing to manage the IRDA asynchronous |
mbed_official | 205:c41fc65bcfb4 | 296 | data transfers. |
mbed_official | 205:c41fc65bcfb4 | 297 | |
mbed_official | 205:c41fc65bcfb4 | 298 | (#) There are two modes of transfer: |
mbed_official | 205:c41fc65bcfb4 | 299 | (+) Blocking mode: the communication is performed in polling mode. |
mbed_official | 205:c41fc65bcfb4 | 300 | The HAL status of all data processing is returned by the same function |
mbed_official | 205:c41fc65bcfb4 | 301 | after finishing transfer. |
mbed_official | 205:c41fc65bcfb4 | 302 | (+) No-Blocking mode: the communication is performed using Interrupts |
mbed_official | 205:c41fc65bcfb4 | 303 | or DMA, these API's return the HAL status. |
mbed_official | 205:c41fc65bcfb4 | 304 | The end of the data processing will be indicated through the |
mbed_official | 205:c41fc65bcfb4 | 305 | dedicated IRDA IRQ when using Interrupt mode or the DMA IRQ when |
mbed_official | 205:c41fc65bcfb4 | 306 | using DMA mode. |
mbed_official | 205:c41fc65bcfb4 | 307 | The HAL_IRDA_TxCpltCallback(), HAL_IRDA_RxCpltCallback() user callbacks |
mbed_official | 205:c41fc65bcfb4 | 308 | will be executed respectivelly at the end of the Transmit or Receive process |
mbed_official | 205:c41fc65bcfb4 | 309 | The HAL_IRDA_ErrorCallback() user callback will be executed when a communication error is detected |
mbed_official | 205:c41fc65bcfb4 | 310 | |
mbed_official | 205:c41fc65bcfb4 | 311 | (#) Blocking mode API's are : |
mbed_official | 205:c41fc65bcfb4 | 312 | (+) HAL_IRDA_Transmit() |
mbed_official | 205:c41fc65bcfb4 | 313 | (+) HAL_IRDA_Receive() |
mbed_official | 205:c41fc65bcfb4 | 314 | |
mbed_official | 205:c41fc65bcfb4 | 315 | (#) Non-Blocking mode API's with Interrupt are : |
mbed_official | 205:c41fc65bcfb4 | 316 | (+) HAL_IRDA_Transmit_IT() |
mbed_official | 205:c41fc65bcfb4 | 317 | (+) HAL_IRDA_Receive_IT() |
mbed_official | 205:c41fc65bcfb4 | 318 | (+) HAL_IRDA_IRQHandler() |
mbed_official | 205:c41fc65bcfb4 | 319 | (+) IRDA_Transmit_IT() |
mbed_official | 205:c41fc65bcfb4 | 320 | (+) IRDA_Receive_IT() |
mbed_official | 205:c41fc65bcfb4 | 321 | |
mbed_official | 205:c41fc65bcfb4 | 322 | (#) Non-Blocking mode functions with DMA are : |
mbed_official | 205:c41fc65bcfb4 | 323 | (+) HAL_IRDA_Transmit_DMA() |
mbed_official | 205:c41fc65bcfb4 | 324 | (+) HAL_IRDA_Receive_DMA() |
mbed_official | 205:c41fc65bcfb4 | 325 | |
mbed_official | 205:c41fc65bcfb4 | 326 | (#) A set of Transfer Complete Callbacks are provided in No_Blocking mode: |
mbed_official | 205:c41fc65bcfb4 | 327 | (+) HAL_IRDA_TxCpltCallback() |
mbed_official | 205:c41fc65bcfb4 | 328 | (+) HAL_IRDA_RxCpltCallback() |
mbed_official | 205:c41fc65bcfb4 | 329 | (+) HAL_IRDA_ErrorCallback() |
mbed_official | 205:c41fc65bcfb4 | 330 | |
mbed_official | 205:c41fc65bcfb4 | 331 | @endverbatim |
mbed_official | 205:c41fc65bcfb4 | 332 | * @{ |
mbed_official | 205:c41fc65bcfb4 | 333 | */ |
mbed_official | 205:c41fc65bcfb4 | 334 | |
mbed_official | 205:c41fc65bcfb4 | 335 | /** |
mbed_official | 205:c41fc65bcfb4 | 336 | * @brief Send an amount of data in blocking mode |
mbed_official | 205:c41fc65bcfb4 | 337 | * @param hirda: IRDA handle |
mbed_official | 205:c41fc65bcfb4 | 338 | * @param pData: pointer to data buffer |
mbed_official | 205:c41fc65bcfb4 | 339 | * @param Size: amount of data to be sent |
mbed_official | 205:c41fc65bcfb4 | 340 | * @param Timeout: Duration of the timeout |
mbed_official | 205:c41fc65bcfb4 | 341 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 342 | */ |
mbed_official | 205:c41fc65bcfb4 | 343 | HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout) |
mbed_official | 205:c41fc65bcfb4 | 344 | { |
mbed_official | 205:c41fc65bcfb4 | 345 | uint16_t* tmp; |
mbed_official | 205:c41fc65bcfb4 | 346 | |
mbed_official | 205:c41fc65bcfb4 | 347 | if ((hirda->State == HAL_IRDA_STATE_READY) || (hirda->State == HAL_IRDA_STATE_BUSY_RX)) |
mbed_official | 205:c41fc65bcfb4 | 348 | { |
mbed_official | 205:c41fc65bcfb4 | 349 | if((pData == NULL) || (Size == 0)) |
mbed_official | 205:c41fc65bcfb4 | 350 | { |
mbed_official | 205:c41fc65bcfb4 | 351 | return HAL_ERROR; |
mbed_official | 205:c41fc65bcfb4 | 352 | } |
mbed_official | 205:c41fc65bcfb4 | 353 | |
mbed_official | 205:c41fc65bcfb4 | 354 | /* Process Locked */ |
mbed_official | 205:c41fc65bcfb4 | 355 | __HAL_LOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 356 | hirda->ErrorCode = HAL_IRDA_ERROR_NONE; |
mbed_official | 205:c41fc65bcfb4 | 357 | |
mbed_official | 205:c41fc65bcfb4 | 358 | if(hirda->State == HAL_IRDA_STATE_BUSY_RX) |
mbed_official | 205:c41fc65bcfb4 | 359 | { |
mbed_official | 205:c41fc65bcfb4 | 360 | hirda->State = HAL_IRDA_STATE_BUSY_TX_RX; |
mbed_official | 205:c41fc65bcfb4 | 361 | } |
mbed_official | 205:c41fc65bcfb4 | 362 | else |
mbed_official | 205:c41fc65bcfb4 | 363 | { |
mbed_official | 205:c41fc65bcfb4 | 364 | hirda->State = HAL_IRDA_STATE_BUSY_TX; |
mbed_official | 205:c41fc65bcfb4 | 365 | } |
mbed_official | 205:c41fc65bcfb4 | 366 | |
mbed_official | 205:c41fc65bcfb4 | 367 | hirda->TxXferSize = Size; |
mbed_official | 205:c41fc65bcfb4 | 368 | hirda->TxXferCount = Size; |
mbed_official | 205:c41fc65bcfb4 | 369 | while(hirda->TxXferCount > 0) |
mbed_official | 205:c41fc65bcfb4 | 370 | { |
mbed_official | 205:c41fc65bcfb4 | 371 | hirda->TxXferCount--; |
mbed_official | 205:c41fc65bcfb4 | 372 | |
mbed_official | 205:c41fc65bcfb4 | 373 | if(IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_TXE, RESET, Timeout) != HAL_OK) |
mbed_official | 205:c41fc65bcfb4 | 374 | { |
mbed_official | 205:c41fc65bcfb4 | 375 | return HAL_TIMEOUT; |
mbed_official | 205:c41fc65bcfb4 | 376 | } |
mbed_official | 205:c41fc65bcfb4 | 377 | if ((hirda->Init.WordLength == IRDA_WORDLENGTH_9B) && (hirda->Init.Parity == IRDA_PARITY_NONE)) |
mbed_official | 205:c41fc65bcfb4 | 378 | { |
mbed_official | 205:c41fc65bcfb4 | 379 | tmp = (uint16_t*) pData; |
mbed_official | 205:c41fc65bcfb4 | 380 | hirda->Instance->TDR = (*tmp & (uint16_t)0x01FF); |
mbed_official | 205:c41fc65bcfb4 | 381 | pData += 2; |
mbed_official | 205:c41fc65bcfb4 | 382 | } |
mbed_official | 205:c41fc65bcfb4 | 383 | else |
mbed_official | 205:c41fc65bcfb4 | 384 | { |
mbed_official | 205:c41fc65bcfb4 | 385 | hirda->Instance->TDR = (*pData++ & (uint8_t)0xFF); |
mbed_official | 205:c41fc65bcfb4 | 386 | } |
mbed_official | 205:c41fc65bcfb4 | 387 | } |
mbed_official | 205:c41fc65bcfb4 | 388 | |
mbed_official | 205:c41fc65bcfb4 | 389 | if(IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_TC, RESET, Timeout) != HAL_OK) |
mbed_official | 205:c41fc65bcfb4 | 390 | { |
mbed_official | 205:c41fc65bcfb4 | 391 | return HAL_TIMEOUT; |
mbed_official | 205:c41fc65bcfb4 | 392 | } |
mbed_official | 205:c41fc65bcfb4 | 393 | |
mbed_official | 205:c41fc65bcfb4 | 394 | if(hirda->State == HAL_IRDA_STATE_BUSY_TX_RX) |
mbed_official | 205:c41fc65bcfb4 | 395 | { |
mbed_official | 205:c41fc65bcfb4 | 396 | hirda->State = HAL_IRDA_STATE_BUSY_RX; |
mbed_official | 205:c41fc65bcfb4 | 397 | } |
mbed_official | 205:c41fc65bcfb4 | 398 | else |
mbed_official | 205:c41fc65bcfb4 | 399 | { |
mbed_official | 205:c41fc65bcfb4 | 400 | hirda->State = HAL_IRDA_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 401 | } |
mbed_official | 205:c41fc65bcfb4 | 402 | |
mbed_official | 205:c41fc65bcfb4 | 403 | /* Process Unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 404 | __HAL_UNLOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 405 | |
mbed_official | 205:c41fc65bcfb4 | 406 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 407 | } |
mbed_official | 205:c41fc65bcfb4 | 408 | else |
mbed_official | 205:c41fc65bcfb4 | 409 | { |
mbed_official | 205:c41fc65bcfb4 | 410 | return HAL_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 411 | } |
mbed_official | 205:c41fc65bcfb4 | 412 | } |
mbed_official | 205:c41fc65bcfb4 | 413 | |
mbed_official | 205:c41fc65bcfb4 | 414 | /** |
mbed_official | 205:c41fc65bcfb4 | 415 | * @brief Receive an amount of data in blocking mode |
mbed_official | 205:c41fc65bcfb4 | 416 | * @param hirda: IRDA handle |
mbed_official | 205:c41fc65bcfb4 | 417 | * @param pData: pointer to data buffer |
mbed_official | 205:c41fc65bcfb4 | 418 | * @param Size: amount of data to be received |
mbed_official | 205:c41fc65bcfb4 | 419 | * @param Timeout: Duration of the timeout |
mbed_official | 205:c41fc65bcfb4 | 420 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 421 | */ |
mbed_official | 205:c41fc65bcfb4 | 422 | HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout) |
mbed_official | 205:c41fc65bcfb4 | 423 | { |
mbed_official | 205:c41fc65bcfb4 | 424 | uint16_t* tmp; |
mbed_official | 205:c41fc65bcfb4 | 425 | uint16_t uhMask; |
mbed_official | 205:c41fc65bcfb4 | 426 | |
mbed_official | 205:c41fc65bcfb4 | 427 | if ((hirda->State == HAL_IRDA_STATE_READY) || (hirda->State == HAL_IRDA_STATE_BUSY_TX)) |
mbed_official | 205:c41fc65bcfb4 | 428 | { |
mbed_official | 205:c41fc65bcfb4 | 429 | if((pData == NULL) || (Size == 0)) |
mbed_official | 205:c41fc65bcfb4 | 430 | { |
mbed_official | 205:c41fc65bcfb4 | 431 | return HAL_ERROR; |
mbed_official | 205:c41fc65bcfb4 | 432 | } |
mbed_official | 205:c41fc65bcfb4 | 433 | |
mbed_official | 205:c41fc65bcfb4 | 434 | /* Process Locked */ |
mbed_official | 205:c41fc65bcfb4 | 435 | __HAL_LOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 436 | hirda->ErrorCode = HAL_IRDA_ERROR_NONE; |
mbed_official | 205:c41fc65bcfb4 | 437 | |
mbed_official | 205:c41fc65bcfb4 | 438 | if(hirda->State == HAL_IRDA_STATE_BUSY_TX) |
mbed_official | 205:c41fc65bcfb4 | 439 | { |
mbed_official | 205:c41fc65bcfb4 | 440 | hirda->State = HAL_IRDA_STATE_BUSY_TX_RX; |
mbed_official | 205:c41fc65bcfb4 | 441 | } |
mbed_official | 205:c41fc65bcfb4 | 442 | else |
mbed_official | 205:c41fc65bcfb4 | 443 | { |
mbed_official | 205:c41fc65bcfb4 | 444 | hirda->State = HAL_IRDA_STATE_BUSY_RX; |
mbed_official | 205:c41fc65bcfb4 | 445 | } |
mbed_official | 205:c41fc65bcfb4 | 446 | |
mbed_official | 205:c41fc65bcfb4 | 447 | hirda->RxXferSize = Size; |
mbed_official | 205:c41fc65bcfb4 | 448 | hirda->RxXferCount = Size; |
mbed_official | 205:c41fc65bcfb4 | 449 | |
mbed_official | 205:c41fc65bcfb4 | 450 | /* Computation of the mask to apply to the RDR register |
mbed_official | 205:c41fc65bcfb4 | 451 | of the UART associated to the IRDA */ |
mbed_official | 205:c41fc65bcfb4 | 452 | __HAL_IRDA_MASK_COMPUTATION(hirda); |
mbed_official | 205:c41fc65bcfb4 | 453 | uhMask = hirda->Mask; |
mbed_official | 205:c41fc65bcfb4 | 454 | |
mbed_official | 205:c41fc65bcfb4 | 455 | /* Check data remaining to be received */ |
mbed_official | 205:c41fc65bcfb4 | 456 | while(hirda->RxXferCount > 0) |
mbed_official | 205:c41fc65bcfb4 | 457 | { |
mbed_official | 205:c41fc65bcfb4 | 458 | hirda->RxXferCount--; |
mbed_official | 205:c41fc65bcfb4 | 459 | |
mbed_official | 205:c41fc65bcfb4 | 460 | if(IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_RXNE, RESET, Timeout) != HAL_OK) |
mbed_official | 205:c41fc65bcfb4 | 461 | { |
mbed_official | 205:c41fc65bcfb4 | 462 | return HAL_TIMEOUT; |
mbed_official | 205:c41fc65bcfb4 | 463 | } |
mbed_official | 205:c41fc65bcfb4 | 464 | if ((hirda->Init.WordLength == IRDA_WORDLENGTH_9B) && (hirda->Init.Parity == IRDA_PARITY_NONE)) |
mbed_official | 205:c41fc65bcfb4 | 465 | { |
mbed_official | 205:c41fc65bcfb4 | 466 | tmp = (uint16_t*) pData ; |
mbed_official | 205:c41fc65bcfb4 | 467 | *tmp = (uint16_t)(hirda->Instance->RDR & uhMask); |
mbed_official | 205:c41fc65bcfb4 | 468 | pData +=2; |
mbed_official | 205:c41fc65bcfb4 | 469 | } |
mbed_official | 205:c41fc65bcfb4 | 470 | else |
mbed_official | 205:c41fc65bcfb4 | 471 | { |
mbed_official | 205:c41fc65bcfb4 | 472 | *pData++ = (uint8_t)(hirda->Instance->RDR & (uint8_t)uhMask); |
mbed_official | 205:c41fc65bcfb4 | 473 | } |
mbed_official | 205:c41fc65bcfb4 | 474 | } |
mbed_official | 205:c41fc65bcfb4 | 475 | |
mbed_official | 205:c41fc65bcfb4 | 476 | if(hirda->State == HAL_IRDA_STATE_BUSY_TX_RX) |
mbed_official | 205:c41fc65bcfb4 | 477 | { |
mbed_official | 205:c41fc65bcfb4 | 478 | hirda->State = HAL_IRDA_STATE_BUSY_TX; |
mbed_official | 205:c41fc65bcfb4 | 479 | } |
mbed_official | 205:c41fc65bcfb4 | 480 | else |
mbed_official | 205:c41fc65bcfb4 | 481 | { |
mbed_official | 205:c41fc65bcfb4 | 482 | hirda->State = HAL_IRDA_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 483 | } |
mbed_official | 205:c41fc65bcfb4 | 484 | |
mbed_official | 205:c41fc65bcfb4 | 485 | /* Process Unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 486 | __HAL_UNLOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 487 | |
mbed_official | 205:c41fc65bcfb4 | 488 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 489 | } |
mbed_official | 205:c41fc65bcfb4 | 490 | else |
mbed_official | 205:c41fc65bcfb4 | 491 | { |
mbed_official | 205:c41fc65bcfb4 | 492 | return HAL_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 493 | } |
mbed_official | 205:c41fc65bcfb4 | 494 | } |
mbed_official | 205:c41fc65bcfb4 | 495 | |
mbed_official | 205:c41fc65bcfb4 | 496 | /** |
mbed_official | 205:c41fc65bcfb4 | 497 | * @brief Send an amount of data in interrupt mode |
mbed_official | 205:c41fc65bcfb4 | 498 | * @param hirda: IRDA handle |
mbed_official | 205:c41fc65bcfb4 | 499 | * @param pData: pointer to data buffer |
mbed_official | 205:c41fc65bcfb4 | 500 | * @param Size: amount of data to be sent |
mbed_official | 205:c41fc65bcfb4 | 501 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 502 | */ |
mbed_official | 205:c41fc65bcfb4 | 503 | HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size) |
mbed_official | 205:c41fc65bcfb4 | 504 | { |
mbed_official | 205:c41fc65bcfb4 | 505 | if ((hirda->State == HAL_IRDA_STATE_READY) || (hirda->State == HAL_IRDA_STATE_BUSY_RX)) |
mbed_official | 205:c41fc65bcfb4 | 506 | { |
mbed_official | 205:c41fc65bcfb4 | 507 | if((pData == NULL) || (Size == 0)) |
mbed_official | 205:c41fc65bcfb4 | 508 | { |
mbed_official | 205:c41fc65bcfb4 | 509 | return HAL_ERROR; |
mbed_official | 205:c41fc65bcfb4 | 510 | } |
mbed_official | 205:c41fc65bcfb4 | 511 | |
mbed_official | 205:c41fc65bcfb4 | 512 | /* Process Locked */ |
mbed_official | 205:c41fc65bcfb4 | 513 | __HAL_LOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 514 | |
mbed_official | 205:c41fc65bcfb4 | 515 | hirda->pTxBuffPtr = pData; |
mbed_official | 205:c41fc65bcfb4 | 516 | hirda->TxXferSize = Size; |
mbed_official | 205:c41fc65bcfb4 | 517 | hirda->TxXferCount = Size; |
mbed_official | 205:c41fc65bcfb4 | 518 | |
mbed_official | 205:c41fc65bcfb4 | 519 | hirda->ErrorCode = HAL_IRDA_ERROR_NONE; |
mbed_official | 205:c41fc65bcfb4 | 520 | if(hirda->State == HAL_IRDA_STATE_BUSY_RX) |
mbed_official | 205:c41fc65bcfb4 | 521 | { |
mbed_official | 205:c41fc65bcfb4 | 522 | hirda->State = HAL_IRDA_STATE_BUSY_TX_RX; |
mbed_official | 205:c41fc65bcfb4 | 523 | } |
mbed_official | 205:c41fc65bcfb4 | 524 | else |
mbed_official | 205:c41fc65bcfb4 | 525 | { |
mbed_official | 205:c41fc65bcfb4 | 526 | hirda->State = HAL_IRDA_STATE_BUSY_TX; |
mbed_official | 205:c41fc65bcfb4 | 527 | } |
mbed_official | 205:c41fc65bcfb4 | 528 | |
mbed_official | 205:c41fc65bcfb4 | 529 | /* Enable the IRDA Error Interrupt: (Frame error, noise error, overrun error) */ |
mbed_official | 205:c41fc65bcfb4 | 530 | __HAL_IRDA_ENABLE_IT(hirda, IRDA_IT_ERR); |
mbed_official | 205:c41fc65bcfb4 | 531 | |
mbed_official | 205:c41fc65bcfb4 | 532 | /* Process Unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 533 | __HAL_UNLOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 534 | |
mbed_official | 205:c41fc65bcfb4 | 535 | /* Enable the IRDA Transmit Complete Interrupt */ |
mbed_official | 205:c41fc65bcfb4 | 536 | __HAL_IRDA_ENABLE_IT(hirda, IRDA_IT_TC); |
mbed_official | 205:c41fc65bcfb4 | 537 | |
mbed_official | 205:c41fc65bcfb4 | 538 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 539 | } |
mbed_official | 205:c41fc65bcfb4 | 540 | else |
mbed_official | 205:c41fc65bcfb4 | 541 | { |
mbed_official | 205:c41fc65bcfb4 | 542 | return HAL_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 543 | } |
mbed_official | 205:c41fc65bcfb4 | 544 | } |
mbed_official | 205:c41fc65bcfb4 | 545 | |
mbed_official | 205:c41fc65bcfb4 | 546 | /** |
mbed_official | 205:c41fc65bcfb4 | 547 | * @brief Receive an amount of data in interrupt mode |
mbed_official | 205:c41fc65bcfb4 | 548 | * @param hirda: IRDA handle |
mbed_official | 205:c41fc65bcfb4 | 549 | * @param pData: pointer to data buffer |
mbed_official | 205:c41fc65bcfb4 | 550 | * @param Size: amount of data to be received |
mbed_official | 205:c41fc65bcfb4 | 551 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 552 | */ |
mbed_official | 205:c41fc65bcfb4 | 553 | HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size) |
mbed_official | 205:c41fc65bcfb4 | 554 | { |
mbed_official | 205:c41fc65bcfb4 | 555 | if ((hirda->State == HAL_IRDA_STATE_READY) || (hirda->State == HAL_IRDA_STATE_BUSY_TX)) |
mbed_official | 205:c41fc65bcfb4 | 556 | { |
mbed_official | 205:c41fc65bcfb4 | 557 | if((pData == NULL) || (Size == 0)) |
mbed_official | 205:c41fc65bcfb4 | 558 | { |
mbed_official | 205:c41fc65bcfb4 | 559 | return HAL_ERROR; |
mbed_official | 205:c41fc65bcfb4 | 560 | } |
mbed_official | 205:c41fc65bcfb4 | 561 | |
mbed_official | 205:c41fc65bcfb4 | 562 | /* Process Locked */ |
mbed_official | 205:c41fc65bcfb4 | 563 | __HAL_LOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 564 | |
mbed_official | 205:c41fc65bcfb4 | 565 | hirda->pRxBuffPtr = pData; |
mbed_official | 205:c41fc65bcfb4 | 566 | hirda->RxXferSize = Size; |
mbed_official | 205:c41fc65bcfb4 | 567 | hirda->RxXferCount = Size; |
mbed_official | 205:c41fc65bcfb4 | 568 | |
mbed_official | 205:c41fc65bcfb4 | 569 | /* Computation of the mask to apply to the RDR register |
mbed_official | 205:c41fc65bcfb4 | 570 | of the UART associated to the IRDA */ |
mbed_official | 205:c41fc65bcfb4 | 571 | __HAL_IRDA_MASK_COMPUTATION(hirda); |
mbed_official | 205:c41fc65bcfb4 | 572 | |
mbed_official | 205:c41fc65bcfb4 | 573 | hirda->ErrorCode = HAL_IRDA_ERROR_NONE; |
mbed_official | 205:c41fc65bcfb4 | 574 | if(hirda->State == HAL_IRDA_STATE_BUSY_TX) |
mbed_official | 205:c41fc65bcfb4 | 575 | { |
mbed_official | 205:c41fc65bcfb4 | 576 | hirda->State = HAL_IRDA_STATE_BUSY_TX_RX; |
mbed_official | 205:c41fc65bcfb4 | 577 | } |
mbed_official | 205:c41fc65bcfb4 | 578 | else |
mbed_official | 205:c41fc65bcfb4 | 579 | { |
mbed_official | 205:c41fc65bcfb4 | 580 | hirda->State = HAL_IRDA_STATE_BUSY_RX; |
mbed_official | 205:c41fc65bcfb4 | 581 | } |
mbed_official | 205:c41fc65bcfb4 | 582 | |
mbed_official | 205:c41fc65bcfb4 | 583 | /* Enable the IRDA Parity Error Interrupt */ |
mbed_official | 205:c41fc65bcfb4 | 584 | __HAL_IRDA_ENABLE_IT(hirda, IRDA_IT_PE); |
mbed_official | 205:c41fc65bcfb4 | 585 | |
mbed_official | 205:c41fc65bcfb4 | 586 | /* Enable the IRDA Error Interrupt: (Frame error, noise error, overrun error) */ |
mbed_official | 205:c41fc65bcfb4 | 587 | __HAL_IRDA_ENABLE_IT(hirda, IRDA_IT_ERR); |
mbed_official | 205:c41fc65bcfb4 | 588 | |
mbed_official | 205:c41fc65bcfb4 | 589 | /* Process Unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 590 | __HAL_UNLOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 591 | |
mbed_official | 205:c41fc65bcfb4 | 592 | /* Enable the IRDA Data Register not empty Interrupt */ |
mbed_official | 205:c41fc65bcfb4 | 593 | __HAL_IRDA_ENABLE_IT(hirda, IRDA_IT_RXNE); |
mbed_official | 205:c41fc65bcfb4 | 594 | |
mbed_official | 205:c41fc65bcfb4 | 595 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 596 | } |
mbed_official | 205:c41fc65bcfb4 | 597 | else |
mbed_official | 205:c41fc65bcfb4 | 598 | { |
mbed_official | 205:c41fc65bcfb4 | 599 | return HAL_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 600 | } |
mbed_official | 205:c41fc65bcfb4 | 601 | } |
mbed_official | 205:c41fc65bcfb4 | 602 | |
mbed_official | 205:c41fc65bcfb4 | 603 | /** |
mbed_official | 205:c41fc65bcfb4 | 604 | * @brief Send an amount of data in DMA mode |
mbed_official | 205:c41fc65bcfb4 | 605 | * @param hirda: IRDA handle |
mbed_official | 205:c41fc65bcfb4 | 606 | * @param pData: pointer to data buffer |
mbed_official | 205:c41fc65bcfb4 | 607 | * @param Size: amount of data to be sent |
mbed_official | 205:c41fc65bcfb4 | 608 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 609 | */ |
mbed_official | 205:c41fc65bcfb4 | 610 | HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size) |
mbed_official | 205:c41fc65bcfb4 | 611 | { |
mbed_official | 205:c41fc65bcfb4 | 612 | uint32_t *tmp; |
mbed_official | 205:c41fc65bcfb4 | 613 | |
mbed_official | 205:c41fc65bcfb4 | 614 | if ((hirda->State == HAL_IRDA_STATE_READY) || (hirda->State == HAL_IRDA_STATE_BUSY_RX)) |
mbed_official | 205:c41fc65bcfb4 | 615 | { |
mbed_official | 205:c41fc65bcfb4 | 616 | if((pData == NULL) || (Size == 0)) |
mbed_official | 205:c41fc65bcfb4 | 617 | { |
mbed_official | 205:c41fc65bcfb4 | 618 | return HAL_ERROR; |
mbed_official | 205:c41fc65bcfb4 | 619 | } |
mbed_official | 205:c41fc65bcfb4 | 620 | |
mbed_official | 205:c41fc65bcfb4 | 621 | /* Process Locked */ |
mbed_official | 205:c41fc65bcfb4 | 622 | __HAL_LOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 623 | |
mbed_official | 205:c41fc65bcfb4 | 624 | hirda->pTxBuffPtr = pData; |
mbed_official | 205:c41fc65bcfb4 | 625 | hirda->TxXferSize = Size; |
mbed_official | 205:c41fc65bcfb4 | 626 | hirda->TxXferCount = Size; |
mbed_official | 205:c41fc65bcfb4 | 627 | |
mbed_official | 205:c41fc65bcfb4 | 628 | hirda->ErrorCode = HAL_IRDA_ERROR_NONE; |
mbed_official | 205:c41fc65bcfb4 | 629 | |
mbed_official | 205:c41fc65bcfb4 | 630 | if(hirda->State == HAL_IRDA_STATE_BUSY_RX) |
mbed_official | 205:c41fc65bcfb4 | 631 | { |
mbed_official | 205:c41fc65bcfb4 | 632 | hirda->State = HAL_IRDA_STATE_BUSY_TX_RX; |
mbed_official | 205:c41fc65bcfb4 | 633 | } |
mbed_official | 205:c41fc65bcfb4 | 634 | else |
mbed_official | 205:c41fc65bcfb4 | 635 | { |
mbed_official | 205:c41fc65bcfb4 | 636 | hirda->State = HAL_IRDA_STATE_BUSY_TX; |
mbed_official | 205:c41fc65bcfb4 | 637 | } |
mbed_official | 205:c41fc65bcfb4 | 638 | |
mbed_official | 205:c41fc65bcfb4 | 639 | /* Set the IRDA DMA transfer complete callback */ |
mbed_official | 205:c41fc65bcfb4 | 640 | hirda->hdmatx->XferCpltCallback = IRDA_DMATransmitCplt; |
mbed_official | 205:c41fc65bcfb4 | 641 | |
mbed_official | 205:c41fc65bcfb4 | 642 | /* Set the DMA error callback */ |
mbed_official | 205:c41fc65bcfb4 | 643 | hirda->hdmatx->XferErrorCallback = IRDA_DMAError; |
mbed_official | 205:c41fc65bcfb4 | 644 | |
mbed_official | 205:c41fc65bcfb4 | 645 | /* Enable the IRDA transmit DMA channel */ |
mbed_official | 205:c41fc65bcfb4 | 646 | tmp = (uint32_t*)&pData; |
mbed_official | 205:c41fc65bcfb4 | 647 | HAL_DMA_Start_IT(hirda->hdmatx, *(uint32_t*)tmp, (uint32_t)&hirda->Instance->TDR, Size); |
mbed_official | 205:c41fc65bcfb4 | 648 | |
mbed_official | 205:c41fc65bcfb4 | 649 | /* Enable the DMA transfer for transmit request by setting the DMAT bit |
mbed_official | 205:c41fc65bcfb4 | 650 | in the IRDA CR3 register */ |
mbed_official | 205:c41fc65bcfb4 | 651 | hirda->Instance->CR3 |= USART_CR3_DMAT; |
mbed_official | 205:c41fc65bcfb4 | 652 | |
mbed_official | 205:c41fc65bcfb4 | 653 | /* Process Unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 654 | __HAL_UNLOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 655 | |
mbed_official | 205:c41fc65bcfb4 | 656 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 657 | } |
mbed_official | 205:c41fc65bcfb4 | 658 | else |
mbed_official | 205:c41fc65bcfb4 | 659 | { |
mbed_official | 205:c41fc65bcfb4 | 660 | return HAL_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 661 | } |
mbed_official | 205:c41fc65bcfb4 | 662 | } |
mbed_official | 205:c41fc65bcfb4 | 663 | |
mbed_official | 205:c41fc65bcfb4 | 664 | /** |
mbed_official | 205:c41fc65bcfb4 | 665 | * @brief Receive an amount of data in DMA mode |
mbed_official | 205:c41fc65bcfb4 | 666 | * @param hirda: IRDA handle |
mbed_official | 205:c41fc65bcfb4 | 667 | * @param pData: pointer to data buffer |
mbed_official | 205:c41fc65bcfb4 | 668 | * @param Size: amount of data to be received |
mbed_official | 205:c41fc65bcfb4 | 669 | * @note When the IRDA parity is enabled (PCE = 1), the received data contain |
mbed_official | 205:c41fc65bcfb4 | 670 | * the parity bit (MSB position) |
mbed_official | 205:c41fc65bcfb4 | 671 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 672 | */ |
mbed_official | 205:c41fc65bcfb4 | 673 | HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size) |
mbed_official | 205:c41fc65bcfb4 | 674 | { |
mbed_official | 205:c41fc65bcfb4 | 675 | uint32_t *tmp; |
mbed_official | 205:c41fc65bcfb4 | 676 | |
mbed_official | 205:c41fc65bcfb4 | 677 | if ((hirda->State == HAL_IRDA_STATE_READY) || (hirda->State == HAL_IRDA_STATE_BUSY_TX)) |
mbed_official | 205:c41fc65bcfb4 | 678 | { |
mbed_official | 205:c41fc65bcfb4 | 679 | if((pData == NULL) || (Size == 0)) |
mbed_official | 205:c41fc65bcfb4 | 680 | { |
mbed_official | 205:c41fc65bcfb4 | 681 | return HAL_ERROR; |
mbed_official | 205:c41fc65bcfb4 | 682 | } |
mbed_official | 205:c41fc65bcfb4 | 683 | |
mbed_official | 205:c41fc65bcfb4 | 684 | /* Process Locked */ |
mbed_official | 205:c41fc65bcfb4 | 685 | __HAL_LOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 686 | |
mbed_official | 205:c41fc65bcfb4 | 687 | hirda->pRxBuffPtr = pData; |
mbed_official | 205:c41fc65bcfb4 | 688 | hirda->RxXferSize = Size; |
mbed_official | 205:c41fc65bcfb4 | 689 | |
mbed_official | 205:c41fc65bcfb4 | 690 | hirda->ErrorCode = HAL_IRDA_ERROR_NONE; |
mbed_official | 205:c41fc65bcfb4 | 691 | if(hirda->State == HAL_IRDA_STATE_BUSY_TX) |
mbed_official | 205:c41fc65bcfb4 | 692 | { |
mbed_official | 205:c41fc65bcfb4 | 693 | hirda->State = HAL_IRDA_STATE_BUSY_TX_RX; |
mbed_official | 205:c41fc65bcfb4 | 694 | } |
mbed_official | 205:c41fc65bcfb4 | 695 | else |
mbed_official | 205:c41fc65bcfb4 | 696 | { |
mbed_official | 205:c41fc65bcfb4 | 697 | hirda->State = HAL_IRDA_STATE_BUSY_RX; |
mbed_official | 205:c41fc65bcfb4 | 698 | } |
mbed_official | 205:c41fc65bcfb4 | 699 | |
mbed_official | 205:c41fc65bcfb4 | 700 | /* Set the IRDA DMA transfer complete callback */ |
mbed_official | 205:c41fc65bcfb4 | 701 | hirda->hdmarx->XferCpltCallback = IRDA_DMAReceiveCplt; |
mbed_official | 205:c41fc65bcfb4 | 702 | |
mbed_official | 205:c41fc65bcfb4 | 703 | /* Set the DMA error callback */ |
mbed_official | 205:c41fc65bcfb4 | 704 | hirda->hdmarx->XferErrorCallback = IRDA_DMAError; |
mbed_official | 205:c41fc65bcfb4 | 705 | |
mbed_official | 205:c41fc65bcfb4 | 706 | /* Enable the DMA channel */ |
mbed_official | 205:c41fc65bcfb4 | 707 | tmp = (uint32_t*)&pData; |
mbed_official | 205:c41fc65bcfb4 | 708 | HAL_DMA_Start_IT(hirda->hdmarx, (uint32_t)&hirda->Instance->RDR, *(uint32_t*)tmp, Size); |
mbed_official | 205:c41fc65bcfb4 | 709 | |
mbed_official | 205:c41fc65bcfb4 | 710 | /* Enable the DMA transfer for the receiver request by setting the DMAR bit |
mbed_official | 205:c41fc65bcfb4 | 711 | in the IRDA CR3 register */ |
mbed_official | 205:c41fc65bcfb4 | 712 | hirda->Instance->CR3 |= USART_CR3_DMAR; |
mbed_official | 205:c41fc65bcfb4 | 713 | |
mbed_official | 205:c41fc65bcfb4 | 714 | /* Process Unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 715 | __HAL_UNLOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 716 | |
mbed_official | 205:c41fc65bcfb4 | 717 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 718 | } |
mbed_official | 205:c41fc65bcfb4 | 719 | else |
mbed_official | 205:c41fc65bcfb4 | 720 | { |
mbed_official | 205:c41fc65bcfb4 | 721 | return HAL_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 722 | } |
mbed_official | 205:c41fc65bcfb4 | 723 | } |
mbed_official | 205:c41fc65bcfb4 | 724 | |
mbed_official | 205:c41fc65bcfb4 | 725 | /** |
mbed_official | 205:c41fc65bcfb4 | 726 | * @brief This function handles IRDA interrupt request. |
mbed_official | 205:c41fc65bcfb4 | 727 | * @param hirda: IRDA handle |
mbed_official | 205:c41fc65bcfb4 | 728 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 729 | */ |
mbed_official | 205:c41fc65bcfb4 | 730 | void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda) |
mbed_official | 205:c41fc65bcfb4 | 731 | { |
mbed_official | 205:c41fc65bcfb4 | 732 | /* IRDA parity error interrupt occurred -------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 733 | if((__HAL_IRDA_GET_IT(hirda, IRDA_IT_PE) != RESET) && (__HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_PE) != RESET)) |
mbed_official | 205:c41fc65bcfb4 | 734 | { |
mbed_official | 205:c41fc65bcfb4 | 735 | __HAL_IRDA_CLEAR_IT(hirda, IRDA_CLEAR_PEF); |
mbed_official | 205:c41fc65bcfb4 | 736 | |
mbed_official | 205:c41fc65bcfb4 | 737 | hirda->ErrorCode |= HAL_IRDA_ERROR_PE; |
mbed_official | 205:c41fc65bcfb4 | 738 | /* Set the IRDA state ready to be able to start again the process */ |
mbed_official | 205:c41fc65bcfb4 | 739 | hirda->State = HAL_IRDA_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 740 | } |
mbed_official | 205:c41fc65bcfb4 | 741 | |
mbed_official | 205:c41fc65bcfb4 | 742 | /* IRDA frame error interrupt occured --------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 743 | if((__HAL_IRDA_GET_IT(hirda, IRDA_IT_FE) != RESET) && (__HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_ERR) != RESET)) |
mbed_official | 205:c41fc65bcfb4 | 744 | { |
mbed_official | 205:c41fc65bcfb4 | 745 | __HAL_IRDA_CLEAR_IT(hirda, IRDA_CLEAR_FEF); |
mbed_official | 205:c41fc65bcfb4 | 746 | |
mbed_official | 205:c41fc65bcfb4 | 747 | hirda->ErrorCode |= HAL_IRDA_ERROR_FE; |
mbed_official | 205:c41fc65bcfb4 | 748 | /* Set the IRDA state ready to be able to start again the process */ |
mbed_official | 205:c41fc65bcfb4 | 749 | hirda->State = HAL_IRDA_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 750 | } |
mbed_official | 205:c41fc65bcfb4 | 751 | |
mbed_official | 205:c41fc65bcfb4 | 752 | /* IRDA noise error interrupt occured --------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 753 | if((__HAL_IRDA_GET_IT(hirda, IRDA_IT_NE) != RESET) && (__HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_ERR) != RESET)) |
mbed_official | 205:c41fc65bcfb4 | 754 | { |
mbed_official | 205:c41fc65bcfb4 | 755 | __HAL_IRDA_CLEAR_IT(hirda, IRDA_CLEAR_NEF); |
mbed_official | 205:c41fc65bcfb4 | 756 | |
mbed_official | 205:c41fc65bcfb4 | 757 | hirda->ErrorCode |= HAL_IRDA_ERROR_NE; |
mbed_official | 205:c41fc65bcfb4 | 758 | /* Set the IRDA state ready to be able to start again the process */ |
mbed_official | 205:c41fc65bcfb4 | 759 | hirda->State = HAL_IRDA_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 760 | } |
mbed_official | 205:c41fc65bcfb4 | 761 | |
mbed_official | 205:c41fc65bcfb4 | 762 | /* IRDA Over-Run interrupt occured -----------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 763 | if((__HAL_IRDA_GET_IT(hirda, IRDA_IT_ORE) != RESET) && (__HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_ERR) != RESET)) |
mbed_official | 205:c41fc65bcfb4 | 764 | { |
mbed_official | 205:c41fc65bcfb4 | 765 | __HAL_IRDA_CLEAR_IT(hirda, IRDA_CLEAR_OREF); |
mbed_official | 205:c41fc65bcfb4 | 766 | |
mbed_official | 205:c41fc65bcfb4 | 767 | hirda->ErrorCode |= HAL_IRDA_ERROR_ORE; |
mbed_official | 205:c41fc65bcfb4 | 768 | /* Set the IRDA state ready to be able to start again the process */ |
mbed_official | 205:c41fc65bcfb4 | 769 | hirda->State = HAL_IRDA_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 770 | } |
mbed_official | 205:c41fc65bcfb4 | 771 | |
mbed_official | 205:c41fc65bcfb4 | 772 | /* Call IRDA Error Call back function if need be --------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 773 | if(hirda->ErrorCode != HAL_IRDA_ERROR_NONE) |
mbed_official | 205:c41fc65bcfb4 | 774 | { |
mbed_official | 205:c41fc65bcfb4 | 775 | HAL_IRDA_ErrorCallback(hirda); |
mbed_official | 205:c41fc65bcfb4 | 776 | } |
mbed_official | 205:c41fc65bcfb4 | 777 | |
mbed_official | 205:c41fc65bcfb4 | 778 | /* IRDA in mode Receiver ---------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 779 | if((__HAL_IRDA_GET_IT(hirda, IRDA_IT_RXNE) != RESET) && (__HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_RXNE) != RESET)) |
mbed_official | 205:c41fc65bcfb4 | 780 | { |
mbed_official | 205:c41fc65bcfb4 | 781 | IRDA_Receive_IT(hirda); |
mbed_official | 205:c41fc65bcfb4 | 782 | /* Clear RXNE interrupt flag */ |
mbed_official | 205:c41fc65bcfb4 | 783 | __HAL_IRDA_SEND_REQ(hirda, IRDA_RXDATA_FLUSH_REQUEST); |
mbed_official | 205:c41fc65bcfb4 | 784 | } |
mbed_official | 205:c41fc65bcfb4 | 785 | |
mbed_official | 205:c41fc65bcfb4 | 786 | |
mbed_official | 205:c41fc65bcfb4 | 787 | /* IRDA in mode Transmitter ------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 788 | if((__HAL_IRDA_GET_IT(hirda, IRDA_IT_TC) != RESET) &&(__HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_TC) != RESET)) |
mbed_official | 205:c41fc65bcfb4 | 789 | { |
mbed_official | 205:c41fc65bcfb4 | 790 | IRDA_Transmit_IT(hirda); |
mbed_official | 205:c41fc65bcfb4 | 791 | } |
mbed_official | 205:c41fc65bcfb4 | 792 | |
mbed_official | 205:c41fc65bcfb4 | 793 | } |
mbed_official | 205:c41fc65bcfb4 | 794 | |
mbed_official | 205:c41fc65bcfb4 | 795 | /** |
mbed_official | 205:c41fc65bcfb4 | 796 | * @brief DMA IRDA Tx transfer completed callback |
mbed_official | 205:c41fc65bcfb4 | 797 | * @param hdma: DMA handle |
mbed_official | 205:c41fc65bcfb4 | 798 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 799 | */ |
mbed_official | 205:c41fc65bcfb4 | 800 | static void IRDA_DMATransmitCplt(DMA_HandleTypeDef *hdma) |
mbed_official | 205:c41fc65bcfb4 | 801 | { |
mbed_official | 205:c41fc65bcfb4 | 802 | IRDA_HandleTypeDef* hirda = ( IRDA_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
mbed_official | 205:c41fc65bcfb4 | 803 | hirda->TxXferCount = 0; |
mbed_official | 205:c41fc65bcfb4 | 804 | |
mbed_official | 205:c41fc65bcfb4 | 805 | /* Disable the DMA transfer for transmit request by setting the DMAT bit |
mbed_official | 205:c41fc65bcfb4 | 806 | in the IRDA CR3 register */ |
mbed_official | 205:c41fc65bcfb4 | 807 | hirda->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_DMAT); |
mbed_official | 205:c41fc65bcfb4 | 808 | |
mbed_official | 205:c41fc65bcfb4 | 809 | /* Wait for IRDA TC Flag */ |
mbed_official | 205:c41fc65bcfb4 | 810 | if(IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_TC, RESET, HAL_IRDA_TXDMA_TIMEOUTVALUE) != HAL_OK) |
mbed_official | 205:c41fc65bcfb4 | 811 | { |
mbed_official | 205:c41fc65bcfb4 | 812 | /* Timeout Occured */ |
mbed_official | 205:c41fc65bcfb4 | 813 | HAL_IRDA_ErrorCallback(hirda); |
mbed_official | 205:c41fc65bcfb4 | 814 | } |
mbed_official | 205:c41fc65bcfb4 | 815 | else |
mbed_official | 205:c41fc65bcfb4 | 816 | { |
mbed_official | 205:c41fc65bcfb4 | 817 | /* No Timeout */ |
mbed_official | 205:c41fc65bcfb4 | 818 | if(hirda->State == HAL_IRDA_STATE_BUSY_TX_RX) |
mbed_official | 205:c41fc65bcfb4 | 819 | { |
mbed_official | 205:c41fc65bcfb4 | 820 | hirda->State = HAL_IRDA_STATE_BUSY_RX; |
mbed_official | 205:c41fc65bcfb4 | 821 | } |
mbed_official | 205:c41fc65bcfb4 | 822 | else |
mbed_official | 205:c41fc65bcfb4 | 823 | { |
mbed_official | 205:c41fc65bcfb4 | 824 | hirda->State = HAL_IRDA_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 825 | } |
mbed_official | 205:c41fc65bcfb4 | 826 | HAL_IRDA_TxCpltCallback(hirda); |
mbed_official | 205:c41fc65bcfb4 | 827 | } |
mbed_official | 205:c41fc65bcfb4 | 828 | } |
mbed_official | 205:c41fc65bcfb4 | 829 | |
mbed_official | 205:c41fc65bcfb4 | 830 | /** |
mbed_official | 205:c41fc65bcfb4 | 831 | * @brief DMA IRDA Rx Transfer completed callback |
mbed_official | 205:c41fc65bcfb4 | 832 | * @param hdma: DMA handle |
mbed_official | 205:c41fc65bcfb4 | 833 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 834 | */ |
mbed_official | 205:c41fc65bcfb4 | 835 | static void IRDA_DMAReceiveCplt(DMA_HandleTypeDef *hdma) |
mbed_official | 205:c41fc65bcfb4 | 836 | { |
mbed_official | 205:c41fc65bcfb4 | 837 | IRDA_HandleTypeDef* hirda = ( IRDA_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
mbed_official | 205:c41fc65bcfb4 | 838 | hirda->RxXferCount = 0; |
mbed_official | 205:c41fc65bcfb4 | 839 | |
mbed_official | 205:c41fc65bcfb4 | 840 | /* Disable the DMA transfer for the receiver request by setting the DMAR bit |
mbed_official | 205:c41fc65bcfb4 | 841 | in the IRDA CR3 register */ |
mbed_official | 205:c41fc65bcfb4 | 842 | hirda->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_DMAR); |
mbed_official | 205:c41fc65bcfb4 | 843 | |
mbed_official | 205:c41fc65bcfb4 | 844 | if(hirda->State == HAL_IRDA_STATE_BUSY_TX_RX) |
mbed_official | 205:c41fc65bcfb4 | 845 | { |
mbed_official | 205:c41fc65bcfb4 | 846 | hirda->State = HAL_IRDA_STATE_BUSY_TX; |
mbed_official | 205:c41fc65bcfb4 | 847 | } |
mbed_official | 205:c41fc65bcfb4 | 848 | else |
mbed_official | 205:c41fc65bcfb4 | 849 | { |
mbed_official | 205:c41fc65bcfb4 | 850 | hirda->State = HAL_IRDA_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 851 | } |
mbed_official | 205:c41fc65bcfb4 | 852 | |
mbed_official | 205:c41fc65bcfb4 | 853 | HAL_IRDA_RxCpltCallback(hirda); |
mbed_official | 205:c41fc65bcfb4 | 854 | } |
mbed_official | 205:c41fc65bcfb4 | 855 | |
mbed_official | 205:c41fc65bcfb4 | 856 | /** |
mbed_official | 205:c41fc65bcfb4 | 857 | * @brief DMA IRDA communication error callback |
mbed_official | 205:c41fc65bcfb4 | 858 | * @param hdma: DMA handle |
mbed_official | 205:c41fc65bcfb4 | 859 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 860 | */ |
mbed_official | 205:c41fc65bcfb4 | 861 | static void IRDA_DMAError(DMA_HandleTypeDef *hdma) |
mbed_official | 205:c41fc65bcfb4 | 862 | { |
mbed_official | 205:c41fc65bcfb4 | 863 | IRDA_HandleTypeDef* hirda = ( IRDA_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
mbed_official | 205:c41fc65bcfb4 | 864 | hirda->RxXferCount = 0; |
mbed_official | 205:c41fc65bcfb4 | 865 | hirda->TxXferCount = 0; |
mbed_official | 205:c41fc65bcfb4 | 866 | hirda->State= HAL_IRDA_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 867 | hirda->ErrorCode |= HAL_IRDA_ERROR_DMA; |
mbed_official | 205:c41fc65bcfb4 | 868 | HAL_IRDA_ErrorCallback(hirda); |
mbed_official | 205:c41fc65bcfb4 | 869 | } |
mbed_official | 205:c41fc65bcfb4 | 870 | |
mbed_official | 205:c41fc65bcfb4 | 871 | /** |
mbed_official | 205:c41fc65bcfb4 | 872 | * @brief Tx Transfer completed callback |
mbed_official | 205:c41fc65bcfb4 | 873 | * @param hirda: irda handle |
mbed_official | 205:c41fc65bcfb4 | 874 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 875 | */ |
mbed_official | 205:c41fc65bcfb4 | 876 | __weak void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda) |
mbed_official | 205:c41fc65bcfb4 | 877 | { |
mbed_official | 205:c41fc65bcfb4 | 878 | /* NOTE : This function should not be modified, when the callback is needed, |
mbed_official | 205:c41fc65bcfb4 | 879 | the HAL_IRDA_TxCpltCallback can be implemented in the user file |
mbed_official | 205:c41fc65bcfb4 | 880 | */ |
mbed_official | 205:c41fc65bcfb4 | 881 | } |
mbed_official | 205:c41fc65bcfb4 | 882 | |
mbed_official | 205:c41fc65bcfb4 | 883 | /** |
mbed_official | 205:c41fc65bcfb4 | 884 | * @brief Rx Transfer completed callback |
mbed_official | 205:c41fc65bcfb4 | 885 | * @param hirda: irda handle |
mbed_official | 205:c41fc65bcfb4 | 886 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 887 | */ |
mbed_official | 205:c41fc65bcfb4 | 888 | __weak void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda) |
mbed_official | 205:c41fc65bcfb4 | 889 | { |
mbed_official | 205:c41fc65bcfb4 | 890 | /* NOTE : This function should not be modified, when the callback is needed, |
mbed_official | 205:c41fc65bcfb4 | 891 | the HAL_IRDA_TxCpltCallback can be implemented in the user file |
mbed_official | 205:c41fc65bcfb4 | 892 | */ |
mbed_official | 205:c41fc65bcfb4 | 893 | } |
mbed_official | 205:c41fc65bcfb4 | 894 | |
mbed_official | 205:c41fc65bcfb4 | 895 | /** |
mbed_official | 205:c41fc65bcfb4 | 896 | * @brief IRDA error callback |
mbed_official | 205:c41fc65bcfb4 | 897 | * @param hirda: IRDA handle |
mbed_official | 205:c41fc65bcfb4 | 898 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 899 | */ |
mbed_official | 205:c41fc65bcfb4 | 900 | __weak void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda) |
mbed_official | 205:c41fc65bcfb4 | 901 | { |
mbed_official | 205:c41fc65bcfb4 | 902 | /* NOTE : This function should not be modified, when the callback is needed, |
mbed_official | 205:c41fc65bcfb4 | 903 | the HAL_IRDA_ErrorCallback can be implemented in the user file |
mbed_official | 205:c41fc65bcfb4 | 904 | */ |
mbed_official | 205:c41fc65bcfb4 | 905 | } |
mbed_official | 205:c41fc65bcfb4 | 906 | |
mbed_official | 205:c41fc65bcfb4 | 907 | /** |
mbed_official | 205:c41fc65bcfb4 | 908 | * @brief Receive an amount of data in non blocking mode. |
mbed_official | 205:c41fc65bcfb4 | 909 | * Function called under interruption only, once |
mbed_official | 205:c41fc65bcfb4 | 910 | * interruptions have been enabled by HAL_IRDA_Transmit_IT() |
mbed_official | 205:c41fc65bcfb4 | 911 | * @param hirda: IRDA handle |
mbed_official | 205:c41fc65bcfb4 | 912 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 913 | */ |
mbed_official | 205:c41fc65bcfb4 | 914 | static HAL_StatusTypeDef IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda) |
mbed_official | 205:c41fc65bcfb4 | 915 | { |
mbed_official | 205:c41fc65bcfb4 | 916 | uint16_t* tmp; |
mbed_official | 205:c41fc65bcfb4 | 917 | |
mbed_official | 205:c41fc65bcfb4 | 918 | if((hirda->State == HAL_IRDA_STATE_BUSY_TX) || (hirda->State == HAL_IRDA_STATE_BUSY_TX_RX)) |
mbed_official | 205:c41fc65bcfb4 | 919 | { |
mbed_official | 205:c41fc65bcfb4 | 920 | __HAL_LOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 921 | |
mbed_official | 205:c41fc65bcfb4 | 922 | if(hirda->TxXferCount == 0) |
mbed_official | 205:c41fc65bcfb4 | 923 | { |
mbed_official | 205:c41fc65bcfb4 | 924 | /* Disable the IRDA Transmit Complete Interrupt */ |
mbed_official | 205:c41fc65bcfb4 | 925 | __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_TC); |
mbed_official | 205:c41fc65bcfb4 | 926 | |
mbed_official | 205:c41fc65bcfb4 | 927 | if(hirda->State == HAL_IRDA_STATE_BUSY_TX_RX) |
mbed_official | 205:c41fc65bcfb4 | 928 | { |
mbed_official | 205:c41fc65bcfb4 | 929 | hirda->State = HAL_IRDA_STATE_BUSY_RX; |
mbed_official | 205:c41fc65bcfb4 | 930 | } |
mbed_official | 205:c41fc65bcfb4 | 931 | else |
mbed_official | 205:c41fc65bcfb4 | 932 | { |
mbed_official | 205:c41fc65bcfb4 | 933 | /* Disable the IRDA Error Interrupt: (Frame error, noise error, overrun error) */ |
mbed_official | 205:c41fc65bcfb4 | 934 | __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_ERR); |
mbed_official | 205:c41fc65bcfb4 | 935 | |
mbed_official | 205:c41fc65bcfb4 | 936 | hirda->State = HAL_IRDA_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 937 | } |
mbed_official | 205:c41fc65bcfb4 | 938 | |
mbed_official | 205:c41fc65bcfb4 | 939 | /* Call the Process Unlocked before calling the Tx call back API to give the possibiity to |
mbed_official | 205:c41fc65bcfb4 | 940 | start again the Transmission under the Tx call back API */ |
mbed_official | 205:c41fc65bcfb4 | 941 | __HAL_UNLOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 942 | |
mbed_official | 205:c41fc65bcfb4 | 943 | HAL_IRDA_TxCpltCallback(hirda); |
mbed_official | 205:c41fc65bcfb4 | 944 | |
mbed_official | 205:c41fc65bcfb4 | 945 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 946 | } |
mbed_official | 205:c41fc65bcfb4 | 947 | else |
mbed_official | 205:c41fc65bcfb4 | 948 | { |
mbed_official | 205:c41fc65bcfb4 | 949 | if ((hirda->Init.WordLength == IRDA_WORDLENGTH_9B) && (hirda->Init.Parity == IRDA_PARITY_NONE)) |
mbed_official | 205:c41fc65bcfb4 | 950 | { |
mbed_official | 205:c41fc65bcfb4 | 951 | tmp = (uint16_t*) hirda->pTxBuffPtr; |
mbed_official | 205:c41fc65bcfb4 | 952 | hirda->Instance->TDR = (*tmp & (uint16_t)0x01FF); |
mbed_official | 205:c41fc65bcfb4 | 953 | hirda->pTxBuffPtr += 2; |
mbed_official | 205:c41fc65bcfb4 | 954 | } |
mbed_official | 205:c41fc65bcfb4 | 955 | else |
mbed_official | 205:c41fc65bcfb4 | 956 | { |
mbed_official | 205:c41fc65bcfb4 | 957 | hirda->Instance->TDR = (uint8_t)(*hirda->pTxBuffPtr++ & (uint8_t)0xFF); |
mbed_official | 205:c41fc65bcfb4 | 958 | } |
mbed_official | 205:c41fc65bcfb4 | 959 | hirda->TxXferCount--; |
mbed_official | 205:c41fc65bcfb4 | 960 | |
mbed_official | 205:c41fc65bcfb4 | 961 | /* Process Unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 962 | __HAL_UNLOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 963 | |
mbed_official | 205:c41fc65bcfb4 | 964 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 965 | } |
mbed_official | 205:c41fc65bcfb4 | 966 | } |
mbed_official | 205:c41fc65bcfb4 | 967 | else |
mbed_official | 205:c41fc65bcfb4 | 968 | { |
mbed_official | 205:c41fc65bcfb4 | 969 | return HAL_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 970 | } |
mbed_official | 205:c41fc65bcfb4 | 971 | } |
mbed_official | 205:c41fc65bcfb4 | 972 | |
mbed_official | 205:c41fc65bcfb4 | 973 | /** |
mbed_official | 205:c41fc65bcfb4 | 974 | * @brief Receive an amount of data in non blocking mode. |
mbed_official | 205:c41fc65bcfb4 | 975 | * Function called under interruption only, once |
mbed_official | 205:c41fc65bcfb4 | 976 | * interruptions have been enabled by HAL_IRDA_Receive_IT() |
mbed_official | 205:c41fc65bcfb4 | 977 | * @param hirda: IRDA handle |
mbed_official | 205:c41fc65bcfb4 | 978 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 979 | */ |
mbed_official | 205:c41fc65bcfb4 | 980 | static HAL_StatusTypeDef IRDA_Receive_IT(IRDA_HandleTypeDef *hirda) |
mbed_official | 205:c41fc65bcfb4 | 981 | { |
mbed_official | 205:c41fc65bcfb4 | 982 | uint16_t* tmp; |
mbed_official | 205:c41fc65bcfb4 | 983 | uint16_t uhMask = hirda->Mask; |
mbed_official | 205:c41fc65bcfb4 | 984 | |
mbed_official | 205:c41fc65bcfb4 | 985 | if ((hirda->State == HAL_IRDA_STATE_BUSY_RX) || (hirda->State == HAL_IRDA_STATE_BUSY_TX_RX)) |
mbed_official | 205:c41fc65bcfb4 | 986 | { |
mbed_official | 205:c41fc65bcfb4 | 987 | /* Process Locked */ |
mbed_official | 205:c41fc65bcfb4 | 988 | __HAL_LOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 989 | |
mbed_official | 205:c41fc65bcfb4 | 990 | if ((hirda->Init.WordLength == IRDA_WORDLENGTH_9B) && (hirda->Init.Parity == IRDA_PARITY_NONE)) |
mbed_official | 205:c41fc65bcfb4 | 991 | { |
mbed_official | 205:c41fc65bcfb4 | 992 | tmp = (uint16_t*) hirda->pRxBuffPtr ; |
mbed_official | 205:c41fc65bcfb4 | 993 | *tmp = (uint16_t)(hirda->Instance->RDR & uhMask); |
mbed_official | 205:c41fc65bcfb4 | 994 | hirda->pRxBuffPtr +=2; |
mbed_official | 205:c41fc65bcfb4 | 995 | } |
mbed_official | 205:c41fc65bcfb4 | 996 | else |
mbed_official | 205:c41fc65bcfb4 | 997 | { |
mbed_official | 205:c41fc65bcfb4 | 998 | *hirda->pRxBuffPtr++ = (uint8_t)(hirda->Instance->RDR & (uint8_t)uhMask); |
mbed_official | 205:c41fc65bcfb4 | 999 | } |
mbed_official | 205:c41fc65bcfb4 | 1000 | |
mbed_official | 205:c41fc65bcfb4 | 1001 | if(--hirda->RxXferCount == 0) |
mbed_official | 205:c41fc65bcfb4 | 1002 | { |
mbed_official | 205:c41fc65bcfb4 | 1003 | __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_RXNE); |
mbed_official | 205:c41fc65bcfb4 | 1004 | |
mbed_official | 205:c41fc65bcfb4 | 1005 | if(hirda->State == HAL_IRDA_STATE_BUSY_TX_RX) |
mbed_official | 205:c41fc65bcfb4 | 1006 | { |
mbed_official | 205:c41fc65bcfb4 | 1007 | hirda->State = HAL_IRDA_STATE_BUSY_TX; |
mbed_official | 205:c41fc65bcfb4 | 1008 | } |
mbed_official | 205:c41fc65bcfb4 | 1009 | else |
mbed_official | 205:c41fc65bcfb4 | 1010 | { |
mbed_official | 205:c41fc65bcfb4 | 1011 | /* Disable the IRDA Parity Error Interrupt */ |
mbed_official | 205:c41fc65bcfb4 | 1012 | __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_PE); |
mbed_official | 205:c41fc65bcfb4 | 1013 | |
mbed_official | 205:c41fc65bcfb4 | 1014 | /* Disable the IRDA Error Interrupt: (Frame error, noise error, overrun error) */ |
mbed_official | 205:c41fc65bcfb4 | 1015 | __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_ERR); |
mbed_official | 205:c41fc65bcfb4 | 1016 | |
mbed_official | 205:c41fc65bcfb4 | 1017 | hirda->State = HAL_IRDA_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 1018 | } |
mbed_official | 205:c41fc65bcfb4 | 1019 | |
mbed_official | 205:c41fc65bcfb4 | 1020 | /* Call the Process Unlocked before calling the Rx call back API to give the possibiity to |
mbed_official | 205:c41fc65bcfb4 | 1021 | start again the receiption under the Rx call back API */ |
mbed_official | 205:c41fc65bcfb4 | 1022 | __HAL_UNLOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 1023 | |
mbed_official | 205:c41fc65bcfb4 | 1024 | HAL_IRDA_RxCpltCallback(hirda); |
mbed_official | 205:c41fc65bcfb4 | 1025 | |
mbed_official | 205:c41fc65bcfb4 | 1026 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 1027 | } |
mbed_official | 205:c41fc65bcfb4 | 1028 | /* Process Unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 1029 | __HAL_UNLOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 1030 | |
mbed_official | 205:c41fc65bcfb4 | 1031 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 1032 | } |
mbed_official | 205:c41fc65bcfb4 | 1033 | else |
mbed_official | 205:c41fc65bcfb4 | 1034 | { |
mbed_official | 205:c41fc65bcfb4 | 1035 | return HAL_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 1036 | } |
mbed_official | 205:c41fc65bcfb4 | 1037 | } |
mbed_official | 205:c41fc65bcfb4 | 1038 | |
mbed_official | 205:c41fc65bcfb4 | 1039 | /** |
mbed_official | 205:c41fc65bcfb4 | 1040 | * @} |
mbed_official | 205:c41fc65bcfb4 | 1041 | */ |
mbed_official | 205:c41fc65bcfb4 | 1042 | |
mbed_official | 205:c41fc65bcfb4 | 1043 | /** @defgroup HAL_IRDA_Group3 Peripheral Control functions |
mbed_official | 205:c41fc65bcfb4 | 1044 | * @brief IRDA control functions |
mbed_official | 205:c41fc65bcfb4 | 1045 | * |
mbed_official | 205:c41fc65bcfb4 | 1046 | @verbatim |
mbed_official | 205:c41fc65bcfb4 | 1047 | =============================================================================== |
mbed_official | 205:c41fc65bcfb4 | 1048 | ##### Peripheral Control functions ##### |
mbed_official | 205:c41fc65bcfb4 | 1049 | =============================================================================== |
mbed_official | 205:c41fc65bcfb4 | 1050 | [..] |
mbed_official | 205:c41fc65bcfb4 | 1051 | This subsection provides a set of functions allowing to control the IRDA. |
mbed_official | 205:c41fc65bcfb4 | 1052 | (+) HAL_IRDA_GetState() API can be helpful to check in run-time the state of the IRDA peripheral. |
mbed_official | 205:c41fc65bcfb4 | 1053 | (+) IRDA_SetConfig() API is used to configure the IRDA communications parameters. |
mbed_official | 205:c41fc65bcfb4 | 1054 | @endverbatim |
mbed_official | 205:c41fc65bcfb4 | 1055 | * @{ |
mbed_official | 205:c41fc65bcfb4 | 1056 | */ |
mbed_official | 205:c41fc65bcfb4 | 1057 | |
mbed_official | 205:c41fc65bcfb4 | 1058 | /** |
mbed_official | 205:c41fc65bcfb4 | 1059 | * @brief return the IRDA state |
mbed_official | 205:c41fc65bcfb4 | 1060 | * @param hirda: irda handle |
mbed_official | 205:c41fc65bcfb4 | 1061 | * @retval HAL state |
mbed_official | 205:c41fc65bcfb4 | 1062 | */ |
mbed_official | 205:c41fc65bcfb4 | 1063 | HAL_IRDA_StateTypeDef HAL_IRDA_GetState(IRDA_HandleTypeDef *hirda) |
mbed_official | 205:c41fc65bcfb4 | 1064 | { |
mbed_official | 205:c41fc65bcfb4 | 1065 | return hirda->State; |
mbed_official | 205:c41fc65bcfb4 | 1066 | } |
mbed_official | 205:c41fc65bcfb4 | 1067 | |
mbed_official | 205:c41fc65bcfb4 | 1068 | /** |
mbed_official | 205:c41fc65bcfb4 | 1069 | * @brief Return the IRDA error code |
mbed_official | 205:c41fc65bcfb4 | 1070 | * @param hirda : pointer to a IRDA_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 1071 | * the configuration information for the specified IRDA. |
mbed_official | 205:c41fc65bcfb4 | 1072 | * @retval IRDA Error Code |
mbed_official | 205:c41fc65bcfb4 | 1073 | */ |
mbed_official | 205:c41fc65bcfb4 | 1074 | uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef *hirda) |
mbed_official | 205:c41fc65bcfb4 | 1075 | { |
mbed_official | 205:c41fc65bcfb4 | 1076 | return hirda->ErrorCode; |
mbed_official | 205:c41fc65bcfb4 | 1077 | } |
mbed_official | 205:c41fc65bcfb4 | 1078 | |
mbed_official | 205:c41fc65bcfb4 | 1079 | /** |
mbed_official | 205:c41fc65bcfb4 | 1080 | * @} |
mbed_official | 205:c41fc65bcfb4 | 1081 | */ |
mbed_official | 205:c41fc65bcfb4 | 1082 | |
mbed_official | 205:c41fc65bcfb4 | 1083 | /** |
mbed_official | 205:c41fc65bcfb4 | 1084 | * @brief Configure the IRDA peripheral |
mbed_official | 205:c41fc65bcfb4 | 1085 | * @param hirda: irda handle |
mbed_official | 205:c41fc65bcfb4 | 1086 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 1087 | */ |
mbed_official | 205:c41fc65bcfb4 | 1088 | static HAL_StatusTypeDef IRDA_SetConfig(IRDA_HandleTypeDef *hirda) |
mbed_official | 205:c41fc65bcfb4 | 1089 | { |
mbed_official | 205:c41fc65bcfb4 | 1090 | uint32_t tmpreg = 0x00000000; |
mbed_official | 205:c41fc65bcfb4 | 1091 | UART_ClockSourceTypeDef clocksource = UART_CLOCKSOURCE_UNDEFINED; |
mbed_official | 205:c41fc65bcfb4 | 1092 | HAL_StatusTypeDef ret = HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 1093 | |
mbed_official | 205:c41fc65bcfb4 | 1094 | /* Check the communication parameters */ |
mbed_official | 205:c41fc65bcfb4 | 1095 | assert_param(IS_IRDA_BAUDRATE(hirda->Init.BaudRate)); |
mbed_official | 205:c41fc65bcfb4 | 1096 | assert_param(IS_IRDA_WORD_LENGTH(hirda->Init.WordLength)); |
mbed_official | 205:c41fc65bcfb4 | 1097 | assert_param(IS_IRDA_PARITY(hirda->Init.Parity)); |
mbed_official | 205:c41fc65bcfb4 | 1098 | assert_param(IS_IRDA_TX_RX_MODE(hirda->Init.Mode)); |
mbed_official | 205:c41fc65bcfb4 | 1099 | assert_param(IS_IRDA_PRESCALER(hirda->Init.Prescaler)); |
mbed_official | 205:c41fc65bcfb4 | 1100 | assert_param(IS_IRDA_POWERMODE(hirda->Init.PowerMode)); |
mbed_official | 205:c41fc65bcfb4 | 1101 | |
mbed_official | 205:c41fc65bcfb4 | 1102 | |
mbed_official | 205:c41fc65bcfb4 | 1103 | |
mbed_official | 205:c41fc65bcfb4 | 1104 | |
mbed_official | 205:c41fc65bcfb4 | 1105 | /*-------------------------- USART CR1 Configuration -----------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 1106 | /* Configure the IRDA Word Length, Parity and transfer Mode: |
mbed_official | 205:c41fc65bcfb4 | 1107 | Set the M bits according to hirda->Init.WordLength value |
mbed_official | 205:c41fc65bcfb4 | 1108 | Set PCE and PS bits according to hirda->Init.Parity value |
mbed_official | 205:c41fc65bcfb4 | 1109 | Set TE and RE bits according to hirda->Init.Mode value */ |
mbed_official | 205:c41fc65bcfb4 | 1110 | tmpreg = (uint32_t)hirda->Init.WordLength | hirda->Init.Parity | hirda->Init.Mode ; |
mbed_official | 205:c41fc65bcfb4 | 1111 | |
mbed_official | 205:c41fc65bcfb4 | 1112 | MODIFY_REG(hirda->Instance->CR1, IRDA_CR1_FIELDS, tmpreg); |
mbed_official | 205:c41fc65bcfb4 | 1113 | |
mbed_official | 205:c41fc65bcfb4 | 1114 | /*-------------------------- USART CR3 Configuration -----------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 1115 | MODIFY_REG(hirda->Instance->CR3, USART_CR3_IRLP, hirda->Init.PowerMode); |
mbed_official | 205:c41fc65bcfb4 | 1116 | |
mbed_official | 205:c41fc65bcfb4 | 1117 | /*-------------------------- USART GTPR Configuration ----------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 1118 | MODIFY_REG(hirda->Instance->GTPR, USART_GTPR_PSC, hirda->Init.Prescaler); |
mbed_official | 205:c41fc65bcfb4 | 1119 | |
mbed_official | 205:c41fc65bcfb4 | 1120 | /*-------------------------- USART BRR Configuration -----------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 1121 | __HAL_UART_GETCLOCKSOURCE(hirda, clocksource); |
mbed_official | 205:c41fc65bcfb4 | 1122 | switch (clocksource) |
mbed_official | 205:c41fc65bcfb4 | 1123 | { |
mbed_official | 205:c41fc65bcfb4 | 1124 | case UART_CLOCKSOURCE_PCLK1: |
mbed_official | 205:c41fc65bcfb4 | 1125 | hirda->Instance->BRR = (uint16_t)(HAL_RCC_GetPCLK1Freq() / hirda->Init.BaudRate); |
mbed_official | 205:c41fc65bcfb4 | 1126 | break; |
mbed_official | 205:c41fc65bcfb4 | 1127 | case UART_CLOCKSOURCE_HSI: |
mbed_official | 205:c41fc65bcfb4 | 1128 | hirda->Instance->BRR = (uint16_t)(HSI_VALUE / hirda->Init.BaudRate); |
mbed_official | 205:c41fc65bcfb4 | 1129 | break; |
mbed_official | 205:c41fc65bcfb4 | 1130 | case UART_CLOCKSOURCE_SYSCLK: |
mbed_official | 205:c41fc65bcfb4 | 1131 | hirda->Instance->BRR = (uint16_t)(HAL_RCC_GetSysClockFreq() / hirda->Init.BaudRate); |
mbed_official | 205:c41fc65bcfb4 | 1132 | break; |
mbed_official | 205:c41fc65bcfb4 | 1133 | case UART_CLOCKSOURCE_LSE: |
mbed_official | 205:c41fc65bcfb4 | 1134 | hirda->Instance->BRR = (uint16_t)(LSE_VALUE / hirda->Init.BaudRate); |
mbed_official | 205:c41fc65bcfb4 | 1135 | break; |
mbed_official | 205:c41fc65bcfb4 | 1136 | case UART_CLOCKSOURCE_UNDEFINED: |
mbed_official | 205:c41fc65bcfb4 | 1137 | default: |
mbed_official | 205:c41fc65bcfb4 | 1138 | ret = HAL_ERROR; |
mbed_official | 205:c41fc65bcfb4 | 1139 | break; |
mbed_official | 205:c41fc65bcfb4 | 1140 | } |
mbed_official | 205:c41fc65bcfb4 | 1141 | |
mbed_official | 205:c41fc65bcfb4 | 1142 | return ret; |
mbed_official | 205:c41fc65bcfb4 | 1143 | } |
mbed_official | 205:c41fc65bcfb4 | 1144 | |
mbed_official | 205:c41fc65bcfb4 | 1145 | /** |
mbed_official | 205:c41fc65bcfb4 | 1146 | * @brief Check the IRDA Idle State |
mbed_official | 205:c41fc65bcfb4 | 1147 | * @param hirda: IRDA handle |
mbed_official | 205:c41fc65bcfb4 | 1148 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 1149 | */ |
mbed_official | 205:c41fc65bcfb4 | 1150 | static HAL_StatusTypeDef IRDA_CheckIdleState(IRDA_HandleTypeDef *hirda) |
mbed_official | 205:c41fc65bcfb4 | 1151 | { |
mbed_official | 205:c41fc65bcfb4 | 1152 | |
mbed_official | 205:c41fc65bcfb4 | 1153 | /* Initialize the IRDA ErrorCode */ |
mbed_official | 205:c41fc65bcfb4 | 1154 | hirda->ErrorCode = HAL_IRDA_ERROR_NONE; |
mbed_official | 205:c41fc65bcfb4 | 1155 | |
mbed_official | 205:c41fc65bcfb4 | 1156 | /* Check if the Transmitter is enabled */ |
mbed_official | 205:c41fc65bcfb4 | 1157 | if((hirda->Instance->CR1 & USART_CR1_TE) == USART_CR1_TE) |
mbed_official | 205:c41fc65bcfb4 | 1158 | { |
mbed_official | 205:c41fc65bcfb4 | 1159 | /* Wait until TEACK flag is set */ |
mbed_official | 205:c41fc65bcfb4 | 1160 | if(IRDA_WaitOnFlagUntilTimeout(hirda, USART_ISR_TEACK, RESET, TEACK_REACK_TIMEOUT) != HAL_OK) |
mbed_official | 205:c41fc65bcfb4 | 1161 | { |
mbed_official | 205:c41fc65bcfb4 | 1162 | /* Timeout Occured */ |
mbed_official | 205:c41fc65bcfb4 | 1163 | return HAL_TIMEOUT; |
mbed_official | 205:c41fc65bcfb4 | 1164 | } |
mbed_official | 205:c41fc65bcfb4 | 1165 | } |
mbed_official | 205:c41fc65bcfb4 | 1166 | /* Check if the Receiver is enabled */ |
mbed_official | 205:c41fc65bcfb4 | 1167 | if((hirda->Instance->CR1 & USART_CR1_RE) == USART_CR1_RE) |
mbed_official | 205:c41fc65bcfb4 | 1168 | { |
mbed_official | 205:c41fc65bcfb4 | 1169 | if(IRDA_WaitOnFlagUntilTimeout(hirda, USART_ISR_REACK, RESET, TEACK_REACK_TIMEOUT) != HAL_OK) |
mbed_official | 205:c41fc65bcfb4 | 1170 | { |
mbed_official | 205:c41fc65bcfb4 | 1171 | /* Timeout Occured */ |
mbed_official | 205:c41fc65bcfb4 | 1172 | return HAL_TIMEOUT; |
mbed_official | 205:c41fc65bcfb4 | 1173 | } |
mbed_official | 205:c41fc65bcfb4 | 1174 | } |
mbed_official | 205:c41fc65bcfb4 | 1175 | /* Initialize the IRDA state*/ |
mbed_official | 205:c41fc65bcfb4 | 1176 | hirda->State= HAL_IRDA_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 1177 | |
mbed_official | 205:c41fc65bcfb4 | 1178 | /* Process Unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 1179 | __HAL_UNLOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 1180 | |
mbed_official | 205:c41fc65bcfb4 | 1181 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 1182 | } |
mbed_official | 205:c41fc65bcfb4 | 1183 | |
mbed_official | 205:c41fc65bcfb4 | 1184 | |
mbed_official | 205:c41fc65bcfb4 | 1185 | /** |
mbed_official | 205:c41fc65bcfb4 | 1186 | * @brief Handle IRDA Communication Timeout. |
mbed_official | 205:c41fc65bcfb4 | 1187 | * @param hirda: IRDA handle |
mbed_official | 205:c41fc65bcfb4 | 1188 | * @param Flag: specifies the IRDA flag to check. |
mbed_official | 205:c41fc65bcfb4 | 1189 | * @param Status: the flag status (SET or RESET). The function is locked in a while loop as long as the flag remains set to Status. |
mbed_official | 205:c41fc65bcfb4 | 1190 | * @param Timeout: Timeout duration |
mbed_official | 205:c41fc65bcfb4 | 1191 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 1192 | */ |
mbed_official | 205:c41fc65bcfb4 | 1193 | static HAL_StatusTypeDef IRDA_WaitOnFlagUntilTimeout(IRDA_HandleTypeDef *hirda, uint32_t Flag, FlagStatus Status, uint32_t Timeout) |
mbed_official | 205:c41fc65bcfb4 | 1194 | { |
mbed_official | 205:c41fc65bcfb4 | 1195 | uint32_t tickstart = HAL_GetTick(); |
mbed_official | 205:c41fc65bcfb4 | 1196 | |
mbed_official | 205:c41fc65bcfb4 | 1197 | /* Wait until flag is set */ |
mbed_official | 205:c41fc65bcfb4 | 1198 | if(Status == RESET) |
mbed_official | 205:c41fc65bcfb4 | 1199 | { |
mbed_official | 205:c41fc65bcfb4 | 1200 | while(__HAL_IRDA_GET_FLAG(hirda, Flag) == RESET) |
mbed_official | 205:c41fc65bcfb4 | 1201 | { |
mbed_official | 205:c41fc65bcfb4 | 1202 | /* Check for the Timeout */ |
mbed_official | 205:c41fc65bcfb4 | 1203 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 205:c41fc65bcfb4 | 1204 | { |
mbed_official | 205:c41fc65bcfb4 | 1205 | if((HAL_GetTick() - tickstart) >= Timeout) |
mbed_official | 205:c41fc65bcfb4 | 1206 | { |
mbed_official | 205:c41fc65bcfb4 | 1207 | /* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts for the interrupt process */ |
mbed_official | 205:c41fc65bcfb4 | 1208 | __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_TXE); |
mbed_official | 205:c41fc65bcfb4 | 1209 | __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_RXNE); |
mbed_official | 205:c41fc65bcfb4 | 1210 | __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_PE); |
mbed_official | 205:c41fc65bcfb4 | 1211 | __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_ERR); |
mbed_official | 205:c41fc65bcfb4 | 1212 | |
mbed_official | 205:c41fc65bcfb4 | 1213 | hirda->State= HAL_IRDA_STATE_TIMEOUT; |
mbed_official | 205:c41fc65bcfb4 | 1214 | |
mbed_official | 205:c41fc65bcfb4 | 1215 | /* Process Unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 1216 | __HAL_UNLOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 1217 | |
mbed_official | 205:c41fc65bcfb4 | 1218 | return HAL_TIMEOUT; |
mbed_official | 205:c41fc65bcfb4 | 1219 | } |
mbed_official | 205:c41fc65bcfb4 | 1220 | } |
mbed_official | 205:c41fc65bcfb4 | 1221 | } |
mbed_official | 205:c41fc65bcfb4 | 1222 | } |
mbed_official | 205:c41fc65bcfb4 | 1223 | else |
mbed_official | 205:c41fc65bcfb4 | 1224 | { |
mbed_official | 205:c41fc65bcfb4 | 1225 | while(__HAL_IRDA_GET_FLAG(hirda, Flag) != RESET) |
mbed_official | 205:c41fc65bcfb4 | 1226 | { |
mbed_official | 205:c41fc65bcfb4 | 1227 | /* Check for the Timeout */ |
mbed_official | 205:c41fc65bcfb4 | 1228 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 205:c41fc65bcfb4 | 1229 | { |
mbed_official | 205:c41fc65bcfb4 | 1230 | if((HAL_GetTick() - tickstart) >= Timeout) |
mbed_official | 205:c41fc65bcfb4 | 1231 | { |
mbed_official | 205:c41fc65bcfb4 | 1232 | /* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts for the interrupt process */ |
mbed_official | 205:c41fc65bcfb4 | 1233 | __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_TXE); |
mbed_official | 205:c41fc65bcfb4 | 1234 | __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_RXNE); |
mbed_official | 205:c41fc65bcfb4 | 1235 | __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_PE); |
mbed_official | 205:c41fc65bcfb4 | 1236 | __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_ERR); |
mbed_official | 205:c41fc65bcfb4 | 1237 | |
mbed_official | 205:c41fc65bcfb4 | 1238 | hirda->State= HAL_IRDA_STATE_TIMEOUT; |
mbed_official | 205:c41fc65bcfb4 | 1239 | |
mbed_official | 205:c41fc65bcfb4 | 1240 | /* Process Unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 1241 | __HAL_UNLOCK(hirda); |
mbed_official | 205:c41fc65bcfb4 | 1242 | |
mbed_official | 205:c41fc65bcfb4 | 1243 | return HAL_TIMEOUT; |
mbed_official | 205:c41fc65bcfb4 | 1244 | } |
mbed_official | 205:c41fc65bcfb4 | 1245 | } |
mbed_official | 205:c41fc65bcfb4 | 1246 | } |
mbed_official | 205:c41fc65bcfb4 | 1247 | } |
mbed_official | 205:c41fc65bcfb4 | 1248 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 1249 | } |
mbed_official | 205:c41fc65bcfb4 | 1250 | |
mbed_official | 205:c41fc65bcfb4 | 1251 | /** |
mbed_official | 205:c41fc65bcfb4 | 1252 | * @} |
mbed_official | 205:c41fc65bcfb4 | 1253 | */ |
mbed_official | 205:c41fc65bcfb4 | 1254 | |
mbed_official | 205:c41fc65bcfb4 | 1255 | #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) */ |
mbed_official | 205:c41fc65bcfb4 | 1256 | |
mbed_official | 205:c41fc65bcfb4 | 1257 | #endif /* HAL_IRDA_MODULE_ENABLED */ |
mbed_official | 205:c41fc65bcfb4 | 1258 | /** |
mbed_official | 205:c41fc65bcfb4 | 1259 | * @} |
mbed_official | 205:c41fc65bcfb4 | 1260 | */ |
mbed_official | 205:c41fc65bcfb4 | 1261 | |
mbed_official | 205:c41fc65bcfb4 | 1262 | /** |
mbed_official | 205:c41fc65bcfb4 | 1263 | * @} |
mbed_official | 205:c41fc65bcfb4 | 1264 | */ |
mbed_official | 205:c41fc65bcfb4 | 1265 | |
mbed_official | 205:c41fc65bcfb4 | 1266 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |