Macros | Functions
stm32f4xx_tim.c File Reference

This file provides firmware functions to manage the following functionalities of the TIM peripheral: More...

#include "stm32f4xx_tim.h"
#include "stm32f4xx_rcc.h"
Include dependency graph for stm32f4xx_tim.c:

Go to the source code of this file.

Macros

#define CCER_CCE_SET   ((uint16_t)0x0001)
 
#define CCER_CCNE_SET   ((uint16_t)0x0004)
 
#define CCMR_OC13M_MASK   ((uint16_t)0xFF8F)
 
#define CCMR_OC24M_MASK   ((uint16_t)0x8FFF)
 
#define CCMR_OFFSET   ((uint16_t)0x0018)
 
#define SMCR_ETR_MASK   ((uint16_t)0x00FF)
 

Functions

static void TI1_Config (TIM_TypeDef *TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection, uint16_t TIM_ICFilter)
 Configure the TI1 as Input. More...
 
static void TI2_Config (TIM_TypeDef *TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection, uint16_t TIM_ICFilter)
 Configure the TI2 as Input. More...
 
static void TI3_Config (TIM_TypeDef *TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection, uint16_t TIM_ICFilter)
 Configure the TI3 as Input. More...
 
static void TI4_Config (TIM_TypeDef *TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection, uint16_t TIM_ICFilter)
 Configure the TI4 as Input. More...
 
void TIM_ARRPreloadConfig (TIM_TypeDef *TIMx, FunctionalState NewState)
 Enables or disables TIMx peripheral Preload register on ARR. More...
 
void TIM_BDTRConfig (TIM_TypeDef *TIMx, TIM_BDTRInitTypeDef *TIM_BDTRInitStruct)
 Configures the Break feature, dead time, Lock level, OSSI/OSSR State and the AOE(automatic output enable). More...
 
void TIM_BDTRStructInit (TIM_BDTRInitTypeDef *TIM_BDTRInitStruct)
 Fills each TIM_BDTRInitStruct member with its default value. More...
 
void TIM_CCPreloadControl (TIM_TypeDef *TIMx, FunctionalState NewState)
 Sets or Resets the TIM peripheral Capture Compare Preload Control bit. More...
 
void TIM_CCxCmd (TIM_TypeDef *TIMx, uint16_t TIM_Channel, uint16_t TIM_CCx)
 Enables or disables the TIM Capture Compare Channel x. More...
 
void TIM_CCxNCmd (TIM_TypeDef *TIMx, uint16_t TIM_Channel, uint16_t TIM_CCxN)
 Enables or disables the TIM Capture Compare Channel xN. More...
 
void TIM_ClearFlag (TIM_TypeDef *TIMx, uint16_t TIM_FLAG)
 Clears the TIMx's pending flags. More...
 
void TIM_ClearITPendingBit (TIM_TypeDef *TIMx, uint16_t TIM_IT)
 Clears the TIMx's interrupt pending bits. More...
 
void TIM_ClearOC1Ref (TIM_TypeDef *TIMx, uint16_t TIM_OCClear)
 Clears or safeguards the OCREF1 signal on an external event. More...
 
void TIM_ClearOC2Ref (TIM_TypeDef *TIMx, uint16_t TIM_OCClear)
 Clears or safeguards the OCREF2 signal on an external event. More...
 
void TIM_ClearOC3Ref (TIM_TypeDef *TIMx, uint16_t TIM_OCClear)
 Clears or safeguards the OCREF3 signal on an external event. More...
 
void TIM_ClearOC4Ref (TIM_TypeDef *TIMx, uint16_t TIM_OCClear)
 Clears or safeguards the OCREF4 signal on an external event. More...
 
void TIM_Cmd (TIM_TypeDef *TIMx, FunctionalState NewState)
 Enables or disables the specified TIM peripheral. More...
 
void TIM_CounterModeConfig (TIM_TypeDef *TIMx, uint16_t TIM_CounterMode)
 Specifies the TIMx Counter Mode to be used. More...
 
void TIM_CtrlPWMOutputs (TIM_TypeDef *TIMx, FunctionalState NewState)
 Enables or disables the TIM peripheral Main Outputs. More...
 
