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