mbed library sources

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Tue Jan 06 16:15:36 2015 +0000
Revision:
441:d2c15dda23c1
Parent:
392:2b59412bb664
Synchronized with git revision 245a60b29caabb42eabdd19658eeac7c3f68313b

Full URL: https://github.com/mbedmicro/mbed/commit/245a60b29caabb42eabdd19658eeac7c3f68313b/

NUCLEO_F072RB/F091RC - adding target to rtos lib and exporter for coide and gcc_arm

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