void TIM_DeInit (TIM_TypeDef *TIMx)
 Deinitializes the TIMx peripheral registers to their default reset values. More...
 
void TIM_DMACmd (TIM_TypeDef *TIMx, uint16_t TIM_DMASource, FunctionalState NewState)
 Enables or disables the TIMx's DMA Requests. More...
 
void TIM_DMAConfig (TIM_TypeDef *TIMx, uint16_t TIM_DMABase, uint16_t TIM_DMABurstLength)
 Configures the TIMx's DMA interface. More...
 
void TIM_EncoderInterfaceConfig (TIM_TypeDef *TIMx, uint16_t TIM_EncoderMode, uint16_t TIM_IC1Polarity, uint16_t TIM_IC2Polarity)
 Configures the TIMx Encoder Interface. More...
 
void TIM_ETRClockMode1Config (TIM_TypeDef *TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter)
 Configures the External clock Mode1. More...
 
void TIM_ETRClockMode2Config (TIM_TypeDef *TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter)
 Configures the External clock Mode2. More...
 
void TIM_ETRConfig (TIM_TypeDef *TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter)
 Configures the TIMx External Trigger (ETR). More...
 
void TIM_ForcedOC1Config (TIM_TypeDef *TIMx, uint16_t TIM_ForcedAction)
 Forces the TIMx output 1 waveform to active or inactive level. More...
 
void TIM_ForcedOC2Config (TIM_TypeDef *TIMx, uint16_t TIM_ForcedAction)
 Forces the TIMx output 2 waveform to active or inactive level. More...
 
void TIM_ForcedOC3Config (TIM_TypeDef *TIMx, uint16_t TIM_ForcedAction)
 Forces the TIMx output 3 waveform to active or inactive level. More...
 
void TIM_ForcedOC4Config (TIM_TypeDef *TIMx, uint16_t TIM_ForcedAction)
 Forces the TIMx output 4 waveform to active or inactive level. More...
 
void TIM_GenerateEvent (TIM_TypeDef *TIMx, uint16_t TIM_EventSource)
 Configures the TIMx event to be generate by software. More...
 
uint32_t TIM_GetCapture1 (TIM_TypeDef *TIMx)
 Gets the TIMx Input Capture 1 value. More...
 
uint32_t TIM_GetCapture2 (TIM_TypeDef *TIMx)
 Gets the TIMx Input Capture 2 value. More...
 
uint32_t TIM_GetCapture3 (TIM_TypeDef *TIMx)
 Gets the TIMx Input Capture 3 value. More...
 
uint32_t TIM_GetCapture4 (TIM_TypeDef *TIMx)
 Gets the TIMx Input Capture 4 value. More...
 
uint32_t TIM_GetCounter (TIM_TypeDef *TIMx)
 Gets the TIMx Counter value. More...
 
FlagStatus TIM_GetFlagStatus (TIM_TypeDef *TIMx, uint16_t TIM_FLAG)
 Checks whether the specified TIM flag is set or not. More...
 
ITStatus TIM_GetITStatus (TIM_TypeDef *TIMx, uint16_t TIM_IT)
 Checks whether the TIM interrupt has occurred or not. More...
 
uint16_t TIM_GetPrescaler (TIM_TypeDef *TIMx)
 Gets the TIMx Prescaler value. More...
 
void TIM_ICInit (TIM_TypeDef *TIMx, TIM_ICInitTypeDef *TIM_ICInitStruct)
 Initializes the TIM peripheral according to the specified parameters in the TIM_ICInitStruct. More...
 
void TIM_ICStructInit (TIM_ICInitTypeDef *TIM_ICInitStruct)
 Fills each TIM_ICInitStruct member with its default value. More...
 
void TIM_InternalClockConfig (TIM_TypeDef *TIMx)
 Configures the TIMx internal Clock. More...
 
void TIM_ITConfig (TIM_TypeDef *TIMx, uint16_t TIM_IT, FunctionalState NewState)
 Enables or disables the specified TIM interrupts. More...
 
void TIM_ITRxExternalClockConfig (TIM_TypeDef *TIMx, uint16_t TIM_InputTriggerSource)
 Configures the TIMx Internal Trigger as External Clock. More...
 
void TIM_OC1FastConfig (TIM_TypeDef *TIMx, uint16_t TIM_OCFast)
 Configures the TIMx Output Compare 1 Fast feature. More...
 
