亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
麻豆精品国产传媒mv男同 | 一本大道久久a久久精二百| 国产欧美精品一区二区色综合| 国产一区在线观看麻豆| 国产三级一区二区三区| 成人污视频在线观看| 亚洲欧洲精品天堂一级| 欧美视频第二页| 爽爽淫人综合网网站| 日韩午夜激情视频| 国产老肥熟一区二区三区| 日本一区二区在线不卡| 一本大道久久精品懂色aⅴ| 日韩精品三区四区| 国产亚洲一二三区| 色综合久久久久综合| 日本不卡中文字幕| 国产欧美一区二区三区在线老狼| 成人av在线资源| 亚洲成av人在线观看| 欧美成人精品3d动漫h| 成人在线视频一区| 午夜精彩视频在线观看不卡| 欧美精品一区二区三区一线天视频| 国产乱国产乱300精品| 一区二区在线观看免费视频播放| 欧美一区二区私人影院日本| 国产.欧美.日韩| 亚洲福利电影网| 欧美国产日韩在线观看| 7777精品伊人久久久大香线蕉的 | 久久伊人中文字幕| 99re这里都是精品| 免费观看成人av| 亚洲日本在线a| 久久综合狠狠综合久久综合88| 91麻豆免费观看| 美女视频黄免费的久久| 一区二区在线免费观看| 久久先锋资源网| 欧美男同性恋视频网站| 成人av综合在线| 国内精品久久久久影院薰衣草| 一区二区三区中文字幕| 国产视频一区二区在线| 这里只有精品视频在线观看| 99re在线视频这里只有精品| 国产一区二区在线观看视频| 亚洲图片欧美综合| 亚洲人被黑人高潮完整版| 欧美一卡2卡三卡4卡5免费| 91丨九色丨蝌蚪丨老版| 国产.欧美.日韩| 九色|91porny| 日产国产高清一区二区三区 | 北条麻妃一区二区三区| 美女视频第一区二区三区免费观看网站| 亚洲欧洲精品一区二区三区 | 亚洲高清免费观看| 亚洲精品国产一区二区精华液| 国产欧美综合在线观看第十页| 精品国产乱码久久久久久牛牛 | 一本久久精品一区二区| 成人av资源下载| 韩国av一区二区| 免费在线观看日韩欧美| 日韩精品电影一区亚洲| 亚洲一区二区三区四区五区黄 | 亚洲电影你懂得| 亚洲精品国产精华液| 中文字幕亚洲在| 一区在线观看免费| 中文字幕欧美三区| 国产精品久久777777| 中文字幕av一区二区三区免费看| 国产亚洲精品免费| 国产网红主播福利一区二区| 久久久久久久网| 国产欧美一区二区精品秋霞影院| 国产亚洲成aⅴ人片在线观看| 国产婷婷色一区二区三区| 久久久另类综合| 国产精品毛片大码女人| ...xxx性欧美| 亚洲综合一区在线| 偷拍一区二区三区| 琪琪一区二区三区| 精品一区二区免费看| 国产一区二区三区在线看麻豆| 韩国一区二区三区| 床上的激情91.| 99精品视频一区二区| 一本大道久久a久久精二百| 欧美午夜精品免费| 91精品国产一区二区三区| 日韩欧美成人激情| 欧美韩国日本综合| 一区二区成人在线观看| 丝袜国产日韩另类美女| 国产在线国偷精品产拍免费yy| 国产美女精品人人做人人爽| www.66久久| 欧美日韩精品一区二区三区四区| 日韩色视频在线观看| 中文字幕国产一区二区| 亚洲免费观看高清完整| 青椒成人免费视频| 成人丝袜18视频在线观看| 色婷婷一区二区三区四区| 欧美猛男男办公室激情| 日韩免费在线观看| 国产精品国产三级国产三级人妇 | 欧美日韩在线直播| 欧美成人免费网站| 亚洲精品视频免费观看| 日本成人在线视频网站| 成+人+亚洲+综合天堂| 51午夜精品国产| 国产精品少妇自拍| 香蕉乱码成人久久天堂爱免费| 国产麻豆日韩欧美久久| 欧美三级在线看| 久久久综合九色合综国产精品| 亚洲精品国产一区二区三区四区在线| 久久国产福利国产秒拍| 色综合视频一区二区三区高清| 精品国产网站在线观看| 一区二区久久久久| 懂色av一区二区三区免费看| 制服丝袜一区二区三区| 国产精品久久久久久久岛一牛影视 | 91精品欧美综合在线观看最新| 久久婷婷国产综合国色天香| 亚洲精品视频在线观看免费| 国产一区视频网站| 欧美三级韩国三级日本一级| 久久久九九九九| 欧美aaa在线| 欧美影视一区在线| 中文字幕亚洲在| 懂色av一区二区夜夜嗨| 欧美成人猛片aaaaaaa| 午夜a成v人精品| 色婷婷av一区二区三区软件| 亚洲国产精品黑人久久久| 经典一区二区三区| 这里只有精品电影| 亚洲无人区一区| 欧洲精品在线观看| 亚洲三级免费电影| 91网站黄www| 国产精品美女久久久久av爽李琼| 狠狠色丁香久久婷婷综合_中| 91精品婷婷国产综合久久| 亚洲影院久久精品| 色综合久久综合| 一区二区三区在线观看国产| 成人丝袜高跟foot| 中文字幕精品三区| 成人免费视频caoporn| 国产欧美日韩综合| 国产999精品久久久久久| 国产亚洲成av人在线观看导航| 蜜桃久久久久久| 精品三级av在线| 久久精品av麻豆的观看方式| 日韩欧美国产不卡| 国产一区二区主播在线| 久久精品人人做人人综合| 国产自产2019最新不卡| www激情久久| 国产精品亚洲一区二区三区在线 | 日韩亚洲欧美综合| 人人狠狠综合久久亚洲| 日韩免费看的电影| 国产在线播放一区| 国产偷v国产偷v亚洲高清| 9i看片成人免费高清| 亚洲男人的天堂在线观看| 91成人看片片| 日韩中文字幕区一区有砖一区| 欧美日韩国产一二三| 蜜臀久久久99精品久久久久久| 精品免费国产二区三区| 国产精品99久久久久| 亚洲欧美电影一区二区| 在线观看日韩一区| 日本sm残虐另类| 久久精品视频免费| 一本到高清视频免费精品| 婷婷综合久久一区二区三区| 欧美videos大乳护士334| 国产成人亚洲精品狼色在线| 亚洲免费在线视频一区 二区| 欧美伊人久久大香线蕉综合69| 日韩高清在线一区| 国产日韩欧美一区二区三区乱码 | 国产成人av电影在线观看| 日韩伦理免费电影| 91精品国产综合久久精品app|