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:
Wed Jul 01 09:45:11 2015 +0100
Revision:
579:53297373a894
Parent:
394:83f921546702
Synchronized with git revision d5b4d2ab9c47edb4dc5776e7177b0c2263459081

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

Initial version of drivers for SAMR21

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 354:e67efb2aab0e 1 /**
mbed_official 354:e67efb2aab0e 2 ******************************************************************************
mbed_official 354:e67efb2aab0e 3 * @file stm32l1xx_hal_tim_ex.c
mbed_official 354:e67efb2aab0e 4 * @author MCD Application Team
mbed_official 354:e67efb2aab0e 5 * @version V1.0.0
mbed_official 354:e67efb2aab0e 6 * @date 5-September-2014
mbed_official 354:e67efb2aab0e 7 * @brief TIM HAL module driver.
mbed_official 354:e67efb2aab0e 8 * This file provides firmware functions to manage the following
mbed_official 354:e67efb2aab0e 9 * functionalities of the Timer extension peripheral:
mbed_official 354:e67efb2aab0e 10 * + Time Master and Slave synchronization configuration
mbed_official 354:e67efb2aab0e 11 * + Timer remapping capabilities configuration
mbed_official 354:e67efb2aab0e 12 @verbatim
mbed_official 354:e67efb2aab0e 13 ==============================================================================
mbed_official 354:e67efb2aab0e 14 ##### TIMER Extended features #####
mbed_official 354:e67efb2aab0e 15 ==============================================================================
mbed_official 354:e67efb2aab0e 16 [..]
mbed_official 354:e67efb2aab0e 17 The Timer Extension features include:
mbed_official 354:e67efb2aab0e 18 (#) Synchronization circuit to control the timer with external signals and to
mbed_official 354:e67efb2aab0e 19 interconnect several timers together.
mbed_official 354:e67efb2aab0e 20 (#) Timer remapping capabilities configuration
mbed_official 354:e67efb2aab0e 21
mbed_official 354:e67efb2aab0e 22 @endverbatim
mbed_official 354:e67efb2aab0e 23 ******************************************************************************
mbed_official 354:e67efb2aab0e 24 * @attention
mbed_official 354:e67efb2aab0e 25 *
mbed_official 354:e67efb2aab0e 26 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 354:e67efb2aab0e 27 *
mbed_official 354:e67efb2aab0e 28 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 354:e67efb2aab0e 29 * are permitted provided that the following conditions are met:
mbed_official 354:e67efb2aab0e 30 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 354:e67efb2aab0e 31 * this list of conditions and the following disclaimer.
mbed_official 354:e67efb2aab0e 32 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 354:e67efb2aab0e 33 * this list of conditions and the following disclaimer in the documentation
mbed_official 354:e67efb2aab0e 34 * and/or other materials provided with the distribution.
mbed_official 354:e67efb2aab0e 35 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 354:e67efb2aab0e 36 * may be used to endorse or promote products derived from this software
mbed_official 354:e67efb2aab0e 37 * without specific prior written permission.
mbed_official 354:e67efb2aab0e 38 *
mbed_official 354:e67efb2aab0e 39 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 354:e67efb2aab0e 40 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 354:e67efb2aab0e 41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 354:e67efb2aab0e 42 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 354:e67efb2aab0e 43 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 354:e67efb2aab0e 44 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 354:e67efb2aab0e 45 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 354:e67efb2aab0e 46 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 354:e67efb2aab0e 47 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 354:e67efb2aab0e 48 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 354:e67efb2aab0e 49 *
mbed_official 354:e67efb2aab0e 50 ******************************************************************************
mbed_official 354:e67efb2aab0e 51 */
mbed_official 354:e67efb2aab0e 52
mbed_official 354:e67efb2aab0e 53 /* Includes ------------------------------------------------------------------*/
mbed_official 354:e67efb2aab0e 54 #include "stm32l1xx_hal.h"
mbed_official 354:e67efb2aab0e 55
mbed_official 354:e67efb2aab0e 56 /** @addtogroup STM32L1xx_HAL_Driver
mbed_official 354:e67efb2aab0e 57 * @{
mbed_official 354:e67efb2aab0e 58 */
mbed_official 354:e67efb2aab0e 59
mbed_official 354:e67efb2aab0e 60 /** @defgroup TIMEx TIMEx
mbed_official 354:e67efb2aab0e 61 * @brief TIM HAL module driver
mbed_official 354:e67efb2aab0e 62 * @{
mbed_official 354:e67efb2aab0e 63 */
mbed_official 354:e67efb2aab0e 64
mbed_official 354:e67efb2aab0e 65 #ifdef HAL_TIM_MODULE_ENABLED
mbed_official 354:e67efb2aab0e 66
mbed_official 354:e67efb2aab0e 67 /* Private typedef -----------------------------------------------------------*/
mbed_official 354:e67efb2aab0e 68 /* Private define ------------------------------------------------------------*/
mbed_official 354:e67efb2aab0e 69 /* Private macro -------------------------------------------------------------*/
mbed_official 354:e67efb2aab0e 70 /* Private variables ---------------------------------------------------------*/
mbed_official 354:e67efb2aab0e 71 /* Private function prototypes -----------------------------------------------*/
mbed_official 354:e67efb2aab0e 72 /* Private functions ---------------------------------------------------------*/
mbed_official 354:e67efb2aab0e 73
mbed_official 354:e67efb2aab0e 74 /** @defgroup TIMEx_Exported_Functions TIMEx Exported Functions
mbed_official 354:e67efb2aab0e 75 * @{
mbed_official 354:e67efb2aab0e 76 */
mbed_official 354:e67efb2aab0e 77
mbed_official 354:e67efb2aab0e 78 /** @defgroup TIMEx_Exported_Functions_Group1 Peripheral Control functions
mbed_official 354:e67efb2aab0e 79 * @brief Peripheral Control functions
mbed_official 354:e67efb2aab0e 80 *
mbed_official 354:e67efb2aab0e 81 @verbatim
mbed_official 354:e67efb2aab0e 82 ==============================================================================
mbed_official 354:e67efb2aab0e 83 ##### Peripheral Control functions #####
mbed_official 354:e67efb2aab0e 84 ==============================================================================
mbed_official 354:e67efb2aab0e 85 [..]
mbed_official 354:e67efb2aab0e 86 This section provides functions allowing to:
mbed_official 354:e67efb2aab0e 87 (+) Configure the commutation event in case of use of the Hall sensor interface.
mbed_official 354:e67efb2aab0e 88 (+) Configure Complementary channels, break features and dead time.
mbed_official 354:e67efb2aab0e 89 (+) Configure Master synchronization.
mbed_official 354:e67efb2aab0e 90 (+) Configure timer remapping capabilities.
mbed_official 354:e67efb2aab0e 91
mbed_official 354:e67efb2aab0e 92 @endverbatim
mbed_official 354:e67efb2aab0e 93 * @{
mbed_official 354:e67efb2aab0e 94 */
mbed_official 354:e67efb2aab0e 95
mbed_official 354:e67efb2aab0e 96 /**
mbed_official 354:e67efb2aab0e 97 * @brief Configures the TIM in master mode.
mbed_official 354:e67efb2aab0e 98 * @param htim: TIM handle.
mbed_official 354:e67efb2aab0e 99 * @param sMasterConfig: pointer to a TIM_MasterConfigTypeDef structure that
mbed_official 354:e67efb2aab0e 100 * contains the selected trigger output (TRGO) and the Master/Slave
mbed_official 354:e67efb2aab0e 101 * mode.
mbed_official 354:e67efb2aab0e 102 * @retval HAL status
mbed_official 354:e67efb2aab0e 103 */
mbed_official 354:e67efb2aab0e 104 HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim, TIM_MasterConfigTypeDef * sMasterConfig)
mbed_official 354:e67efb2aab0e 105 {
mbed_official 354:e67efb2aab0e 106 /* Check the parameters */
mbed_official 354:e67efb2aab0e 107 assert_param(IS_TIM_MASTER_INSTANCE(htim->Instance));
mbed_official 354:e67efb2aab0e 108 assert_param(IS_TIM_TRGO_SOURCE(sMasterConfig->MasterOutputTrigger));
mbed_official 354:e67efb2aab0e 109 assert_param(IS_TIM_MSM_STATE(sMasterConfig->MasterSlaveMode));
mbed_official 354:e67efb2aab0e 110
mbed_official 354:e67efb2aab0e 111 __HAL_LOCK(htim);
mbed_official 354:e67efb2aab0e 112
mbed_official 354:e67efb2aab0e 113 htim->State = HAL_TIM_STATE_BUSY;
mbed_official 354:e67efb2aab0e 114
mbed_official 354:e67efb2aab0e 115 /* Reset the MMS Bits */
mbed_official 354:e67efb2aab0e 116 htim->Instance->CR2 &= ~TIM_CR2_MMS;
mbed_official 354:e67efb2aab0e 117 /* Select the TRGO source */
mbed_official 354:e67efb2aab0e 118 htim->Instance->CR2 |= sMasterConfig->MasterOutputTrigger;
mbed_official 354:e67efb2aab0e 119
mbed_official 354:e67efb2aab0e 120 /* Reset the MSM Bit */
mbed_official 354:e67efb2aab0e 121 htim->Instance->SMCR &= ~TIM_SMCR_MSM;
mbed_official 354:e67efb2aab0e 122 /* Set or Reset the MSM Bit */
mbed_official 354:e67efb2aab0e 123 htim->Instance->SMCR |= sMasterConfig->MasterSlaveMode;
mbed_official 354:e67efb2aab0e 124
mbed_official 354:e67efb2aab0e 125 htim->State = HAL_TIM_STATE_READY;
mbed_official 354:e67efb2aab0e 126
mbed_official 354:e67efb2aab0e 127 __HAL_UNLOCK(htim);
mbed_official 354:e67efb2aab0e 128
mbed_official 354:e67efb2aab0e 129 return HAL_OK;
mbed_official 354:e67efb2aab0e 130 }
mbed_official 354:e67efb2aab0e 131
mbed_official 354:e67efb2aab0e 132 /**
mbed_official 354:e67efb2aab0e 133 * @brief Configures the TIM2/TIM3/TIM9/TIM10/TIM11 Remapping input capabilities.
mbed_official 354:e67efb2aab0e 134 * @param htim: TIM handle.
mbed_official 354:e67efb2aab0e 135 * @param Remap: specifies the TIM remapping source.
mbed_official 354:e67efb2aab0e 136 * This parameter is a combination of the following values depending on TIM instance.
mbed_official 354:e67efb2aab0e 137 *
mbed_official 354:e67efb2aab0e 138 * For TIM2, the parameter can have the following values:
mbed_official 354:e67efb2aab0e 139 * @arg TIM_TIM2_ITR1_TIM10_OC: TIM2 ITR1 input is connected to TIM10 OC
mbed_official 354:e67efb2aab0e 140 * @arg TIM_TIM2_ITR1_TIM5_TGO: TIM2 ITR1 input is connected to TIM5 TGO
mbed_official 354:e67efb2aab0e 141 *
mbed_official 354:e67efb2aab0e 142 * For TIM3, the parameter can have the following values:
mbed_official 354:e67efb2aab0e 143 * @arg TIM_TIM3_ITR2_TIM11_OC: TIM3 ITR2 input is connected to TIM11 OC
mbed_official 354:e67efb2aab0e 144 * @arg TIM_TIM3_ITR2_TIM5_TGO: TIM3 ITR2 input is connected to TIM5 TGO
mbed_official 354:e67efb2aab0e 145 *
mbed_official 354:e67efb2aab0e 146 * For TIM9, the parameter is a combination of 2 fields (field1 | field2):
mbed_official 354:e67efb2aab0e 147 * field1 can have the following values:
mbed_official 354:e67efb2aab0e 148 * @arg TIM_TIM9_ITR1_TIM3_TGO: TIM9 ITR1 input is connected to TIM3 TGO
mbed_official 354:e67efb2aab0e 149 * @arg TIM_TIM9_ITR1_TS: TIM9 ITR1 input is connected to touch sensing I/O
mbed_official 354:e67efb2aab0e 150 * field2 can have the following values:
mbed_official 354:e67efb2aab0e 151 * @arg TIM_TIM9_GPIO: TIM9 Channel1 is connected to GPIO
mbed_official 354:e67efb2aab0e 152 * @arg TIM_TIM9_LSE: TIM9 Channel1 is connected to LSE internal clock
mbed_official 354:e67efb2aab0e 153 * @arg TIM_TIM9_GPIO1: TIM9 Channel1 is connected to GPIO
mbed_official 354:e67efb2aab0e 154 * @arg TIM_TIM9_GPIO2: TIM9 Channel1 is connected to GPIO
mbed_official 354:e67efb2aab0e 155 *
mbed_official 354:e67efb2aab0e 156 * For TIM10, the parameter is a combination of 3 fields (field1 | field2 | field3):
mbed_official 354:e67efb2aab0e 157 * field1 can have the following values:
mbed_official 354:e67efb2aab0e 158 * @arg TIM_TIM10_TI1RMP: TIM10 Channel 1 depends on TI1_RMP
mbed_official 354:e67efb2aab0e 159 * @arg TIM_TIM10_RI: TIM10 Channel 1 is connected to RI
mbed_official 354:e67efb2aab0e 160 * field2 can have the following values:
mbed_official 354:e67efb2aab0e 161 * @arg TIM_TIM10_ETR_LSE: TIM10 ETR input is connected to LSE clock
mbed_official 354:e67efb2aab0e 162 * @arg TIM_TIM10_ETR_TIM9_TGO: TIM10 ETR input is connected to TIM9 TGO
mbed_official 354:e67efb2aab0e 163 * field3 can have the following values:
mbed_official 354:e67efb2aab0e 164 * @arg TIM_TIM10_GPIO: TIM10 Channel1 is connected to GPIO
mbed_official 354:e67efb2aab0e 165 * @arg TIM_TIM10_LSI: TIM10 Channel1 is connected to LSI internal clock
mbed_official 354:e67efb2aab0e 166 * @arg TIM_TIM10_LSE: TIM10 Channel1 is connected to LSE internal clock
mbed_official 354:e67efb2aab0e 167 * @arg TIM_TIM10_RTC: TIM10 Channel1 is connected to RTC wakeup interrupt
mbed_official 354:e67efb2aab0e 168 *
mbed_official 354:e67efb2aab0e 169 * For TIM11, the parameter is a combination of 3 fields (field1 | field2 | field3):
mbed_official 354:e67efb2aab0e 170 * field1 can have the following values:
mbed_official 354:e67efb2aab0e 171 * @arg TIM_TIM11_TI1RMP: TIM11 Channel 1 depends on TI1_RMP
mbed_official 354:e67efb2aab0e 172 * @arg TIM_TIM11_RI: TIM11 Channel 1 is connected to RI
mbed_official 354:e67efb2aab0e 173 * field2 can have the following values:
mbed_official 354:e67efb2aab0e 174 * @arg TIM_TIM11_ETR_LSE: TIM11 ETR input is connected to LSE clock
mbed_official 354:e67efb2aab0e 175 * @arg TIM_TIM11_ETR_TIM9_TGO: TIM11 ETR input is connected to TIM9 TGO
mbed_official 354:e67efb2aab0e 176 * field3 can have the following values:
mbed_official 354:e67efb2aab0e 177 * @arg TIM_TIM11_GPIO: TIM11 Channel1 is connected to GPIO
mbed_official 354:e67efb2aab0e 178 * @arg TIM_TIM11_MSI: TIM11 Channel1 is connected to MSI internal clock
mbed_official 354:e67efb2aab0e 179 * @arg TIM_TIM11_HSE_RTC: TIM11 Channel1 is connected to HSE_RTC clock
mbed_official 354:e67efb2aab0e 180 * @arg TIM_TIM11_GPIO1: TIM11 Channel1 is connected to GPIO
mbed_official 354:e67efb2aab0e 181 *
mbed_official 354:e67efb2aab0e 182 * @retval HAL status
mbed_official 354:e67efb2aab0e 183 */
mbed_official 354:e67efb2aab0e 184 HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap)
mbed_official 354:e67efb2aab0e 185 {
mbed_official 354:e67efb2aab0e 186 __HAL_LOCK(htim);
mbed_official 354:e67efb2aab0e 187
mbed_official 354:e67efb2aab0e 188 /* Check parameters */
mbed_official 354:e67efb2aab0e 189 assert_param(IS_TIM_REMAP_INSTANCE(htim->Instance));
mbed_official 354:e67efb2aab0e 190 assert_param(IS_TIM_REMAP(htim->Instance,Remap));
mbed_official 354:e67efb2aab0e 191
mbed_official 354:e67efb2aab0e 192 /* Set the Timer remapping configuration */
mbed_official 354:e67efb2aab0e 193 htim->Instance->OR = Remap;
mbed_official 354:e67efb2aab0e 194
mbed_official 354:e67efb2aab0e 195 htim->State = HAL_TIM_STATE_READY;
mbed_official 354:e67efb2aab0e 196
mbed_official 354:e67efb2aab0e 197 __HAL_UNLOCK(htim);
mbed_official 354:e67efb2aab0e 198
mbed_official 354:e67efb2aab0e 199 return HAL_OK;
mbed_official 354:e67efb2aab0e 200 }
mbed_official 354:e67efb2aab0e 201
mbed_official 354:e67efb2aab0e 202 /**
mbed_official 354:e67efb2aab0e 203 * @}
mbed_official 354:e67efb2aab0e 204 */
mbed_official 354:e67efb2aab0e 205
mbed_official 354:e67efb2aab0e 206 /** @defgroup TIMEx_Exported_Functions_Group2 Extension Callbacks functions
mbed_official 354:e67efb2aab0e 207 * @brief Extension Callbacks functions
mbed_official 354:e67efb2aab0e 208 *
mbed_official 354:e67efb2aab0e 209 @verbatim
mbed_official 354:e67efb2aab0e 210 ==============================================================================
mbed_official 354:e67efb2aab0e 211 ##### Extension Callbacks functions #####
mbed_official 354:e67efb2aab0e 212 ==============================================================================
mbed_official 354:e67efb2aab0e 213 [..]
mbed_official 354:e67efb2aab0e 214 This section provides Extension TIM callback functions:
mbed_official 354:e67efb2aab0e 215 (+) Timer Commutation callback
mbed_official 354:e67efb2aab0e 216 (+) Timer Break callback
mbed_official 354:e67efb2aab0e 217
mbed_official 354:e67efb2aab0e 218 @endverbatim
mbed_official 354:e67efb2aab0e 219 * @{
mbed_official 354:e67efb2aab0e 220 */
mbed_official 354:e67efb2aab0e 221
mbed_official 354:e67efb2aab0e 222
mbed_official 354:e67efb2aab0e 223 /**
mbed_official 354:e67efb2aab0e 224 * @}
mbed_official 354:e67efb2aab0e 225 */
mbed_official 354:e67efb2aab0e 226
mbed_official 354:e67efb2aab0e 227 /** @defgroup TIMEx_Exported_Functions_Group3 Extension Peripheral State functions
mbed_official 354:e67efb2aab0e 228 * @brief Extension Peripheral State functions
mbed_official 354:e67efb2aab0e 229 *
mbed_official 354:e67efb2aab0e 230 @verbatim
mbed_official 354:e67efb2aab0e 231 ==============================================================================
mbed_official 354:e67efb2aab0e 232 ##### Extension Peripheral State functions #####
mbed_official 354:e67efb2aab0e 233 ==============================================================================
mbed_official 354:e67efb2aab0e 234 [..]
mbed_official 354:e67efb2aab0e 235 This subsection permit to get in run-time the status of the peripheral
mbed_official 354:e67efb2aab0e 236 and the data flow.
mbed_official 354:e67efb2aab0e 237
mbed_official 354:e67efb2aab0e 238 @endverbatim
mbed_official 354:e67efb2aab0e 239 * @{
mbed_official 354:e67efb2aab0e 240 */
mbed_official 354:e67efb2aab0e 241
mbed_official 354:e67efb2aab0e 242
mbed_official 354:e67efb2aab0e 243 /**
mbed_official 354:e67efb2aab0e 244 * @}
mbed_official 354:e67efb2aab0e 245 */
mbed_official 354:e67efb2aab0e 246
mbed_official 354:e67efb2aab0e 247 #endif /* HAL_TIM_MODULE_ENABLED */
mbed_official 354:e67efb2aab0e 248 /**
mbed_official 354:e67efb2aab0e 249 * @}
mbed_official 354:e67efb2aab0e 250 */
mbed_official 354:e67efb2aab0e 251
mbed_official 354:e67efb2aab0e 252 /**
mbed_official 354:e67efb2aab0e 253 * @}
mbed_official 354:e67efb2aab0e 254 */
mbed_official 354:e67efb2aab0e 255
mbed_official 354:e67efb2aab0e 256 /**
mbed_official 354:e67efb2aab0e 257 * @}
mbed_official 354:e67efb2aab0e 258 */
mbed_official 354:e67efb2aab0e 259
mbed_official 354:e67efb2aab0e 260 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/