void TIM_OC1Init (TIM_TypeDef *TIMx, TIM_OCInitTypeDef *TIM_OCInitStruct)
 Initializes the TIMx Channel1 according to the specified parameters in the TIM_OCInitStruct. More...
 
void TIM_OC1NPolarityConfig (TIM_TypeDef *TIMx, uint16_t TIM_OCNPolarity)
 Configures the TIMx Channel 1N polarity. More...
 
void TIM_OC1PolarityConfig (TIM_TypeDef *TIMx, uint16_t TIM_OCPolarity)
 Configures the TIMx channel 1 polarity. More...
 
void TIM_OC1PreloadConfig (TIM_TypeDef *TIMx, uint16_t TIM_OCPreload)
 Enables or disables the TIMx peripheral Preload register on CCR1. More...
 
void TIM_OC2FastConfig (TIM_TypeDef *TIMx, uint16_t TIM_OCFast)
 Configures the TIMx Output Compare 2 Fast feature. More...
 
void TIM_OC2Init (TIM_TypeDef *TIMx, TIM_OCInitTypeDef *TIM_OCInitStruct)
 Initializes the TIMx Channel2 according to the specified parameters in the TIM_OCInitStruct. More...
 
void TIM_OC2NPolarityConfig (TIM_TypeDef *TIMx, uint16_t TIM_OCNPolarity)
 Configures the TIMx Channel 2N polarity. More...
 
void TIM_OC2PolarityConfig (TIM_TypeDef *TIMx, uint16_t TIM_OCPolarity)
 Configures the TIMx channel 2 polarity. More...
 
void TIM_OC2PreloadConfig (TIM_TypeDef *TIMx, uint16_t TIM_OCPreload)
 Enables or disables the TIMx peripheral Preload register on CCR2. More...
 
void TIM_OC3FastConfig (TIM_TypeDef *TIMx, uint16_t TIM_OCFast)
 Configures the TIMx Output Compare 3 Fast feature. More...
 
void TIM_OC3Init (TIM_TypeDef *TIMx, TIM_OCInitTypeDef *TIM_OCInitStruct)
 Initializes the TIMx Channel3 according to the specified parameters in the TIM_OCInitStruct. More...
 
void TIM_OC3NPolarityConfig (TIM_TypeDef *TIMx, uint16_t TIM_OCNPolarity)
 Configures the TIMx Channel 3N polarity. More...
 
void TIM_OC3PolarityConfig (TIM_TypeDef *TIMx, uint16_t TIM_OCPolarity)
 Configures the TIMx channel 3 polarity. More...
 
void TIM_OC3PreloadConfig (TIM_TypeDef *TIMx, uint16_t TIM_OCPreload)
 Enables or disables the TIMx peripheral Preload register on CCR3. More...
 
void TIM_OC4FastConfig (TIM_TypeDef *TIMx, uint16_t TIM_OCFast)
 Configures the TIMx Output Compare 4 Fast feature. More...
 
void TIM_OC4Init (TIM_TypeDef *TIMx, TIM_OCInitTypeDef *TIM_OCInitStruct)
 Initializes the TIMx Channel4 according to the specified parameters in the TIM_OCInitStruct. More...
 
void TIM_OC4PolarityConfig (TIM_TypeDef *TIMx, uint16_t TIM_OCPolarity)
 Configures the TIMx channel 4 polarity. More...
 
void TIM_OC4PreloadConfig (TIM_TypeDef *TIMx, uint16_t TIM_OCPreload)
 Enables or disables the TIMx peripheral Preload register on CCR4. More...
 
void TIM_OCStructInit (TIM_OCInitTypeDef *TIM_OCInitStruct)
 Fills each TIM_OCInitStruct member with its default value. More...
 
void TIM_PrescalerConfig (TIM_TypeDef *TIMx, uint16_t Prescaler, uint16_t TIM_PSCReloadMode)
 Configures the TIMx Prescaler. More...
 
void TIM_PWMIConfig (TIM_TypeDef *TIMx, TIM_ICInitTypeDef *TIM_ICInitStruct)
 Configures the TIM peripheral according to the specified parameters in the TIM_ICInitStruct to measure an external PWM signal. More...
 
