mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
Kojto
Date:
Thu Jul 07 14:34:11 2016 +0100
Revision:
122:f9eeca106725
Parent:
110:165afa46840b
Release 122 of the mbed library

Changes:
- new targets - Nucleo L432KC, Beetle, Nucleo F446ZE, Nucleo L011K4
- Thread safety addition - mbed API should contain a statement about thread safety
- critical section API addition
- CAS API (core_util_atomic_incr/decr)
- DEVICE_ are generated from targets.json file, device.h deprecated
- Callback replaces FunctionPointer to provide std like interface
- mbed HAL API docs improvements
- toolchain - prexif attributes with MBED_
- add new attributes - packed, weak, forcedinline, align
- target.json - contains targets definitions
- ST - L1XX - Cube update to 1.5
- SPI clock selection fix (clock from APB domain)
- F7 - Cube update v1.4.0
- L0 - baudrate init fix
- L1 - Cube update v1.5
- F3 - baudrate init fix, 3 targets CAN support
- F4 - Cube update v1.12.0, 3 targets CAN support
- L4XX - Cube update v1.5.1
- F0 - update Cube to v1.5.0
- L4 - 2 targets (L476RG/VG) CAN support
- NXP - pwm clock fix for KSDK2 MCU
- LPC2368 - remove ARM toolchain support - due to regression
- KSDK2 - fix SPI , I2C address and repeat start
- Silabs - some fixes backported from mbed 3
- Renesas - RZ_A1H - SystemCoreClockUpdate addition

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 89:552587b429a1 1 /**
bogdanm 89:552587b429a1 2 ******************************************************************************
bogdanm 89:552587b429a1 3 * @file stm32f4xx_hal_smartcard.h
bogdanm 89:552587b429a1 4 * @author MCD Application Team
Kojto 122:f9eeca106725 5 * @version V1.5.0
Kojto 122:f9eeca106725 6 * @date 06-May-2016
bogdanm 89:552587b429a1 7 * @brief Header file of SMARTCARD HAL module.
bogdanm 89:552587b429a1 8 ******************************************************************************
bogdanm 89:552587b429a1 9 * @attention
bogdanm 89:552587b429a1 10 *
Kojto 122:f9eeca106725 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
bogdanm 89:552587b429a1 12 *
bogdanm 89:552587b429a1 13 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 89:552587b429a1 14 * are permitted provided that the following conditions are met:
bogdanm 89:552587b429a1 15 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 89:552587b429a1 16 * this list of conditions and the following disclaimer.
bogdanm 89:552587b429a1 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 89:552587b429a1 18 * this list of conditions and the following disclaimer in the documentation
bogdanm 89:552587b429a1 19 * and/or other materials provided with the distribution.
bogdanm 89:552587b429a1 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 89:552587b429a1 21 * may be used to endorse or promote products derived from this software
bogdanm 89:552587b429a1 22 * without specific prior written permission.
bogdanm 89:552587b429a1 23 *
bogdanm 89:552587b429a1 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 89:552587b429a1 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 89:552587b429a1 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 89:552587b429a1 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 89:552587b429a1 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 89:552587b429a1 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 89:552587b429a1 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 89:552587b429a1 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 89:552587b429a1 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 89:552587b429a1 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 89:552587b429a1 34 *
bogdanm 89:552587b429a1 35 ******************************************************************************
bogdanm 89:552587b429a1 36 */
bogdanm 89:552587b429a1 37
bogdanm 89:552587b429a1 38 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 89:552587b429a1 39 #ifndef __STM32F4xx_HAL_SMARTCARD_H
bogdanm 89:552587b429a1 40 #define __STM32F4xx_HAL_SMARTCARD_H
bogdanm 89:552587b429a1 41
bogdanm 89:552587b429a1 42 #ifdef __cplusplus
bogdanm 89:552587b429a1 43 extern "C" {
bogdanm 89:552587b429a1 44 #endif
bogdanm 89:552587b429a1 45
bogdanm 89:552587b429a1 46 /* Includes ------------------------------------------------------------------*/
bogdanm 89:552587b429a1 47 #include "stm32f4xx_hal_def.h"
bogdanm 89:552587b429a1 48
bogdanm 89:552587b429a1 49 /** @addtogroup STM32F4xx_HAL_Driver
bogdanm 89:552587b429a1 50 * @{
bogdanm 89:552587b429a1 51 */
bogdanm 89:552587b429a1 52
bogdanm 89:552587b429a1 53 /** @addtogroup SMARTCARD
bogdanm 89:552587b429a1 54 * @{
bogdanm 89:552587b429a1 55 */
bogdanm 89:552587b429a1 56
Kojto 99:dbbf35b96557 57 /* Exported types ------------------------------------------------------------*/
Kojto 99:dbbf35b96557 58 /** @defgroup SMARTCARD_Exported_Types SMARTCARD Exported Types
Kojto 99:dbbf35b96557 59 * @{
Kojto 99:dbbf35b96557 60 */
Kojto 99:dbbf35b96557 61
bogdanm 89:552587b429a1 62 /**
bogdanm 89:552587b429a1 63 * @brief SMARTCARD Init Structure definition
bogdanm 89:552587b429a1 64 */
bogdanm 89:552587b429a1 65 typedef struct
bogdanm 89:552587b429a1 66 {
bogdanm 89:552587b429a1 67 uint32_t BaudRate; /*!< This member configures the SmartCard communication baud rate.
bogdanm 89:552587b429a1 68 The baud rate is computed using the following formula:
bogdanm 89:552587b429a1 69 - IntegerDivider = ((PCLKx) / (8 * (hirda->Init.BaudRate)))
bogdanm 89:552587b429a1 70 - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 8) + 0.5 */
bogdanm 89:552587b429a1 71
bogdanm 89:552587b429a1 72 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
bogdanm 89:552587b429a1 73 This parameter can be a value of @ref SMARTCARD_Word_Length */
bogdanm 89:552587b429a1 74
bogdanm 89:552587b429a1 75 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
bogdanm 89:552587b429a1 76 This parameter can be a value of @ref SMARTCARD_Stop_Bits */
bogdanm 89:552587b429a1 77
bogdanm 89:552587b429a1 78 uint32_t Parity; /*!< Specifies the parity mode.
bogdanm 89:552587b429a1 79 This parameter can be a value of @ref SMARTCARD_Parity
bogdanm 89:552587b429a1 80 @note When parity is enabled, the computed parity is inserted
bogdanm 89:552587b429a1 81 at the MSB position of the transmitted data (9th bit when
bogdanm 89:552587b429a1 82 the word length is set to 9 data bits; 8th bit when the
bogdanm 89:552587b429a1 83 word length is set to 8 data bits).*/
bogdanm 89:552587b429a1 84
Kojto 99:dbbf35b96557 85 uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
bogdanm 89:552587b429a1 86 This parameter can be a value of @ref SMARTCARD_Mode */
bogdanm 89:552587b429a1 87
bogdanm 89:552587b429a1 88 uint32_t CLKPolarity; /*!< Specifies the steady state of the serial clock.
bogdanm 89:552587b429a1 89 This parameter can be a value of @ref SMARTCARD_Clock_Polarity */
bogdanm 89:552587b429a1 90
bogdanm 89:552587b429a1 91 uint32_t CLKPhase; /*!< Specifies the clock transition on which the bit capture is made.
bogdanm 89:552587b429a1 92 This parameter can be a value of @ref SMARTCARD_Clock_Phase */
bogdanm 89:552587b429a1 93
bogdanm 89:552587b429a1 94 uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted
bogdanm 89:552587b429a1 95 data bit (MSB) has to be output on the SCLK pin in synchronous mode.
bogdanm 89:552587b429a1 96 This parameter can be a value of @ref SMARTCARD_Last_Bit */
bogdanm 89:552587b429a1 97
Kojto 99:dbbf35b96557 98 uint32_t Prescaler; /*!< Specifies the SmartCard Prescaler value used for dividing the system clock
Kojto 122:f9eeca106725 99 to provide the smartcard clock. The value given in the register (5 significant bits)
Kojto 122:f9eeca106725 100 is multiplied by 2 to give the division factor of the source clock frequency.
Kojto 99:dbbf35b96557 101 This parameter can be a value of @ref SMARTCARD_Prescaler */
Kojto 122:f9eeca106725 102
Kojto 122:f9eeca106725 103 uint32_t GuardTime; /*!< Specifies the SmartCard Guard Time value in terms of number of baud clocks */
bogdanm 89:552587b429a1 104
bogdanm 89:552587b429a1 105 uint32_t NACKState; /*!< Specifies the SmartCard NACK Transmission state.
Kojto 122:f9eeca106725 106 This parameter can be a value of @ref SMARTCARD_NACK_State */
bogdanm 89:552587b429a1 107 }SMARTCARD_InitTypeDef;
bogdanm 89:552587b429a1 108
bogdanm 89:552587b429a1 109 /**
Kojto 122:f9eeca106725 110 * @brief HAL SMARTCARD State structures definition
Kojto 122:f9eeca106725 111 * @note HAL SMARTCARD State value is a combination of 2 different substates: gState and RxState.
Kojto 122:f9eeca106725 112 * - gState contains SMARTCARD state information related to global Handle management
Kojto 122:f9eeca106725 113 * and also information related to Tx operations.
Kojto 122:f9eeca106725 114 * gState value coding follow below described bitmap :
Kojto 122:f9eeca106725 115 * b7-b6 Error information
Kojto 122:f9eeca106725 116 * 00 : No Error
Kojto 122:f9eeca106725 117 * 01 : (Not Used)
Kojto 122:f9eeca106725 118 * 10 : Timeout
Kojto 122:f9eeca106725 119 * 11 : Error
Kojto 122:f9eeca106725 120 * b5 IP initilisation status
Kojto 122:f9eeca106725 121 * 0 : Reset (IP not initialized)
Kojto 122:f9eeca106725 122 * 1 : Init done (IP not initialized. HAL SMARTCARD Init function already called)
Kojto 122:f9eeca106725 123 * b4-b3 (not used)
Kojto 122:f9eeca106725 124 * xx : Should be set to 00
Kojto 122:f9eeca106725 125 * b2 Intrinsic process state
Kojto 122:f9eeca106725 126 * 0 : Ready
Kojto 122:f9eeca106725 127 * 1 : Busy (IP busy with some configuration or internal operations)
Kojto 122:f9eeca106725 128 * b1 (not used)
Kojto 122:f9eeca106725 129 * x : Should be set to 0
Kojto 122:f9eeca106725 130 * b0 Tx state
Kojto 122:f9eeca106725 131 * 0 : Ready (no Tx operation ongoing)
Kojto 122:f9eeca106725 132 * 1 : Busy (Tx operation ongoing)
Kojto 122:f9eeca106725 133 * - RxState contains information related to Rx operations.
Kojto 122:f9eeca106725 134 * RxState value coding follow below described bitmap :
Kojto 122:f9eeca106725 135 * b7-b6 (not used)
Kojto 122:f9eeca106725 136 * xx : Should be set to 00
Kojto 122:f9eeca106725 137 * b5 IP initilisation status
Kojto 122:f9eeca106725 138 * 0 : Reset (IP not initialized)
Kojto 122:f9eeca106725 139 * 1 : Init done (IP not initialized)
Kojto 122:f9eeca106725 140 * b4-b2 (not used)
Kojto 122:f9eeca106725 141 * xxx : Should be set to 000
Kojto 122:f9eeca106725 142 * b1 Rx state
Kojto 122:f9eeca106725 143 * 0 : Ready (no Rx operation ongoing)
Kojto 122:f9eeca106725 144 * 1 : Busy (Rx operation ongoing)
Kojto 122:f9eeca106725 145 * b0 (not used)
Kojto 122:f9eeca106725 146 * x : Should be set to 0.
bogdanm 89:552587b429a1 147 */
bogdanm 89:552587b429a1 148 typedef enum
bogdanm 89:552587b429a1 149 {
Kojto 122:f9eeca106725 150 HAL_SMARTCARD_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized
Kojto 122:f9eeca106725 151 Value is allowed for gState and RxState */
Kojto 122:f9eeca106725 152 HAL_SMARTCARD_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use
Kojto 122:f9eeca106725 153 Value is allowed for gState and RxState */
Kojto 122:f9eeca106725 154 HAL_SMARTCARD_STATE_BUSY = 0x24U, /*!< an internal process is ongoing
Kojto 122:f9eeca106725 155 Value is allowed for gState only */
Kojto 122:f9eeca106725 156 HAL_SMARTCARD_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing
Kojto 122:f9eeca106725 157 Value is allowed for gState only */
Kojto 122:f9eeca106725 158 HAL_SMARTCARD_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing
Kojto 122:f9eeca106725 159 Value is allowed for RxState only */
Kojto 122:f9eeca106725 160 HAL_SMARTCARD_STATE_BUSY_TX_RX = 0x23U, /*!< Data Transmission and Reception process is ongoing
Kojto 122:f9eeca106725 161 Not to be used for neither gState nor RxState.
Kojto 122:f9eeca106725 162 Value is result of combination (Or) between gState and RxState values */
Kojto 122:f9eeca106725 163 HAL_SMARTCARD_STATE_TIMEOUT = 0xA0U, /*!< Timeout state
Kojto 122:f9eeca106725 164 Value is allowed for gState only */
Kojto 122:f9eeca106725 165 HAL_SMARTCARD_STATE_ERROR = 0xE0U /*!< Error
Kojto 122:f9eeca106725 166 Value is allowed for gState only */
bogdanm 89:552587b429a1 167 }HAL_SMARTCARD_StateTypeDef;
bogdanm 89:552587b429a1 168
bogdanm 89:552587b429a1 169 /**
bogdanm 89:552587b429a1 170 * @brief SMARTCARD handle Structure definition
bogdanm 89:552587b429a1 171 */
bogdanm 89:552587b429a1 172 typedef struct
bogdanm 89:552587b429a1 173 {
bogdanm 89:552587b429a1 174 USART_TypeDef *Instance; /* USART registers base address */
bogdanm 89:552587b429a1 175
Kojto 99:dbbf35b96557 176 SMARTCARD_InitTypeDef Init; /* SmartCard communication parameters */
bogdanm 89:552587b429a1 177
bogdanm 89:552587b429a1 178 uint8_t *pTxBuffPtr; /* Pointer to SmartCard Tx transfer Buffer */
bogdanm 89:552587b429a1 179
bogdanm 89:552587b429a1 180 uint16_t TxXferSize; /* SmartCard Tx Transfer size */
bogdanm 89:552587b429a1 181
bogdanm 89:552587b429a1 182 uint16_t TxXferCount; /* SmartCard Tx Transfer Counter */
bogdanm 89:552587b429a1 183
bogdanm 89:552587b429a1 184 uint8_t *pRxBuffPtr; /* Pointer to SmartCard Rx transfer Buffer */
bogdanm 89:552587b429a1 185
bogdanm 89:552587b429a1 186 uint16_t RxXferSize; /* SmartCard Rx Transfer size */
bogdanm 89:552587b429a1 187
bogdanm 89:552587b429a1 188 uint16_t RxXferCount; /* SmartCard Rx Transfer Counter */
bogdanm 89:552587b429a1 189
bogdanm 89:552587b429a1 190 DMA_HandleTypeDef *hdmatx; /* SmartCard Tx DMA Handle parameters */
bogdanm 89:552587b429a1 191
bogdanm 89:552587b429a1 192 DMA_HandleTypeDef *hdmarx; /* SmartCard Rx DMA Handle parameters */
bogdanm 89:552587b429a1 193
Kojto 99:dbbf35b96557 194 HAL_LockTypeDef Lock; /* Locking object */
bogdanm 89:552587b429a1 195
Kojto 122:f9eeca106725 196 __IO HAL_SMARTCARD_StateTypeDef gState; /* SmartCard state information related to global Handle management
Kojto 122:f9eeca106725 197 and also related to Tx operations.
Kojto 122:f9eeca106725 198 This parameter can be a value of @ref HAL_SMARTCARD_StateTypeDef */
Kojto 122:f9eeca106725 199
Kojto 122:f9eeca106725 200 __IO HAL_SMARTCARD_StateTypeDef RxState; /* SmartCard state information related to Rx operations.
Kojto 122:f9eeca106725 201 This parameter can be a value of @ref HAL_SMARTCARD_StateTypeDef */
bogdanm 89:552587b429a1 202
Kojto 99:dbbf35b96557 203 __IO uint32_t ErrorCode; /* SmartCard Error code */
Kojto 99:dbbf35b96557 204
bogdanm 89:552587b429a1 205 }SMARTCARD_HandleTypeDef;
bogdanm 89:552587b429a1 206
bogdanm 89:552587b429a1 207 /**
bogdanm 89:552587b429a1 208 * @}
bogdanm 89:552587b429a1 209 */
bogdanm 89:552587b429a1 210
Kojto 99:dbbf35b96557 211 /* Exported constants --------------------------------------------------------*/
Kojto 99:dbbf35b96557 212 /** @defgroup SMARTCARD_Exported_Constants SMARTCARD Exported constants
bogdanm 89:552587b429a1 213 * @{
bogdanm 89:552587b429a1 214 */
Kojto 99:dbbf35b96557 215 /** @defgroup SMARTCARD_Error_Code SMARTCARD Error Code
Kojto 99:dbbf35b96557 216 * @brief SMARTCARD Error Code
Kojto 99:dbbf35b96557 217 * @{
Kojto 99:dbbf35b96557 218 */
Kojto 122:f9eeca106725 219 #define HAL_SMARTCARD_ERROR_NONE ((uint32_t)0x00000000U) /*!< No error */
Kojto 122:f9eeca106725 220 #define HAL_SMARTCARD_ERROR_PE ((uint32_t)0x00000001U) /*!< Parity error */
Kojto 122:f9eeca106725 221 #define HAL_SMARTCARD_ERROR_NE ((uint32_t)0x00000002U) /*!< Noise error */
Kojto 122:f9eeca106725 222 #define HAL_SMARTCARD_ERROR_FE ((uint32_t)0x00000004U) /*!< Frame error */
Kojto 122:f9eeca106725 223 #define HAL_SMARTCARD_ERROR_ORE ((uint32_t)0x00000008U) /*!< Overrun error */
Kojto 122:f9eeca106725 224 #define HAL_SMARTCARD_ERROR_DMA ((uint32_t)0x00000010U) /*!< DMA transfer error */
bogdanm 89:552587b429a1 225 /**
bogdanm 89:552587b429a1 226 * @}
bogdanm 89:552587b429a1 227 */
bogdanm 89:552587b429a1 228
Kojto 99:dbbf35b96557 229 /** @defgroup SMARTCARD_Word_Length SMARTCARD Word Length
bogdanm 89:552587b429a1 230 * @{
bogdanm 89:552587b429a1 231 */
Kojto 99:dbbf35b96557 232 #define SMARTCARD_WORDLENGTH_9B ((uint32_t)USART_CR1_M)
bogdanm 89:552587b429a1 233 /**
bogdanm 89:552587b429a1 234 * @}
bogdanm 89:552587b429a1 235 */
bogdanm 89:552587b429a1 236
Kojto 99:dbbf35b96557 237 /** @defgroup SMARTCARD_Stop_Bits SMARTCARD Number of Stop Bits
Kojto 99:dbbf35b96557 238 * @{
Kojto 99:dbbf35b96557 239 */
Kojto 99:dbbf35b96557 240 #define SMARTCARD_STOPBITS_0_5 ((uint32_t)USART_CR2_STOP_0)
Kojto 99:dbbf35b96557 241 #define SMARTCARD_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1))
Kojto 99:dbbf35b96557 242 /**
Kojto 99:dbbf35b96557 243 * @}
Kojto 99:dbbf35b96557 244 */
Kojto 99:dbbf35b96557 245
Kojto 99:dbbf35b96557 246 /** @defgroup SMARTCARD_Parity SMARTCARD Parity
Kojto 99:dbbf35b96557 247 * @{
Kojto 99:dbbf35b96557 248 */
Kojto 99:dbbf35b96557 249 #define SMARTCARD_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
Kojto 99:dbbf35b96557 250 #define SMARTCARD_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
Kojto 99:dbbf35b96557 251 /**
Kojto 99:dbbf35b96557 252 * @}
Kojto 99:dbbf35b96557 253 */
Kojto 99:dbbf35b96557 254
Kojto 99:dbbf35b96557 255 /** @defgroup SMARTCARD_Mode SMARTCARD Mode
bogdanm 89:552587b429a1 256 * @{
bogdanm 89:552587b429a1 257 */
bogdanm 89:552587b429a1 258 #define SMARTCARD_MODE_RX ((uint32_t)USART_CR1_RE)
bogdanm 89:552587b429a1 259 #define SMARTCARD_MODE_TX ((uint32_t)USART_CR1_TE)
bogdanm 89:552587b429a1 260 #define SMARTCARD_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
bogdanm 89:552587b429a1 261 /**
bogdanm 89:552587b429a1 262 * @}
bogdanm 89:552587b429a1 263 */
bogdanm 89:552587b429a1 264
Kojto 99:dbbf35b96557 265 /** @defgroup SMARTCARD_Clock_Polarity SMARTCARD Clock Polarity
bogdanm 89:552587b429a1 266 * @{
bogdanm 89:552587b429a1 267 */
Kojto 122:f9eeca106725 268 #define SMARTCARD_POLARITY_LOW ((uint32_t)0x00000000U)
bogdanm 89:552587b429a1 269 #define SMARTCARD_POLARITY_HIGH ((uint32_t)USART_CR2_CPOL)
bogdanm 89:552587b429a1 270 /**
bogdanm 89:552587b429a1 271 * @}
bogdanm 89:552587b429a1 272 */
bogdanm 89:552587b429a1 273
Kojto 99:dbbf35b96557 274 /** @defgroup SMARTCARD_Clock_Phase SMARTCARD Clock Phase
bogdanm 89:552587b429a1 275 * @{
bogdanm 89:552587b429a1 276 */
Kojto 122:f9eeca106725 277 #define SMARTCARD_PHASE_1EDGE ((uint32_t)0x00000000U)
bogdanm 89:552587b429a1 278 #define SMARTCARD_PHASE_2EDGE ((uint32_t)USART_CR2_CPHA)
bogdanm 89:552587b429a1 279 /**
bogdanm 89:552587b429a1 280 * @}
bogdanm 89:552587b429a1 281 */
bogdanm 89:552587b429a1 282
Kojto 99:dbbf35b96557 283 /** @defgroup SMARTCARD_Last_Bit SMARTCARD Last Bit
bogdanm 89:552587b429a1 284 * @{
bogdanm 89:552587b429a1 285 */
Kojto 122:f9eeca106725 286 #define SMARTCARD_LASTBIT_DISABLE ((uint32_t)0x00000000U)
bogdanm 89:552587b429a1 287 #define SMARTCARD_LASTBIT_ENABLE ((uint32_t)USART_CR2_LBCL)
bogdanm 89:552587b429a1 288 /**
bogdanm 89:552587b429a1 289 * @}
bogdanm 89:552587b429a1 290 */
bogdanm 89:552587b429a1 291
Kojto 122:f9eeca106725 292 /** @defgroup SMARTCARD_NACK_State SMARTCARD NACK State
bogdanm 89:552587b429a1 293 * @{
bogdanm 89:552587b429a1 294 */
Kojto 99:dbbf35b96557 295 #define SMARTCARD_NACK_ENABLE ((uint32_t)USART_CR3_NACK)
Kojto 122:f9eeca106725 296 #define SMARTCARD_NACK_DISABLE ((uint32_t)0x00000000U)
Kojto 99:dbbf35b96557 297 /**
Kojto 99:dbbf35b96557 298 * @}
Kojto 99:dbbf35b96557 299 */
Kojto 99:dbbf35b96557 300
Kojto 122:f9eeca106725 301 /** @defgroup SMARTCARD_DMA_Requests SMARTCARD DMA requests
Kojto 99:dbbf35b96557 302 * @{
Kojto 99:dbbf35b96557 303 */
Kojto 99:dbbf35b96557 304 #define SMARTCARD_DMAREQ_TX ((uint32_t)USART_CR3_DMAT)
Kojto 99:dbbf35b96557 305 #define SMARTCARD_DMAREQ_RX ((uint32_t)USART_CR3_DMAR)
bogdanm 89:552587b429a1 306 /**
bogdanm 89:552587b429a1 307 * @}
bogdanm 89:552587b429a1 308 */
bogdanm 89:552587b429a1 309
Kojto 99:dbbf35b96557 310 /** @defgroup SMARTCARD_Prescaler SMARTCARD Prescaler
bogdanm 89:552587b429a1 311 * @{
bogdanm 89:552587b429a1 312 */
Kojto 122:f9eeca106725 313 #define SMARTCARD_PRESCALER_SYSCLK_DIV2 ((uint32_t)0x00000001U) /*!< SYSCLK divided by 2 */
Kojto 122:f9eeca106725 314 #define SMARTCARD_PRESCALER_SYSCLK_DIV4 ((uint32_t)0x00000002U) /*!< SYSCLK divided by 4 */
Kojto 122:f9eeca106725 315 #define SMARTCARD_PRESCALER_SYSCLK_DIV6 ((uint32_t)0x00000003U) /*!< SYSCLK divided by 6 */
Kojto 122:f9eeca106725 316 #define SMARTCARD_PRESCALER_SYSCLK_DIV8 ((uint32_t)0x00000004U) /*!< SYSCLK divided by 8 */
Kojto 122:f9eeca106725 317 #define SMARTCARD_PRESCALER_SYSCLK_DIV10 ((uint32_t)0x00000005U) /*!< SYSCLK divided by 10 */
Kojto 122:f9eeca106725 318 #define SMARTCARD_PRESCALER_SYSCLK_DIV12 ((uint32_t)0x00000006U) /*!< SYSCLK divided by 12 */
Kojto 122:f9eeca106725 319 #define SMARTCARD_PRESCALER_SYSCLK_DIV14 ((uint32_t)0x00000007U) /*!< SYSCLK divided by 14 */
Kojto 122:f9eeca106725 320 #define SMARTCARD_PRESCALER_SYSCLK_DIV16 ((uint32_t)0x00000008U) /*!< SYSCLK divided by 16 */
Kojto 122:f9eeca106725 321 #define SMARTCARD_PRESCALER_SYSCLK_DIV18 ((uint32_t)0x00000009U) /*!< SYSCLK divided by 18 */
Kojto 122:f9eeca106725 322 #define SMARTCARD_PRESCALER_SYSCLK_DIV20 ((uint32_t)0x0000000AU) /*!< SYSCLK divided by 20 */
Kojto 122:f9eeca106725 323 #define SMARTCARD_PRESCALER_SYSCLK_DIV22 ((uint32_t)0x0000000BU) /*!< SYSCLK divided by 22 */
Kojto 122:f9eeca106725 324 #define SMARTCARD_PRESCALER_SYSCLK_DIV24 ((uint32_t)0x0000000CU) /*!< SYSCLK divided by 24 */
Kojto 122:f9eeca106725 325 #define SMARTCARD_PRESCALER_SYSCLK_DIV26 ((uint32_t)0x0000000DU) /*!< SYSCLK divided by 26 */
Kojto 122:f9eeca106725 326 #define SMARTCARD_PRESCALER_SYSCLK_DIV28 ((uint32_t)0x0000000EU) /*!< SYSCLK divided by 28 */
Kojto 122:f9eeca106725 327 #define SMARTCARD_PRESCALER_SYSCLK_DIV30 ((uint32_t)0x0000000FU) /*!< SYSCLK divided by 30 */
Kojto 122:f9eeca106725 328 #define SMARTCARD_PRESCALER_SYSCLK_DIV32 ((uint32_t)0x00000010U) /*!< SYSCLK divided by 32 */
Kojto 122:f9eeca106725 329 #define SMARTCARD_PRESCALER_SYSCLK_DIV34 ((uint32_t)0x00000011U) /*!< SYSCLK divided by 34 */
Kojto 122:f9eeca106725 330 #define SMARTCARD_PRESCALER_SYSCLK_DIV36 ((uint32_t)0x00000012U) /*!< SYSCLK divided by 36 */
Kojto 122:f9eeca106725 331 #define SMARTCARD_PRESCALER_SYSCLK_DIV38 ((uint32_t)0x00000013U) /*!< SYSCLK divided by 38 */
Kojto 122:f9eeca106725 332 #define SMARTCARD_PRESCALER_SYSCLK_DIV40 ((uint32_t)0x00000014U) /*!< SYSCLK divided by 40 */
Kojto 122:f9eeca106725 333 #define SMARTCARD_PRESCALER_SYSCLK_DIV42 ((uint32_t)0x00000015U) /*!< SYSCLK divided by 42 */
Kojto 122:f9eeca106725 334 #define SMARTCARD_PRESCALER_SYSCLK_DIV44 ((uint32_t)0x00000016U) /*!< SYSCLK divided by 44 */
Kojto 122:f9eeca106725 335 #define SMARTCARD_PRESCALER_SYSCLK_DIV46 ((uint32_t)0x00000017U) /*!< SYSCLK divided by 46 */
Kojto 122:f9eeca106725 336 #define SMARTCARD_PRESCALER_SYSCLK_DIV48 ((uint32_t)0x00000018U) /*!< SYSCLK divided by 48 */
Kojto 122:f9eeca106725 337 #define SMARTCARD_PRESCALER_SYSCLK_DIV50 ((uint32_t)0x00000019U) /*!< SYSCLK divided by 50 */
Kojto 122:f9eeca106725 338 #define SMARTCARD_PRESCALER_SYSCLK_DIV52 ((uint32_t)0x0000001AU) /*!< SYSCLK divided by 52 */
Kojto 122:f9eeca106725 339 #define SMARTCARD_PRESCALER_SYSCLK_DIV54 ((uint32_t)0x0000001BU) /*!< SYSCLK divided by 54 */
Kojto 122:f9eeca106725 340 #define SMARTCARD_PRESCALER_SYSCLK_DIV56 ((uint32_t)0x0000001CU) /*!< SYSCLK divided by 56 */
Kojto 122:f9eeca106725 341 #define SMARTCARD_PRESCALER_SYSCLK_DIV58 ((uint32_t)0x0000001DU) /*!< SYSCLK divided by 58 */
Kojto 122:f9eeca106725 342 #define SMARTCARD_PRESCALER_SYSCLK_DIV60 ((uint32_t)0x0000001EU) /*!< SYSCLK divided by 60 */
Kojto 122:f9eeca106725 343 #define SMARTCARD_PRESCALER_SYSCLK_DIV62 ((uint32_t)0x0000001FU) /*!< SYSCLK divided by 62 */
bogdanm 89:552587b429a1 344 /**
bogdanm 89:552587b429a1 345 * @}
bogdanm 89:552587b429a1 346 */
bogdanm 89:552587b429a1 347
Kojto 99:dbbf35b96557 348 /** @defgroup SmartCard_Flags SMARTCARD Flags
bogdanm 89:552587b429a1 349 * Elements values convention: 0xXXXX
bogdanm 89:552587b429a1 350 * - 0xXXXX : Flag mask in the SR register
bogdanm 89:552587b429a1 351 * @{
bogdanm 89:552587b429a1 352 */
Kojto 122:f9eeca106725 353 #define SMARTCARD_FLAG_TXE ((uint32_t)0x00000080U)
Kojto 122:f9eeca106725 354 #define SMARTCARD_FLAG_TC ((uint32_t)0x00000040U)
Kojto 122:f9eeca106725 355 #define SMARTCARD_FLAG_RXNE ((uint32_t)0x00000020U)
Kojto 122:f9eeca106725 356 #define SMARTCARD_FLAG_IDLE ((uint32_t)0x00000010U)
Kojto 122:f9eeca106725 357 #define SMARTCARD_FLAG_ORE ((uint32_t)0x00000008U)
Kojto 122:f9eeca106725 358 #define SMARTCARD_FLAG_NE ((uint32_t)0x00000004U)
Kojto 122:f9eeca106725 359 #define SMARTCARD_FLAG_FE ((uint32_t)0x00000002U)
Kojto 122:f9eeca106725 360 #define SMARTCARD_FLAG_PE ((uint32_t)0x00000001U)
bogdanm 89:552587b429a1 361 /**
bogdanm 89:552587b429a1 362 * @}
bogdanm 89:552587b429a1 363 */
bogdanm 89:552587b429a1 364
Kojto 99:dbbf35b96557 365 /** @defgroup SmartCard_Interrupt_definition SMARTCARD Interrupts Definition
bogdanm 89:552587b429a1 366 * Elements values convention: 0xY000XXXX
bogdanm 89:552587b429a1 367 * - XXXX : Interrupt mask in the XX register
bogdanm 89:552587b429a1 368 * - Y : Interrupt source register (2bits)
bogdanm 89:552587b429a1 369 * - 01: CR1 register
bogdanm 89:552587b429a1 370 * - 10: CR3 register
bogdanm 89:552587b429a1 371 * @{
bogdanm 89:552587b429a1 372 */
Kojto 122:f9eeca106725 373 #define SMARTCARD_IT_PE ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28U | USART_CR1_PEIE))
Kojto 122:f9eeca106725 374 #define SMARTCARD_IT_TXE ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28U | USART_CR1_TXEIE))
Kojto 122:f9eeca106725 375 #define SMARTCARD_IT_TC ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28U | USART_CR1_TCIE))
Kojto 122:f9eeca106725 376 #define SMARTCARD_IT_RXNE ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28U | USART_CR1_RXNEIE))
Kojto 122:f9eeca106725 377 #define SMARTCARD_IT_IDLE ((uint32_t)(SMARTCARD_CR1_REG_INDEX << 28U | USART_CR1_IDLEIE))
Kojto 122:f9eeca106725 378 #define SMARTCARD_IT_ERR ((uint32_t)(SMARTCARD_CR3_REG_INDEX << 28U | USART_CR3_EIE))
bogdanm 89:552587b429a1 379 /**
bogdanm 89:552587b429a1 380 * @}
bogdanm 89:552587b429a1 381 */
bogdanm 89:552587b429a1 382
bogdanm 89:552587b429a1 383 /**
bogdanm 89:552587b429a1 384 * @}
bogdanm 89:552587b429a1 385 */
bogdanm 89:552587b429a1 386
bogdanm 89:552587b429a1 387 /* Exported macro ------------------------------------------------------------*/
Kojto 99:dbbf35b96557 388 /** @defgroup SMARTCARD_Exported_Macros SMARTCARD Exported Macros
Kojto 99:dbbf35b96557 389 * @{
Kojto 99:dbbf35b96557 390 */
bogdanm 89:552587b429a1 391
Kojto 122:f9eeca106725 392 /** @brief Reset SMARTCARD handle gstate & RxState
bogdanm 89:552587b429a1 393 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 89:552587b429a1 394 * @retval None
bogdanm 89:552587b429a1 395 */
Kojto 122:f9eeca106725 396 #define __HAL_SMARTCARD_RESET_HANDLE_STATE(__HANDLE__) do{ \
Kojto 122:f9eeca106725 397 (__HANDLE__)->gState = HAL_SMARTCARD_STATE_RESET; \
Kojto 122:f9eeca106725 398 (__HANDLE__)->RxState = HAL_SMARTCARD_STATE_RESET; \
Kojto 122:f9eeca106725 399 } while(0)
bogdanm 89:552587b429a1 400
bogdanm 89:552587b429a1 401 /** @brief Flushs the Smartcard DR register
bogdanm 89:552587b429a1 402 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 89:552587b429a1 403 */
bogdanm 89:552587b429a1 404 #define __HAL_SMARTCARD_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR)
bogdanm 89:552587b429a1 405
bogdanm 89:552587b429a1 406 /** @brief Checks whether the specified Smartcard flag is set or not.
bogdanm 89:552587b429a1 407 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 89:552587b429a1 408 * @param __FLAG__: specifies the flag to check.
bogdanm 89:552587b429a1 409 * This parameter can be one of the following values:
bogdanm 89:552587b429a1 410 * @arg SMARTCARD_FLAG_TXE: Transmit data register empty flag
bogdanm 89:552587b429a1 411 * @arg SMARTCARD_FLAG_TC: Transmission Complete flag
bogdanm 89:552587b429a1 412 * @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag
bogdanm 89:552587b429a1 413 * @arg SMARTCARD_FLAG_IDLE: Idle Line detection flag
Kojto 99:dbbf35b96557 414 * @arg SMARTCARD_FLAG_ORE: Overrun Error flag
bogdanm 89:552587b429a1 415 * @arg SMARTCARD_FLAG_NE: Noise Error flag
bogdanm 89:552587b429a1 416 * @arg SMARTCARD_FLAG_FE: Framing Error flag
bogdanm 89:552587b429a1 417 * @arg SMARTCARD_FLAG_PE: Parity Error flag
bogdanm 89:552587b429a1 418 * @retval The new state of __FLAG__ (TRUE or FALSE).
bogdanm 89:552587b429a1 419 */
bogdanm 89:552587b429a1 420 #define __HAL_SMARTCARD_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
bogdanm 89:552587b429a1 421
bogdanm 89:552587b429a1 422 /** @brief Clears the specified Smartcard pending flags.
bogdanm 89:552587b429a1 423 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 89:552587b429a1 424 * @param __FLAG__: specifies the flag to check.
bogdanm 89:552587b429a1 425 * This parameter can be any combination of the following values:
bogdanm 89:552587b429a1 426 * @arg SMARTCARD_FLAG_TC: Transmission Complete flag.
bogdanm 89:552587b429a1 427 * @arg SMARTCARD_FLAG_RXNE: Receive data register not empty flag.
bogdanm 89:552587b429a1 428 *
Kojto 99:dbbf35b96557 429 * @note PE (Parity error), FE (Framing error), NE (Noise error) and ORE (Overrun
bogdanm 89:552587b429a1 430 * error) flags are cleared by software sequence: a read operation to
bogdanm 89:552587b429a1 431 * USART_SR register followed by a read operation to USART_DR register.
bogdanm 89:552587b429a1 432 * @note RXNE flag can be also cleared by a read to the USART_DR register.
bogdanm 89:552587b429a1 433 * @note TC flag can be also cleared by software sequence: a read operation to
bogdanm 89:552587b429a1 434 * USART_SR register followed by a write operation to USART_DR register.
bogdanm 89:552587b429a1 435 * @note TXE flag is cleared only by a write to the USART_DR register.
bogdanm 89:552587b429a1 436 */
bogdanm 92:4fc01daae5a5 437 #define __HAL_SMARTCARD_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
bogdanm 92:4fc01daae5a5 438
bogdanm 92:4fc01daae5a5 439 /** @brief Clear the SMARTCARD PE pending flag.
bogdanm 92:4fc01daae5a5 440 * @param __HANDLE__: specifies the USART Handle.
bogdanm 92:4fc01daae5a5 441 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
Kojto 122:f9eeca106725 442 * SMARTCARD peripheral.
bogdanm 92:4fc01daae5a5 443 * @retval None
bogdanm 92:4fc01daae5a5 444 */
Kojto 99:dbbf35b96557 445 #define __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__) \
Kojto 99:dbbf35b96557 446 do{ \
Kojto 122:f9eeca106725 447 __IO uint32_t tmpreg = 0x00U; \
Kojto 99:dbbf35b96557 448 tmpreg = (__HANDLE__)->Instance->SR; \
Kojto 99:dbbf35b96557 449 tmpreg = (__HANDLE__)->Instance->DR; \
Kojto 99:dbbf35b96557 450 UNUSED(tmpreg); \
Kojto 99:dbbf35b96557 451 } while(0)
Kojto 122:f9eeca106725 452
bogdanm 92:4fc01daae5a5 453 /** @brief Clear the SMARTCARD FE pending flag.
bogdanm 92:4fc01daae5a5 454 * @param __HANDLE__: specifies the USART Handle.
bogdanm 92:4fc01daae5a5 455 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
Kojto 122:f9eeca106725 456 * SMARTCARD peripheral.
bogdanm 92:4fc01daae5a5 457 * @retval None
bogdanm 92:4fc01daae5a5 458 */
bogdanm 92:4fc01daae5a5 459 #define __HAL_SMARTCARD_CLEAR_FEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
bogdanm 92:4fc01daae5a5 460
bogdanm 92:4fc01daae5a5 461 /** @brief Clear the SMARTCARD NE pending flag.
bogdanm 92:4fc01daae5a5 462 * @param __HANDLE__: specifies the USART Handle.
bogdanm 92:4fc01daae5a5 463 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
Kojto 122:f9eeca106725 464 * SMARTCARD peripheral.
bogdanm 92:4fc01daae5a5 465 * @retval None
bogdanm 92:4fc01daae5a5 466 */
bogdanm 92:4fc01daae5a5 467 #define __HAL_SMARTCARD_CLEAR_NEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
bogdanm 92:4fc01daae5a5 468
bogdanm 92:4fc01daae5a5 469 /** @brief Clear the SMARTCARD ORE pending flag.
bogdanm 92:4fc01daae5a5 470 * @param __HANDLE__: specifies the USART Handle.
bogdanm 92:4fc01daae5a5 471 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
Kojto 122:f9eeca106725 472 * SMARTCARD peripheral.
bogdanm 92:4fc01daae5a5 473 * @retval None
bogdanm 92:4fc01daae5a5 474 */
bogdanm 92:4fc01daae5a5 475 #define __HAL_SMARTCARD_CLEAR_OREFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
bogdanm 92:4fc01daae5a5 476
bogdanm 92:4fc01daae5a5 477 /** @brief Clear the SMARTCARD IDLE pending flag.
bogdanm 92:4fc01daae5a5 478 * @param __HANDLE__: specifies the USART Handle.
bogdanm 92:4fc01daae5a5 479 * This parameter can be USARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
Kojto 122:f9eeca106725 480 * SMARTCARD peripheral.
bogdanm 92:4fc01daae5a5 481 * @retval None
bogdanm 92:4fc01daae5a5 482 */
bogdanm 92:4fc01daae5a5 483 #define __HAL_SMARTCARD_CLEAR_IDLEFLAG(__HANDLE__) __HAL_SMARTCARD_CLEAR_PEFLAG(__HANDLE__)
bogdanm 92:4fc01daae5a5 484
bogdanm 89:552587b429a1 485 /** @brief Enables or disables the specified SmartCard interrupts.
bogdanm 89:552587b429a1 486 * @param __HANDLE__: specifies the SMARTCARD Handle.
bogdanm 89:552587b429a1 487 * @param __INTERRUPT__: specifies the SMARTCARD interrupt source to check.
bogdanm 89:552587b429a1 488 * This parameter can be one of the following values:
bogdanm 89:552587b429a1 489 * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt
bogdanm 89:552587b429a1 490 * @arg SMARTCARD_IT_TC: Transmission complete interrupt
bogdanm 89:552587b429a1 491 * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
bogdanm 89:552587b429a1 492 * @arg SMARTCARD_IT_IDLE: Idle line detection interrupt
bogdanm 89:552587b429a1 493 * @arg SMARTCARD_IT_PE: Parity Error interrupt
bogdanm 89:552587b429a1 494 * @arg SMARTCARD_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
bogdanm 89:552587b429a1 495 */
Kojto 122:f9eeca106725 496 #define __HAL_SMARTCARD_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == 1U)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & SMARTCARD_IT_MASK)): \
Kojto 99:dbbf35b96557 497 ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & SMARTCARD_IT_MASK)))
Kojto 122:f9eeca106725 498 #define __HAL_SMARTCARD_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == 1U)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & SMARTCARD_IT_MASK)): \
Kojto 99:dbbf35b96557 499 ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & SMARTCARD_IT_MASK)))
bogdanm 89:552587b429a1 500
bogdanm 89:552587b429a1 501 /** @brief Checks whether the specified SmartCard interrupt has occurred or not.
bogdanm 89:552587b429a1 502 * @param __HANDLE__: specifies the SmartCard Handle.
bogdanm 89:552587b429a1 503 * @param __IT__: specifies the SMARTCARD interrupt source to check.
bogdanm 89:552587b429a1 504 * This parameter can be one of the following values:
bogdanm 89:552587b429a1 505 * @arg SMARTCARD_IT_TXE: Transmit Data Register empty interrupt
bogdanm 89:552587b429a1 506 * @arg SMARTCARD_IT_TC: Transmission complete interrupt
bogdanm 89:552587b429a1 507 * @arg SMARTCARD_IT_RXNE: Receive Data register not empty interrupt
bogdanm 89:552587b429a1 508 * @arg SMARTCARD_IT_IDLE: Idle line detection interrupt
bogdanm 89:552587b429a1 509 * @arg SMARTCARD_IT_ERR: Error interrupt
bogdanm 89:552587b429a1 510 * @arg SMARTCARD_IT_PE: Parity Error interrupt
bogdanm 89:552587b429a1 511 * @retval The new state of __IT__ (TRUE or FALSE).
bogdanm 89:552587b429a1 512 */
Kojto 122:f9eeca106725 513 #define __HAL_SMARTCARD_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28U) == 1U)? (__HANDLE__)->Instance->CR1: (__HANDLE__)->Instance->CR3) & (((uint32_t)(__IT__)) & SMARTCARD_IT_MASK))
bogdanm 89:552587b429a1 514
Kojto 99:dbbf35b96557 515 /** @brief Macro to enable the SMARTCARD's one bit sample method
Kojto 99:dbbf35b96557 516 * @param __HANDLE__: specifies the SMARTCARD Handle.
Kojto 99:dbbf35b96557 517 * @retval None
Kojto 99:dbbf35b96557 518 */
Kojto 99:dbbf35b96557 519 #define __HAL_SMARTCARD_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
Kojto 99:dbbf35b96557 520
Kojto 99:dbbf35b96557 521 /** @brief Macro to disable the SMARTCARD's one bit sample method
Kojto 99:dbbf35b96557 522 * @param __HANDLE__: specifies the SMARTCARD Handle.
Kojto 99:dbbf35b96557 523 * @retval None
Kojto 99:dbbf35b96557 524 */
Kojto 99:dbbf35b96557 525 #define __HAL_SMARTCARD_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_ONEBIT))
Kojto 99:dbbf35b96557 526
Kojto 99:dbbf35b96557 527 /** @brief Enable the USART associated to the SMARTCARD Handle
Kojto 99:dbbf35b96557 528 * @param __HANDLE__: specifies the SMARTCARD Handle.
Kojto 99:dbbf35b96557 529 * SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
Kojto 99:dbbf35b96557 530 * @retval None
bogdanm 89:552587b429a1 531 */
Kojto 99:dbbf35b96557 532 #define __HAL_SMARTCARD_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
Kojto 99:dbbf35b96557 533
Kojto 99:dbbf35b96557 534 /** @brief Disable the USART associated to the SMARTCARD Handle
Kojto 99:dbbf35b96557 535 * @param __HANDLE__: specifies the SMARTCARD Handle.
Kojto 99:dbbf35b96557 536 * SMARTCARD Handle selects the USARTx peripheral (USART availability and x value depending on device).
Kojto 99:dbbf35b96557 537 * @retval None
Kojto 99:dbbf35b96557 538 */
Kojto 99:dbbf35b96557 539 #define __HAL_SMARTCARD_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
bogdanm 89:552587b429a1 540
bogdanm 89:552587b429a1 541 /** @brief Macros to enable or disable the SmartCard DMA request.
bogdanm 89:552587b429a1 542 * @param __HANDLE__: specifies the SmartCard Handle.
bogdanm 89:552587b429a1 543 * @param __REQUEST__: specifies the SmartCard DMA request.
bogdanm 89:552587b429a1 544 * This parameter can be one of the following values:
bogdanm 89:552587b429a1 545 * @arg SMARTCARD_DMAREQ_TX: SmartCard DMA transmit request
bogdanm 89:552587b429a1 546 * @arg SMARTCARD_DMAREQ_RX: SmartCard DMA receive request
bogdanm 89:552587b429a1 547 */
Kojto 99:dbbf35b96557 548 #define __HAL_SMARTCARD_DMA_REQUEST_ENABLE(__HANDLE__, __REQUEST__) ((__HANDLE__)->Instance->CR3 |= (__REQUEST__))
Kojto 99:dbbf35b96557 549 #define __HAL_SMARTCARD_DMA_REQUEST_DISABLE(__HANDLE__, __REQUEST__) ((__HANDLE__)->Instance->CR3 &= ~(__REQUEST__))
bogdanm 89:552587b429a1 550
Kojto 99:dbbf35b96557 551 /**
Kojto 99:dbbf35b96557 552 * @}
Kojto 99:dbbf35b96557 553 */
bogdanm 89:552587b429a1 554
bogdanm 89:552587b429a1 555 /* Exported functions --------------------------------------------------------*/
Kojto 99:dbbf35b96557 556 /** @addtogroup SMARTCARD_Exported_Functions
Kojto 99:dbbf35b96557 557 * @{
Kojto 99:dbbf35b96557 558 */
Kojto 99:dbbf35b96557 559
Kojto 99:dbbf35b96557 560 /** @addtogroup SMARTCARD_Exported_Functions_Group1
Kojto 99:dbbf35b96557 561 * @{
Kojto 99:dbbf35b96557 562 */
bogdanm 89:552587b429a1 563 /* Initialization/de-initialization functions **********************************/
bogdanm 89:552587b429a1 564 HAL_StatusTypeDef HAL_SMARTCARD_Init(SMARTCARD_HandleTypeDef *hsc);
bogdanm 89:552587b429a1 565 HAL_StatusTypeDef HAL_SMARTCARD_ReInit(SMARTCARD_HandleTypeDef *hsc);
bogdanm 89:552587b429a1 566 HAL_StatusTypeDef HAL_SMARTCARD_DeInit(SMARTCARD_HandleTypeDef *hsc);
bogdanm 89:552587b429a1 567 void HAL_SMARTCARD_MspInit(SMARTCARD_HandleTypeDef *hsc);
bogdanm 89:552587b429a1 568 void HAL_SMARTCARD_MspDeInit(SMARTCARD_HandleTypeDef *hsc);
Kojto 99:dbbf35b96557 569 /**
Kojto 99:dbbf35b96557 570 * @}
Kojto 99:dbbf35b96557 571 */
Kojto 99:dbbf35b96557 572
Kojto 99:dbbf35b96557 573 /** @addtogroup SMARTCARD_Exported_Functions_Group2
Kojto 99:dbbf35b96557 574 * @{
Kojto 99:dbbf35b96557 575 */
bogdanm 89:552587b429a1 576 /* IO operation functions *******************************************************/
bogdanm 89:552587b429a1 577 HAL_StatusTypeDef HAL_SMARTCARD_Transmit(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout);
bogdanm 89:552587b429a1 578 HAL_StatusTypeDef HAL_SMARTCARD_Receive(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size, uint32_t Timeout);
bogdanm 89:552587b429a1 579 HAL_StatusTypeDef HAL_SMARTCARD_Transmit_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size);
bogdanm 89:552587b429a1 580 HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size);
bogdanm 89:552587b429a1 581 HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size);
bogdanm 89:552587b429a1 582 HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA(SMARTCARD_HandleTypeDef *hsc, uint8_t *pData, uint16_t Size);
Kojto 122:f9eeca106725 583
bogdanm 89:552587b429a1 584 void HAL_SMARTCARD_IRQHandler(SMARTCARD_HandleTypeDef *hsc);
bogdanm 89:552587b429a1 585 void HAL_SMARTCARD_TxCpltCallback(SMARTCARD_HandleTypeDef *hsc);
bogdanm 89:552587b429a1 586 void HAL_SMARTCARD_RxCpltCallback(SMARTCARD_HandleTypeDef *hsc);
bogdanm 89:552587b429a1 587 void HAL_SMARTCARD_ErrorCallback(SMARTCARD_HandleTypeDef *hsc);
Kojto 99:dbbf35b96557 588 /**
Kojto 99:dbbf35b96557 589 * @}
Kojto 99:dbbf35b96557 590 */
bogdanm 89:552587b429a1 591
Kojto 99:dbbf35b96557 592 /** @addtogroup SMARTCARD_Exported_Functions_Group3
Kojto 99:dbbf35b96557 593 * @{
Kojto 99:dbbf35b96557 594 */
bogdanm 89:552587b429a1 595 /* Peripheral State functions **************************************************/
bogdanm 89:552587b429a1 596 HAL_SMARTCARD_StateTypeDef HAL_SMARTCARD_GetState(SMARTCARD_HandleTypeDef *hsc);
Kojto 99:dbbf35b96557 597 uint32_t HAL_SMARTCARD_GetError(SMARTCARD_HandleTypeDef *hsc);
bogdanm 89:552587b429a1 598
bogdanm 89:552587b429a1 599 /**
bogdanm 89:552587b429a1 600 * @}
bogdanm 89:552587b429a1 601 */
bogdanm 89:552587b429a1 602
bogdanm 89:552587b429a1 603 /**
bogdanm 89:552587b429a1 604 * @}
bogdanm 89:552587b429a1 605 */
Kojto 99:dbbf35b96557 606 /* Private types -------------------------------------------------------------*/
Kojto 99:dbbf35b96557 607 /* Private variables ---------------------------------------------------------*/
Kojto 99:dbbf35b96557 608 /* Private constants ---------------------------------------------------------*/
Kojto 99:dbbf35b96557 609 /** @defgroup SMARTCARD_Private_Constants SMARTCARD Private Constants
Kojto 99:dbbf35b96557 610 * @{
Kojto 99:dbbf35b96557 611 */
bogdanm 89:552587b429a1 612
Kojto 99:dbbf35b96557 613 /** @brief SMARTCARD interruptions flag mask
Kojto 99:dbbf35b96557 614 *
Kojto 99:dbbf35b96557 615 */
Kojto 99:dbbf35b96557 616 #define SMARTCARD_IT_MASK ((uint32_t) USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE | USART_CR1_RXNEIE | \
Kojto 99:dbbf35b96557 617 USART_CR1_IDLEIE | USART_CR3_EIE )
Kojto 99:dbbf35b96557 618
Kojto 122:f9eeca106725 619 #define SMARTCARD_DIV(_PCLK_, _BAUD_) (((_PCLK_)*25U)/(4U*(_BAUD_)))
Kojto 122:f9eeca106725 620 #define SMARTCARD_DIVMANT(_PCLK_, _BAUD_) (SMARTCARD_DIV((_PCLK_), (_BAUD_))/100U)
Kojto 122:f9eeca106725 621 #define SMARTCARD_DIVFRAQ(_PCLK_, _BAUD_) (((SMARTCARD_DIV((_PCLK_), (_BAUD_)) - (SMARTCARD_DIVMANT((_PCLK_), (_BAUD_)) * 100U)) * 16U + 50U) / 100U)
Kojto 122:f9eeca106725 622 /* SMARTCARD BRR = mantissa + overflow + fraction
Kojto 122:f9eeca106725 623 = (SMARTCARD DIVMANT << 4) + (SMARTCARD DIVFRAQ & 0xF0) + (SMARTCARD DIVFRAQ & 0x0FU) */
Kojto 122:f9eeca106725 624 #define SMARTCARD_BRR(_PCLK_, _BAUD_) (((SMARTCARD_DIVMANT((_PCLK_), (_BAUD_)) << 4U) + \
Kojto 122:f9eeca106725 625 (SMARTCARD_DIVFRAQ((_PCLK_), (_BAUD_)) & 0xF0U)) + \
Kojto 122:f9eeca106725 626 (SMARTCARD_DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0FU))
Kojto 122:f9eeca106725 627
Kojto 122:f9eeca106725 628 #define SMARTCARD_CR1_REG_INDEX 1U
Kojto 122:f9eeca106725 629 #define SMARTCARD_CR3_REG_INDEX 3U
Kojto 99:dbbf35b96557 630 /**
Kojto 99:dbbf35b96557 631 * @}
Kojto 99:dbbf35b96557 632 */
Kojto 99:dbbf35b96557 633
Kojto 99:dbbf35b96557 634 /* Private macros --------------------------------------------------------*/
Kojto 99:dbbf35b96557 635 /** @defgroup SMARTCARD_Private_Macros SMARTCARD Private Macros
Kojto 99:dbbf35b96557 636 * @{
Kojto 99:dbbf35b96557 637 */
Kojto 99:dbbf35b96557 638 #define IS_SMARTCARD_WORD_LENGTH(LENGTH) ((LENGTH) == SMARTCARD_WORDLENGTH_9B)
Kojto 99:dbbf35b96557 639 #define IS_SMARTCARD_STOPBITS(STOPBITS) (((STOPBITS) == SMARTCARD_STOPBITS_0_5) || \
Kojto 99:dbbf35b96557 640 ((STOPBITS) == SMARTCARD_STOPBITS_1_5))
Kojto 99:dbbf35b96557 641 #define IS_SMARTCARD_PARITY(PARITY) (((PARITY) == SMARTCARD_PARITY_EVEN) || \
Kojto 99:dbbf35b96557 642 ((PARITY) == SMARTCARD_PARITY_ODD))
Kojto 122:f9eeca106725 643 #define IS_SMARTCARD_MODE(MODE) ((((MODE) & (uint32_t)0x0000FFF3U) == 0x00U) && ((MODE) != (uint32_t)0x000000U))
Kojto 99:dbbf35b96557 644 #define IS_SMARTCARD_POLARITY(CPOL) (((CPOL) == SMARTCARD_POLARITY_LOW) || ((CPOL) == SMARTCARD_POLARITY_HIGH))
Kojto 99:dbbf35b96557 645 #define IS_SMARTCARD_PHASE(CPHA) (((CPHA) == SMARTCARD_PHASE_1EDGE) || ((CPHA) == SMARTCARD_PHASE_2EDGE))
Kojto 99:dbbf35b96557 646 #define IS_SMARTCARD_LASTBIT(LASTBIT) (((LASTBIT) == SMARTCARD_LASTBIT_DISABLE) || \
Kojto 99:dbbf35b96557 647 ((LASTBIT) == SMARTCARD_LASTBIT_ENABLE))
Kojto 99:dbbf35b96557 648 #define IS_SMARTCARD_NACK_STATE(NACK) (((NACK) == SMARTCARD_NACK_ENABLE) || \
Kojto 99:dbbf35b96557 649 ((NACK) == SMARTCARD_NACK_DISABLE))
Kojto 122:f9eeca106725 650 #define IS_SMARTCARD_BAUDRATE(BAUDRATE) ((BAUDRATE) < 10500001U)
Kojto 99:dbbf35b96557 651 /**
Kojto 99:dbbf35b96557 652 * @}
Kojto 99:dbbf35b96557 653 */
Kojto 99:dbbf35b96557 654
Kojto 99:dbbf35b96557 655 /* Private functions ---------------------------------------------------------*/
Kojto 99:dbbf35b96557 656 /** @defgroup SMARTCARD_Private_Functions SMARTCARD Private Functions
Kojto 99:dbbf35b96557 657 * @{
Kojto 99:dbbf35b96557 658 */
Kojto 99:dbbf35b96557 659
Kojto 99:dbbf35b96557 660 /**
Kojto 99:dbbf35b96557 661 * @}
Kojto 99:dbbf35b96557 662 */
Kojto 99:dbbf35b96557 663
Kojto 99:dbbf35b96557 664 /**
Kojto 99:dbbf35b96557 665 * @}
Kojto 99:dbbf35b96557 666 */
Kojto 99:dbbf35b96557 667
Kojto 99:dbbf35b96557 668 /**
Kojto 99:dbbf35b96557 669 * @}
Kojto 99:dbbf35b96557 670 */
bogdanm 89:552587b429a1 671 #ifdef __cplusplus
bogdanm 89:552587b429a1 672 }
bogdanm 89:552587b429a1 673 #endif
bogdanm 89:552587b429a1 674
bogdanm 89:552587b429a1 675 #endif /* __STM32F4xx_HAL_SMARTCARD_H */
bogdanm 89:552587b429a1 676
bogdanm 89:552587b429a1 677 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/