mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
targets/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_hal_smartcard_ex.c@156:95d6b41a828b, 2017-01-16 (annotated)
- Committer:
- <>
- Date:
- Mon Jan 16 15:03:32 2017 +0000
- Revision:
- 156:95d6b41a828b
- Parent:
- 149:156823d33999
- Child:
- 180:96ed750bd169
This updates the lib to the mbed lib v134
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 144:ef7eb2e8f9f7 | 1 | /** |
<> | 144:ef7eb2e8f9f7 | 2 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 3 | * @file stm32f0xx_hal_smartcard_ex.c |
<> | 144:ef7eb2e8f9f7 | 4 | * @author MCD Application Team |
<> | 156:95d6b41a828b | 5 | * @version V1.5.0 |
<> | 156:95d6b41a828b | 6 | * @date 04-November-2016 |
<> | 144:ef7eb2e8f9f7 | 7 | * @brief SMARTCARD HAL module driver. |
<> | 144:ef7eb2e8f9f7 | 8 | * This file provides extended firmware functions to manage the following |
<> | 144:ef7eb2e8f9f7 | 9 | * functionalities of the SmartCard. |
<> | 156:95d6b41a828b | 10 | * + Initialization and de-initialization functions |
<> | 156:95d6b41a828b | 11 | * + Peripheral Control functions |
<> | 144:ef7eb2e8f9f7 | 12 | * |
<> | 144:ef7eb2e8f9f7 | 13 | * |
<> | 144:ef7eb2e8f9f7 | 14 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 15 | ============================================================================= |
<> | 144:ef7eb2e8f9f7 | 16 | ##### SMARTCARD peripheral extended features ##### |
<> | 144:ef7eb2e8f9f7 | 17 | ============================================================================= |
<> | 144:ef7eb2e8f9f7 | 18 | [..] |
<> | 144:ef7eb2e8f9f7 | 19 | The Extended SMARTCARD HAL driver can be used as follows: |
<> | 144:ef7eb2e8f9f7 | 20 | |
<> | 144:ef7eb2e8f9f7 | 21 | (#) After having configured the SMARTCARD basic features with HAL_SMARTCARD_Init(), |
<> | 144:ef7eb2e8f9f7 | 22 | then program SMARTCARD advanced features if required (TX/RX pins swap, TimeOut, |
<> | 144:ef7eb2e8f9f7 | 23 | auto-retry counter,...) in the hsmartcard AdvancedInit structure. |
<> | 144:ef7eb2e8f9f7 | 24 | |
<> | 144:ef7eb2e8f9f7 | 25 | |
<> | 144:ef7eb2e8f9f7 | 26 | |
<> | 144:ef7eb2e8f9f7 | 27 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 28 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 29 | * @attention |
<> | 144:ef7eb2e8f9f7 | 30 | * |
<> | 144:ef7eb2e8f9f7 | 31 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
<> | 144:ef7eb2e8f9f7 | 32 | * |
<> | 144:ef7eb2e8f9f7 | 33 | * Redistribution and use in source and binary forms, with or without modification, |
<> | 144:ef7eb2e8f9f7 | 34 | * are permitted provided that the following conditions are met: |
<> | 144:ef7eb2e8f9f7 | 35 | * 1. Redistributions of source code must retain the above copyright notice, |
<> | 144:ef7eb2e8f9f7 | 36 | * this list of conditions and the following disclaimer. |
<> | 144:ef7eb2e8f9f7 | 37 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
<> | 144:ef7eb2e8f9f7 | 38 | * this list of conditions and the following disclaimer in the documentation |
<> | 144:ef7eb2e8f9f7 | 39 | * and/or other materials provided with the distribution. |
<> | 144:ef7eb2e8f9f7 | 40 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
<> | 144:ef7eb2e8f9f7 | 41 | * may be used to endorse or promote products derived from this software |
<> | 144:ef7eb2e8f9f7 | 42 | * without specific prior written permission. |
<> | 144:ef7eb2e8f9f7 | 43 | * |
<> | 144:ef7eb2e8f9f7 | 44 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
<> | 144:ef7eb2e8f9f7 | 45 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
<> | 144:ef7eb2e8f9f7 | 46 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
<> | 144:ef7eb2e8f9f7 | 47 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
<> | 144:ef7eb2e8f9f7 | 48 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
<> | 144:ef7eb2e8f9f7 | 49 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
<> | 144:ef7eb2e8f9f7 | 50 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
<> | 144:ef7eb2e8f9f7 | 51 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
<> | 144:ef7eb2e8f9f7 | 52 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
<> | 144:ef7eb2e8f9f7 | 53 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
<> | 144:ef7eb2e8f9f7 | 54 | * |
<> | 144:ef7eb2e8f9f7 | 55 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 56 | */ |
<> | 144:ef7eb2e8f9f7 | 57 | |
<> | 144:ef7eb2e8f9f7 | 58 | /* Includes ------------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 59 | #include "stm32f0xx_hal.h" |
<> | 144:ef7eb2e8f9f7 | 60 | |
<> | 144:ef7eb2e8f9f7 | 61 | #if !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) |
<> | 144:ef7eb2e8f9f7 | 62 | |
<> | 144:ef7eb2e8f9f7 | 63 | /** @addtogroup STM32F0xx_HAL_Driver |
<> | 144:ef7eb2e8f9f7 | 64 | * @{ |
<> | 144:ef7eb2e8f9f7 | 65 | */ |
<> | 144:ef7eb2e8f9f7 | 66 | |
<> | 144:ef7eb2e8f9f7 | 67 | /** @defgroup SMARTCARDEx SMARTCARDEx |
<> | 144:ef7eb2e8f9f7 | 68 | * @brief SMARTCARD Extended HAL module driver |
<> | 144:ef7eb2e8f9f7 | 69 | * @{ |
<> | 144:ef7eb2e8f9f7 | 70 | */ |
<> | 156:95d6b41a828b | 71 | #ifdef HAL_SMARTCARD_MODULE_ENABLED |
<> | 144:ef7eb2e8f9f7 | 72 | |
<> | 144:ef7eb2e8f9f7 | 73 | /* Private typedef -----------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 74 | /* Private define ------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 75 | /* Private macros ------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 76 | /* Private variables ---------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 77 | /* Private function prototypes -----------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 78 | |
<> | 144:ef7eb2e8f9f7 | 79 | /* Exported functions --------------------------------------------------------*/ |
<> | 156:95d6b41a828b | 80 | /** @defgroup SMARTCARDEx_Exported_Functions SMARTCARD Extended Exported Functions |
<> | 144:ef7eb2e8f9f7 | 81 | * @{ |
<> | 144:ef7eb2e8f9f7 | 82 | */ |
<> | 144:ef7eb2e8f9f7 | 83 | |
<> | 144:ef7eb2e8f9f7 | 84 | /** @defgroup SMARTCARDEx_Exported_Functions_Group1 Extended Peripheral Control functions |
<> | 144:ef7eb2e8f9f7 | 85 | * @brief Extended control functions |
<> | 144:ef7eb2e8f9f7 | 86 | * |
<> | 144:ef7eb2e8f9f7 | 87 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 88 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 89 | ##### Peripheral Control functions ##### |
<> | 144:ef7eb2e8f9f7 | 90 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 91 | [..] |
<> | 144:ef7eb2e8f9f7 | 92 | This subsection provides a set of functions allowing to initialize the SMARTCARD. |
<> | 144:ef7eb2e8f9f7 | 93 | (+) HAL_SMARTCARDEx_BlockLength_Config() API allows to configure the Block Length on the fly |
<> | 144:ef7eb2e8f9f7 | 94 | (+) HAL_SMARTCARDEx_TimeOut_Config() API allows to configure the receiver timeout value on the fly |
<> | 144:ef7eb2e8f9f7 | 95 | (+) HAL_SMARTCARDEx_EnableReceiverTimeOut() API enables the receiver timeout feature |
<> | 144:ef7eb2e8f9f7 | 96 | (+) HAL_SMARTCARDEx_DisableReceiverTimeOut() API disables the receiver timeout feature |
<> | 144:ef7eb2e8f9f7 | 97 | |
<> | 144:ef7eb2e8f9f7 | 98 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 99 | * @{ |
<> | 144:ef7eb2e8f9f7 | 100 | */ |
<> | 144:ef7eb2e8f9f7 | 101 | |
<> | 144:ef7eb2e8f9f7 | 102 | /** |
<> | 144:ef7eb2e8f9f7 | 103 | * @brief Update on the fly the SMARTCARD block length in RTOR register. |
<> | 144:ef7eb2e8f9f7 | 104 | * @param hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains |
<> | 144:ef7eb2e8f9f7 | 105 | * the configuration information for the specified SMARTCARD module. |
<> | 144:ef7eb2e8f9f7 | 106 | * @param BlockLength: SMARTCARD block length (8-bit long at most) |
<> | 144:ef7eb2e8f9f7 | 107 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 108 | */ |
<> | 144:ef7eb2e8f9f7 | 109 | void HAL_SMARTCARDEx_BlockLength_Config(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t BlockLength) |
<> | 144:ef7eb2e8f9f7 | 110 | { |
<> | 144:ef7eb2e8f9f7 | 111 | MODIFY_REG(hsmartcard->Instance->RTOR, USART_RTOR_BLEN, ((uint32_t)BlockLength << SMARTCARD_RTOR_BLEN_LSB_POS)); |
<> | 144:ef7eb2e8f9f7 | 112 | } |
<> | 144:ef7eb2e8f9f7 | 113 | |
<> | 144:ef7eb2e8f9f7 | 114 | /** |
<> | 144:ef7eb2e8f9f7 | 115 | * @brief Update on the fly the receiver timeout value in RTOR register. |
<> | 144:ef7eb2e8f9f7 | 116 | * @param hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains |
<> | 144:ef7eb2e8f9f7 | 117 | * the configuration information for the specified SMARTCARD module. |
<> | 144:ef7eb2e8f9f7 | 118 | * @param TimeOutValue: receiver timeout value in number of baud blocks. The timeout |
<> | 144:ef7eb2e8f9f7 | 119 | * value must be less or equal to 0x0FFFFFFFF. |
<> | 144:ef7eb2e8f9f7 | 120 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 121 | */ |
<> | 144:ef7eb2e8f9f7 | 122 | void HAL_SMARTCARDEx_TimeOut_Config(SMARTCARD_HandleTypeDef *hsmartcard, uint32_t TimeOutValue) |
<> | 144:ef7eb2e8f9f7 | 123 | { |
<> | 144:ef7eb2e8f9f7 | 124 | assert_param(IS_SMARTCARD_TIMEOUT_VALUE(hsmartcard->Init.TimeOutValue)); |
<> | 144:ef7eb2e8f9f7 | 125 | MODIFY_REG(hsmartcard->Instance->RTOR, USART_RTOR_RTO, TimeOutValue); |
<> | 144:ef7eb2e8f9f7 | 126 | } |
<> | 144:ef7eb2e8f9f7 | 127 | |
<> | 144:ef7eb2e8f9f7 | 128 | /** |
<> | 144:ef7eb2e8f9f7 | 129 | * @brief Enable the SMARTCARD receiver timeout feature. |
<> | 144:ef7eb2e8f9f7 | 130 | * @param hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains |
<> | 144:ef7eb2e8f9f7 | 131 | * the configuration information for the specified SMARTCARD module. |
<> | 144:ef7eb2e8f9f7 | 132 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 133 | */ |
<> | 144:ef7eb2e8f9f7 | 134 | HAL_StatusTypeDef HAL_SMARTCARDEx_EnableReceiverTimeOut(SMARTCARD_HandleTypeDef *hsmartcard) |
<> | 144:ef7eb2e8f9f7 | 135 | { |
<> | 144:ef7eb2e8f9f7 | 136 | |
<> | 156:95d6b41a828b | 137 | if(hsmartcard->gState == HAL_SMARTCARD_STATE_READY) |
<> | 156:95d6b41a828b | 138 | { |
<> | 156:95d6b41a828b | 139 | /* Process Locked */ |
<> | 156:95d6b41a828b | 140 | __HAL_LOCK(hsmartcard); |
<> | 144:ef7eb2e8f9f7 | 141 | |
<> | 156:95d6b41a828b | 142 | hsmartcard->gState = HAL_SMARTCARD_STATE_BUSY; |
<> | 156:95d6b41a828b | 143 | |
<> | 156:95d6b41a828b | 144 | /* Set the USART RTOEN bit */ |
<> | 156:95d6b41a828b | 145 | SET_BIT(hsmartcard->Instance->CR2, USART_CR2_RTOEN); |
<> | 144:ef7eb2e8f9f7 | 146 | |
<> | 156:95d6b41a828b | 147 | hsmartcard->gState = HAL_SMARTCARD_STATE_READY; |
<> | 144:ef7eb2e8f9f7 | 148 | |
<> | 156:95d6b41a828b | 149 | /* Process Unlocked */ |
<> | 156:95d6b41a828b | 150 | __HAL_UNLOCK(hsmartcard); |
<> | 144:ef7eb2e8f9f7 | 151 | |
<> | 156:95d6b41a828b | 152 | return HAL_OK; |
<> | 156:95d6b41a828b | 153 | } |
<> | 156:95d6b41a828b | 154 | else |
<> | 156:95d6b41a828b | 155 | { |
<> | 156:95d6b41a828b | 156 | return HAL_BUSY; |
<> | 156:95d6b41a828b | 157 | } |
<> | 144:ef7eb2e8f9f7 | 158 | } |
<> | 144:ef7eb2e8f9f7 | 159 | |
<> | 144:ef7eb2e8f9f7 | 160 | /** |
<> | 144:ef7eb2e8f9f7 | 161 | * @brief Disable the SMARTCARD receiver timeout feature. |
<> | 144:ef7eb2e8f9f7 | 162 | * @param hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains |
<> | 144:ef7eb2e8f9f7 | 163 | * the configuration information for the specified SMARTCARD module. |
<> | 144:ef7eb2e8f9f7 | 164 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 165 | */ |
<> | 144:ef7eb2e8f9f7 | 166 | HAL_StatusTypeDef HAL_SMARTCARDEx_DisableReceiverTimeOut(SMARTCARD_HandleTypeDef *hsmartcard) |
<> | 144:ef7eb2e8f9f7 | 167 | { |
<> | 144:ef7eb2e8f9f7 | 168 | |
<> | 156:95d6b41a828b | 169 | if(hsmartcard->gState == HAL_SMARTCARD_STATE_READY) |
<> | 156:95d6b41a828b | 170 | { |
<> | 156:95d6b41a828b | 171 | /* Process Locked */ |
<> | 156:95d6b41a828b | 172 | __HAL_LOCK(hsmartcard); |
<> | 144:ef7eb2e8f9f7 | 173 | |
<> | 156:95d6b41a828b | 174 | hsmartcard->gState = HAL_SMARTCARD_STATE_BUSY; |
<> | 156:95d6b41a828b | 175 | |
<> | 156:95d6b41a828b | 176 | /* Clear the USART RTOEN bit */ |
<> | 156:95d6b41a828b | 177 | CLEAR_BIT(hsmartcard->Instance->CR2, USART_CR2_RTOEN); |
<> | 144:ef7eb2e8f9f7 | 178 | |
<> | 156:95d6b41a828b | 179 | hsmartcard->gState = HAL_SMARTCARD_STATE_READY; |
<> | 144:ef7eb2e8f9f7 | 180 | |
<> | 156:95d6b41a828b | 181 | /* Process Unlocked */ |
<> | 156:95d6b41a828b | 182 | __HAL_UNLOCK(hsmartcard); |
<> | 144:ef7eb2e8f9f7 | 183 | |
<> | 156:95d6b41a828b | 184 | return HAL_OK; |
<> | 156:95d6b41a828b | 185 | } |
<> | 156:95d6b41a828b | 186 | else |
<> | 156:95d6b41a828b | 187 | { |
<> | 156:95d6b41a828b | 188 | return HAL_BUSY; |
<> | 156:95d6b41a828b | 189 | } |
<> | 144:ef7eb2e8f9f7 | 190 | } |
<> | 144:ef7eb2e8f9f7 | 191 | |
<> | 144:ef7eb2e8f9f7 | 192 | /** |
<> | 144:ef7eb2e8f9f7 | 193 | * @} |
<> | 144:ef7eb2e8f9f7 | 194 | */ |
<> | 144:ef7eb2e8f9f7 | 195 | |
<> | 144:ef7eb2e8f9f7 | 196 | /** |
<> | 144:ef7eb2e8f9f7 | 197 | * @} |
<> | 144:ef7eb2e8f9f7 | 198 | */ |
<> | 144:ef7eb2e8f9f7 | 199 | |
<> | 156:95d6b41a828b | 200 | #endif /* HAL_SMARTCARD_MODULE_ENABLED */ |
<> | 156:95d6b41a828b | 201 | |
<> | 144:ef7eb2e8f9f7 | 202 | /** |
<> | 144:ef7eb2e8f9f7 | 203 | * @} |
<> | 144:ef7eb2e8f9f7 | 204 | */ |
<> | 144:ef7eb2e8f9f7 | 205 | |
<> | 144:ef7eb2e8f9f7 | 206 | /** |
<> | 144:ef7eb2e8f9f7 | 207 | * @} |
<> | 144:ef7eb2e8f9f7 | 208 | */ |
<> | 144:ef7eb2e8f9f7 | 209 | |
<> | 144:ef7eb2e8f9f7 | 210 | #endif /* !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */ |
<> | 144:ef7eb2e8f9f7 | 211 | |
<> | 144:ef7eb2e8f9f7 | 212 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |