亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? stm32l1xx_tim.c

?? STM32+Grlib
?? C
?? 第 1 頁 / 共 5 頁
字號:
/**
  ******************************************************************************
  * @file    stm32l1xx_tim.c
  * @author  MCD Application Team
  * @version V1.0.0
  * @date    31-December-2010
  * @brief   This file provides firmware functions to manage the following 
  *          functionalities of the TIM peripheral:
  *            - TimeBase management
  *            - Output Compare management
  *            - Input Capture management
  *            - Interrupts, DMA and flags management
  *            - Clocks management
  *            - Synchronization management
  *            - Specific interface management
  *            - Specific remapping management      
  *              
  *  @verbatim
  *  
  *          ===================================================================
  *                                 How to use this driver
  *          ===================================================================
  *          This driver provides functions to configure and program the TIM 
  *          of all STM32L1xx devices
  *          These functions are split in 8 groups: 
  *   
  *          1. 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     
  *                 
  *          2. 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    
  *                   
  *          3. 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      
  *        
  *          4. 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  
  *              
  *          5. 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
  *         
  *          6. 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   
  *     
  *          7. TIM specific interface management, this group includes all 
  *             needed functions to use the specific TIM interface:
  *                   - Encoder Interface Configuration
  *                   - Select Hall Sensor   
  *         
  *          8. TIM specific remapping management includes the Remapping 
  *             configuration of specific timers               
  *   
  *  @endverbatim
  *    
  ******************************************************************************
  * @attention
  *
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  *
  * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
  ******************************************************************************  
  */ 

/* Includes ------------------------------------------------------------------*/
#include "stm32l1xx_tim.h"
#include "stm32l1xx_rcc.h"

/** @addtogroup STM32L1xx_StdPeriph_Driver
  * @{
  */

/** @defgroup TIM 
  * @brief TIM driver modules
  * @{
  */

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/

/* ---------------------- TIM registers bit mask ------------------------ */
#define SMCR_ETR_MASK               ((uint16_t)0x00FF) 
#define CCMR_OFFSET                 ((uint16_t)0x0018)
#define CCER_CCE_SET                ((uint16_t)0x0001)  
  
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/

static void TI1_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection,
                       uint16_t TIM_ICFilter);
static void TI2_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection,
                       uint16_t TIM_ICFilter);
static void TI3_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection,
                       uint16_t TIM_ICFilter);
static void TI4_Config(TIM_TypeDef* TIMx, uint16_t TIM_ICPolarity, uint16_t TIM_ICSelection,
                       uint16_t TIM_ICFilter);
/* Private functions ---------------------------------------------------------*/

/** @defgroup TIM_Private_Functions
  * @{
  */

/** @defgroup TIM_Group1 TimeBase management functions
 *  @brief   TimeBase management functions 
 *
@verbatim   
 ===============================================================================
                       TimeBase management functions
 ===============================================================================  
  
       ===================================================================      
              TIM Driver: how to use it in Timing(Time base) Mode
       =================================================================== 
       To use the Timer in Timing(Time base) mode, the following steps are mandatory:
       
       1. Enable TIM clock using RCC_APBxPeriphClockCmd(RCC_APBxPeriph_TIMx, ENABLE) function
                    
       2. Fill the TIM_TimeBaseInitStruct with the desired parameters.
       
       3. Call TIM_TimeBaseInit(TIMx, &TIM_TimeBaseInitStruct) to configure the Time Base unit
          with the corresponding configuration
          
       4. Enable the NVIC if you need to generate the update interrupt. 
          
       5. Enable the corresponding interrupt using the function TIM_ITConfig(TIMx, TIM_IT_Update) 
       
       6. Call the TIM_Cmd(ENABLE) function to enable the TIM counter.
             
       Note1: All other functions can be used seperatly to modify, if needed,
          a specific feature of the Timer. 

@endverbatim
  * @{
  */

/**
  * @brief  Deinitializes the TIMx peripheral registers to their default reset values.
  * @param  TIMx: where x can be 2 to 11 to select the TIM peripheral.
  * @retval None
  *   
  */
void TIM_DeInit(TIM_TypeDef* TIMx)
{
  /* Check the parameters */
  assert_param(IS_TIM_ALL_PERIPH(TIMx)); 
   
  if (TIMx == TIM2)
  {
    RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM2, ENABLE);
    RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM2, DISABLE);
  }
  else if (TIMx == TIM3)
  {
    RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM3, ENABLE);
    RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM3, DISABLE);
  }
  else if (TIMx == TIM4)
  {
    RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM4, ENABLE);
    RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM4, DISABLE);
  } 

  else if (TIMx == TIM6)
  {
    RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM6, ENABLE);
    RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM6, DISABLE);
  } 
  else if (TIMx == TIM7)
  {
    RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM7, ENABLE);
    RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM7, DISABLE);
  } 

  else if (TIMx == TIM9)
  {
    RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM9, ENABLE);
    RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM9, DISABLE);
  } 
  else if (TIMx == TIM10)
  {
    RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM10, ENABLE);
    RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM10, DISABLE);
  } 
  else
  {
    if (TIMx == TIM11)
    {
      RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM11, ENABLE);
      RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM11, DISABLE); 
    }  
  }
     
}

/**
  * @brief  Initializes the TIMx Time Base Unit peripheral according to 
  *         the specified parameters in the TIM_TimeBaseInitStruct.
  * @param  TIMx: where x can be 2 to 11 to select the TIM peripheral.
  * @param  TIM_TimeBaseInitStruct: pointer to a TIM_TimeBaseInitTypeDef
  *         structure that contains the configuration information for
  *         the specified TIM peripheral.
  * @retval None
  */
void TIM_TimeBaseInit(TIM_TypeDef* TIMx, TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct)
{
  uint16_t tmpcr1 = 0;

  /* Check the parameters */
  assert_param(IS_TIM_ALL_PERIPH(TIMx)); 
  assert_param(IS_TIM_COUNTER_MODE(TIM_TimeBaseInitStruct->TIM_CounterMode));
  assert_param(IS_TIM_CKD_DIV(TIM_TimeBaseInitStruct->TIM_ClockDivision));

  tmpcr1 = TIMx->CR1;  

  if(((TIMx) == TIM2) || ((TIMx) == TIM3) || ((TIMx) == TIM4))
  {											
    /* Select the Counter Mode */
    tmpcr1 &= (uint16_t)(~((uint16_t)(TIM_CR1_DIR | TIM_CR1_CMS)));
    tmpcr1 |= (uint32_t)TIM_TimeBaseInitStruct->TIM_CounterMode;
  }
 
  if(((TIMx) != TIM6) && ((TIMx) != TIM7))
  {
    /* Set the clock division */
    tmpcr1 &= (uint16_t)(~((uint16_t)TIM_CR1_CKD));
    tmpcr1 |= (uint32_t)TIM_TimeBaseInitStruct->TIM_ClockDivision;
  }

  TIMx->CR1 = tmpcr1;

  /* Set the Autoreload value */
  TIMx->ARR = TIM_TimeBaseInitStruct->TIM_Period ;
 
  /* Set the Prescaler value */
  TIMx->PSC = TIM_TimeBaseInitStruct->TIM_Prescaler;
    
  /* Generate an update event to reload the Prescaler value immediatly */
  TIMx->EGR = TIM_PSCReloadMode_Immediate;          
}

/**
  * @brief  Fills each TIM_TimeBaseInitStruct member with its default value.
  * @param  TIM_TimeBaseInitStruct : pointer to a TIM_TimeBaseInitTypeDef
  *         structure which will be initialized.
  * @retval None
  */
void TIM_TimeBaseStructInit(TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct)
{
  /* Set the default configuration */
  TIM_TimeBaseInitStruct->TIM_Period = 0xFFFF;
  TIM_TimeBaseInitStruct->TIM_Prescaler = 0x0000;
  TIM_TimeBaseInitStruct->TIM_ClockDivision = TIM_CKD_DIV1;
  TIM_TimeBaseInitStruct->TIM_CounterMode = TIM_CounterMode_Up;
}

/**
  * @brief  Configures the TIMx Prescaler.
  * @param  TIMx: where x can be 2 to 11 to select the TIM peripheral.
  * @param  Prescaler: specifies the Prescaler Register value
  * @param  TIM_PSCReloadMode: specifies the TIM Prescaler Reload mode
  *   This parameter can be one of the following values:
  *     @arg TIM_PSCReloadMode_Update: The Prescaler is loaded at the update event.
  *     @arg TIM_PSCReloadMode_Immediate: The Prescaler is loaded immediatly.
  * @retval None
  */
