mbed(SerialHalfDuplex入り)

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Mar 17 14:27:45 2015 +0000
Revision:
96:487b796308b0
Release 96 of the mbed library

Changes:
- IAR support for ble boards, lpc, ethernet stack
- RTC - attach function to redirect time functions
- Nucleo F103RB - cube driver
- k20xx - fixes for teensy and k20 platforms in sleep/deepsleep and usb
- STM32L0, Nucleo/Disco L053 - refactoring

Who changed what in which revision?

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