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