void TIM_RemapConfig (TIM_TypeDef *TIMx, uint16_t TIM_Remap)
 Configures the TIM2, TIM5 and TIM11 Remapping input capabilities. More...
 
void TIM_SelectCCDMA (TIM_TypeDef *TIMx, FunctionalState NewState)
 Selects the TIMx peripheral Capture Compare DMA source. More...
 
void TIM_SelectCOM (TIM_TypeDef *TIMx, FunctionalState NewState)
 Selects the TIM peripheral Commutation event. More...
 
void TIM_SelectHallSensor (TIM_TypeDef *TIMx, FunctionalState NewState)
 Enables or disables the TIMx's Hall sensor interface. More...
 
void TIM_SelectInputTrigger (TIM_TypeDef *TIMx, uint16_t TIM_InputTriggerSource)
 Selects the Input Trigger source. More...
 
void TIM_SelectMasterSlaveMode (TIM_TypeDef *TIMx, uint16_t TIM_MasterSlaveMode)
 Sets or Resets the TIMx Master/Slave Mode. More...
 
void TIM_SelectOCxM (TIM_TypeDef *TIMx, uint16_t TIM_Channel, uint16_t TIM_OCMode)
 Selects the TIM Output Compare Mode. More...
 
void TIM_SelectOnePulseMode (TIM_TypeDef *TIMx, uint16_t TIM_OPMode)
 Selects the TIMx's One Pulse Mode. More...
 
void TIM_SelectOutputTrigger (TIM_TypeDef *TIMx, uint16_t TIM_TRGOSource)
 Selects the TIMx Trigger Output Mode. More...
 
void TIM_SelectSlaveMode (TIM_TypeDef *TIMx, uint16_t TIM_SlaveMode)
 Selects the TIMx Slave Mode. More...
 
void TIM_SetAutoreload (TIM_TypeDef *TIMx, uint32_t Autoreload)
 Sets the TIMx Autoreload Register value. More...
 
void TIM_SetClockDivision (TIM_TypeDef *TIMx, uint16_t TIM_CKD)
 Sets the TIMx Clock Division value. More...
 
void TIM_SetCompare1 (TIM_TypeDef *TIMx, uint32_t Compare1)
 Sets the TIMx Capture Compare1 Register value. More...
 
void TIM_SetCompare2 (TIM_TypeDef *TIMx, uint32_t Compare2)
 Sets the TIMx Capture Compare2 Register value. More...
 
void TIM_SetCompare3 (TIM_TypeDef *TIMx, uint32_t Compare3)
 Sets the TIMx Capture Compare3 Register value. More...
 
void TIM_SetCompare4 (TIM_TypeDef *TIMx, uint32_t Compare4)
 Sets the TIMx Capture Compare4 Register value. More...
 
void TIM_SetCounter (TIM_TypeDef *TIMx, uint32_t Counter)
 Sets the TIMx Counter Register value. More...
 
void TIM_SetIC1Prescaler (TIM_TypeDef *TIMx, uint16_t TIM_ICPSC)
 Sets the TIMx Input Capture 1 prescaler. More...
 
void TIM_SetIC2Prescaler (TIM_TypeDef *TIMx, uint16_t TIM_ICPSC)
 Sets the TIMx Input Capture 2 prescaler. More...
 
void TIM_SetIC3Prescaler (TIM_TypeDef *TIMx, uint16_t TIM_ICPSC)
 Sets the TIMx Input Capture 3 prescaler. More...
 
void TIM_SetIC4Prescaler (TIM_TypeDef *TIMx, uint16_t TIM_ICPSC)
 Sets the TIMx Input Capture 4 prescaler. More...
 
void TIM_TimeBaseInit (TIM_TypeDef *TIMx, TIM_TimeBaseInitTypeDef *TIM_TimeBaseInitStruct)
 Initializes the TIMx Time Base Unit peripheral according to the specified parameters in the TIM_TimeBaseInitStruct. More...
 
void TIM_TimeBaseStructInit (TIM_TimeBaseInitTypeDef *TIM_TimeBaseInitStruct)
 Fills each TIM_TimeBaseInitStruct member with its default value. More...
 
