Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sat Jun 03 00:22:44 2017 +0000
Revision:
46:b156ef445742
Parent:
18:6a4db94011d3
Final code for internal battlebot competition.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 18:6a4db94011d3 1 /**
sahilmgandhi 18:6a4db94011d3 2 ******************************************************************************
sahilmgandhi 18:6a4db94011d3 3 * @file stm32f2xx_hal_smartcard.c
sahilmgandhi 18:6a4db94011d3 4 * @author MCD Application Team
sahilmgandhi 18:6a4db94011d3 5 * @version V1.1.3
sahilmgandhi 18:6a4db94011d3 6 * @date 29-June-2016
sahilmgandhi 18:6a4db94011d3 7 * @brief SMARTCARD HAL module driver.
sahilmgandhi 18:6a4db94011d3 8 * This file provides firmware functions to manage the following
sahilmgandhi 18:6a4db94011d3 9 * functionalities of the SMARTCARD peripheral:
sahilmgandhi 18:6a4db94011d3 10 * + Initialization and de-initialization functions
sahilmgandhi 18:6a4db94011d3 11 * + IO operation functions
sahilmgandhi 18:6a4db94011d3 12 * + Peripheral State and Errors functions
sahilmgandhi 18:6a4db94011d3 13 *
sahilmgandhi 18:6a4db94011d3 14 @verbatim
sahilmgandhi 18:6a4db94011d3 15 ==============================================================================
sahilmgandhi 18:6a4db94011d3 16 ##### How to use this driver #####
sahilmgandhi 18:6a4db94011d3 17 ==============================================================================
sahilmgandhi 18:6a4db94011d3 18 [..]
sahilmgandhi 18:6a4db94011d3 19 The SMARTCARD HAL driver can be used as follows:
sahilmgandhi 18:6a4db94011d3 20
sahilmgandhi 18:6a4db94011d3 21 (#) Declare a SMARTCARD_HandleTypeDef handle structure.
sahilmgandhi 18:6a4db94011d3 22 (#) Initialize the SMARTCARD low level resources by implementing the HAL_SMARTCARD_MspInit() API:
sahilmgandhi 18:6a4db94011d3 23 (##) Enable the USARTx interface clock.
sahilmgandhi 18:6a4db94011d3 24 (##) SMARTCARD pins configuration:
sahilmgandhi 18:6a4db94011d3 25 (+++) Enable the clock for the SMARTCARD GPIOs.
sahilmgandhi 18:6a4db94011d3 26 (+++) Configure these SMARTCARD pins as alternate function pull-up.
sahilmgandhi 18:6a4db94011d3 27 (##) NVIC configuration if you need to use interrupt process (HAL_SMARTCARD_Transmit_IT()
sahilmgandhi 18:6a4db94011d3 28 and HAL_SMARTCARD_Receive_IT() APIs):
sahilmgandhi 18:6a4db94011d3 29 (+++) Configure the USARTx interrupt priority.
sahilmgandhi 18:6a4db94011d3 30 (+++) Enable the NVIC USART IRQ handle.
sahilmgandhi 18:6a4db94011d3 31 (##) DMA Configuration if you need to use DMA process (HAL_SMARTCARD_Transmit_DMA()
sahilmgandhi 18:6a4db94011d3 32 and HAL_SMARTCARD_Receive_DMA() APIs):
sahilmgandhi 18:6a4db94011d3 33 (+++) Declare a DMA handle structure for the Tx/Rx stream.
sahilmgandhi 18:6a4db94011d3 34 (+++) Enable the DMAx interface clock.
sahilmgandhi 18:6a4db94011d3 35 (+++) Configure the declared DMA handle structure with the required Tx/Rx parameters.
sahilmgandhi 18:6a4db94011d3 36 (+++) Configure the DMA Tx/Rx Stream.
sahilmgandhi 18:6a4db94011d3 37 (+++) Associate the initialized DMA handle to the SMARTCARD DMA Tx/Rx handle.
sahilmgandhi 18:6a4db94011d3 38 (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx/Rx Stream.
sahilmgandhi 18:6a4db94011d3 39
sahilmgandhi 18:6a4db94011d3 40 (#) Program the Baud Rate, Word Length , Stop Bit, Parity, Hardware
sahilmgandhi 18:6a4db94011d3 41 flow control and Mode(Receiver/Transmitter) in the SMARTCARD Init structure.
sahilmgandhi 18:6a4db94011d3 42
sahilmgandhi 18:6a4db94011d3 43 (#) Initialize the SMARTCARD registers by calling the HAL_SMARTCARD_Init() API:
sahilmgandhi 18:6a4db94011d3 44 (++) These APIs configure also the low level Hardware GPIO, CLOCK, CORTEX...etc)
sahilmgandhi 18:6a4db94011d3 45 by calling the customized HAL_SMARTCARD_MspInit() API.
sahilmgandhi 18:6a4db94011d3 46 [..]
sahilmgandhi 18:6a4db94011d3 47 (@) The specific SMARTCARD interrupts (Transmission complete interrupt,
sahilmgandhi 18:6a4db94011d3 48 RXNE interrupt and Error Interrupts) will be managed using the macros
sahilmgandhi 18:6a4db94011d3 49 __HAL_SMARTCARD_ENABLE_IT() and __HAL_SMARTCARD_DISABLE_IT() inside the transmit and receive process.
sahilmgandhi 18:6a4db94011d3 50
sahilmgandhi 18:6a4db94011d3 51 [..]
sahilmgandhi 18:6a4db94011d3 52 Three operation modes are available within this driver :
sahilmgandhi 18:6a4db94011d3 53
sahilmgandhi 18:6a4db94011d3 54 *** Polling mode IO operation ***
sahilmgandhi 18:6a4db94011d3 55 =================================
sahilmgandhi 18:6a4db94011d3 56 [..]
sahilmgandhi 18:6a4db94011d3 57 (+) Send an amount of data in blocking mode using HAL_SMARTCARD_Transmit()
sahilmgandhi 18:6a4db94011d3 58 (+) Receive an amount of data in blocking mode using HAL_SMARTCARD_Receive()
sahilmgandhi 18:6a4db94011d3 59
sahilmgandhi 18:6a4db94011d3 60 *** Interrupt mode IO operation ***
sahilmgandhi 18:6a4db94011d3 61 ===================================
sahilmgandhi 18:6a4db94011d3 62 [..]
sahilmgandhi 18:6a4db94011d3 63 (+) Send an amount of data in non blocking mode using HAL_SMARTCARD_Transmit_IT()
sahilmgandhi 18:6a4db94011d3 64 (+) At transmission end of transfer HAL_SMARTCARD_TxCpltCallback is executed and user can
sahilmgandhi 18:6a4db94011d3 65 add his own code by customization of function pointer HAL_SMARTCARD_TxCpltCallback
sahilmgandhi 18:6a4db94011d3 66 (+) Receive an amount of data in non blocking mode using HAL_SMARTCARD_Receive_IT()
sahilmgandhi 18:6a4db94011d3 67 (+) At reception end of transfer HAL_SMARTCARD_RxCpltCallback is executed and user can
sahilmgandhi 18:6a4db94011d3 68 add his own code by customization of function pointer HAL_SMARTCARD_RxCpltCallback
sahilmgandhi 18:6a4db94011d3 69 (+) In case of transfer Error, HAL_SMARTCARD_ErrorCallback() function is executed and user can
sahilmgandhi 18:6a4db94011d3 70 add his own code by customization of function pointer HAL_SMARTCARD_ErrorCallback
sahilmgandhi 18:6a4db94011d3 71
sahilmgandhi 18:6a4db94011d3 72 *** DMA mode IO operation ***
sahilmgandhi 18:6a4db94011d3 73 ==============================
sahilmgandhi 18:6a4db94011d3 74 [..]
sahilmgandhi 18:6a4db94011d3 75 (+) Send an amount of data in non blocking mode (DMA) using HAL_SMARTCARD_Transmit_DMA()
sahilmgandhi 18:6a4db94011d3 76 (+) At transmission end of transfer HAL_SMARTCARD_TxCpltCallback is executed and user can
sahilmgandhi 18:6a4db94011d3 77 add his own code by customization of function pointer HAL_SMARTCARD_TxCpltCallback
sahilmgandhi 18:6a4db94011d3 78 (+) Receive an amount of data in non blocking mode (DMA) using HAL_SMARTCARD_Receive_DMA()
sahilmgandhi 18:6a4db94011d3 79 (+) At reception end of transfer HAL_SMARTCARD_RxCpltCallback is executed and user can
sahilmgandhi 18:6a4db94011d3 80 add his own code by customization of function pointer HAL_SMARTCARD_RxCpltCallback
sahilmgandhi 18:6a4db94011d3 81 (+) In case of transfer Error, HAL_SMARTCARD_ErrorCallback() function is executed and user can
sahilmgandhi 18:6a4db94011d3 82 add his own code by customization of function pointer HAL_SMARTCARD_ErrorCallback
sahilmgandhi 18:6a4db94011d3 83
sahilmgandhi 18:6a4db94011d3 84 *** SMARTCARD HAL driver macros list ***
sahilmgandhi 18:6a4db94011d3 85 =============================================
sahilmgandhi 18:6a4db94011d3 86 [..]
sahilmgandhi 18:6a4db94011d3 87 Below the list of most used macros in SMARTCARD HAL driver.
sahilmgandhi 18:6a4db94011d3 88
sahilmgandhi 18:6a4db94011d3 89 (+) __HAL_SMARTCARD_ENABLE: Enable the SMARTCARD peripheral
sahilmgandhi 18:6a4db94011d3 90 (+) __HAL_SMARTCARD_DISABLE: Disable the SMARTCARD peripheral
sahilmgandhi 18:6a4db94011d3 91 (+) __HAL_SMARTCARD_GET_FLAG : Check whether the specified SMARTCARD flag is set or not
sahilmgandhi 18:6a4db94011d3 92 (+) __HAL_SMARTCARD_CLEAR_FLAG : Clear the specified SMARTCARD pending flag
sahilmgandhi 18:6a4db94011d3 93 (+) __HAL_SMARTCARD_ENABLE_IT: Enable the specified SMARTCARD interrupt
sahilmgandhi 18:6a4db94011d3 94 (+) __HAL_SMARTCARD_DISABLE_IT: Disable the specified SMARTCARD interrupt
sahilmgandhi 18:6a4db94011d3 95
sahilmgandhi 18:6a4db94011d3 96 [..]
sahilmgandhi 18:6a4db94011d3 97 (@) You can refer to the SMARTCARD HAL driver header file for more useful macros
sahilmgandhi 18:6a4db94011d3 98
sahilmgandhi 18:6a4db94011d3 99 @endverbatim
sahilmgandhi 18:6a4db94011d3 100 ******************************************************************************
sahilmgandhi 18:6a4db94011d3 101 * @attention
sahilmgandhi 18:6a4db94011d3 102 *
sahilmgandhi 18:6a4db94011d3 103 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
sahilmgandhi 18:6a4db94011d3 104 *
sahilmgandhi 18:6a4db94011d3 105 * Redistribution and use in source and binary forms, with or without modification,
sahilmgandhi 18:6a4db94011d3 106 * are permitted provided that the following conditions are met:
sahilmgandhi 18:6a4db94011d3 107 * 1. Redistributions of source code must retain the above copyright notice,
sahilmgandhi 18:6a4db94011d3 108 * this list of conditions and the following disclaimer.
sahilmgandhi 18:6a4db94011d3 109 * 2. Redistributions in binary form must reproduce the above copyright notice,
sahilmgandhi 18:6a4db94011d3 110 * this list of conditions and the following disclaimer in the documentation
sahilmgandhi 18:6a4db94011d3 111 * and/or other materials provided with the distribution.
sahilmgandhi 18:6a4db94011d3 112 * 3. Neither the name of STMicroelectronics nor the names of its contributors
sahilmgandhi 18:6a4db94011d3 113 * may be used to endorse or promote products derived from this software
sahilmgandhi 18:6a4db94011d3 114 * without specific prior written permission.
sahilmgandhi 18:6a4db94011d3 115 *
sahilmgandhi 18:6a4db94011d3 116 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
sahilmgandhi 18:6a4db94011d3 117 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sahilmgandhi 18:6a4db94011d3 118 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
sahilmgandhi 18:6a4db94011d3 119 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
sahilmgandhi 18:6a4db94011d3 120 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sahilmgandhi 18:6a4db94011d3 121 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
sahilmgandhi 18:6a4db94011d3 122 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
sahilmgandhi 18:6a4db94011d3 123 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
sahilmgandhi 18:6a4db94011d3 124 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
sahilmgandhi 18:6a4db94011d3 125 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
sahilmgandhi 18:6a4db94011d3 126 *
sahilmgandhi 18:6a4db94011d3 127 ******************************************************************************
sahilmgandhi 18:6a4db94011d3 128 */
sahilmgandhi 18:6a4db94011d3 129
sahilmgandhi 18:6a4db94011d3 130 /* Includes ------------------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 131 #include "stm32f2xx_hal.h"
sahilmgandhi 18:6a4db94011d3 132
sahilmgandhi 18:6a4db94011d3 133 /** @addtogroup STM32F2xx_HAL_Driver
sahilmgandhi 18:6a4db94011d3 134 * @{
sahilmgandhi 18:6a4db94011d3 135 */
sahilmgandhi 18:6a4db94011d3 136
sahilmgandhi 18:6a4db94011d3 137 /** @defgroup SMARTCARD SMARTCARD
sahilmgandhi 18:6a4db94011d3 138 * @brief HAL USART SMARTCARD module driver
sahilmgandhi 18:6a4db94011d3 139 * @{
sahilmgandhi 18:6a4db94011d3 140 */
sahilmgandhi 18:6a4db94011d3 141 #ifdef HAL_SMARTCARD_MODULE_ENABLED
sahilmgandhi 18:6a4db94011d3 142 /* Private typedef -----------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 143 /* Private define ------------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 144 /** @addtogroup SMARTCARD_Private_Constants
sahilmgandhi 18:6a4db94011d3 145 * @{
sahilmgandhi 18:6a4db94011d3 146 */
sahilmgandhi 18:6a4db94011d3 147 /**
sahilmgandhi 18:6a4db94011d3 148 * @}
sahilmgandhi 18:6a4db94011d3 149 */
sahilmgandhi 18:6a4db94011d3 150 /* Private macro -------------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 151 /* Private variables ---------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 152 /* Private function prototypes -----------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 153 /** @addtogroup SMARTCARD_Private_Functions
sahilmgandhi 18:6a4db94011d3 154 * @{
sahilmgandhi 18:6a4db94011d3 155 */
sahilmgandhi 18:6a4db94011d3 156 static void SMARTCARD_EndTxTransfer(SMARTCARD_HandleTypeDef *hsc);
sahilmgandhi 18:6a4db94011d3 157 static void SMARTCARD_EndRxTransfer(SMARTCARD_HandleTypeDef *hsc);
sahilmgandhi 18:6a4db94011d3 158 static void SMARTCARD_SetConfig (SMARTCARD_HandleTypeDef *hsc);
sahilmgandhi 18:6a4db94011d3 159 static HAL_StatusTypeDef SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsc);
sahilmgandhi 18:6a4db94011d3 160 static HAL_StatusTypeDef SMARTCARD_EndTransmit_IT(SMARTCARD_HandleTypeDef *hsmartcard);
sahilmgandhi 18:6a4db94011d3 161 static HAL_StatusTypeDef SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc);
sahilmgandhi 18:6a4db94011d3 162 static void SMARTCARD_DMATransmitCplt(DMA_HandleTypeDef *hdma);
sahilmgandhi 18:6a4db94011d3 163 static void SMARTCARD_DMAReceiveCplt(DMA_HandleTypeDef *hdma);
sahilmgandhi 18:6a4db94011d3 164 static void SMARTCARD_DMAError(DMA_HandleTypeDef *hdma);
sahilmgandhi 18:6a4db94011d3 165 static void SMARTCARD_DMAAbortOnError(DMA_HandleTypeDef *hdma);
sahilmgandhi 18:6a4db94011d3 166 static HAL_StatusTypeDef SMARTCARD_WaitOnFlagUntilTimeout(SMARTCARD_HandleTypeDef *hsc, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout);
sahilmgandhi 18:6a4db94011d3 167 /**
sahilmgandhi 18:6a4db94011d3 168 * @}
sahilmgandhi 18:6a4db94011d3 169 */
sahilmgandhi 18:6a4db94011d3 170 /* Exported functions --------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 171 /** @defgroup SMARTCARD_Exported_Functions SMARTCARD Exported Functions
sahilmgandhi 18:6a4db94011d3 172 * @{
sahilmgandhi 18:6a4db94011d3 173 */
sahilmgandhi 18:6a4db94011d3 174
sahilmgandhi 18:6a4db94011d3 175 /** @defgroup SMARTCARD_Exported_Functions_Group1 SmartCard Initialization and de-initialization functions
sahilmgandhi 18:6a4db94011d3 176 * @brief Initialization and Configuration functions
sahilmgandhi 18:6a4db94011d3 177 *
sahilmgandhi 18:6a4db94011d3 178 @verbatim
sahilmgandhi 18:6a4db94011d3 179 ==============================================================================
sahilmgandhi 18:6a4db94011d3 180 ##### Initialization and Configuration functions #####
sahilmgandhi 18:6a4db94011d3 181 ==============================================================================
sahilmgandhi 18:6a4db94011d3 182 [..]
sahilmgandhi 18:6a4db94011d3 183 This subsection provides a set of functions allowing to initialize the USART
sahilmgandhi 18:6a4db94011d3 184 in Smartcard mode.
sahilmgandhi 18:6a4db94011d3 185 [..]
sahilmgandhi 18:6a4db94011d3 186 The Smartcard interface is designed to support asynchronous protocol Smartcards as
sahilmgandhi 18:6a4db94011d3 187 defined in the ISO 7816-3 standard.
sahilmgandhi 18:6a4db94011d3 188 [..]
sahilmgandhi 18:6a4db94011d3 189 The USART can provide a clock to the smartcard through the SCLK output.
sahilmgandhi 18:6a4db94011d3 190 In smartcard mode, SCLK is not associated to the communication but is simply derived
sahilmgandhi 18:6a4db94011d3 191 from the internal peripheral input clock through a 5-bit prescaler.
sahilmgandhi 18:6a4db94011d3 192 [..]
sahilmgandhi 18:6a4db94011d3 193 (+) For the Smartcard mode only these parameters can be configured:
sahilmgandhi 18:6a4db94011d3 194 (++) Baud Rate
sahilmgandhi 18:6a4db94011d3 195 (++) Word Length => Should be 9 bits (8 bits + parity)
sahilmgandhi 18:6a4db94011d3 196 (++) Stop Bit
sahilmgandhi 18:6a4db94011d3 197 (++) Parity: => Should be enabled
sahilmgandhi 18:6a4db94011d3 198
sahilmgandhi 18:6a4db94011d3 199 (+++) +-------------------------------------------------------------+
sahilmgandhi 18:6a4db94011d3 200 (+++) | M bit | PCE bit | SMARTCARD frame |
sahilmgandhi 18:6a4db94011d3 201 (+++) |---------------------|---------------------------------------|
sahilmgandhi 18:6a4db94011d3 202 (+++) | 1 | 1 | | SB | 8 bit data | PB | STB | |
sahilmgandhi 18:6a4db94011d3 203 (+++) +-------------------------------------------------------------+
sahilmgandhi 18:6a4db94011d3 204
sahilmgandhi 18:6a4db94011d3 205 (++) USART polarity
sahilmgandhi 18:6a4db94011d3 206 (++) USART phase
sahilmgandhi 18:6a4db94011d3 207 (++) USART LastBit
sahilmgandhi 18:6a4db94011d3 208 (++) Receiver/transmitter modes
sahilmgandhi 18:6a4db94011d3 209 (++) Prescaler
sahilmgandhi 18:6a4db94011d3 210 (++) GuardTime
sahilmgandhi 18:6a4db94011d3 211 (++) NACKState: The Smartcard NACK state
sahilmgandhi 18:6a4db94011d3 212
sahilmgandhi 18:6a4db94011d3 213 (+) Recommended SmartCard interface configuration to get the Answer to Reset from the Card:
sahilmgandhi 18:6a4db94011d3 214 (++) Word Length = 9 Bits
sahilmgandhi 18:6a4db94011d3 215 (++) 1.5 Stop Bit
sahilmgandhi 18:6a4db94011d3 216 (++) Even parity
sahilmgandhi 18:6a4db94011d3 217 (++) BaudRate = 12096 baud
sahilmgandhi 18:6a4db94011d3 218 (++) Tx and Rx enabled
sahilmgandhi 18:6a4db94011d3 219 [..]
sahilmgandhi 18:6a4db94011d3 220 Please refer to the ISO 7816-3 specification for more details.
sahilmgandhi 18:6a4db94011d3 221
sahilmgandhi 18:6a4db94011d3 222 -@- It is also possible to choose 0.5 stop bit for receiving but it is recommended
sahilmgandhi 18:6a4db94011d3 223 to use 1.5 stop bits for both transmitting and receiving to avoid switching
sahilmgandhi 18:6a4db94011d3 224 between the two configurations.
sahilmgandhi 18:6a4db94011d3 225 [..]
sahilmgandhi 18:6a4db94011d3 226 The HAL_SMARTCARD_Init() function follows the USART SmartCard configuration
sahilmgandhi 18:6a4db94011d3 227 procedure (details for the procedure are available in reference manual (RM0329)).
sahilmgandhi 18:6a4db94011d3 228
sahilmgandhi 18:6a4db94011d3 229 @endverbatim
sahilmgandhi 18:6a4db94011d3 230 * @{
sahilmgandhi 18:6a4db94011d3 231 */
sahilmgandhi 18:6a4db94011d3 232
sahilmgandhi 18:6a4db94011d3 233 /**
sahilmgandhi 18:6a4db94011d3 234 * @brief Initializes the SmartCard mode according to the specified
sahilmgandhi 18:6a4db94011d3 235 * parameters in the SMARTCARD_InitTypeDef and create the associated handle .
sahilmgandhi 18:6a4db94011d3 236 * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 237 * the configuration information for SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 238 * @retval HAL status
sahilmgandhi 18:6a4db94011d3 239 */
sahilmgandhi 18:6a4db94011d3 240 HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsc)
sahilmgandhi 18:6a4db94011d3 241 {
sahilmgandhi 18:6a4db94011d3 242 /* Check the SMARTCARD handle allocation */
sahilmgandhi 18:6a4db94011d3 243 if(hsc == NULL)
sahilmgandhi 18:6a4db94011d3 244 {
sahilmgandhi 18:6a4db94011d3 245 return HAL_ERROR;
sahilmgandhi 18:6a4db94011d3 246 }
sahilmgandhi 18:6a4db94011d3 247
sahilmgandhi 18:6a4db94011d3 248 /* Check the parameters */
sahilmgandhi 18:6a4db94011d3 249 assert_param(IS_SMARTCARD_INSTANCE(hsc->Instance));
sahilmgandhi 18:6a4db94011d3 250 assert_param(IS_SMARTCARD_NACK_STATE(hsc->Init.NACKState));
sahilmgandhi 18:6a4db94011d3 251
sahilmgandhi 18:6a4db94011d3 252 if(hsc->gState == HAL_SMARTCARD_STATE_RESET)
sahilmgandhi 18:6a4db94011d3 253 {
sahilmgandhi 18:6a4db94011d3 254 /* Allocate lock resource and initialize it */
sahilmgandhi 18:6a4db94011d3 255 hsc->Lock = HAL_UNLOCKED;
sahilmgandhi 18:6a4db94011d3 256 /* Init the low level hardware : GPIO, CLOCK, CORTEX...etc */
sahilmgandhi 18:6a4db94011d3 257 HAL_SMARTCARD_MspInit(hsc);
sahilmgandhi 18:6a4db94011d3 258 }
sahilmgandhi 18:6a4db94011d3 259
sahilmgandhi 18:6a4db94011d3 260 hsc->gState = HAL_SMARTCARD_STATE_BUSY;
sahilmgandhi 18:6a4db94011d3 261
sahilmgandhi 18:6a4db94011d3 262 /* Set the Prescaler */
sahilmgandhi 18:6a4db94011d3 263 MODIFY_REG(hsc->Instance->GTPR, USART_GTPR_PSC, hsc->Init.Prescaler);
sahilmgandhi 18:6a4db94011d3 264
sahilmgandhi 18:6a4db94011d3 265 /* Set the Guard Time */
sahilmgandhi 18:6a4db94011d3 266 MODIFY_REG(hsc->Instance->GTPR, USART_GTPR_GT, ((hsc->Init.GuardTime)<<8));
sahilmgandhi 18:6a4db94011d3 267
sahilmgandhi 18:6a4db94011d3 268 /* Set the Smartcard Communication parameters */
sahilmgandhi 18:6a4db94011d3 269 SMARTCARD_SetConfig(hsc);
sahilmgandhi 18:6a4db94011d3 270
sahilmgandhi 18:6a4db94011d3 271 /* In SmartCard mode, the following bits must be kept cleared:
sahilmgandhi 18:6a4db94011d3 272 - LINEN bit in the USART_CR2 register
sahilmgandhi 18:6a4db94011d3 273 - HDSEL and IREN bits in the USART_CR3 register.*/
sahilmgandhi 18:6a4db94011d3 274 CLEAR_BIT(hsc->Instance->CR2, USART_CR2_LINEN);
sahilmgandhi 18:6a4db94011d3 275 CLEAR_BIT(hsc->Instance->CR3, (USART_CR3_IREN | USART_CR3_HDSEL));
sahilmgandhi 18:6a4db94011d3 276
sahilmgandhi 18:6a4db94011d3 277 /* Enable the SMARTCARD Parity Error Interrupt */
sahilmgandhi 18:6a4db94011d3 278 SET_BIT(hsc->Instance->CR1, USART_CR1_PEIE);
sahilmgandhi 18:6a4db94011d3 279
sahilmgandhi 18:6a4db94011d3 280 /* Enable the SMARTCARD Framing Error Interrupt */
sahilmgandhi 18:6a4db94011d3 281 SET_BIT(hsc->Instance->CR3, USART_CR3_EIE);
sahilmgandhi 18:6a4db94011d3 282
sahilmgandhi 18:6a4db94011d3 283 /* Enable the Peripheral */
sahilmgandhi 18:6a4db94011d3 284 __HAL_SMARTCARD_ENABLE(hsc);
sahilmgandhi 18:6a4db94011d3 285
sahilmgandhi 18:6a4db94011d3 286 /* Configure the Smartcard NACK state */
sahilmgandhi 18:6a4db94011d3 287 MODIFY_REG(hsc->Instance->CR3, USART_CR3_NACK, hsc->Init.NACKState);
sahilmgandhi 18:6a4db94011d3 288
sahilmgandhi 18:6a4db94011d3 289 /* Enable the SC mode by setting the SCEN bit in the CR3 register */
sahilmgandhi 18:6a4db94011d3 290 hsc->Instance->CR3 |= (USART_CR3_SCEN);
sahilmgandhi 18:6a4db94011d3 291
sahilmgandhi 18:6a4db94011d3 292 /* Initialize the SMARTCARD state*/
sahilmgandhi 18:6a4db94011d3 293 hsc->ErrorCode = HAL_SMARTCARD_ERROR_NONE;
sahilmgandhi 18:6a4db94011d3 294 hsc->gState= HAL_SMARTCARD_STATE_READY;
sahilmgandhi 18:6a4db94011d3 295 hsc->RxState= HAL_SMARTCARD_STATE_READY;
sahilmgandhi 18:6a4db94011d3 296
sahilmgandhi 18:6a4db94011d3 297 return HAL_OK;
sahilmgandhi 18:6a4db94011d3 298 }
sahilmgandhi 18:6a4db94011d3 299
sahilmgandhi 18:6a4db94011d3 300 /**
sahilmgandhi 18:6a4db94011d3 301 * @brief DeInitializes the USART SmartCard peripheral
sahilmgandhi 18:6a4db94011d3 302 * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 303 * the configuration information for SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 304 * @retval HAL status
sahilmgandhi 18:6a4db94011d3 305 */
sahilmgandhi 18:6a4db94011d3 306 HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc)
sahilmgandhi 18:6a4db94011d3 307 {
sahilmgandhi 18:6a4db94011d3 308 /* Check the SMARTCARD handle allocation */
sahilmgandhi 18:6a4db94011d3 309 if(hsc == NULL)
sahilmgandhi 18:6a4db94011d3 310 {
sahilmgandhi 18:6a4db94011d3 311 return HAL_ERROR;
sahilmgandhi 18:6a4db94011d3 312 }
sahilmgandhi 18:6a4db94011d3 313
sahilmgandhi 18:6a4db94011d3 314 /* Check the parameters */
sahilmgandhi 18:6a4db94011d3 315 assert_param(IS_SMARTCARD_INSTANCE(hsc->Instance));
sahilmgandhi 18:6a4db94011d3 316
sahilmgandhi 18:6a4db94011d3 317 hsc->gState = HAL_SMARTCARD_STATE_BUSY;
sahilmgandhi 18:6a4db94011d3 318
sahilmgandhi 18:6a4db94011d3 319 /* Disable the Peripheral */
sahilmgandhi 18:6a4db94011d3 320 __HAL_SMARTCARD_DISABLE(hsc);
sahilmgandhi 18:6a4db94011d3 321
sahilmgandhi 18:6a4db94011d3 322 /* DeInit the low level hardware */
sahilmgandhi 18:6a4db94011d3 323 HAL_SMARTCARD_MspDeInit(hsc);
sahilmgandhi 18:6a4db94011d3 324
sahilmgandhi 18:6a4db94011d3 325 hsc->ErrorCode = HAL_SMARTCARD_ERROR_NONE;
sahilmgandhi 18:6a4db94011d3 326 hsc->gState = HAL_SMARTCARD_STATE_RESET;
sahilmgandhi 18:6a4db94011d3 327 hsc->RxState = HAL_SMARTCARD_STATE_RESET;
sahilmgandhi 18:6a4db94011d3 328
sahilmgandhi 18:6a4db94011d3 329 /* Release Lock */
sahilmgandhi 18:6a4db94011d3 330 __HAL_UNLOCK(hsc);
sahilmgandhi 18:6a4db94011d3 331
sahilmgandhi 18:6a4db94011d3 332 return HAL_OK;
sahilmgandhi 18:6a4db94011d3 333 }
sahilmgandhi 18:6a4db94011d3 334
sahilmgandhi 18:6a4db94011d3 335 /**
sahilmgandhi 18:6a4db94011d3 336 * @brief SMARTCARD MSP Init
sahilmgandhi 18:6a4db94011d3 337 * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 338 * the configuration information for SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 339 * @retval None
sahilmgandhi 18:6a4db94011d3 340 */
sahilmgandhi 18:6a4db94011d3 341 __weak void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsc)
sahilmgandhi 18:6a4db94011d3 342 {
sahilmgandhi 18:6a4db94011d3 343 /* Prevent unused argument(s) compilation warning */
sahilmgandhi 18:6a4db94011d3 344 UNUSED(hsc);
sahilmgandhi 18:6a4db94011d3 345 /* NOTE : This function Should not be modified, when the callback is needed,
sahilmgandhi 18:6a4db94011d3 346 the HAL_SMARTCARD_MspInit could be implemented in the user file
sahilmgandhi 18:6a4db94011d3 347 */
sahilmgandhi 18:6a4db94011d3 348 }
sahilmgandhi 18:6a4db94011d3 349
sahilmgandhi 18:6a4db94011d3 350 /**
sahilmgandhi 18:6a4db94011d3 351 * @brief SMARTCARD MSP DeInit
sahilmgandhi 18:6a4db94011d3 352 * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 353 * the configuration information for SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 354 * @retval None
sahilmgandhi 18:6a4db94011d3 355 */
sahilmgandhi 18:6a4db94011d3 356 __weak void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsc)
sahilmgandhi 18:6a4db94011d3 357 {
sahilmgandhi 18:6a4db94011d3 358 /* Prevent unused argument(s) compilation warning */
sahilmgandhi 18:6a4db94011d3 359 UNUSED(hsc);
sahilmgandhi 18:6a4db94011d3 360 /* NOTE : This function Should not be modified, when the callback is needed,
sahilmgandhi 18:6a4db94011d3 361 the HAL_SMARTCARD_MspDeInit could be implemented in the user file
sahilmgandhi 18:6a4db94011d3 362 */
sahilmgandhi 18:6a4db94011d3 363 }
sahilmgandhi 18:6a4db94011d3 364
sahilmgandhi 18:6a4db94011d3 365 /**
sahilmgandhi 18:6a4db94011d3 366 * @}
sahilmgandhi 18:6a4db94011d3 367 */
sahilmgandhi 18:6a4db94011d3 368
sahilmgandhi 18:6a4db94011d3 369 /** @defgroup SMARTCARD_Exported_Functions_Group2 IO operation functions
sahilmgandhi 18:6a4db94011d3 370 * @brief SMARTCARD Transmit and Receive functions
sahilmgandhi 18:6a4db94011d3 371 *
sahilmgandhi 18:6a4db94011d3 372 @verbatim
sahilmgandhi 18:6a4db94011d3 373 ===============================================================================
sahilmgandhi 18:6a4db94011d3 374 ##### IO operation functions #####
sahilmgandhi 18:6a4db94011d3 375 ===============================================================================
sahilmgandhi 18:6a4db94011d3 376 This subsection provides a set of functions allowing to manage the SMARTCARD data transfers.
sahilmgandhi 18:6a4db94011d3 377 [..]
sahilmgandhi 18:6a4db94011d3 378 Smartcard is a single wire half duplex communication protocol.
sahilmgandhi 18:6a4db94011d3 379 The Smartcard interface is designed to support asynchronous protocol Smartcards as
sahilmgandhi 18:6a4db94011d3 380 defined in the ISO 7816-3 standard. The USART should be configured as:
sahilmgandhi 18:6a4db94011d3 381 (+) 8 bits plus parity: where M=1 and PCE=1 in the USART_CR1 register
sahilmgandhi 18:6a4db94011d3 382 (+) 1.5 stop bits when transmitting and receiving: where STOP=11 in the USART_CR2 register.
sahilmgandhi 18:6a4db94011d3 383
sahilmgandhi 18:6a4db94011d3 384 (#) There are two modes of transfer:
sahilmgandhi 18:6a4db94011d3 385 (++) Blocking mode: The communication is performed in polling mode.
sahilmgandhi 18:6a4db94011d3 386 The HAL status of all data processing is returned by the same function
sahilmgandhi 18:6a4db94011d3 387 after finishing transfer.
sahilmgandhi 18:6a4db94011d3 388 (++) Non Blocking mode: The communication is performed using Interrupts
sahilmgandhi 18:6a4db94011d3 389 or DMA, These APIs return the HAL status.
sahilmgandhi 18:6a4db94011d3 390 The end of the data processing will be indicated through the
sahilmgandhi 18:6a4db94011d3 391 dedicated SMARTCARD IRQ when using Interrupt mode or the DMA IRQ when
sahilmgandhi 18:6a4db94011d3 392 using DMA mode.
sahilmgandhi 18:6a4db94011d3 393 The HAL_SMARTCARD_TxCpltCallback(), HAL_SMARTCARD_RxCpltCallback() user callbacks
sahilmgandhi 18:6a4db94011d3 394 will be executed respectively at the end of the Transmit or Receive process
sahilmgandhi 18:6a4db94011d3 395 The HAL_SMARTCARD_ErrorCallback() user callback will be executed when a communication error is detected
sahilmgandhi 18:6a4db94011d3 396
sahilmgandhi 18:6a4db94011d3 397 (#) Blocking mode APIs are :
sahilmgandhi 18:6a4db94011d3 398 (++) HAL_SMARTCARD_Transmit()
sahilmgandhi 18:6a4db94011d3 399 (++) HAL_SMARTCARD_Receive()
sahilmgandhi 18:6a4db94011d3 400
sahilmgandhi 18:6a4db94011d3 401 (#) Non Blocking mode APIs with Interrupt are :
sahilmgandhi 18:6a4db94011d3 402 (++) HAL_SMARTCARD_Transmit_IT()
sahilmgandhi 18:6a4db94011d3 403 (++) HAL_SMARTCARD_Receive_IT()
sahilmgandhi 18:6a4db94011d3 404 (++) HAL_SMARTCARD_IRQHandler()
sahilmgandhi 18:6a4db94011d3 405
sahilmgandhi 18:6a4db94011d3 406 (#) Non Blocking mode functions with DMA are :
sahilmgandhi 18:6a4db94011d3 407 (++) HAL_SMARTCARD_Transmit_DMA()
sahilmgandhi 18:6a4db94011d3 408 (++) HAL_SMARTCARD_Receive_DMA()
sahilmgandhi 18:6a4db94011d3 409
sahilmgandhi 18:6a4db94011d3 410 (#) A set of Transfer Complete Callbacks are provided in non Blocking mode:
sahilmgandhi 18:6a4db94011d3 411 (++) HAL_SMARTCARD_TxCpltCallback()
sahilmgandhi 18:6a4db94011d3 412 (++) HAL_SMARTCARD_RxCpltCallback()
sahilmgandhi 18:6a4db94011d3 413 (++) HAL_SMARTCARD_ErrorCallback()
sahilmgandhi 18:6a4db94011d3 414
sahilmgandhi 18:6a4db94011d3 415 @endverbatim
sahilmgandhi 18:6a4db94011d3 416 * @{
sahilmgandhi 18:6a4db94011d3 417 */
sahilmgandhi 18:6a4db94011d3 418
sahilmgandhi 18:6a4db94011d3 419 /**
sahilmgandhi 18:6a4db94011d3 420 * @brief Send an amount of data in blocking mode
sahilmgandhi 18:6a4db94011d3 421 * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 422 * the configuration information for SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 423 * @param pData: pointer to data buffer
sahilmgandhi 18:6a4db94011d3 424 * @param Size: amount of data to be sent
sahilmgandhi 18:6a4db94011d3 425 * @param Timeout: Timeout duration
sahilmgandhi 18:6a4db94011d3 426 * @retval HAL status
sahilmgandhi 18:6a4db94011d3 427 */
sahilmgandhi 18:6a4db94011d3 428 HAL_StatusTypeDef HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout)
sahilmgandhi 18:6a4db94011d3 429 {
sahilmgandhi 18:6a4db94011d3 430 uint16_t* tmp;
sahilmgandhi 18:6a4db94011d3 431 uint32_t tickstart = 0U;
sahilmgandhi 18:6a4db94011d3 432
sahilmgandhi 18:6a4db94011d3 433 if(hsc->gState == HAL_SMARTCARD_STATE_READY)
sahilmgandhi 18:6a4db94011d3 434 {
sahilmgandhi 18:6a4db94011d3 435 if((pData == NULL) || (Size == 0U))
sahilmgandhi 18:6a4db94011d3 436 {
sahilmgandhi 18:6a4db94011d3 437 return HAL_ERROR;
sahilmgandhi 18:6a4db94011d3 438 }
sahilmgandhi 18:6a4db94011d3 439
sahilmgandhi 18:6a4db94011d3 440 /* Process Locked */
sahilmgandhi 18:6a4db94011d3 441 __HAL_LOCK(hsc);
sahilmgandhi 18:6a4db94011d3 442
sahilmgandhi 18:6a4db94011d3 443 hsc->ErrorCode = HAL_SMARTCARD_ERROR_NONE;
sahilmgandhi 18:6a4db94011d3 444 hsc->gState = HAL_SMARTCARD_STATE_BUSY_TX;
sahilmgandhi 18:6a4db94011d3 445
sahilmgandhi 18:6a4db94011d3 446 /* Init tickstart for timeout managment */
sahilmgandhi 18:6a4db94011d3 447 tickstart = HAL_GetTick();
sahilmgandhi 18:6a4db94011d3 448
sahilmgandhi 18:6a4db94011d3 449 hsc->TxXferSize = Size;
sahilmgandhi 18:6a4db94011d3 450 hsc->TxXferCount = Size;
sahilmgandhi 18:6a4db94011d3 451 while(hsc->TxXferCount > 0U)
sahilmgandhi 18:6a4db94011d3 452 {
sahilmgandhi 18:6a4db94011d3 453 hsc->TxXferCount--;
sahilmgandhi 18:6a4db94011d3 454 if(SMARTCARD_WaitOnFlagUntilTimeout(hsc, SMARTCARD_FLAG_TXE, RESET, tickstart, Timeout) != HAL_OK)
sahilmgandhi 18:6a4db94011d3 455 {
sahilmgandhi 18:6a4db94011d3 456 return HAL_TIMEOUT;
sahilmgandhi 18:6a4db94011d3 457 }
sahilmgandhi 18:6a4db94011d3 458 tmp = (uint16_t*) pData;
sahilmgandhi 18:6a4db94011d3 459 hsc->Instance->DR = (*tmp & (uint16_t)0x01FFU);
sahilmgandhi 18:6a4db94011d3 460 pData +=1U;
sahilmgandhi 18:6a4db94011d3 461 }
sahilmgandhi 18:6a4db94011d3 462
sahilmgandhi 18:6a4db94011d3 463 if(SMARTCARD_WaitOnFlagUntilTimeout(hsc, SMARTCARD_FLAG_TC, RESET, tickstart, Timeout) != HAL_OK)
sahilmgandhi 18:6a4db94011d3 464 {
sahilmgandhi 18:6a4db94011d3 465 return HAL_TIMEOUT;
sahilmgandhi 18:6a4db94011d3 466 }
sahilmgandhi 18:6a4db94011d3 467
sahilmgandhi 18:6a4db94011d3 468 /* At end of Tx process, restore hsc->gState to Ready */
sahilmgandhi 18:6a4db94011d3 469 hsc->gState = HAL_SMARTCARD_STATE_READY;
sahilmgandhi 18:6a4db94011d3 470
sahilmgandhi 18:6a4db94011d3 471 /* Process Unlocked */
sahilmgandhi 18:6a4db94011d3 472 __HAL_UNLOCK(hsc);
sahilmgandhi 18:6a4db94011d3 473
sahilmgandhi 18:6a4db94011d3 474 return HAL_OK;
sahilmgandhi 18:6a4db94011d3 475 }
sahilmgandhi 18:6a4db94011d3 476 else
sahilmgandhi 18:6a4db94011d3 477 {
sahilmgandhi 18:6a4db94011d3 478 return HAL_BUSY;
sahilmgandhi 18:6a4db94011d3 479 }
sahilmgandhi 18:6a4db94011d3 480 }
sahilmgandhi 18:6a4db94011d3 481
sahilmgandhi 18:6a4db94011d3 482 /**
sahilmgandhi 18:6a4db94011d3 483 * @brief Receive an amount of data in blocking mode
sahilmgandhi 18:6a4db94011d3 484 * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 485 * the configuration information for SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 486 * @param pData: pointer to data buffer
sahilmgandhi 18:6a4db94011d3 487 * @param Size: amount of data to be received
sahilmgandhi 18:6a4db94011d3 488 * @param Timeout: Timeout duration
sahilmgandhi 18:6a4db94011d3 489 * @retval HAL status
sahilmgandhi 18:6a4db94011d3 490 */
sahilmgandhi 18:6a4db94011d3 491 HAL_StatusTypeDef HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout)
sahilmgandhi 18:6a4db94011d3 492 {
sahilmgandhi 18:6a4db94011d3 493 uint16_t* tmp;
sahilmgandhi 18:6a4db94011d3 494 uint32_t tickstart = 0U;
sahilmgandhi 18:6a4db94011d3 495
sahilmgandhi 18:6a4db94011d3 496 if(hsc->RxState == HAL_SMARTCARD_STATE_READY)
sahilmgandhi 18:6a4db94011d3 497 {
sahilmgandhi 18:6a4db94011d3 498 if((pData == NULL) || (Size == 0U))
sahilmgandhi 18:6a4db94011d3 499 {
sahilmgandhi 18:6a4db94011d3 500 return HAL_ERROR;
sahilmgandhi 18:6a4db94011d3 501 }
sahilmgandhi 18:6a4db94011d3 502
sahilmgandhi 18:6a4db94011d3 503 /* Process Locked */
sahilmgandhi 18:6a4db94011d3 504 __HAL_LOCK(hsc);
sahilmgandhi 18:6a4db94011d3 505
sahilmgandhi 18:6a4db94011d3 506 hsc->ErrorCode = HAL_SMARTCARD_ERROR_NONE;
sahilmgandhi 18:6a4db94011d3 507 hsc->RxState = HAL_SMARTCARD_STATE_BUSY_RX;
sahilmgandhi 18:6a4db94011d3 508
sahilmgandhi 18:6a4db94011d3 509 /* Init tickstart for timeout managment */
sahilmgandhi 18:6a4db94011d3 510 tickstart = HAL_GetTick();
sahilmgandhi 18:6a4db94011d3 511
sahilmgandhi 18:6a4db94011d3 512 hsc->RxXferSize = Size;
sahilmgandhi 18:6a4db94011d3 513 hsc->RxXferCount = Size;
sahilmgandhi 18:6a4db94011d3 514
sahilmgandhi 18:6a4db94011d3 515 /* Check the remain data to be received */
sahilmgandhi 18:6a4db94011d3 516 while(hsc->RxXferCount > 0U)
sahilmgandhi 18:6a4db94011d3 517 {
sahilmgandhi 18:6a4db94011d3 518 hsc->RxXferCount--;
sahilmgandhi 18:6a4db94011d3 519 if(SMARTCARD_WaitOnFlagUntilTimeout(hsc, SMARTCARD_FLAG_RXNE, RESET, tickstart, Timeout) != HAL_OK)
sahilmgandhi 18:6a4db94011d3 520 {
sahilmgandhi 18:6a4db94011d3 521 return HAL_TIMEOUT;
sahilmgandhi 18:6a4db94011d3 522 }
sahilmgandhi 18:6a4db94011d3 523 tmp = (uint16_t*) pData;
sahilmgandhi 18:6a4db94011d3 524 *tmp = (uint8_t)(hsc->Instance->DR & (uint8_t)0xFFU);
sahilmgandhi 18:6a4db94011d3 525 pData +=1U;
sahilmgandhi 18:6a4db94011d3 526 }
sahilmgandhi 18:6a4db94011d3 527
sahilmgandhi 18:6a4db94011d3 528 /* At end of Rx process, restore hsc->RxState to Ready */
sahilmgandhi 18:6a4db94011d3 529 hsc->RxState = HAL_SMARTCARD_STATE_READY;
sahilmgandhi 18:6a4db94011d3 530
sahilmgandhi 18:6a4db94011d3 531 /* Process Unlocked */
sahilmgandhi 18:6a4db94011d3 532 __HAL_UNLOCK(hsc);
sahilmgandhi 18:6a4db94011d3 533
sahilmgandhi 18:6a4db94011d3 534 return HAL_OK;
sahilmgandhi 18:6a4db94011d3 535 }
sahilmgandhi 18:6a4db94011d3 536 else
sahilmgandhi 18:6a4db94011d3 537 {
sahilmgandhi 18:6a4db94011d3 538 return HAL_BUSY;
sahilmgandhi 18:6a4db94011d3 539 }
sahilmgandhi 18:6a4db94011d3 540 }
sahilmgandhi 18:6a4db94011d3 541
sahilmgandhi 18:6a4db94011d3 542 /**
sahilmgandhi 18:6a4db94011d3 543 * @brief Send an amount of data in non blocking mode
sahilmgandhi 18:6a4db94011d3 544 * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 545 * the configuration information for SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 546 * @param pData: pointer to data buffer
sahilmgandhi 18:6a4db94011d3 547 * @param Size: amount of data to be sent
sahilmgandhi 18:6a4db94011d3 548 * @retval HAL status
sahilmgandhi 18:6a4db94011d3 549 */
sahilmgandhi 18:6a4db94011d3 550 HAL_StatusTypeDef HAL_SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size)
sahilmgandhi 18:6a4db94011d3 551 {
sahilmgandhi 18:6a4db94011d3 552 /* Check that a Tx process is not already ongoing */
sahilmgandhi 18:6a4db94011d3 553 if(hsc->gState == HAL_SMARTCARD_STATE_READY)
sahilmgandhi 18:6a4db94011d3 554 {
sahilmgandhi 18:6a4db94011d3 555 if((pData == NULL) || (Size == 0U))
sahilmgandhi 18:6a4db94011d3 556 {
sahilmgandhi 18:6a4db94011d3 557 return HAL_ERROR;
sahilmgandhi 18:6a4db94011d3 558 }
sahilmgandhi 18:6a4db94011d3 559
sahilmgandhi 18:6a4db94011d3 560 /* Process Locked */
sahilmgandhi 18:6a4db94011d3 561 __HAL_LOCK(hsc);
sahilmgandhi 18:6a4db94011d3 562
sahilmgandhi 18:6a4db94011d3 563 hsc->pTxBuffPtr = pData;
sahilmgandhi 18:6a4db94011d3 564 hsc->TxXferSize = Size;
sahilmgandhi 18:6a4db94011d3 565 hsc->TxXferCount = Size;
sahilmgandhi 18:6a4db94011d3 566
sahilmgandhi 18:6a4db94011d3 567 hsc->ErrorCode = HAL_SMARTCARD_ERROR_NONE;
sahilmgandhi 18:6a4db94011d3 568 hsc->gState = HAL_SMARTCARD_STATE_BUSY_TX;
sahilmgandhi 18:6a4db94011d3 569
sahilmgandhi 18:6a4db94011d3 570 /* Process Unlocked */
sahilmgandhi 18:6a4db94011d3 571 __HAL_UNLOCK(hsc);
sahilmgandhi 18:6a4db94011d3 572
sahilmgandhi 18:6a4db94011d3 573 /* Enable the SMARTCARD Parity Error Interrupt */
sahilmgandhi 18:6a4db94011d3 574 SET_BIT(hsc->Instance->CR1, USART_CR1_PEIE);
sahilmgandhi 18:6a4db94011d3 575
sahilmgandhi 18:6a4db94011d3 576 /* Disable the SMARTCARD Error Interrupt: (Frame error, noise error, overrun error) */
sahilmgandhi 18:6a4db94011d3 577 CLEAR_BIT(hsc->Instance->CR3, USART_CR3_EIE);
sahilmgandhi 18:6a4db94011d3 578
sahilmgandhi 18:6a4db94011d3 579 /* Enable the SMARTCARD Transmit data register empty Interrupt */
sahilmgandhi 18:6a4db94011d3 580 SET_BIT(hsc->Instance->CR1, USART_CR1_TXEIE);
sahilmgandhi 18:6a4db94011d3 581
sahilmgandhi 18:6a4db94011d3 582 return HAL_OK;
sahilmgandhi 18:6a4db94011d3 583 }
sahilmgandhi 18:6a4db94011d3 584 else
sahilmgandhi 18:6a4db94011d3 585 {
sahilmgandhi 18:6a4db94011d3 586 return HAL_BUSY;
sahilmgandhi 18:6a4db94011d3 587 }
sahilmgandhi 18:6a4db94011d3 588 }
sahilmgandhi 18:6a4db94011d3 589
sahilmgandhi 18:6a4db94011d3 590 /**
sahilmgandhi 18:6a4db94011d3 591 * @brief Receive an amount of data in non blocking mode
sahilmgandhi 18:6a4db94011d3 592 * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 593 * the configuration information for SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 594 * @param pData: pointer to data buffer
sahilmgandhi 18:6a4db94011d3 595 * @param Size: amount of data to be received
sahilmgandhi 18:6a4db94011d3 596 * @retval HAL status
sahilmgandhi 18:6a4db94011d3 597 */
sahilmgandhi 18:6a4db94011d3 598 HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size)
sahilmgandhi 18:6a4db94011d3 599 {
sahilmgandhi 18:6a4db94011d3 600 /* Check that a Rx process is not already ongoing */
sahilmgandhi 18:6a4db94011d3 601 if(hsc->RxState == HAL_SMARTCARD_STATE_READY)
sahilmgandhi 18:6a4db94011d3 602 {
sahilmgandhi 18:6a4db94011d3 603 if((pData == NULL) || (Size == 0U))
sahilmgandhi 18:6a4db94011d3 604 {
sahilmgandhi 18:6a4db94011d3 605 return HAL_ERROR;
sahilmgandhi 18:6a4db94011d3 606 }
sahilmgandhi 18:6a4db94011d3 607
sahilmgandhi 18:6a4db94011d3 608 /* Process Locked */
sahilmgandhi 18:6a4db94011d3 609 __HAL_LOCK(hsc);
sahilmgandhi 18:6a4db94011d3 610
sahilmgandhi 18:6a4db94011d3 611 hsc->pRxBuffPtr = pData;
sahilmgandhi 18:6a4db94011d3 612 hsc->RxXferSize = Size;
sahilmgandhi 18:6a4db94011d3 613 hsc->RxXferCount = Size;
sahilmgandhi 18:6a4db94011d3 614
sahilmgandhi 18:6a4db94011d3 615 hsc->ErrorCode = HAL_SMARTCARD_ERROR_NONE;
sahilmgandhi 18:6a4db94011d3 616 hsc->RxState = HAL_SMARTCARD_STATE_BUSY_RX;
sahilmgandhi 18:6a4db94011d3 617
sahilmgandhi 18:6a4db94011d3 618 /* Process Unlocked */
sahilmgandhi 18:6a4db94011d3 619 __HAL_UNLOCK(hsc);
sahilmgandhi 18:6a4db94011d3 620
sahilmgandhi 18:6a4db94011d3 621 /* Enable the SMARTCARD Parity Error and Data Register not empty Interrupts */
sahilmgandhi 18:6a4db94011d3 622 SET_BIT(hsc->Instance->CR1, USART_CR1_PEIE| USART_CR1_RXNEIE);
sahilmgandhi 18:6a4db94011d3 623
sahilmgandhi 18:6a4db94011d3 624 /* Enable the SMARTCARD Error Interrupt: (Frame error, noise error, overrun error) */
sahilmgandhi 18:6a4db94011d3 625 SET_BIT(hsc->Instance->CR3, USART_CR3_EIE);
sahilmgandhi 18:6a4db94011d3 626
sahilmgandhi 18:6a4db94011d3 627 return HAL_OK;
sahilmgandhi 18:6a4db94011d3 628 }
sahilmgandhi 18:6a4db94011d3 629 else
sahilmgandhi 18:6a4db94011d3 630 {
sahilmgandhi 18:6a4db94011d3 631 return HAL_BUSY;
sahilmgandhi 18:6a4db94011d3 632 }
sahilmgandhi 18:6a4db94011d3 633 }
sahilmgandhi 18:6a4db94011d3 634
sahilmgandhi 18:6a4db94011d3 635 /**
sahilmgandhi 18:6a4db94011d3 636 * @brief Send an amount of data in non blocking mode
sahilmgandhi 18:6a4db94011d3 637 * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 638 * the configuration information for SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 639 * @param pData: pointer to data buffer
sahilmgandhi 18:6a4db94011d3 640 * @param Size: amount of data to be sent
sahilmgandhi 18:6a4db94011d3 641 * @retval HAL status
sahilmgandhi 18:6a4db94011d3 642 */
sahilmgandhi 18:6a4db94011d3 643 HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size)
sahilmgandhi 18:6a4db94011d3 644 {
sahilmgandhi 18:6a4db94011d3 645 uint32_t *tmp;
sahilmgandhi 18:6a4db94011d3 646
sahilmgandhi 18:6a4db94011d3 647 /* Check that a Tx process is not already ongoing */
sahilmgandhi 18:6a4db94011d3 648 if(hsc->gState == HAL_SMARTCARD_STATE_READY)
sahilmgandhi 18:6a4db94011d3 649 {
sahilmgandhi 18:6a4db94011d3 650 if((pData == NULL) || (Size == 0U))
sahilmgandhi 18:6a4db94011d3 651 {
sahilmgandhi 18:6a4db94011d3 652 return HAL_ERROR;
sahilmgandhi 18:6a4db94011d3 653 }
sahilmgandhi 18:6a4db94011d3 654
sahilmgandhi 18:6a4db94011d3 655 /* Process Locked */
sahilmgandhi 18:6a4db94011d3 656 __HAL_LOCK(hsc);
sahilmgandhi 18:6a4db94011d3 657
sahilmgandhi 18:6a4db94011d3 658 hsc->pTxBuffPtr = pData;
sahilmgandhi 18:6a4db94011d3 659 hsc->TxXferSize = Size;
sahilmgandhi 18:6a4db94011d3 660 hsc->TxXferCount = Size;
sahilmgandhi 18:6a4db94011d3 661
sahilmgandhi 18:6a4db94011d3 662 hsc->ErrorCode = HAL_SMARTCARD_ERROR_NONE;
sahilmgandhi 18:6a4db94011d3 663 hsc->gState = HAL_SMARTCARD_STATE_BUSY_TX;
sahilmgandhi 18:6a4db94011d3 664
sahilmgandhi 18:6a4db94011d3 665 /* Set the SMARTCARD DMA transfer complete callback */
sahilmgandhi 18:6a4db94011d3 666 hsc->hdmatx->XferCpltCallback = SMARTCARD_DMATransmitCplt;
sahilmgandhi 18:6a4db94011d3 667
sahilmgandhi 18:6a4db94011d3 668 /* Set the DMA error callback */
sahilmgandhi 18:6a4db94011d3 669 hsc->hdmatx->XferErrorCallback = SMARTCARD_DMAError;
sahilmgandhi 18:6a4db94011d3 670
sahilmgandhi 18:6a4db94011d3 671 /* Set the DMA abort callback */
sahilmgandhi 18:6a4db94011d3 672 hsc->hdmatx->XferAbortCallback = NULL;
sahilmgandhi 18:6a4db94011d3 673
sahilmgandhi 18:6a4db94011d3 674 /* Enable the SMARTCARD transmit DMA Stream */
sahilmgandhi 18:6a4db94011d3 675 tmp = (uint32_t*)&pData;
sahilmgandhi 18:6a4db94011d3 676 HAL_DMA_Start_IT(hsc->hdmatx, *(uint32_t*)tmp, (uint32_t)&hsc->Instance->DR, Size);
sahilmgandhi 18:6a4db94011d3 677
sahilmgandhi 18:6a4db94011d3 678 /* Clear the TC flag in the SR register by writing 0 to it */
sahilmgandhi 18:6a4db94011d3 679 __HAL_SMARTCARD_CLEAR_FLAG(hsc, SMARTCARD_FLAG_TC);
sahilmgandhi 18:6a4db94011d3 680
sahilmgandhi 18:6a4db94011d3 681 /* Process Unlocked */
sahilmgandhi 18:6a4db94011d3 682 __HAL_UNLOCK(hsc);
sahilmgandhi 18:6a4db94011d3 683
sahilmgandhi 18:6a4db94011d3 684 /* Enable the DMA transfer for transmit request by setting the DMAT bit
sahilmgandhi 18:6a4db94011d3 685 in the SMARTCARD CR3 register */
sahilmgandhi 18:6a4db94011d3 686 SET_BIT(hsc->Instance->CR3, USART_CR3_DMAT);
sahilmgandhi 18:6a4db94011d3 687
sahilmgandhi 18:6a4db94011d3 688 return HAL_OK;
sahilmgandhi 18:6a4db94011d3 689 }
sahilmgandhi 18:6a4db94011d3 690 else
sahilmgandhi 18:6a4db94011d3 691 {
sahilmgandhi 18:6a4db94011d3 692 return HAL_BUSY;
sahilmgandhi 18:6a4db94011d3 693 }
sahilmgandhi 18:6a4db94011d3 694 }
sahilmgandhi 18:6a4db94011d3 695
sahilmgandhi 18:6a4db94011d3 696 /**
sahilmgandhi 18:6a4db94011d3 697 * @brief Receive an amount of data in non blocking mode
sahilmgandhi 18:6a4db94011d3 698 * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 699 * the configuration information for SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 700 * @param pData: pointer to data buffer
sahilmgandhi 18:6a4db94011d3 701 * @param Size: amount of data to be received
sahilmgandhi 18:6a4db94011d3 702 * @note When the SMARTCARD parity is enabled (PCE = 1) the data received contain the parity bit.s
sahilmgandhi 18:6a4db94011d3 703 * @retval HAL status
sahilmgandhi 18:6a4db94011d3 704 */
sahilmgandhi 18:6a4db94011d3 705 HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size)
sahilmgandhi 18:6a4db94011d3 706 {
sahilmgandhi 18:6a4db94011d3 707 uint32_t *tmp;
sahilmgandhi 18:6a4db94011d3 708
sahilmgandhi 18:6a4db94011d3 709 /* Check that a Rx process is not already ongoing */
sahilmgandhi 18:6a4db94011d3 710 if(hsc->RxState == HAL_SMARTCARD_STATE_READY)
sahilmgandhi 18:6a4db94011d3 711 {
sahilmgandhi 18:6a4db94011d3 712 if((pData == NULL) || (Size == 0U))
sahilmgandhi 18:6a4db94011d3 713 {
sahilmgandhi 18:6a4db94011d3 714 return HAL_ERROR;
sahilmgandhi 18:6a4db94011d3 715 }
sahilmgandhi 18:6a4db94011d3 716
sahilmgandhi 18:6a4db94011d3 717 /* Process Locked */
sahilmgandhi 18:6a4db94011d3 718 __HAL_LOCK(hsc);
sahilmgandhi 18:6a4db94011d3 719
sahilmgandhi 18:6a4db94011d3 720 hsc->pRxBuffPtr = pData;
sahilmgandhi 18:6a4db94011d3 721 hsc->RxXferSize = Size;
sahilmgandhi 18:6a4db94011d3 722
sahilmgandhi 18:6a4db94011d3 723 hsc->ErrorCode = HAL_SMARTCARD_ERROR_NONE;
sahilmgandhi 18:6a4db94011d3 724 hsc->RxState = HAL_SMARTCARD_STATE_BUSY_RX;
sahilmgandhi 18:6a4db94011d3 725
sahilmgandhi 18:6a4db94011d3 726 /* Set the SMARTCARD DMA transfer complete callback */
sahilmgandhi 18:6a4db94011d3 727 hsc->hdmarx->XferCpltCallback = SMARTCARD_DMAReceiveCplt;
sahilmgandhi 18:6a4db94011d3 728
sahilmgandhi 18:6a4db94011d3 729 /* Set the DMA error callback */
sahilmgandhi 18:6a4db94011d3 730 hsc->hdmarx->XferErrorCallback = SMARTCARD_DMAError;
sahilmgandhi 18:6a4db94011d3 731
sahilmgandhi 18:6a4db94011d3 732 /* Set the DMA abort callback */
sahilmgandhi 18:6a4db94011d3 733 hsc->hdmatx->XferAbortCallback = NULL;
sahilmgandhi 18:6a4db94011d3 734
sahilmgandhi 18:6a4db94011d3 735 /* Enable the DMA Stream */
sahilmgandhi 18:6a4db94011d3 736 tmp = (uint32_t*)&pData;
sahilmgandhi 18:6a4db94011d3 737 HAL_DMA_Start_IT(hsc->hdmarx, (uint32_t)&hsc->Instance->DR, *(uint32_t*)tmp, Size);
sahilmgandhi 18:6a4db94011d3 738
sahilmgandhi 18:6a4db94011d3 739 /* Process Unlocked */
sahilmgandhi 18:6a4db94011d3 740 __HAL_UNLOCK(hsc);
sahilmgandhi 18:6a4db94011d3 741
sahilmgandhi 18:6a4db94011d3 742 /* Enable the SMARTCARD Parity Error Interrupt */
sahilmgandhi 18:6a4db94011d3 743 SET_BIT(hsc->Instance->CR1, USART_CR1_PEIE);
sahilmgandhi 18:6a4db94011d3 744
sahilmgandhi 18:6a4db94011d3 745 /* Enable the SMARTCARD Error Interrupt: (Frame error, noise error, overrun error) */
sahilmgandhi 18:6a4db94011d3 746 SET_BIT(hsc->Instance->CR3, USART_CR3_EIE);
sahilmgandhi 18:6a4db94011d3 747
sahilmgandhi 18:6a4db94011d3 748 /* Enable the DMA transfer for the receiver request by setting the DMAR bit
sahilmgandhi 18:6a4db94011d3 749 in the SMARTCARD CR3 register */
sahilmgandhi 18:6a4db94011d3 750 SET_BIT(hsc->Instance->CR3, USART_CR3_DMAR);
sahilmgandhi 18:6a4db94011d3 751
sahilmgandhi 18:6a4db94011d3 752 return HAL_OK;
sahilmgandhi 18:6a4db94011d3 753 }
sahilmgandhi 18:6a4db94011d3 754 else
sahilmgandhi 18:6a4db94011d3 755 {
sahilmgandhi 18:6a4db94011d3 756 return HAL_BUSY;
sahilmgandhi 18:6a4db94011d3 757 }
sahilmgandhi 18:6a4db94011d3 758 }
sahilmgandhi 18:6a4db94011d3 759
sahilmgandhi 18:6a4db94011d3 760 /**
sahilmgandhi 18:6a4db94011d3 761 * @brief This function handles SMARTCARD interrupt request.
sahilmgandhi 18:6a4db94011d3 762 * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 763 * the configuration information for SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 764 * @retval None
sahilmgandhi 18:6a4db94011d3 765 */
sahilmgandhi 18:6a4db94011d3 766 void HAL_SMARTCARD_IRQHandler(SMARTCARD_HandleTypeDef *hsc)
sahilmgandhi 18:6a4db94011d3 767 {
sahilmgandhi 18:6a4db94011d3 768 uint32_t isrflags = READ_REG(hsc->Instance->SR);
sahilmgandhi 18:6a4db94011d3 769 uint32_t cr1its = READ_REG(hsc->Instance->CR1);
sahilmgandhi 18:6a4db94011d3 770 uint32_t cr3its = READ_REG(hsc->Instance->CR3);
sahilmgandhi 18:6a4db94011d3 771 uint32_t dmarequest = 0x00U;
sahilmgandhi 18:6a4db94011d3 772 uint32_t errorflags = 0x00U;
sahilmgandhi 18:6a4db94011d3 773
sahilmgandhi 18:6a4db94011d3 774 /* If no error occurs */
sahilmgandhi 18:6a4db94011d3 775 errorflags = (isrflags & (uint32_t)(USART_SR_PE | USART_SR_FE | USART_SR_ORE | USART_SR_NE));
sahilmgandhi 18:6a4db94011d3 776 if(errorflags == RESET)
sahilmgandhi 18:6a4db94011d3 777 {
sahilmgandhi 18:6a4db94011d3 778 /* SMARTCARD in mode Receiver -------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 779 if(((isrflags & USART_SR_RXNE) != RESET) && ((cr1its & USART_CR1_RXNEIE) != RESET))
sahilmgandhi 18:6a4db94011d3 780 {
sahilmgandhi 18:6a4db94011d3 781 SMARTCARD_Receive_IT(hsc);
sahilmgandhi 18:6a4db94011d3 782 return;
sahilmgandhi 18:6a4db94011d3 783 }
sahilmgandhi 18:6a4db94011d3 784 }
sahilmgandhi 18:6a4db94011d3 785
sahilmgandhi 18:6a4db94011d3 786 /* If some errors occur */
sahilmgandhi 18:6a4db94011d3 787 if((errorflags != RESET) && (((cr3its & USART_CR3_EIE) != RESET) || ((cr1its & (USART_CR1_RXNEIE | USART_CR1_PEIE)) != RESET)))
sahilmgandhi 18:6a4db94011d3 788 {
sahilmgandhi 18:6a4db94011d3 789 /* SMARTCARD parity error interrupt occurred ---------------------------*/
sahilmgandhi 18:6a4db94011d3 790 if(((isrflags & SMARTCARD_FLAG_PE) != RESET) && ((cr1its & USART_CR1_PEIE) != RESET))
sahilmgandhi 18:6a4db94011d3 791 {
sahilmgandhi 18:6a4db94011d3 792 hsc->ErrorCode |= HAL_SMARTCARD_ERROR_PE;
sahilmgandhi 18:6a4db94011d3 793 }
sahilmgandhi 18:6a4db94011d3 794
sahilmgandhi 18:6a4db94011d3 795 /* SMARTCARD frame error interrupt occurred ----------------------------*/
sahilmgandhi 18:6a4db94011d3 796 if(((isrflags & SMARTCARD_FLAG_FE) != RESET) && ((cr3its & USART_CR3_EIE) != RESET))
sahilmgandhi 18:6a4db94011d3 797 {
sahilmgandhi 18:6a4db94011d3 798 hsc->ErrorCode |= HAL_SMARTCARD_ERROR_FE;
sahilmgandhi 18:6a4db94011d3 799 }
sahilmgandhi 18:6a4db94011d3 800
sahilmgandhi 18:6a4db94011d3 801 /* SMARTCARD noise error interrupt occurred ----------------------------*/
sahilmgandhi 18:6a4db94011d3 802 if(((isrflags & SMARTCARD_FLAG_NE) != RESET) && ((cr3its & USART_CR3_EIE) != RESET))
sahilmgandhi 18:6a4db94011d3 803 {
sahilmgandhi 18:6a4db94011d3 804 hsc->ErrorCode |= HAL_SMARTCARD_ERROR_NE;
sahilmgandhi 18:6a4db94011d3 805 }
sahilmgandhi 18:6a4db94011d3 806
sahilmgandhi 18:6a4db94011d3 807 /* SMARTCARD Over-Run interrupt occurred -------------------------------*/
sahilmgandhi 18:6a4db94011d3 808 if(((isrflags & SMARTCARD_FLAG_ORE) != RESET) && ((cr3its & USART_CR3_EIE) != RESET))
sahilmgandhi 18:6a4db94011d3 809 {
sahilmgandhi 18:6a4db94011d3 810 hsc->ErrorCode |= HAL_SMARTCARD_ERROR_ORE;
sahilmgandhi 18:6a4db94011d3 811 }
sahilmgandhi 18:6a4db94011d3 812 /* Call the Error call Back in case of Errors */
sahilmgandhi 18:6a4db94011d3 813 if(hsc->ErrorCode != HAL_SMARTCARD_ERROR_NONE)
sahilmgandhi 18:6a4db94011d3 814 {
sahilmgandhi 18:6a4db94011d3 815 /* SMARTCARD in mode Receiver -----------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 816 if(((isrflags & USART_SR_RXNE) != RESET) && ((cr1its & USART_CR1_RXNEIE) != RESET))
sahilmgandhi 18:6a4db94011d3 817 {
sahilmgandhi 18:6a4db94011d3 818 SMARTCARD_Receive_IT(hsc);
sahilmgandhi 18:6a4db94011d3 819 }
sahilmgandhi 18:6a4db94011d3 820
sahilmgandhi 18:6a4db94011d3 821 /* If Overrun error occurs, or if any error occurs in DMA mode reception,
sahilmgandhi 18:6a4db94011d3 822 consider error as blocking */
sahilmgandhi 18:6a4db94011d3 823 dmarequest = HAL_IS_BIT_SET(hsc->Instance->CR3, USART_CR3_DMAR);
sahilmgandhi 18:6a4db94011d3 824 if(((hsc->ErrorCode & HAL_SMARTCARD_ERROR_ORE) != RESET) || dmarequest)
sahilmgandhi 18:6a4db94011d3 825 {
sahilmgandhi 18:6a4db94011d3 826 /* Blocking error : transfer is aborted
sahilmgandhi 18:6a4db94011d3 827 Set the SMARTCARD state ready to be able to start again the process,
sahilmgandhi 18:6a4db94011d3 828 Disable Rx Interrupts, and disable Rx DMA request, if ongoing */
sahilmgandhi 18:6a4db94011d3 829 SMARTCARD_EndRxTransfer(hsc);
sahilmgandhi 18:6a4db94011d3 830 /* Disable the SMARTCARD DMA Rx request if enabled */
sahilmgandhi 18:6a4db94011d3 831 if(HAL_IS_BIT_SET(hsc->Instance->CR3, USART_CR3_DMAR))
sahilmgandhi 18:6a4db94011d3 832 {
sahilmgandhi 18:6a4db94011d3 833 CLEAR_BIT(hsc->Instance->CR3, USART_CR3_DMAR);
sahilmgandhi 18:6a4db94011d3 834
sahilmgandhi 18:6a4db94011d3 835 /* Abort the SMARTCARD DMA Rx channel */
sahilmgandhi 18:6a4db94011d3 836 if(hsc->hdmarx != NULL)
sahilmgandhi 18:6a4db94011d3 837 {
sahilmgandhi 18:6a4db94011d3 838 /* Set the SMARTCARD DMA Abort callback :
sahilmgandhi 18:6a4db94011d3 839 will lead to call HAL_SMARTCARD_ErrorCallback() at end of DMA abort procedure */
sahilmgandhi 18:6a4db94011d3 840 hsc->hdmarx->XferAbortCallback = SMARTCARD_DMAAbortOnError;
sahilmgandhi 18:6a4db94011d3 841
sahilmgandhi 18:6a4db94011d3 842 if(HAL_DMA_Abort_IT(hsc->hdmarx) != HAL_OK)
sahilmgandhi 18:6a4db94011d3 843 {
sahilmgandhi 18:6a4db94011d3 844 /* Call Directly XferAbortCallback function in case of error */
sahilmgandhi 18:6a4db94011d3 845 hsc->hdmarx->XferAbortCallback(hsc->hdmarx);
sahilmgandhi 18:6a4db94011d3 846 }
sahilmgandhi 18:6a4db94011d3 847 }
sahilmgandhi 18:6a4db94011d3 848 else
sahilmgandhi 18:6a4db94011d3 849 {
sahilmgandhi 18:6a4db94011d3 850 /* Call user error callback */
sahilmgandhi 18:6a4db94011d3 851 HAL_SMARTCARD_ErrorCallback(hsc);
sahilmgandhi 18:6a4db94011d3 852 }
sahilmgandhi 18:6a4db94011d3 853 }
sahilmgandhi 18:6a4db94011d3 854 else
sahilmgandhi 18:6a4db94011d3 855 {
sahilmgandhi 18:6a4db94011d3 856 /* Call user error callback */
sahilmgandhi 18:6a4db94011d3 857 HAL_SMARTCARD_ErrorCallback(hsc);
sahilmgandhi 18:6a4db94011d3 858 }
sahilmgandhi 18:6a4db94011d3 859 }
sahilmgandhi 18:6a4db94011d3 860 else
sahilmgandhi 18:6a4db94011d3 861 {
sahilmgandhi 18:6a4db94011d3 862 /* Call user error callback */
sahilmgandhi 18:6a4db94011d3 863 HAL_SMARTCARD_ErrorCallback(hsc);
sahilmgandhi 18:6a4db94011d3 864 hsc->ErrorCode = HAL_SMARTCARD_ERROR_NONE;
sahilmgandhi 18:6a4db94011d3 865 }
sahilmgandhi 18:6a4db94011d3 866 }
sahilmgandhi 18:6a4db94011d3 867 return;
sahilmgandhi 18:6a4db94011d3 868 } /* End if some error occurs */
sahilmgandhi 18:6a4db94011d3 869
sahilmgandhi 18:6a4db94011d3 870 /* SMARTCARD in mode Transmitter -------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 871 if(((isrflags & SMARTCARD_FLAG_TXE) != RESET) && ((cr1its & USART_CR1_TXEIE) != RESET))
sahilmgandhi 18:6a4db94011d3 872 {
sahilmgandhi 18:6a4db94011d3 873 SMARTCARD_Transmit_IT(hsc);
sahilmgandhi 18:6a4db94011d3 874 return;
sahilmgandhi 18:6a4db94011d3 875 }
sahilmgandhi 18:6a4db94011d3 876
sahilmgandhi 18:6a4db94011d3 877 /* SMARTCARD in mode Transmitter (transmission end) ------------------------*/
sahilmgandhi 18:6a4db94011d3 878 if(((isrflags & SMARTCARD_FLAG_TC) != RESET) && ((cr1its & USART_CR1_TCIE) != RESET))
sahilmgandhi 18:6a4db94011d3 879 {
sahilmgandhi 18:6a4db94011d3 880 SMARTCARD_EndTransmit_IT(hsc);
sahilmgandhi 18:6a4db94011d3 881 return;
sahilmgandhi 18:6a4db94011d3 882 }
sahilmgandhi 18:6a4db94011d3 883 }
sahilmgandhi 18:6a4db94011d3 884
sahilmgandhi 18:6a4db94011d3 885 /**
sahilmgandhi 18:6a4db94011d3 886 * @brief Tx Transfer completed callbacks
sahilmgandhi 18:6a4db94011d3 887 * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 888 * the configuration information for SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 889 * @retval None
sahilmgandhi 18:6a4db94011d3 890 */
sahilmgandhi 18:6a4db94011d3 891 __weak void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsc)
sahilmgandhi 18:6a4db94011d3 892 {
sahilmgandhi 18:6a4db94011d3 893 /* Prevent unused argument(s) compilation warning */
sahilmgandhi 18:6a4db94011d3 894 UNUSED(hsc);
sahilmgandhi 18:6a4db94011d3 895 /* NOTE : This function Should not be modified, when the callback is needed,
sahilmgandhi 18:6a4db94011d3 896 the HAL_SMARTCARD_TxCpltCallback could be implemented in the user file
sahilmgandhi 18:6a4db94011d3 897 */
sahilmgandhi 18:6a4db94011d3 898 }
sahilmgandhi 18:6a4db94011d3 899
sahilmgandhi 18:6a4db94011d3 900 /**
sahilmgandhi 18:6a4db94011d3 901 * @brief Rx Transfer completed callbacks
sahilmgandhi 18:6a4db94011d3 902 * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 903 * the configuration information for SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 904 * @retval None
sahilmgandhi 18:6a4db94011d3 905 */
sahilmgandhi 18:6a4db94011d3 906 __weak void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsc)
sahilmgandhi 18:6a4db94011d3 907 {
sahilmgandhi 18:6a4db94011d3 908 /* Prevent unused argument(s) compilation warning */
sahilmgandhi 18:6a4db94011d3 909 UNUSED(hsc);
sahilmgandhi 18:6a4db94011d3 910 /* NOTE : This function Should not be modified, when the callback is needed,
sahilmgandhi 18:6a4db94011d3 911 the HAL_SMARTCARD_TxCpltCallback could be implemented in the user file
sahilmgandhi 18:6a4db94011d3 912 */
sahilmgandhi 18:6a4db94011d3 913 }
sahilmgandhi 18:6a4db94011d3 914
sahilmgandhi 18:6a4db94011d3 915 /**
sahilmgandhi 18:6a4db94011d3 916 * @brief SMARTCARD error callbacks
sahilmgandhi 18:6a4db94011d3 917 * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 918 * the configuration information for SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 919 * @retval None
sahilmgandhi 18:6a4db94011d3 920 */
sahilmgandhi 18:6a4db94011d3 921 __weak void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsc)
sahilmgandhi 18:6a4db94011d3 922 {
sahilmgandhi 18:6a4db94011d3 923 /* Prevent unused argument(s) compilation warning */
sahilmgandhi 18:6a4db94011d3 924 UNUSED(hsc);
sahilmgandhi 18:6a4db94011d3 925 /* NOTE : This function Should not be modified, when the callback is needed,
sahilmgandhi 18:6a4db94011d3 926 the HAL_SMARTCARD_ErrorCallback could be implemented in the user file
sahilmgandhi 18:6a4db94011d3 927 */
sahilmgandhi 18:6a4db94011d3 928 }
sahilmgandhi 18:6a4db94011d3 929
sahilmgandhi 18:6a4db94011d3 930 /**
sahilmgandhi 18:6a4db94011d3 931 * @}
sahilmgandhi 18:6a4db94011d3 932 */
sahilmgandhi 18:6a4db94011d3 933
sahilmgandhi 18:6a4db94011d3 934 /** @defgroup SMARTCARD_Exported_Functions_Group3 Peripheral State and Errors functions
sahilmgandhi 18:6a4db94011d3 935 * @brief SMARTCARD State and Errors functions
sahilmgandhi 18:6a4db94011d3 936 *
sahilmgandhi 18:6a4db94011d3 937 @verbatim
sahilmgandhi 18:6a4db94011d3 938 ===============================================================================
sahilmgandhi 18:6a4db94011d3 939 ##### Peripheral State and Errors functions #####
sahilmgandhi 18:6a4db94011d3 940 ===============================================================================
sahilmgandhi 18:6a4db94011d3 941 [..]
sahilmgandhi 18:6a4db94011d3 942 This subsection provides a set of functions allowing to control the SmartCard.
sahilmgandhi 18:6a4db94011d3 943 (+) HAL_SMARTCARD_GetState() API can be helpful to check in run-time the state of the SmartCard peripheral.
sahilmgandhi 18:6a4db94011d3 944 (+) HAL_SMARTCARD_GetError() check in run-time errors that could be occurred during communication.
sahilmgandhi 18:6a4db94011d3 945 @endverbatim
sahilmgandhi 18:6a4db94011d3 946 * @{
sahilmgandhi 18:6a4db94011d3 947 */
sahilmgandhi 18:6a4db94011d3 948
sahilmgandhi 18:6a4db94011d3 949 /**
sahilmgandhi 18:6a4db94011d3 950 * @brief return the SMARTCARD state
sahilmgandhi 18:6a4db94011d3 951 * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 952 * the configuration information for SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 953 * @retval HAL state
sahilmgandhi 18:6a4db94011d3 954 */
sahilmgandhi 18:6a4db94011d3 955 HAL_SMARTCARD_StateTypeDef HAL_SMARTCARD_GetState(SMARTCARD_HandleTypeDef *hsc)
sahilmgandhi 18:6a4db94011d3 956 {
sahilmgandhi 18:6a4db94011d3 957 uint32_t temp1= 0x00U, temp2 = 0x00U;
sahilmgandhi 18:6a4db94011d3 958 temp1 = hsc->gState;
sahilmgandhi 18:6a4db94011d3 959 temp2 = hsc->RxState;
sahilmgandhi 18:6a4db94011d3 960
sahilmgandhi 18:6a4db94011d3 961 return (HAL_SMARTCARD_StateTypeDef)(temp1 | temp2);
sahilmgandhi 18:6a4db94011d3 962 }
sahilmgandhi 18:6a4db94011d3 963
sahilmgandhi 18:6a4db94011d3 964 /**
sahilmgandhi 18:6a4db94011d3 965 * @brief Return the SMARTCARD error code
sahilmgandhi 18:6a4db94011d3 966 * @param hsc : pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 967 * the configuration information for the specified SMARTCARD.
sahilmgandhi 18:6a4db94011d3 968 * @retval SMARTCARD Error Code
sahilmgandhi 18:6a4db94011d3 969 */
sahilmgandhi 18:6a4db94011d3 970 uint32_t HAL_SMARTCARD_GetError(SMARTCARD_HandleTypeDef *hsc)
sahilmgandhi 18:6a4db94011d3 971 {
sahilmgandhi 18:6a4db94011d3 972 return hsc->ErrorCode;
sahilmgandhi 18:6a4db94011d3 973 }
sahilmgandhi 18:6a4db94011d3 974
sahilmgandhi 18:6a4db94011d3 975 /**
sahilmgandhi 18:6a4db94011d3 976 * @}
sahilmgandhi 18:6a4db94011d3 977 */
sahilmgandhi 18:6a4db94011d3 978
sahilmgandhi 18:6a4db94011d3 979 /**
sahilmgandhi 18:6a4db94011d3 980 * @brief DMA SMARTCARD transmit process complete callback
sahilmgandhi 18:6a4db94011d3 981 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 982 * the configuration information for the specified DMA module.
sahilmgandhi 18:6a4db94011d3 983 * @retval None
sahilmgandhi 18:6a4db94011d3 984 */
sahilmgandhi 18:6a4db94011d3 985 static void SMARTCARD_DMATransmitCplt(DMA_HandleTypeDef *hdma)
sahilmgandhi 18:6a4db94011d3 986 {
sahilmgandhi 18:6a4db94011d3 987 SMARTCARD_HandleTypeDef* hsc = ( SMARTCARD_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
sahilmgandhi 18:6a4db94011d3 988
sahilmgandhi 18:6a4db94011d3 989 hsc->TxXferCount = 0U;
sahilmgandhi 18:6a4db94011d3 990
sahilmgandhi 18:6a4db94011d3 991 /* Disable the DMA transfer for transmit request by setting the DMAT bit
sahilmgandhi 18:6a4db94011d3 992 in the USART CR3 register */
sahilmgandhi 18:6a4db94011d3 993 CLEAR_BIT(hsc->Instance->CR3, USART_CR3_DMAT);
sahilmgandhi 18:6a4db94011d3 994
sahilmgandhi 18:6a4db94011d3 995 /* Enable the SMARTCARD Transmit Complete Interrupt */
sahilmgandhi 18:6a4db94011d3 996 SET_BIT(hsc->Instance->CR1, USART_CR1_TCIE);
sahilmgandhi 18:6a4db94011d3 997 }
sahilmgandhi 18:6a4db94011d3 998
sahilmgandhi 18:6a4db94011d3 999 /**
sahilmgandhi 18:6a4db94011d3 1000 * @brief DMA SMARTCARD receive process complete callback
sahilmgandhi 18:6a4db94011d3 1001 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 1002 * the configuration information for the specified DMA module.
sahilmgandhi 18:6a4db94011d3 1003 * @retval None
sahilmgandhi 18:6a4db94011d3 1004 */
sahilmgandhi 18:6a4db94011d3 1005 static void SMARTCARD_DMAReceiveCplt(DMA_HandleTypeDef *hdma)
sahilmgandhi 18:6a4db94011d3 1006 {
sahilmgandhi 18:6a4db94011d3 1007 SMARTCARD_HandleTypeDef* hsc = ( SMARTCARD_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
sahilmgandhi 18:6a4db94011d3 1008
sahilmgandhi 18:6a4db94011d3 1009 hsc->RxXferCount = 0U;
sahilmgandhi 18:6a4db94011d3 1010
sahilmgandhi 18:6a4db94011d3 1011 /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
sahilmgandhi 18:6a4db94011d3 1012 CLEAR_BIT(hsc->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
sahilmgandhi 18:6a4db94011d3 1013 CLEAR_BIT(hsc->Instance->CR3, USART_CR3_EIE);
sahilmgandhi 18:6a4db94011d3 1014
sahilmgandhi 18:6a4db94011d3 1015 /* Disable the DMA transfer for the receiver request by setting the DMAR bit
sahilmgandhi 18:6a4db94011d3 1016 in the USART CR3 register */
sahilmgandhi 18:6a4db94011d3 1017 CLEAR_BIT(hsc->Instance->CR3, USART_CR3_DMAR);
sahilmgandhi 18:6a4db94011d3 1018
sahilmgandhi 18:6a4db94011d3 1019 /* At end of Rx process, restore hsc->RxState to Ready */
sahilmgandhi 18:6a4db94011d3 1020 hsc->RxState = HAL_SMARTCARD_STATE_READY;
sahilmgandhi 18:6a4db94011d3 1021
sahilmgandhi 18:6a4db94011d3 1022 HAL_SMARTCARD_RxCpltCallback(hsc);
sahilmgandhi 18:6a4db94011d3 1023 }
sahilmgandhi 18:6a4db94011d3 1024
sahilmgandhi 18:6a4db94011d3 1025 /**
sahilmgandhi 18:6a4db94011d3 1026 * @brief DMA SMARTCARD communication error callback
sahilmgandhi 18:6a4db94011d3 1027 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 1028 * the configuration information for the specified DMA module.
sahilmgandhi 18:6a4db94011d3 1029 * @retval None
sahilmgandhi 18:6a4db94011d3 1030 */
sahilmgandhi 18:6a4db94011d3 1031 static void SMARTCARD_DMAError(DMA_HandleTypeDef *hdma)
sahilmgandhi 18:6a4db94011d3 1032 {
sahilmgandhi 18:6a4db94011d3 1033 uint32_t dmarequest = 0x00U;
sahilmgandhi 18:6a4db94011d3 1034 SMARTCARD_HandleTypeDef* hsc = ( SMARTCARD_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
sahilmgandhi 18:6a4db94011d3 1035 hsc->RxXferCount = 0U;
sahilmgandhi 18:6a4db94011d3 1036 hsc->TxXferCount = 0U;
sahilmgandhi 18:6a4db94011d3 1037 hsc->ErrorCode = HAL_SMARTCARD_ERROR_DMA;
sahilmgandhi 18:6a4db94011d3 1038
sahilmgandhi 18:6a4db94011d3 1039 /* Stop SMARTCARD DMA Tx request if ongoing */
sahilmgandhi 18:6a4db94011d3 1040 dmarequest = HAL_IS_BIT_SET(hsc->Instance->CR3, USART_CR3_DMAT);
sahilmgandhi 18:6a4db94011d3 1041 if((hsc->gState == HAL_SMARTCARD_STATE_BUSY_TX) && dmarequest)
sahilmgandhi 18:6a4db94011d3 1042 {
sahilmgandhi 18:6a4db94011d3 1043 SMARTCARD_EndTxTransfer(hsc);
sahilmgandhi 18:6a4db94011d3 1044 }
sahilmgandhi 18:6a4db94011d3 1045
sahilmgandhi 18:6a4db94011d3 1046 /* Stop SMARTCARD DMA Rx request if ongoing */
sahilmgandhi 18:6a4db94011d3 1047 dmarequest = HAL_IS_BIT_SET(hsc->Instance->CR3, USART_CR3_DMAR);
sahilmgandhi 18:6a4db94011d3 1048 if((hsc->RxState == HAL_SMARTCARD_STATE_BUSY_RX) && dmarequest)
sahilmgandhi 18:6a4db94011d3 1049 {
sahilmgandhi 18:6a4db94011d3 1050 SMARTCARD_EndRxTransfer(hsc);
sahilmgandhi 18:6a4db94011d3 1051 }
sahilmgandhi 18:6a4db94011d3 1052
sahilmgandhi 18:6a4db94011d3 1053 HAL_SMARTCARD_ErrorCallback(hsc);
sahilmgandhi 18:6a4db94011d3 1054 }
sahilmgandhi 18:6a4db94011d3 1055
sahilmgandhi 18:6a4db94011d3 1056 /**
sahilmgandhi 18:6a4db94011d3 1057 * @brief This function handles SMARTCARD Communication Timeout.
sahilmgandhi 18:6a4db94011d3 1058 * @param hsc: SMARTCARD handle
sahilmgandhi 18:6a4db94011d3 1059 * @param Flag: specifies the SMARTCARD flag to check.
sahilmgandhi 18:6a4db94011d3 1060 * @param Status: The new Flag status (SET or RESET).
sahilmgandhi 18:6a4db94011d3 1061 * @param Timeout: Timeout duration
sahilmgandhi 18:6a4db94011d3 1062 * @param Tickstart: tick start value
sahilmgandhi 18:6a4db94011d3 1063 * @retval HAL status
sahilmgandhi 18:6a4db94011d3 1064 */
sahilmgandhi 18:6a4db94011d3 1065 static HAL_StatusTypeDef SMARTCARD_WaitOnFlagUntilTimeout(SMARTCARD_HandleTypeDef *hsc, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout)
sahilmgandhi 18:6a4db94011d3 1066 {
sahilmgandhi 18:6a4db94011d3 1067 /* Wait until flag is set */
sahilmgandhi 18:6a4db94011d3 1068 while((__HAL_SMARTCARD_GET_FLAG(hsc, Flag) ? SET : RESET) == Status)
sahilmgandhi 18:6a4db94011d3 1069 {
sahilmgandhi 18:6a4db94011d3 1070 /* Check for the Timeout */
sahilmgandhi 18:6a4db94011d3 1071 if(Timeout != HAL_MAX_DELAY)
sahilmgandhi 18:6a4db94011d3 1072 {
sahilmgandhi 18:6a4db94011d3 1073 if((Timeout == 0U)||((HAL_GetTick() - Tickstart ) > Timeout))
sahilmgandhi 18:6a4db94011d3 1074 {
sahilmgandhi 18:6a4db94011d3 1075 /* Disable TXE and RXNE interrupts for the interrupt process */
sahilmgandhi 18:6a4db94011d3 1076 CLEAR_BIT(hsc->Instance->CR1, USART_CR1_TXEIE);
sahilmgandhi 18:6a4db94011d3 1077 CLEAR_BIT(hsc->Instance->CR1, USART_CR1_RXNEIE);
sahilmgandhi 18:6a4db94011d3 1078
sahilmgandhi 18:6a4db94011d3 1079 hsc->gState= HAL_SMARTCARD_STATE_READY;
sahilmgandhi 18:6a4db94011d3 1080 hsc->RxState= HAL_SMARTCARD_STATE_READY;
sahilmgandhi 18:6a4db94011d3 1081
sahilmgandhi 18:6a4db94011d3 1082 /* Process Unlocked */
sahilmgandhi 18:6a4db94011d3 1083 __HAL_UNLOCK(hsc);
sahilmgandhi 18:6a4db94011d3 1084
sahilmgandhi 18:6a4db94011d3 1085 return HAL_TIMEOUT;
sahilmgandhi 18:6a4db94011d3 1086 }
sahilmgandhi 18:6a4db94011d3 1087 }
sahilmgandhi 18:6a4db94011d3 1088 }
sahilmgandhi 18:6a4db94011d3 1089 return HAL_OK;
sahilmgandhi 18:6a4db94011d3 1090 }
sahilmgandhi 18:6a4db94011d3 1091
sahilmgandhi 18:6a4db94011d3 1092 /**
sahilmgandhi 18:6a4db94011d3 1093 * @brief End ongoing Tx transfer on SMARTCARD peripheral (following error detection or Transmit completion).
sahilmgandhi 18:6a4db94011d3 1094 * @param hsc: SMARTCARD handle.
sahilmgandhi 18:6a4db94011d3 1095 * @retval None
sahilmgandhi 18:6a4db94011d3 1096 */
sahilmgandhi 18:6a4db94011d3 1097 static void SMARTCARD_EndTxTransfer(SMARTCARD_HandleTypeDef *hsc)
sahilmgandhi 18:6a4db94011d3 1098 {
sahilmgandhi 18:6a4db94011d3 1099 /* At end of Tx process, restore hsc->gState to Ready */
sahilmgandhi 18:6a4db94011d3 1100 hsc->gState = HAL_SMARTCARD_STATE_READY;
sahilmgandhi 18:6a4db94011d3 1101
sahilmgandhi 18:6a4db94011d3 1102 /* Disable TXEIE and TCIE interrupts */
sahilmgandhi 18:6a4db94011d3 1103 CLEAR_BIT(hsc->Instance->CR1, (USART_CR1_TXEIE | USART_CR1_TCIE));
sahilmgandhi 18:6a4db94011d3 1104 }
sahilmgandhi 18:6a4db94011d3 1105
sahilmgandhi 18:6a4db94011d3 1106
sahilmgandhi 18:6a4db94011d3 1107 /**
sahilmgandhi 18:6a4db94011d3 1108 * @brief End ongoing Rx transfer on SMARTCARD peripheral (following error detection or Reception completion).
sahilmgandhi 18:6a4db94011d3 1109 * @param hsc: SMARTCARD handle.
sahilmgandhi 18:6a4db94011d3 1110 * @retval None
sahilmgandhi 18:6a4db94011d3 1111 */
sahilmgandhi 18:6a4db94011d3 1112 static void SMARTCARD_EndRxTransfer(SMARTCARD_HandleTypeDef *hsc)
sahilmgandhi 18:6a4db94011d3 1113 {
sahilmgandhi 18:6a4db94011d3 1114 /* At end of Rx process, restore hsc->RxState to Ready */
sahilmgandhi 18:6a4db94011d3 1115 hsc->RxState = HAL_SMARTCARD_STATE_READY;
sahilmgandhi 18:6a4db94011d3 1116
sahilmgandhi 18:6a4db94011d3 1117 /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
sahilmgandhi 18:6a4db94011d3 1118 CLEAR_BIT(hsc->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
sahilmgandhi 18:6a4db94011d3 1119 CLEAR_BIT(hsc->Instance->CR3, USART_CR3_EIE);
sahilmgandhi 18:6a4db94011d3 1120 }
sahilmgandhi 18:6a4db94011d3 1121
sahilmgandhi 18:6a4db94011d3 1122 /**
sahilmgandhi 18:6a4db94011d3 1123 * @brief Send an amount of data in non blocking mode
sahilmgandhi 18:6a4db94011d3 1124 * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 1125 * the configuration information for SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 1126 * @retval HAL status
sahilmgandhi 18:6a4db94011d3 1127 */
sahilmgandhi 18:6a4db94011d3 1128 static HAL_StatusTypeDef SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsc)
sahilmgandhi 18:6a4db94011d3 1129 {
sahilmgandhi 18:6a4db94011d3 1130 uint16_t* tmp;
sahilmgandhi 18:6a4db94011d3 1131
sahilmgandhi 18:6a4db94011d3 1132 /* Check that a Tx process is ongoing */
sahilmgandhi 18:6a4db94011d3 1133 if(hsc->gState == HAL_SMARTCARD_STATE_BUSY_TX)
sahilmgandhi 18:6a4db94011d3 1134 {
sahilmgandhi 18:6a4db94011d3 1135 tmp = (uint16_t*) hsc->pTxBuffPtr;
sahilmgandhi 18:6a4db94011d3 1136 hsc->Instance->DR = (uint16_t)(*tmp & (uint16_t)0x01FFU);
sahilmgandhi 18:6a4db94011d3 1137 hsc->pTxBuffPtr += 1U;
sahilmgandhi 18:6a4db94011d3 1138
sahilmgandhi 18:6a4db94011d3 1139 if(--hsc->TxXferCount == 0U)
sahilmgandhi 18:6a4db94011d3 1140 {
sahilmgandhi 18:6a4db94011d3 1141 /* Disable the SMARTCARD Transmit data register empty Interrupt */
sahilmgandhi 18:6a4db94011d3 1142 CLEAR_BIT(hsc->Instance->CR1, USART_CR1_TXEIE);
sahilmgandhi 18:6a4db94011d3 1143
sahilmgandhi 18:6a4db94011d3 1144 /* Enable the SMARTCARD Transmit Complete Interrupt */
sahilmgandhi 18:6a4db94011d3 1145 SET_BIT(hsc->Instance->CR1, USART_CR1_TCIE);
sahilmgandhi 18:6a4db94011d3 1146 }
sahilmgandhi 18:6a4db94011d3 1147
sahilmgandhi 18:6a4db94011d3 1148 return HAL_OK;
sahilmgandhi 18:6a4db94011d3 1149 }
sahilmgandhi 18:6a4db94011d3 1150 else
sahilmgandhi 18:6a4db94011d3 1151 {
sahilmgandhi 18:6a4db94011d3 1152 return HAL_BUSY;
sahilmgandhi 18:6a4db94011d3 1153 }
sahilmgandhi 18:6a4db94011d3 1154 }
sahilmgandhi 18:6a4db94011d3 1155
sahilmgandhi 18:6a4db94011d3 1156 /**
sahilmgandhi 18:6a4db94011d3 1157 * @brief Wraps up transmission in non blocking mode.
sahilmgandhi 18:6a4db94011d3 1158 * @param hsmartcard: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 1159 * the configuration information for the specified SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 1160 * @retval HAL status
sahilmgandhi 18:6a4db94011d3 1161 */
sahilmgandhi 18:6a4db94011d3 1162 static HAL_StatusTypeDef SMARTCARD_EndTransmit_IT(SMARTCARD_HandleTypeDef *hsmartcard)
sahilmgandhi 18:6a4db94011d3 1163 {
sahilmgandhi 18:6a4db94011d3 1164 /* Disable the SMARTCARD Transmit Complete Interrupt */
sahilmgandhi 18:6a4db94011d3 1165 CLEAR_BIT(hsmartcard->Instance->CR1, USART_CR1_TCIE);
sahilmgandhi 18:6a4db94011d3 1166
sahilmgandhi 18:6a4db94011d3 1167 /* Disable the SMARTCARD Error Interrupt: (Frame error, noise error, overrun error) */
sahilmgandhi 18:6a4db94011d3 1168 CLEAR_BIT(hsmartcard->Instance->CR3, USART_CR3_EIE);
sahilmgandhi 18:6a4db94011d3 1169
sahilmgandhi 18:6a4db94011d3 1170 /* Tx process is ended, restore hsmartcard->gState to Ready */
sahilmgandhi 18:6a4db94011d3 1171 hsmartcard->gState = HAL_SMARTCARD_STATE_READY;
sahilmgandhi 18:6a4db94011d3 1172
sahilmgandhi 18:6a4db94011d3 1173 HAL_SMARTCARD_TxCpltCallback(hsmartcard);
sahilmgandhi 18:6a4db94011d3 1174
sahilmgandhi 18:6a4db94011d3 1175 return HAL_OK;
sahilmgandhi 18:6a4db94011d3 1176 }
sahilmgandhi 18:6a4db94011d3 1177
sahilmgandhi 18:6a4db94011d3 1178 /**
sahilmgandhi 18:6a4db94011d3 1179 * @brief Receive an amount of data in non blocking mode
sahilmgandhi 18:6a4db94011d3 1180 * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 1181 * the configuration information for SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 1182 * @retval HAL status
sahilmgandhi 18:6a4db94011d3 1183 */
sahilmgandhi 18:6a4db94011d3 1184 static HAL_StatusTypeDef SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc)
sahilmgandhi 18:6a4db94011d3 1185 {
sahilmgandhi 18:6a4db94011d3 1186 uint16_t* tmp;
sahilmgandhi 18:6a4db94011d3 1187
sahilmgandhi 18:6a4db94011d3 1188 /* Check that a Rx process is ongoing */
sahilmgandhi 18:6a4db94011d3 1189 if(hsc->RxState == HAL_SMARTCARD_STATE_BUSY_RX)
sahilmgandhi 18:6a4db94011d3 1190 {
sahilmgandhi 18:6a4db94011d3 1191 tmp = (uint16_t*) hsc->pRxBuffPtr;
sahilmgandhi 18:6a4db94011d3 1192 *tmp = (uint8_t)(hsc->Instance->DR & (uint8_t)0x00FFU);
sahilmgandhi 18:6a4db94011d3 1193 hsc->pRxBuffPtr += 1U;
sahilmgandhi 18:6a4db94011d3 1194
sahilmgandhi 18:6a4db94011d3 1195 if(--hsc->RxXferCount == 0U)
sahilmgandhi 18:6a4db94011d3 1196 {
sahilmgandhi 18:6a4db94011d3 1197 CLEAR_BIT(hsc->Instance->CR1, USART_CR1_RXNEIE);
sahilmgandhi 18:6a4db94011d3 1198
sahilmgandhi 18:6a4db94011d3 1199 /* Disable the SMARTCARD Parity Error Interrupt */
sahilmgandhi 18:6a4db94011d3 1200 CLEAR_BIT(hsc->Instance->CR1, USART_CR1_PEIE);
sahilmgandhi 18:6a4db94011d3 1201
sahilmgandhi 18:6a4db94011d3 1202 /* Disable the SMARTCARD Error Interrupt: (Frame error, noise error, overrun error) */
sahilmgandhi 18:6a4db94011d3 1203 CLEAR_BIT(hsc->Instance->CR3, USART_CR3_EIE);
sahilmgandhi 18:6a4db94011d3 1204
sahilmgandhi 18:6a4db94011d3 1205 /* Rx process is completed, restore hsc->RxState to Ready */
sahilmgandhi 18:6a4db94011d3 1206 hsc->RxState = HAL_SMARTCARD_STATE_READY;
sahilmgandhi 18:6a4db94011d3 1207
sahilmgandhi 18:6a4db94011d3 1208 HAL_SMARTCARD_RxCpltCallback(hsc);
sahilmgandhi 18:6a4db94011d3 1209
sahilmgandhi 18:6a4db94011d3 1210 return HAL_OK;
sahilmgandhi 18:6a4db94011d3 1211 }
sahilmgandhi 18:6a4db94011d3 1212 return HAL_OK;
sahilmgandhi 18:6a4db94011d3 1213 }
sahilmgandhi 18:6a4db94011d3 1214 else
sahilmgandhi 18:6a4db94011d3 1215 {
sahilmgandhi 18:6a4db94011d3 1216 return HAL_BUSY;
sahilmgandhi 18:6a4db94011d3 1217 }
sahilmgandhi 18:6a4db94011d3 1218 }
sahilmgandhi 18:6a4db94011d3 1219
sahilmgandhi 18:6a4db94011d3 1220 /**
sahilmgandhi 18:6a4db94011d3 1221 * @brief DMA SMARTCARD communication abort callback, when initiated by HAL services on Error
sahilmgandhi 18:6a4db94011d3 1222 * (To be called at end of DMA Abort procedure following error occurrence).
sahilmgandhi 18:6a4db94011d3 1223 * @param hdma DMA handle.
sahilmgandhi 18:6a4db94011d3 1224 * @retval None
sahilmgandhi 18:6a4db94011d3 1225 */
sahilmgandhi 18:6a4db94011d3 1226 static void SMARTCARD_DMAAbortOnError(DMA_HandleTypeDef *hdma)
sahilmgandhi 18:6a4db94011d3 1227 {
sahilmgandhi 18:6a4db94011d3 1228 SMARTCARD_HandleTypeDef* hsc = (SMARTCARD_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
sahilmgandhi 18:6a4db94011d3 1229 hsc->RxXferCount = 0x00U;
sahilmgandhi 18:6a4db94011d3 1230 hsc->TxXferCount = 0x00U;
sahilmgandhi 18:6a4db94011d3 1231
sahilmgandhi 18:6a4db94011d3 1232 HAL_SMARTCARD_ErrorCallback(hsc);
sahilmgandhi 18:6a4db94011d3 1233 }
sahilmgandhi 18:6a4db94011d3 1234
sahilmgandhi 18:6a4db94011d3 1235 /**
sahilmgandhi 18:6a4db94011d3 1236 * @brief Configure the SMARTCARD peripheral
sahilmgandhi 18:6a4db94011d3 1237 * @param hsc: pointer to a SMARTCARD_HandleTypeDef structure that contains
sahilmgandhi 18:6a4db94011d3 1238 * the configuration information for SMARTCARD module.
sahilmgandhi 18:6a4db94011d3 1239 * @retval None
sahilmgandhi 18:6a4db94011d3 1240 */
sahilmgandhi 18:6a4db94011d3 1241 static void SMARTCARD_SetConfig(SMARTCARD_HandleTypeDef *hsc)
sahilmgandhi 18:6a4db94011d3 1242 {
sahilmgandhi 18:6a4db94011d3 1243 uint32_t tmpreg = 0x00U;
sahilmgandhi 18:6a4db94011d3 1244
sahilmgandhi 18:6a4db94011d3 1245 /* Check the parameters */
sahilmgandhi 18:6a4db94011d3 1246 assert_param(IS_SMARTCARD_INSTANCE(hsc->Instance));
sahilmgandhi 18:6a4db94011d3 1247 assert_param(IS_SMARTCARD_POLARITY(hsc->Init.CLKPolarity));
sahilmgandhi 18:6a4db94011d3 1248 assert_param(IS_SMARTCARD_PHASE(hsc->Init.CLKPhase));
sahilmgandhi 18:6a4db94011d3 1249 assert_param(IS_SMARTCARD_LASTBIT(hsc->Init.CLKLastBit));
sahilmgandhi 18:6a4db94011d3 1250 assert_param(IS_SMARTCARD_BAUDRATE(hsc->Init.BaudRate));
sahilmgandhi 18:6a4db94011d3 1251 assert_param(IS_SMARTCARD_WORD_LENGTH(hsc->Init.WordLength));
sahilmgandhi 18:6a4db94011d3 1252 assert_param(IS_SMARTCARD_STOPBITS(hsc->Init.StopBits));
sahilmgandhi 18:6a4db94011d3 1253 assert_param(IS_SMARTCARD_PARITY(hsc->Init.Parity));
sahilmgandhi 18:6a4db94011d3 1254 assert_param(IS_SMARTCARD_MODE(hsc->Init.Mode));
sahilmgandhi 18:6a4db94011d3 1255 assert_param(IS_SMARTCARD_NACK_STATE(hsc->Init.NACKState));
sahilmgandhi 18:6a4db94011d3 1256
sahilmgandhi 18:6a4db94011d3 1257 /* The LBCL, CPOL and CPHA bits have to be selected when both the transmitter and the
sahilmgandhi 18:6a4db94011d3 1258 receiver are disabled (TE=RE=0) to ensure that the clock pulses function correctly. */
sahilmgandhi 18:6a4db94011d3 1259 CLEAR_BIT(hsc->Instance->CR1, (USART_CR1_TE | USART_CR1_RE));
sahilmgandhi 18:6a4db94011d3 1260
sahilmgandhi 18:6a4db94011d3 1261 /*---------------------------- USART CR2 Configuration ---------------------*/
sahilmgandhi 18:6a4db94011d3 1262 tmpreg = hsc->Instance->CR2;
sahilmgandhi 18:6a4db94011d3 1263 /* Clear CLKEN, CPOL, CPHA and LBCL bits */
sahilmgandhi 18:6a4db94011d3 1264 tmpreg &= (uint32_t)~((uint32_t)(USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_CLKEN | USART_CR2_LBCL));
sahilmgandhi 18:6a4db94011d3 1265 /* Configure the SMARTCARD Clock, CPOL, CPHA and LastBit -----------------------*/
sahilmgandhi 18:6a4db94011d3 1266 /* Set CPOL bit according to hsc->Init.CLKPolarity value */
sahilmgandhi 18:6a4db94011d3 1267 /* Set CPHA bit according to hsc->Init.CLKPhase value */
sahilmgandhi 18:6a4db94011d3 1268 /* Set LBCL bit according to hsc->Init.CLKLastBit value */
sahilmgandhi 18:6a4db94011d3 1269 /* Set Stop Bits: Set STOP[13:12] bits according to hsc->Init.StopBits value */
sahilmgandhi 18:6a4db94011d3 1270 tmpreg |= (uint32_t)(USART_CR2_CLKEN | hsc->Init.CLKPolarity |
sahilmgandhi 18:6a4db94011d3 1271 hsc->Init.CLKPhase| hsc->Init.CLKLastBit | hsc->Init.StopBits);
sahilmgandhi 18:6a4db94011d3 1272 /* Write to USART CR2 */
sahilmgandhi 18:6a4db94011d3 1273 WRITE_REG(hsc->Instance->CR2, (uint32_t)tmpreg);
sahilmgandhi 18:6a4db94011d3 1274
sahilmgandhi 18:6a4db94011d3 1275 tmpreg = hsc->Instance->CR2;
sahilmgandhi 18:6a4db94011d3 1276
sahilmgandhi 18:6a4db94011d3 1277 /* Clear STOP[13:12] bits */
sahilmgandhi 18:6a4db94011d3 1278 tmpreg &= (uint32_t)~((uint32_t)USART_CR2_STOP);
sahilmgandhi 18:6a4db94011d3 1279
sahilmgandhi 18:6a4db94011d3 1280 /* Set Stop Bits: Set STOP[13:12] bits according to hsc->Init.StopBits value */
sahilmgandhi 18:6a4db94011d3 1281 tmpreg |= (uint32_t)(hsc->Init.StopBits);
sahilmgandhi 18:6a4db94011d3 1282
sahilmgandhi 18:6a4db94011d3 1283 /* Write to USART CR2 */
sahilmgandhi 18:6a4db94011d3 1284 WRITE_REG(hsc->Instance->CR2, (uint32_t)tmpreg);
sahilmgandhi 18:6a4db94011d3 1285
sahilmgandhi 18:6a4db94011d3 1286 /*-------------------------- USART CR1 Configuration -----------------------*/
sahilmgandhi 18:6a4db94011d3 1287 tmpreg = hsc->Instance->CR1;
sahilmgandhi 18:6a4db94011d3 1288
sahilmgandhi 18:6a4db94011d3 1289 /* Clear M, PCE, PS, TE and RE bits */
sahilmgandhi 18:6a4db94011d3 1290 tmpreg &= (uint32_t)~((uint32_t)(USART_CR1_M | USART_CR1_PCE | USART_CR1_PS | USART_CR1_TE | \
sahilmgandhi 18:6a4db94011d3 1291 USART_CR1_RE));
sahilmgandhi 18:6a4db94011d3 1292
sahilmgandhi 18:6a4db94011d3 1293 /* Configure the SMARTCARD Word Length, Parity and mode:
sahilmgandhi 18:6a4db94011d3 1294 Set the M bits according to hsc->Init.WordLength value
sahilmgandhi 18:6a4db94011d3 1295 Set PCE and PS bits according to hsc->Init.Parity value
sahilmgandhi 18:6a4db94011d3 1296 Set TE and RE bits according to hsc->Init.Mode value */
sahilmgandhi 18:6a4db94011d3 1297 tmpreg |= (uint32_t)hsc->Init.WordLength | hsc->Init.Parity | hsc->Init.Mode;
sahilmgandhi 18:6a4db94011d3 1298
sahilmgandhi 18:6a4db94011d3 1299 /* Write to USART CR1 */
sahilmgandhi 18:6a4db94011d3 1300 WRITE_REG(hsc->Instance->CR1, (uint32_t)tmpreg);
sahilmgandhi 18:6a4db94011d3 1301
sahilmgandhi 18:6a4db94011d3 1302 /*-------------------------- USART CR3 Configuration -----------------------*/
sahilmgandhi 18:6a4db94011d3 1303 /* Clear CTSE and RTSE bits */
sahilmgandhi 18:6a4db94011d3 1304 CLEAR_BIT(hsc->Instance->CR3, (USART_CR3_RTSE | USART_CR3_CTSE));
sahilmgandhi 18:6a4db94011d3 1305
sahilmgandhi 18:6a4db94011d3 1306 /*-------------------------- USART BRR Configuration -----------------------*/
sahilmgandhi 18:6a4db94011d3 1307 if((hsc->Instance == USART1) || (hsc->Instance == USART6))
sahilmgandhi 18:6a4db94011d3 1308 {
sahilmgandhi 18:6a4db94011d3 1309 hsc->Instance->BRR = SMARTCARD_BRR(HAL_RCC_GetPCLK2Freq(), hsc->Init.BaudRate);
sahilmgandhi 18:6a4db94011d3 1310 }
sahilmgandhi 18:6a4db94011d3 1311 else
sahilmgandhi 18:6a4db94011d3 1312 {
sahilmgandhi 18:6a4db94011d3 1313 hsc->Instance->BRR = SMARTCARD_BRR(HAL_RCC_GetPCLK1Freq(), hsc->Init.BaudRate);
sahilmgandhi 18:6a4db94011d3 1314 }
sahilmgandhi 18:6a4db94011d3 1315 }
sahilmgandhi 18:6a4db94011d3 1316
sahilmgandhi 18:6a4db94011d3 1317 /**
sahilmgandhi 18:6a4db94011d3 1318 * @}
sahilmgandhi 18:6a4db94011d3 1319 */
sahilmgandhi 18:6a4db94011d3 1320
sahilmgandhi 18:6a4db94011d3 1321 #endif /* HAL_SMARTCARD_MODULE_ENABLED */
sahilmgandhi 18:6a4db94011d3 1322 /**
sahilmgandhi 18:6a4db94011d3 1323 * @}
sahilmgandhi 18:6a4db94011d3 1324 */
sahilmgandhi 18:6a4db94011d3 1325
sahilmgandhi 18:6a4db94011d3 1326 /**
sahilmgandhi 18:6a4db94011d3 1327 * @}
sahilmgandhi 18:6a4db94011d3 1328 */
sahilmgandhi 18:6a4db94011d3 1329
sahilmgandhi 18:6a4db94011d3 1330 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/