void TIM_PrescalerConfig(TIM_TypeDef* TIMx, uint16_t Prescaler, uint16_t TIM_PSCReloadMode)
{
  /* Check the parameters */
  assert_param(IS_TIM_ALL_PERIPH(TIMx));
  assert_param(IS_TIM_PRESCALER_RELOAD(TIM_PSCReloadMode));
  
  /* Set the Prescaler value */
  TIMx->PSC = Prescaler;
  /* Set or reset the UG Bit */
  TIMx->EGR = TIM_PSCReloadMode;
}

/**
  * @brief  Specifies the TIMx Counter Mode to be used.
  * @param  TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
  * @param  TIM_CounterMode: specifies the Counter Mode to be used
  *   This parameter can be one of the following values:
  *     @arg TIM_CounterMode_Up: TIM Up Counting Mode
  *     @arg TIM_CounterMode_Down: TIM Down Counting Mode
  *     @arg TIM_CounterMode_CenterAligned1: TIM Center Aligned Mode1
  *     @arg TIM_CounterMode_CenterAligned2: TIM Center Aligned Mode2
  *     @arg TIM_CounterMode_CenterAligned3: TIM Center Aligned Mode3
  * @retval None
  */
void TIM_CounterModeConfig(TIM_TypeDef* TIMx, uint16_t TIM_CounterMode)
{
  uint16_t tmpcr1 = 0;
  
  /* Check the parameters */
  assert_param(IS_TIM_LIST3_PERIPH(TIMx));
  assert_param(IS_TIM_COUNTER_MODE(TIM_CounterMode));
  
  tmpcr1 = TIMx->CR1;
  /* Reset the CMS and DIR Bits */
  tmpcr1 &= (uint16_t)(~((uint16_t)(TIM_CR1_DIR | TIM_CR1_CMS)));
  /* Set the Counter Mode */
  tmpcr1 |= TIM_CounterMode;
  /* Write to TIMx CR1 register */
  TIMx->CR1 = tmpcr1;
}

/**
  * @brief  Sets the TIMx Counter Register value
  * @param  TIMx: where x can be 2 to 11 to select the TIM peripheral.
  * @param  Counter: specifies the Counter register new value.
  * @retval None
  */