void TIM_TIxExternalClockConfig (TIM_TypeDef *TIMx, uint16_t TIM_TIxExternalCLKSource, uint16_t TIM_ICPolarity, uint16_t ICFilter)
 Configures the TIMx Trigger as External Clock. More...
 
void TIM_UpdateDisableConfig (TIM_TypeDef *TIMx, FunctionalState NewState)
 Enables or Disables the TIMx Update event. More...
 
void TIM_UpdateRequestConfig (TIM_TypeDef *TIMx, uint16_t TIM_UpdateSource)
 Configures the TIMx Update Request Interrupt source. More...
 

Detailed Description

This file provides firmware functions to manage the following functionalities of the TIM peripheral:

Author
MCD Application Team
Version
V1.1.0
Date
11-January-2013
  • TimeBase management
  • Output Compare management
  • Input Capture management
  • Advanced-control timers (TIM1 and TIM8) specific features
  • Interrupts, DMA and flags management
  • Clocks management
  • Synchronization management
  • Specific interface management
  • Specific remapping management
===============================================================================
                  #####  How to use this driver #####
===============================================================================
   [..]
   This driver provides functions to configure and program the TIM 
   of all STM32F4xx devices.
   These functions are split in 9 groups: 
    
     (#) TIM TimeBase management: this group includes all needed functions 
         to configure the TM Timebase unit:
       (++) Set/Get Prescaler
       (++) Set/Get Autoreload  
       (++) Counter modes configuration
       (++) Set Clock division  
       (++) Select the One Pulse mode
       (++) Update Request Configuration
       (++) Update Disable Configuration
       (++) Auto-Preload Configuration 
       (++) Enable/Disable the counter     
                  
     (#) TIM Output Compare management: this group includes all needed 
         functions to configure the Capture/Compare unit used in Output 
         compare mode: 
       (++) Configure each channel, independently, in Output Compare mode
       (++) Select the output compare modes
       (++) Select the Polarities of each channel
       (++) Set/Get the Capture/Compare register values
       (++) Select the Output Compare Fast mode 
       (++) Select the Output Compare Forced mode  
       (++) Output Compare-Preload Configuration 
       (++) Clear Output Compare Reference
       (++) Select the OCREF Clear signal
       (++) Enable/Disable the Capture/Compare Channels    
                    
     (#) TIM Input Capture management: this group includes all needed 
         functions to configure the Capture/Compare unit used in 
         Input Capture mode:
       (++) Configure each channel in input capture mode
       (++) Configure Channel1/2 in PWM Input mode
       (++) Set the Input Capture Prescaler
       (++) Get the Capture/Compare values      
                    
     (#) Advanced-control timers (TIM1 and TIM8) specific features
       (++) Configures the Break input, dead time, Lock level, the OSSI,
            the OSSR State and the AOE(automatic output enable)
       (++) Enable/Disable the TIM peripheral Main Outputs
       (++) Select the Commutation event
       (++) Set/Reset the Capture Compare Preload Control bit
                               
     (#) TIM interrupts, DMA and flags management
       (++) Enable/Disable interrupt sources
       (++) Get flags status
       (++) Clear flags/ Pending bits
       (++) Enable/Disable DMA requests 
       (++) Configure DMA burst mode
       (++) Select CaptureCompare DMA request  
               
     (#) TIM clocks management: this group includes all needed functions 
         to configure the clock controller unit:
       (++) Select internal/External clock
       (++) Select the external clock mode: ETR(Mode1/Mode2), TIx or ITRx
          
     (#) TIM synchronization management: this group includes all needed 
         functions to configure the Synchronization unit:
       (++) Select Input Trigger  
       (++) Select Output Trigger  
       (++) Select Master Slave Mode 
       (++) ETR Configuration when used as external trigger   
      
     (#) TIM specific interface management, this group includes all 
         needed functions to use the specific TIM interface:
       (++) Encoder Interface Configuration
       (++) Select Hall Sensor   
          
     (#) TIM specific remapping management includes the Remapping 
         configuration of specific timers               
Attention

© COPYRIGHT 2013 STMicroelectronics

Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); You may not use this file except in compliance with the License. You may obtain a copy of the License at:

   http://www.st.com/software_license_agreement_liberty_v2

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file stm32f4xx_tim.c.



rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Wed Jul 3 2019 19:59:27