mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Thu May 22 20:00:09 2014 +0100
Revision:
205:c41fc65bcfb4
Child:
218:44081b78fdc2
Synchronized with git revision ea4b6f76efab17a3f7d7777b0cc1ef05fec6d1cb

Full URL: https://github.com/mbedmicro/mbed/commit/ea4b6f76efab17a3f7d7777b0cc1ef05fec6d1cb/

[NUCLEO_F072RB] cmsis files

Who changed what in which revision?

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