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:
489:119543c9f674
Parent:
382:ee426a420dbb
--- a/targets/cmsis/TARGET_STM/TARGET_STM32L0/stm32l0xx_hal_tim_ex.c	Thu Mar 05 13:15:07 2015 +0000
+++ b/targets/cmsis/TARGET_STM/TARGET_STM32L0/stm32l0xx_hal_tim_ex.c	Thu Mar 12 14:30:49 2015 +0000
@@ -2,8 +2,8 @@
   ******************************************************************************
   * @file    stm32l0xx_hal_tim_ex.c
   * @author  MCD Application Team
-  * @version V1.1.0
-  * @date    18-June-2014
+  * @version V1.2.0
+  * @date    06-February-2015
   * @brief   TIM HAL module driver.
   * @brief   This file provides firmware functions to manage the following 
   *          functionalities of the Timer (TIM) peripheral:
@@ -33,11 +33,11 @@
 ================================================================================
     [..]
      (#) Enable the TIM interface clock using 
-         __TIMx_CLK_ENABLE(); 
+         __HAL_RCC_TIMx_CLK_ENABLE(); 
        
      (#) TIM pins configuration
           (++) Enable the clock for the TIM GPIOs using the following function:
-              __GPIOx_CLK_ENABLE();   
+              __HAL_RCC_GPIOx_CLK_ENABLE();   
           (++) Configure these TIM pins in Alternate function mode using HAL_GPIO_Init();  
 
      (#) The external Clock can be configured, if needed (the default clock is the internal clock from the APBx), 
@@ -55,7 +55,7 @@
   ******************************************************************************
   * @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:
@@ -89,27 +89,21 @@
   * @{
   */
 
-/** @defgroup TIMEx 
+/** @addtogroup TIMEx
   * @brief TIMEx HAL module driver
   * @{
   */
 
 #ifdef HAL_TIM_MODULE_ENABLED
 
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/   
-/* Private functions ---------------------------------------------------------*/
 
-/** @defgroup TIMEx_Private_Functions
+/** @addtogroup TIMEx_Exported_Functions
   * @{
   */
 
 
-/** @defgroup TIMEx_Group1 Peripheral Control functions
- *  @brief   	Peripheral Control functions 
+/** @addtogroup TIMEx_Exported_Functions_Group1
+ *  @brief    Peripheral Control functions
  *
 @verbatim   
  ===============================================================================
@@ -159,65 +153,188 @@
   return HAL_OK;
 }  
 
+
+#if defined (STM32L071xx) || defined (STM32L072xx) || defined (STM32L073xx) \
+    || defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx)
+
 /**
-  * @brief  Configures the TIM2, TIM21 and TIM22 Remapping input capabilities.
+  * @brief  Configures the remapping of the TIM2, TIM3, TIM21 and TIM22 inputs.
+  *         The channel inputs (T1..T4) and the Trigger input (ETR) of the
+  *         timers can be remaped thanks to this function. When an input is
+  *         mapped, on a GPIO, refer yourself to the GPIO alternate functions
+  *         for more details.
+  * @note   It is not possible to connect TIM2 and TIM21 on
+  *         GPIOB5_AF4 at the same time.
+  *         When selecting TIM3_TI2_GPIOB5_AF4, Channel2 of TIM3 will be
+  *         connected to GPIOB5_AF4 and Channel2 of TIM22 will be connected to
+  *         some other GPIOs. (refer to alternate functions for more details)
+  *         When selecting TIM3_TI2_GPIO_DEF, Channel2 of Timer 3 will be
+  *         connected an GPIO (other than GPIOB5_AF4) and Channel2 of TIM22
+  *         will be connected to GPIOB5_AF4.
+  *
   * @param  htim: pointer to a TIM_HandleTypeDef structure that contains
-  *                the configuration information for TIM module.
-  * @param  TIM_Remap: specifies the TIM input remapping source.
-  *          This parameter can be one of the following values:
-  *            @arg TIM2_ETR_GPIO: TIM2  ETR is connected to GPIO (default)
-  *            @arg TIM2_ETR_HSI48: TIM2  ETR is connected to HSI48
-  *            @arg TIM2_ETR_LSE: TIM2  ETR is connected to LSE
-  *            @arg TIM2_ETR_COMP2_OUT: TIM2  ETR is connected to COMP2 output
-  *            @arg TIM2_ETR_COMP1_OUT: TIM2  ETR is connected to COMP1 output
-  *            @arg TIM2_TI4_GPIO1: TIM2  TI4 is connected to GPIO1(default)
-  *            @arg TIM2_TI4_COMP1: TIM2  TI4 is connected to COMP1
-  *            @arg TIM2_TI4_COMP2: TIM2  TI4 is connected to COMP2
-  *            @arg TIM2_TI4_GPIO2: TIM2  TI4 is connected to GPIO2
-  *            @arg TIM21_ETR_GPIO: TIM21 ETR is connected to GPIO(default)
-  *            @arg TIM21_ETR_COMP2_OUT: TIM21 ETR is connected to COMP2 output
-  *            @arg TIM21_ETR_COMP1_OUT: TIM21 ETR is connected to COMP1 output
-  *            @arg TIM21_ETR_LSE: TIM21 ETR is connected to LSE
-  *            @arg TIM21_TI1_MCO: TIM21 TI1 is connected to MCO
-  *            @arg TIM21_TI1_RTC_WKUT_IT: TIM21 TI1 is connected to RTC WAKEUP interrupt
-  *            @arg TIM21_TI1_HSE_RTC: TIM21 TI1 is connected to HSE_RTC 
-  *            @arg TIM21_TI1_MSI: TIM21 TI1 is connected to MSI clock
-  *            @arg TIM21_TI1_LSE: TIM21 TI1 is connected to LSE
-  *            @arg TIM21_TI1_LSI: TIM21 TI1 is connected to LSI  
-  *            @arg TIM21_TI1_COMP1_OUT: TIM21 TI1 is connected to COMP1_OUT
-  *            @arg TIM21_TI1_GPIO: TIM21 TI1 is connected to GPIO(default)
-  *            @arg TIM21_TI2_GPIO: TIM21 TI2 is connected to GPIO(default)
-  *            @arg TIM21_TI2_COMP2_OUT: TIM21 TI2 is connected to COMP2 output
-  *            @arg TIM22_ETR_LSE: TIM22 ETR is connected to LSE
-  *            @arg TIM22_ETR_COMP2_OUT: TIM22 ETR is connected to COMP2 output
-  *            @arg TIM22_ETR_COMP1_OUT: TIM22 ETR is connected to COMP1 output
-  *            @arg TIM22_ETR_GPIO: TIM22 ETR is connected to GPIO(default)  
-  *            @arg TIM22_TI1_GPIO1: TIM22 TI1 is connected to GPIO(default)
-  *            @arg TIM22_TI1_COMP2_OUT: TIM22 TI1 is connected to COMP2 output 
-  *            @arg TIM22_TI1_COMP1_OUT: TIM22 TI1 is connected to COMP1 output
-  *            @arg TIM22_TI1_GPIO2: TIM22 TI1 is connected to GPIO 
+  *               the configuration information for TIM module.
+  * @param  Remap: specifies the TIM input remapping source.
+  *                This parameter is a combination of the following values
+  *                depending on TIM instance:
+  *
+  *         For TIM2, the parameter can have the following values:
+  *           @arg TIM2_ETR_GPIO:      TIM2  ETR connected to GPIO (default):
+  *                                    GPIOA(0)_AF5 or GPIOA(5)_AF2 or
+  *                                    GPIOA(15)_AF2 or GPIOE(9)_AF2
+  *           @arg TIM2_ETR_HSI48:     TIM2  ETR connected to HSI48
+  *           @arg TIM2_ETR_LSE:       TIM2  ETR connected to LSE
+  *           @arg TIM2_ETR_COMP2_OUT: TIM2  ETR connected to COMP2 output
+  *           @arg TIM2_ETR_COMP1_OUT: TIM2  ETR connected to COMP1 output
+  *           @arg TIM2_TI4_GPIO :     TIM2  TI4 connected to GPIO1(default):
+  *                                    GPIOA(3)_AF2 or GPIOB(11)_AF2 or
+  *                                    GPIOE(12)_AF0
+  *           @arg TIM2_TI4_COMP1:     TIM2  TI4 connected to COMP1
+  *           @arg TIM2_TI4_COMP2:     TIM2  TI4 connected to COMP2
+  *
+  *         For TIM3, the parameter can have the following values:
+  *           @arg TIM3_ETR_GPIO:      TIM3  ETR connected to GPIO (default):
+  *                                    GPIOE(2)_AF2 or GPIOD(2)_AF2 or
+  *                                    GPIOE(2)AF2
+  *           @arg TIM3_ETR_HSI:       TIM3 ETR connected to HSI
+  *           @arg TIM3_TI1_USB_SOF:   TIM3 TI1 connected to USB_SOF (default)
+  *           @arg TIM3_TI1_GPIO:      TIM3 TI1 connected to GPIO :
+  *                                    GPIOE(3)_AF2 or GPIOA(6)_AF2 or
+  *                                    GPIOC(6)_AF2 or GPIOB(4)_AF2
+  *           @arg TIM3_TI2_GPIOB5_AF4:TIM3 TI3 connected to GPIOB(5)_AF4
+  *                                    (refer to note)
+  *           @arg TIM3_TI2_GPIO_DEF:  TIM3 TI3 connected to GPIO (default):
+  *                                    GPIO_A(7)_AF2 or GPIO_B(5)_AF4 or
+  *                                    GPIOC(7)_AF2 or GPIOE(7)_AF2
+  *           @arg TIM3_TI4_GPIO_DEF:  TIM3 TI4 connected to GPIO:
+  *                                    GPIO_B(1)_AF2 or GPIO_E(6)_AF2
+  *           @arg TIM3_TI4_GPIOC9_AF2:TIM3 TI4 connected to GPIOC(9)_AF2
+  *
+  *         For TIM21, the parameter can have the following values:
+  *           @arg TIM21_ETR_GPIO:     TIM21 ETR connected to GPIO(default) :
+  *                                    APB2_PC(9)_AF0 or APB2_PA(1)_AF5
+  *           @arg TIM21_ETR_COMP2_OUT:TIM21 ETR connected to COMP2 output
+  *           @arg TIM21_ETR_COMP1_OUT:TIM21 ETR connected to COMP1 output
+  *           @arg TIM21_ETR_LSE:      TIM21 ETR connected to LSE
+  *           @arg TIM21_TI1_MCO:      TIM21 TI1 connected to MCO
+  *           @arg TIM21_TI1_RTC_WKUT_IT: TIM21 TI1 connected to RTC WAKEUP interrupt
+  *           @arg TIM21_TI1_HSE_RTC:  TIM21 TI1 connected to HSE_RTC
+  *           @arg TIM21_TI1_MSI:      TIM21 TI1 connected to MSI clock
+  *           @arg TIM21_TI1_LSE:      TIM21 TI1 connected to LSE
+  *           @arg TIM21_TI1_LSI:      TIM21 TI1 connected to LSI
+  *           @arg TIM21_TI1_COMP1_OUT:TIM21 TI1 connected to COMP1_OUT
+  *           @arg TIM21_TI1_GPIO:     TIM21 TI1 connected to GPIO(default):
+  *                                    GPIOA(2)_AF0 or GPIOB(13)_AF6 or
+  *                                    GPIOE(5)_AF0 or GPIOD(0)_AF0
+  *           @arg TIM21_TI2_GPIO:     TIM21 TI2 connected to GPIO(default):
+  *                                    GPIOA(3)_AF0 or GPIOB(14)_AF6 or
+  *                                    GPIOE(6)_AF0 or GPIOD(7)_AF1
+  *           @arg TIM21_TI2_COMP2_OUT:TIM21 TI2 connected to COMP2 output
+  *
+  *         For TIM22, the parameter can have the following values:
+  *           @arg TIM22_ETR_LSE:      TIM22 ETR connected to LSE
+  *           @arg TIM22_ETR_COMP2_OUT:TIM22 ETR connected to COMP2 output
+  *           @arg TIM22_ETR_COMP1_OUT:TIM22 ETR connected to COMP1 output
+  *           @arg TIM22_ETR_GPIO:     TIM22 ETR connected to GPIO(default):
+  *                                    GPIOC(8)_AF0 or GPIOA(4)_AF5
+  *           @arg TIM22_TI1_GPIO1:    TIM22 TI1 connected to GPIO(default):
+  *                                    GPIOC(6)_AF0 or GPIOA(6)_AF5 or
+  *                                    GPIOB(4)_AF4 or GPIOE(0)_AF3
+  *           @arg TIM22_TI1_COMP2_OUT:TIM22 TI1 connected to COMP2 output
+  *           @arg TIM22_TI1_COMP1_OUT:TIM22 TI1 connected to COMP1 output
+  *           @arg TIM22_TI1_GPIO2:    TIM22 TI1 connected to GPIO:
+  *                                    GPIOC(6)_AF0 or GPIOA(6)_AF5 or
+  *                                    GPIOB(4)_AF4 or GPIOE(3)_AF0
+  *
   * @retval HAL status
   */
+#else
+/**
+  * @brief  Configures the remapping of the TIM2, TIM21 and TIM22 inputs.
+  *         The channel inputs (T1..T4) and the Trigger input (ETR) of the
+  *         timers can be remaped thanks to this function. When an input is
+  *         mapped, on a GPIO, refer yourself to the GPIO alternate functions
+  *         for more details.
+  *
+  * @param  htim: pointer to a TIM_HandleTypeDef structure that contains
+  *               the configuration information for TIM module.
+  * @param  Remap: specifies the TIM input remapping source.
+  *                This parameter is a combination of the following values
+  *                depending on TIM instance:
+  *
+  *         For TIM2, the parameter can have the following values:
+  *           @arg TIM2_ETR_GPIO:      TIM2  ETR connected to GPIO (default):
+  *                                    GPIOA(0)_AF5 or GPIOA(5)_AF2 or
+  *                                    GPIOA(15)_AF2 or GPIOE(9)_AF2
+  *           @arg TIM2_ETR_HSI48:     TIM2  ETR connected to HSI48
+  *           @arg TIM2_ETR_LSE:       TIM2  ETR connected to LSE
+  *           @arg TIM2_ETR_COMP2_OUT: TIM2  ETR connected to COMP2 output
+  *           @arg TIM2_ETR_COMP1_OUT: TIM2  ETR connected to COMP1 output
+  *           @arg TIM2_TI4_GPIO:      TIM2  TI4 connected to GPIO1(default):
+  *                                    GPIOA(3)_AF2 or GPIOB(11)_AF2 or
+  *                                    GPIOE(12)_AF0
+  *           @arg TIM2_TI4_COMP1:     TIM2  TI4 connected to COMP1
+  *           @arg TIM2_TI4_COMP2:     TIM2  TI4 connected to COMP2
+  *           @arg TIM2_TI4_GPIO2:     TIM2  TI4 connected to GPIO2 :
+  *                                    GPIOA(3)_AF2 or GPIOB(11)_AF2 or
+  *                                    GPIOE(12)_AF0
+  *
+  *         For TIM21, the parameter can have the following values:
+  *           @arg TIM21_ETR_GPIO:     TIM21 ETR connected to GPIO(default) :
+  *                                    APB2_PC(9)_AF0 or APB2_PA(1)_AF5
+  *           @arg TIM21_ETR_COMP2_OUT:TIM21 ETR connected to COMP2 output
+  *           @arg TIM21_ETR_COMP1_OUT:TIM21 ETR connected to COMP1 output
+  *           @arg TIM21_ETR_LSE:      TIM21 ETR connected to LSE
+  *           @arg TIM21_TI1_MCO:      TIM21 TI1 connected to MCO
+  *           @arg TIM21_TI1_RTC_WKUT_IT: TIM21 TI1 connected to RTC WAKEUP interrupt
+  *           @arg TIM21_TI1_HSE_RTC:  TIM21 TI1 connected to HSE_RTC
+  *           @arg TIM21_TI1_MSI:      TIM21 TI1 connected to MSI clock
+  *           @arg TIM21_TI1_LSE:      TIM21 TI1 connected to LSE
+  *           @arg TIM21_TI1_LSI:      TIM21 TI1 connected to LSI
+  *           @arg TIM21_TI1_COMP1_OUT:TIM21 TI1 connected to COMP1_OUT
+  *           @arg TIM21_TI1_GPIO:     TIM21 TI1 connected to GPIO(default):
+  *                                    GPIOA(2)_AF0 or GPIOB(13)_AF6 or
+  *                                    GPIOE(5)_AF0 or GPIOD(0)_AF0
+  *           @arg TIM21_TI2_GPIO:     TIM21 TI2 connected to GPIO(default):
+  *                                    GPIOA(3)_AF0 or GPIOB(14)_AF6 or
+  *                                    GPIOE(6)_AF0 or GPIOD(7)_AF1
+  *           @arg TIM21_TI2_COMP2_OUT:TIM21 TI2 connected to COMP2 output
+  *
+  *         For TIM22, the parameter can have the following values:
+  *           @arg TIM22_ETR_LSE:      TIM22 ETR connected to LSE
+  *           @arg TIM22_ETR_COMP2_OUT:TIM22 ETR connected to COMP2 output
+  *           @arg TIM22_ETR_COMP1_OUT:TIM22 ETR connected to COMP1 output
+  *           @arg TIM22_ETR_GPIO:     TIM22 ETR connected to GPIO(default):
+  *                                    GPIOC(8)_AF0 or GPIOA(4)_AF5
+  *           @arg TIM22_TI1_GPIO1:    TIM22 TI1 connected to GPIO(default):
+  *                                    GPIOC(6)_AF0 or GPIOA(6)_AF5 or
+  *                                    GPIOB(4)_AF4 or GPIOE(0)_AF3
+  *           @arg TIM22_TI1_COMP2_OUT:TIM22 TI1 connected to COMP2 output
+  *           @arg TIM22_TI1_COMP1_OUT:TIM22 TI1 connected to COMP1 output
+  *           @arg TIM22_TI1_GPIO2:    TIM22 TI1 connected to GPIO:
+  *                                    GPIOC(6)_AF0 or GPIOA(6)_AF5 or
+  *                                    GPIOB(4)_AF4 or GPIOE(3)_AF0
+  *
+  * @retval HAL status
+  */
+
+#endif /* STM32L07xxx or STM32L08xxx */
+
 HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap)
 {
-  __HAL_LOCK(htim);
-    
+
+   __HAL_LOCK(htim);
+
   /* Check parameters */
-  assert_param(IS_TIM_REMAP_INSTANCE(htim->Instance));
-  assert_param(IS_TIM_REMAP(Remap));
-  
-  /* Change the handler state */
-  htim->State = HAL_TIM_STATE_BUSY;
-  
+  assert_param(IS_TIM_REMAP(htim->Instance,Remap));
+
   /* Set the Timer remapping configuration */
-  htim->Instance->OR &=  (uint32_t)(Remap >> 16);
-  htim->Instance->OR |=  Remap;
-  
-  /* Change the handler state */
+  htim->Instance->OR = Remap;
+
   htim->State = HAL_TIM_STATE_READY;
-  
-  __HAL_UNLOCK(htim);  
-  
+
+  __HAL_UNLOCK(htim);
+
   return HAL_OK;
 }