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:
Thu Oct 09 08:15:07 2014 +0100
Revision:
340:28d1f895c6fe
Synchronized with git revision b5a4c8e80393336b2656fb29ab46d405d3068602

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

HAL: nrf51822 - Few fixes for PWM and Serial

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 340:28d1f895c6fe 5 * @version V1.1.0
mbed_official 340:28d1f895c6fe 6 * @date 03-Oct-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 340:28d1f895c6fe 63 /** @addtogroup STM32F0xx_HAL_Driver
mbed_official 340:28d1f895c6fe 64 * @{
mbed_official 340:28d1f895c6fe 65 */
mbed_official 340:28d1f895c6fe 66
mbed_official 340:28d1f895c6fe 67 /** @defgroup SMARTCARDEx SMARTCARD Extended HAL module driver
mbed_official 340:28d1f895c6fe 68 * @brief SMARTCARD Extended HAL module driver
mbed_official 340:28d1f895c6fe 69 * @{
mbed_official 340:28d1f895c6fe 70 */
mbed_official 340:28d1f895c6fe 71 #ifdef HAL_SMARTCARD_MODULE_ENABLED
mbed_official 340:28d1f895c6fe 72
mbed_official 340:28d1f895c6fe 73 #if !defined(STM32F030x6) && !defined(STM32F030x8)
mbed_official 340:28d1f895c6fe 74
mbed_official 340:28d1f895c6fe 75 /* Private typedef -----------------------------------------------------------*/
mbed_official 340:28d1f895c6fe 76 /* Private define ------------------------------------------------------------*/
mbed_official 340:28d1f895c6fe 77 /* Private macro -------------------------------------------------------------*/
mbed_official 340:28d1f895c6fe 78 /* Private variables ---------------------------------------------------------*/
mbed_official 340:28d1f895c6fe 79 /* Private function prototypes -----------------------------------------------*/
mbed_official 340:28d1f895c6fe 80 /* Exported functions ---------------------------------------------------------*/
mbed_official 340:28d1f895c6fe 81
mbed_official 340:28d1f895c6fe 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 340:28d1f895c6fe 89 @verbatim
mbed_official 340:28d1f895c6fe 90 ===============================================================================
mbed_official 340:28d1f895c6fe 91 ##### Peripheral Control functions #####
mbed_official 340:28d1f895c6fe 92 ===============================================================================
mbed_official 340:28d1f895c6fe 93 [..]
mbed_official 340:28d1f895c6fe 94 This subsection provides a set of functions allowing to initialize the SMARTCARD.
mbed_official 340:28d1f895c6fe 95 (+) HAL_SMARTCARDEx_BlockLength_Config() API allows to configure the Block Length on the fly
mbed_official 340:28d1f895c6fe 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 340:28d1f895c6fe 98 (+) HAL_SMARTCARDEx_DisableReceiverTimeOut() API disables the receiver timeout feature
mbed_official 340:28d1f895c6fe 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 340:28d1f895c6fe 105 * @brief Update on the fly the SMARTCARD block length in RTOR register
mbed_official 340:28d1f895c6fe 106 * @param hsmartcard: SMARTCARD handle
mbed_official 340:28d1f895c6fe 107 * @param BlockLength: SMARTCARD block length (8-bit long at most)
mbed_official 340:28d1f895c6fe 108 * @retval None
mbed_official 340:28d1f895c6fe 109 */
mbed_official 340:28d1f895c6fe 110 void HAL_SMARTCARDEx_BlockLength_Config(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t BlockLength)
mbed_official 340:28d1f895c6fe 111 {
mbed_official 340:28d1f895c6fe 112 MODIFY_REG(hsmartcard->Instance->RTOR, USART_RTOR_BLEN, ((uint32_t)BlockLength << SMARTCARD_RTOR_BLEN_LSB_POS));
mbed_official 340:28d1f895c6fe 113 }
mbed_official 340:28d1f895c6fe 114
mbed_official 340:28d1f895c6fe 115 /**
mbed_official 340:28d1f895c6fe 116 * @brief Update on the fly the receiver timeout value in RTOR register
mbed_official 340:28d1f895c6fe 117 * @param hsmartcard: SMARTCARD handle
mbed_official 340:28d1f895c6fe 118 * @param TimeOutValue: receiver timeout value in number of baud blocks. The timeout
mbed_official 340:28d1f895c6fe 119 * value must be less or equal to 0x0FFFFFFFF.
mbed_official 340:28d1f895c6fe 120 * @retval None
mbed_official 340:28d1f895c6fe 121 */
mbed_official 340:28d1f895c6fe 122 void HAL_SMARTCARDEx_TimeOut_Config(SMARTCARD_HandleTypeDef *hsmartcard, uint32_t TimeOutValue)
mbed_official 340:28d1f895c6fe 123 {
mbed_official 340:28d1f895c6fe 124 assert_param(IS_SMARTCARD_TIMEOUT_VALUE(hsmartcard->Init.TimeOutValue));
mbed_official 340:28d1f895c6fe 125 MODIFY_REG(hsmartcard->Instance->RTOR, USART_RTOR_RTO, TimeOutValue);
mbed_official 340:28d1f895c6fe 126 }
mbed_official 340:28d1f895c6fe 127
mbed_official 340:28d1f895c6fe 128 /**
mbed_official 340:28d1f895c6fe 129 * @brief Enable the SMARTCARD receiver timeout feature
mbed_official 340:28d1f895c6fe 130 * @param hsmartcard: SMARTCARD handle
mbed_official 340:28d1f895c6fe 131 * @retval HAL status
mbed_official 340:28d1f895c6fe 132 */
mbed_official 340:28d1f895c6fe 133 HAL_StatusTypeDef HAL_SMARTCARDEx_EnableReceiverTimeOut(SMARTCARD_HandleTypeDef *hsmartcard)
mbed_official 340:28d1f895c6fe 134 {
mbed_official 340:28d1f895c6fe 135
mbed_official 340:28d1f895c6fe 136 /* Process Locked */
mbed_official 340:28d1f895c6fe 137 __HAL_LOCK(hsmartcard);
mbed_official 340:28d1f895c6fe 138
mbed_official 340:28d1f895c6fe 139 hsmartcard->State = HAL_SMARTCARD_STATE_BUSY;
mbed_official 340:28d1f895c6fe 140
mbed_official 340:28d1f895c6fe 141 /* Set the USART RTOEN bit */
mbed_official 340:28d1f895c6fe 142 hsmartcard->Instance->CR2 |= USART_CR2_RTOEN;
mbed_official 340:28d1f895c6fe 143
mbed_official 340:28d1f895c6fe 144 hsmartcard->State = HAL_SMARTCARD_STATE_READY;
mbed_official 340:28d1f895c6fe 145
mbed_official 340:28d1f895c6fe 146 /* Process Unlocked */
mbed_official 340:28d1f895c6fe 147 __HAL_UNLOCK(hsmartcard);
mbed_official 340:28d1f895c6fe 148
mbed_official 340:28d1f895c6fe 149 return HAL_OK;
mbed_official 340:28d1f895c6fe 150 }
mbed_official 340:28d1f895c6fe 151
mbed_official 340:28d1f895c6fe 152 /**
mbed_official 340:28d1f895c6fe 153 * @brief Disable the SMARTCARD receiver timeout feature
mbed_official 340:28d1f895c6fe 154 * @param hsmartcard: SMARTCARD handle
mbed_official 340:28d1f895c6fe 155 * @retval HAL status
mbed_official 340:28d1f895c6fe 156 */
mbed_official 340:28d1f895c6fe 157 HAL_StatusTypeDef HAL_SMARTCARDEx_DisableReceiverTimeOut(SMARTCARD_HandleTypeDef *hsmartcard)
mbed_official 340:28d1f895c6fe 158 {
mbed_official 340:28d1f895c6fe 159
mbed_official 340:28d1f895c6fe 160 /* Process Locked */
mbed_official 340:28d1f895c6fe 161 __HAL_LOCK(hsmartcard);
mbed_official 340:28d1f895c6fe 162
mbed_official 340:28d1f895c6fe 163 hsmartcard->State = HAL_SMARTCARD_STATE_BUSY;
mbed_official 340:28d1f895c6fe 164
mbed_official 340:28d1f895c6fe 165 /* Clear the USART RTOEN bit */
mbed_official 340:28d1f895c6fe 166 hsmartcard->Instance->CR2 &= ~(USART_CR2_RTOEN);
mbed_official 340:28d1f895c6fe 167
mbed_official 340:28d1f895c6fe 168 hsmartcard->State = HAL_SMARTCARD_STATE_READY;
mbed_official 340:28d1f895c6fe 169
mbed_official 340:28d1f895c6fe 170 /* Process Unlocked */
mbed_official 340:28d1f895c6fe 171 __HAL_UNLOCK(hsmartcard);
mbed_official 340:28d1f895c6fe 172
mbed_official 340:28d1f895c6fe 173 return HAL_OK;
mbed_official 340:28d1f895c6fe 174 }
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 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) */
mbed_official 340:28d1f895c6fe 185
mbed_official 340:28d1f895c6fe 186 #endif /* HAL_SMARTCARD_MODULE_ENABLED */
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 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/