mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Revision:
156:95d6b41a828b
Parent:
149:156823d33999
Child:
180:96ed750bd169
--- a/targets/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_hal_smartcard_ex.c	Thu Jan 05 10:51:54 2017 +0000
+++ b/targets/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_hal_smartcard_ex.c	Mon Jan 16 15:03:32 2017 +0000
@@ -2,14 +2,13 @@
   ******************************************************************************
   * @file    stm32f0xx_hal_smartcard_ex.c
   * @author  MCD Application Team
-  * @version V1.4.0
-  * @date    27-May-2016
+  * @version V1.5.0
+  * @date    04-November-2016
   * @brief   SMARTCARD HAL module driver.
-  *
   *          This file provides extended firmware functions to manage the following
   *          functionalities of the SmartCard.
-  *           + Initialization and de-initialization function
-  *           + Peripheral Control function
+  *           + Initialization and de-initialization functions
+  *           + Peripheral Control functions
   *
   *
   @verbatim
@@ -59,8 +58,6 @@
 /* Includes ------------------------------------------------------------------*/
 #include "stm32f0xx_hal.h"
 
-#ifdef HAL_SMARTCARD_MODULE_ENABLED
-
 #if !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC)
 
 /** @addtogroup STM32F0xx_HAL_Driver
@@ -71,6 +68,7 @@
   * @brief SMARTCARD Extended HAL module driver
   * @{
   */
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
 
 /* Private typedef -----------------------------------------------------------*/
 /* Private define ------------------------------------------------------------*/
@@ -79,7 +77,7 @@
 /* Private function prototypes -----------------------------------------------*/
 
 /* Exported functions --------------------------------------------------------*/
-/** @defgroup SMARTCARDEx_Exported_Functions  SMARTCARDEx Exported Functions
+/** @defgroup SMARTCARDEx_Exported_Functions  SMARTCARD Extended Exported Functions
   * @{
   */
 
@@ -136,20 +134,27 @@
 HAL_StatusTypeDef HAL_SMARTCARDEx_EnableReceiverTimeOut(SMARTCARD_HandleTypeDef *hsmartcard)
 {
 
-  /* Process Locked */
-  __HAL_LOCK(hsmartcard);
+  if(hsmartcard->gState == HAL_SMARTCARD_STATE_READY)
+  {
+    /* Process Locked */
+    __HAL_LOCK(hsmartcard);
 
-  hsmartcard->gState = HAL_SMARTCARD_STATE_BUSY;
+    hsmartcard->gState = HAL_SMARTCARD_STATE_BUSY;
+
+    /* Set the USART RTOEN bit */
+    SET_BIT(hsmartcard->Instance->CR2, USART_CR2_RTOEN);
 
-  /* Set the USART RTOEN bit */
-  hsmartcard->Instance->CR2 |= USART_CR2_RTOEN;
+    hsmartcard->gState = HAL_SMARTCARD_STATE_READY;
 
-  hsmartcard->gState = HAL_SMARTCARD_STATE_READY;
+    /* Process Unlocked */
+    __HAL_UNLOCK(hsmartcard);
 
-  /* Process Unlocked */
-  __HAL_UNLOCK(hsmartcard);
-
-  return HAL_OK;
+    return HAL_OK;
+  }
+  else
+  {
+    return HAL_BUSY;
+  }
 }
 
 /**
@@ -161,20 +166,27 @@
 HAL_StatusTypeDef HAL_SMARTCARDEx_DisableReceiverTimeOut(SMARTCARD_HandleTypeDef *hsmartcard)
 {
 
-  /* Process Locked */
-  __HAL_LOCK(hsmartcard);
+  if(hsmartcard->gState == HAL_SMARTCARD_STATE_READY)
+  {
+    /* Process Locked */
+    __HAL_LOCK(hsmartcard);
 
-  hsmartcard->gState = HAL_SMARTCARD_STATE_BUSY;
+    hsmartcard->gState = HAL_SMARTCARD_STATE_BUSY;
+
+    /* Clear the USART RTOEN bit */
+    CLEAR_BIT(hsmartcard->Instance->CR2, USART_CR2_RTOEN);
 
-  /* Clear the USART RTOEN bit */
-  hsmartcard->Instance->CR2 &= ~(USART_CR2_RTOEN);
+    hsmartcard->gState = HAL_SMARTCARD_STATE_READY;
 
-  hsmartcard->gState = HAL_SMARTCARD_STATE_READY;
+    /* Process Unlocked */
+    __HAL_UNLOCK(hsmartcard);
 
-  /* Process Unlocked */
-  __HAL_UNLOCK(hsmartcard);
-
-  return HAL_OK;
+    return HAL_OK;
+  }
+  else
+  {
+    return HAL_BUSY;
+  }
 }
 
 /**
@@ -185,6 +197,8 @@
   * @}
   */
 
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
 /**
   * @}
   */
@@ -195,6 +209,4 @@
 
 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC)  */
 
-#endif /* HAL_SMARTCARD_MODULE_ENABLED */
-
 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/