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.

Revision:
630:825f75ca301e
Parent:
441:d2c15dda23c1
--- a/targets/cmsis/TARGET_STM/TARGET_STM32F0/stm32f0xx_hal_adc_ex.c	Mon Sep 28 10:30:09 2015 +0100
+++ b/targets/cmsis/TARGET_STM/TARGET_STM32F0/stm32f0xx_hal_adc_ex.c	Mon Sep 28 10:45:10 2015 +0100
@@ -2,109 +2,26 @@
   ******************************************************************************
   * @file    stm32f0xx_hal_adc_ex.c
   * @author  MCD Application Team
-  * @version V1.2.0
-  * @date    11-December-2014
+  * @version V1.3.0
+  * @date    26-June-2015
   * @brief   This file provides firmware functions to manage the following 
   *          functionalities of the Analog to Digital Convertor (ADC)
   *          peripheral:
   *           + Operation functions
   *             ++ Calibration (ADC automatic self-calibration)
-  *         
+  *          Other functions (generic functions) are available in file 
+  *          "stm32l1xx_hal_adc.c".
+  *
   @verbatim
-  ==============================================================================
-                    ##### ADC specific features #####
-  ==============================================================================
   [..] 
-  (#) 12-bit, 10-bit, 8-bit or 6-bit configurable resolution
-
-  (#) Interrupt generation at the end of regular conversion and in case of 
-      analog watchdog or overrun events.
-  
-  (#) Single and continuous conversion modes.
-  
-  (#) Scan mode for automatic conversion of channel 0 to channel 'n'.
-  
-  (#) Data alignment with in-built data coherency.
-  
-  (#) Programmable sampling time.
-  
-  (#) ADC conversion group Regular.
-
-  (#) External trigger (timer or EXTI) with configurable polarity.
-
-  (#) DMA request generation for transfer of conversions data of regular group.
-
-  (#) ADC calibration
-  
-  (#) ADC supply requirements: 2.4 V to 3.6 V at full speed and down to 1.8 V at 
-      slower speed.
-  
-  (#) ADC input range: from Vref minud (connected to Vssa) to Vref plus(connected to 
-      Vdda or to an external voltage reference).
-
-
-                     ##### How to use this driver #####
-  ==============================================================================
-    [..]
-
-    (#) Enable the ADC interface 
-        As prerequisite, into HAL_ADC_MspInit(), ADC clock must be configured  
-        at RCC top level: clock source and clock prescaler.
-        Two possible clock sources: synchronous clock derived from APB clock
-        or asynchronous clock derived from ADC dedicated HSI RC oscillator
-        14MHz.
-        Example:
-          __ADC1_CLK_ENABLE();                         (mandatory)
-          
-          HI14 enable or let under control of ADC:     (optional)
-
-          RCC_OscInitTypeDef   RCC_OscInitStructure;
-          RCC_OscInitStructure.OscillatorType = RCC_OSCILLATORTYPE_HSI14;
-          RCC_OscInitStructure.HSI14CalibrationValue = RCC_HSI14CALIBRATION_DEFAULT;
-          RCC_OscInitStructure.HSI14State = RCC_HSI14_ADC_CONTROL;
-          RCC_OscInitStructure.PLL...   (optional if used for system clock)
-          HAL_RCC_OscConfig(&RCC_OscInitStructure);
-          
-          Parameter "HSI14State" must be set either:
-           - to "...HSI14State = RCC_HSI14_ADC_CONTROL" to let the ADC control 
-             the HSI14 oscillator enable/disable (if not used to supply the main 
-             system clock): feature used if ADC mode LowPowerAutoPowerOff is 
-             enabled.
-           - to "...HSI14State = RCC_HSI14_ON" to maintain the HSI14 oscillator
-             always enabled: can be used to supply the main system clock.
-
-    (#) ADC pins configuration
-         (++) Enable the clock for the ADC GPIOs using the following function:
-             __GPIOx_CLK_ENABLE();   
-         (++) Configure these ADC pins in analog mode using HAL_GPIO_Init();  
-  
-     (#) Configure the ADC parameters (conversion resolution, data alignment,  
-         continuous mode, ...) using the HAL_ADC_Init() function.
-
-     (#) Activate the ADC peripheral using one of the start functions: 
-         HAL_ADC_Start(), HAL_ADC_Start_IT(), HAL_ADC_Start_DMA().
-  
-     *** Regular channels group configuration ***
-     ============================================
-     [..]    
-       (+) To configure the ADC regular channels group features, use 
-           HAL_ADC_Init() and HAL_ADC_ConfigChannel() functions.
-       (+) To activate the continuous mode, use the HAL_ADC_Init() function.   
-       (+) To read the ADC converted values, use the HAL_ADC_GetValue() function.
-              
-     *** DMA for Regular channels group features configuration ***
-     ============================================================= 
-     [..]
-       (+) To enable the DMA mode for regular channels group, use the  
-           HAL_ADC_Start_DMA() function.
-       (+) To enable the generation of DMA requests continuously at the end of 
-           the last DMA transfer, use the HAL_ADC_Init() function.
-  
-    @endverbatim
+  (@) Sections "ADC peripheral features" and "How to use this driver" are
+      available in file of generic functions "stm32l1xx_hal_adc.c".
+  [..]
+  @endverbatim
   ******************************************************************************
   * @attention
   *
-  * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
+  * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
   *
   * Redistribution and use in source and binary forms, with or without modification,
   * are permitted provided that the following conditions are met:
@@ -138,7 +55,7 @@
   * @{
   */
 
-/** @defgroup ADCEx ADCEx Extended HAL Module Driver
+/** @defgroup ADCEx ADCEx
   * @brief ADC HAL module driver
   * @{
   */
@@ -163,8 +80,8 @@
 /**
   * @}
   */
-  
-/* Private macro -------------------------------------------------------------*/
+
+/* Private macros -------------------------------------------------------------*/
 /* Private variables ---------------------------------------------------------*/
 /* Private function prototypes -----------------------------------------------*/
 /* Private functions ---------------------------------------------------------*/
@@ -174,9 +91,9 @@
   */
 
 /** @defgroup ADCEx_Exported_Functions_Group1 Extended Initialization/de-initialization functions 
- *  @brief    Extended Initialization and Configuration functions 
+ *  @brief    Extended Initialization and Configuration functions
  *
-@verbatim    
+@verbatim
  ===============================================================================
                       ##### IO operation functions #####
  ===============================================================================
@@ -197,7 +114,7 @@
   */
 HAL_StatusTypeDef HAL_ADCEx_Calibration_Start(ADC_HandleTypeDef* hadc)
 {
-  HAL_StatusTypeDef tmpHALStatus = HAL_OK;
+  HAL_StatusTypeDef tmp_hal_status = HAL_OK;
   uint32_t tickstart=0;
   
   /* Check the parameters */
@@ -205,12 +122,14 @@
 
   /* Process locked */
   __HAL_LOCK(hadc);
-       
-  /* Calibration prerequisite: ADC must be disabled.                          */
-  if (__HAL_ADC_IS_ENABLED(hadc) == RESET )
+  
+  /* Calibration prerequisite: ADC must be disabled. */
+  if (ADC_IS_ENABLE(hadc) == RESET)
   {
-    /* Change ADC state */
-    hadc->State = HAL_ADC_STATE_READY;
+    /* Set ADC state */
+    ADC_STATE_CLR_SET(hadc->State, 
+                      HAL_ADC_STATE_REG_BUSY,
+                      HAL_ADC_STATE_BUSY_INTERNAL);
     
     /* Start ADC calibration */
     hadc->Instance->CR |= ADC_CR_ADCAL;
@@ -223,7 +142,9 @@
       if((HAL_GetTick() - tickstart) > ADC_CALIBRATION_TIMEOUT)
       {
         /* Update ADC state machine to error */
-        hadc->State = HAL_ADC_STATE_ERROR;
+        ADC_STATE_CLR_SET(hadc->State,
+                          HAL_ADC_STATE_BUSY_INTERNAL,
+                          HAL_ADC_STATE_ERROR_INTERNAL);
         
         /* Process unlocked */
         __HAL_UNLOCK(hadc);
@@ -231,18 +152,25 @@
         return HAL_ERROR;
       }
     }
+    
+    /* Set ADC state */
+    ADC_STATE_CLR_SET(hadc->State,
+                      HAL_ADC_STATE_BUSY_INTERNAL,
+                      HAL_ADC_STATE_READY);
   }
   else
   {
     /* Update ADC state machine to error */
-    hadc->State = HAL_ADC_STATE_ERROR;
+    SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_CONFIG);
+    
+    tmp_hal_status = HAL_ERROR;
   }
   
   /* Process unlocked */
   __HAL_UNLOCK(hadc);
   
   /* Return function status */
-  return tmpHALStatus;
+  return tmp_hal_status;
 }
 
 /**