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