void TIM_SetCounter(TIM_TypeDef* TIMx, uint32_t Counter)
{
  /* Check the parameters */
   assert_param(IS_TIM_ALL_PERIPH(TIMx));
   
  /* Set the Counter Register value */
  TIMx->CNT = Counter;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲蜜臀av乱码久久精品蜜桃| 国产欧美日韩精品在线| 99亚偷拍自图区亚洲| 久久99精品久久久久久| 老司机一区二区| 日韩国产精品91| 韩国三级中文字幕hd久久精品| 精久久久久久久久久久| 成人国产亚洲欧美成人综合网| 成人sese在线| 91国偷自产一区二区使用方法| 欧美裸体bbwbbwbbw| 欧美不卡一区二区三区| 国产欧美精品一区二区色综合 | 91在线精品一区二区| 91欧美一区二区| 欧美午夜精品久久久久久孕妇| 91福利视频在线| 欧美一区二区视频免费观看| 久久久久久一级片| 综合精品久久久| 天堂成人国产精品一区| 国产一区二区网址| 色婷婷国产精品久久包臀| 欧美日韩在线播放一区| 久久视频一区二区| 亚洲一区影音先锋| 国产精品18久久久久久久网站| a4yy欧美一区二区三区| 欧美精三区欧美精三区| 国产亚洲一区二区三区在线观看| 亚洲四区在线观看| 乱一区二区av| 在线精品视频免费观看| 国产婷婷色一区二区三区| 亚洲欧美一区二区久久| 精品一区二区三区在线视频| 91小视频免费观看| 日韩免费观看高清完整版 | 国产精品第13页| 日韩国产在线一| av动漫一区二区| 日韩欧美在线影院| 又紧又大又爽精品一区二区| 国产在线一区二区| 欧美日韩一二三区| 亚洲国产精品激情在线观看| 卡一卡二国产精品| 欧美日韩aaaaaa| 玉米视频成人免费看| 成人性生交大片| 欧美精品一区二区三区蜜桃| 亚洲福利电影网| 色综合网色综合| 国产午夜久久久久| 久久成人久久爱| 在线观看91av| 舔着乳尖日韩一区| 欧美亚洲综合久久| 亚洲精品国产品国语在线app| 丰满白嫩尤物一区二区| 久久综合九色综合久久久精品综合| 午夜精品久久久| 在线精品视频免费播放| 亚洲另类春色国产| 色老汉一区二区三区| 亚洲视频在线一区二区| 成人网在线播放| 国产区在线观看成人精品| 国产乱码精品一区二区三区五月婷| 91精品在线观看入口| 日韩av一区二区三区四区| 欧美日韩高清在线| 男女激情视频一区| 日韩女优av电影| 国产精品18久久久久久久久| 久久久蜜臀国产一区二区| 国产一区美女在线| 国产精品无码永久免费888| fc2成人免费人成在线观看播放| 久久精品夜色噜噜亚洲a∨| 国产精品99久久不卡二区| 中文字幕巨乱亚洲| 91麻豆免费在线观看| 亚洲人成网站色在线观看| 色婷婷综合五月| 视频一区欧美精品| 日韩一卡二卡三卡| 国产成人啪免费观看软件| 国产精品成人一区二区三区夜夜夜| 99精品欧美一区| 亚洲成人免费影院| 日韩精品一区二区三区蜜臀| 国产馆精品极品| 亚洲激情图片qvod| 欧美一级日韩免费不卡| 国产不卡高清在线观看视频| 日韩一区在线播放| 欧美日本韩国一区二区三区视频| 麻豆精品一二三| 国产精品久久久久久福利一牛影视| 色狠狠桃花综合| 精品一区二区三区蜜桃| 中文字幕永久在线不卡| 欧美视频第二页| 国产麻豆精品95视频| 亚洲综合丝袜美腿| 精品少妇一区二区三区视频免付费 | 国产欧美日韩卡一| 欧美日韩国产高清一区| 成人亚洲一区二区一| 日韩av二区在线播放| 国产精品天天摸av网| 欧美乱妇20p| 91在线观看高清| 久久99国产精品免费| 亚洲成人精品一区| 中文字幕综合网| 久久久综合九色合综国产精品| 欧美性色黄大片手机版| 国产剧情一区在线| 日韩vs国产vs欧美| 一区二区三区欧美| 国产精品视频你懂的| 欧美大片在线观看一区| 在线观看成人小视频| 成人av免费在线观看| 国产综合色精品一区二区三区| 亚洲国产成人高清精品| 中文字幕日韩一区二区| 国产清纯白嫩初高生在线观看91 | 亚洲欧洲精品天堂一级| 欧美xxx久久| 69p69国产精品| 色悠悠久久综合| av日韩在线网站| 99热精品一区二区| 国产精品亚洲一区二区三区妖精| 婷婷中文字幕综合| 亚洲成人av电影| 亚洲一二三四在线观看| 国产精品国产三级国产aⅴ中文| 日韩精品一区二区三区视频播放| 欧美日产国产精品| 欧美高清视频不卡网| 欧美另类videos死尸| 欧美手机在线视频| 欧美视频一区二区三区| 91久久线看在观草草青青| 91性感美女视频| 色婷婷激情一区二区三区| 91在线云播放| 欧美色区777第一页| 欧亚洲嫩模精品一区三区| 一本色道**综合亚洲精品蜜桃冫| 99re8在线精品视频免费播放| 成人永久aaa| 色综合久久88色综合天天| 韩国三级中文字幕hd久久精品| 中文字幕免费在线观看视频一区| 91香蕉国产在线观看软件| 不卡一区二区在线| 99国产精品久久久久久久久久| 97成人超碰视| 成人在线综合网站| 99久久精品国产导航| 色综合久久久久综合| 视频一区二区中文字幕| 国产麻豆欧美日韩一区| 69成人精品免费视频| 亚洲免费看黄网站| 国产成人精品www牛牛影视| 欧美日韩国产不卡| 一区二区三区四区视频精品免费 | 91麻豆精品91久久久久久清纯| 国产精品国产三级国产普通话三级 | 欧美一卡二卡在线观看| 亚洲精品菠萝久久久久久久| 国产呦萝稀缺另类资源| 日韩一二三四区| 丝袜诱惑亚洲看片| 欧美午夜精品久久久久久超碰| 亚洲色图视频网| 成人高清视频在线| 国产欧美精品国产国产专区| 国内精品久久久久影院薰衣草| 欧美一区二区日韩| 日本不卡1234视频| 日韩一本二本av| 美女www一区二区| 日韩三级免费观看| 免费成人小视频| 日韩欧美中文字幕精品| 欧美aaaaaa午夜精品| 欧美区一区二区三区| 亚洲国产精品麻豆| 欧美日韩午夜精品| 亚洲国产成人va在线观看天堂| 在线观看网站黄不卡| 亚洲自拍欧美精品|