mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Mon Sep 28 10:45:10 2015 +0100
Revision:
630:825f75ca301e
Parent:
441:d2c15dda23c1
Synchronized with git revision 54fbe4144faf309c37205a5d39fa665daa919f10

Full URL: https://github.com/mbedmicro/mbed/commit/54fbe4144faf309c37205a5d39fa665daa919f10/

NUCLEO_F031K6 : Add new target

Who changed what in which revision?

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