/**
******************************************************************************
* @file stm32f10x_tim.c
* @author MCD Application Team
* @version V3.6.2
* @date 17-September-2021
* @brief This file provides all the TIM firmware functions.
******************************************************************************
* @attention
*
* Copyright (c) 2012 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32f10x_tim.h"
#include "stm32f10x_rcc.h"
/** @addtogroup STM32F10x_StdPeriph_Driver
* @{
*/
/** @defgroup TIM
* @brief TIM driver modules
* @{
*/
/** @defgroup TIM_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup TIM_Private_Defines
* @{
*/
/* ---------------------- TIM registers bit mask ------------------------ */
#define SMCR_ETR_Mask ((uint16_t)0x00FF)
#define CCMR_Offset ((uint16_t)0x0018)
#define CCER_CCE_Set ((uint16_t)0x0001)
#define CCER_CCNE_Set ((uint16_t)0x0004)
/**
* @}
*/
/** @defgroup TIM_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup TIM_Private_Variables
* @{
*/
/**
* @}
*/
/** @defgroup TIM_Private_FunctionPrototypes
* @{
*/
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);
/**
* @}
*/
/** @defgroup TIM_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup TIM_Private_Variables
* @{
*/
/**
* @}
*/
/** @defgroup TIM_Private_FunctionPrototypes
* @{
*/
/**
* @}
*/
/** @defgroup TIM_Private_Functions
* @{
*/
/**
* @brief Deinitializes the TIMx peripheral registers to their default reset values.
* @param TIMx: where x can be 1 to 17 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 == TIM1)
{
RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM1, ENABLE);
RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM1, DISABLE);
}
else 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 == TIM5)
{
RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM5, ENABLE);
RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM5, 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 == TIM8)
{
RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM8, ENABLE);
RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM8, 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);
}
else if (TIMx == TIM12)
{
RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM12, ENABLE);
RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM12, DISABLE);
}
else if (TIMx == TIM13)
{
RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM13, ENABLE);
RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM13, DISABLE);
}
else if (TIMx == TIM14)
{
RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM14, ENABLE);
RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM14, DISABLE);
}
else if (TIMx == TIM15)
{
RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM15, ENABLE);
RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM15, DISABLE);
}
else if (TIMx == TIM16)
{
RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM16, ENABLE);
RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM16, DISABLE);
}
else
{
if (TIMx == TIM17)
{
RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM17, ENABLE);
RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM17, DISABLE);
}
}
}
/**
* @brief Initializes the TIMx Time Base Unit peripheral according to
* the specified parameters in the TIM_TimeBaseInitStruct.
* @param TIMx: where x can be 1 to 17 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 == TIM1) || (TIMx == TIM8)|| (TIMx == TIM2) || (TIMx == TIM3)||
(TIMx == TIM4) || (TIMx == TIM5))
{
/* 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;
if ((TIMx == TIM1) || (TIMx == TIM8)|| (TIMx == TIM15)|| (TIMx == TIM16) || (TIMx == TIM17))
{
/* Set the Repetition Counter value */
TIMx->RCR = TIM_TimeBaseInitStruct->TIM_RepetitionCounter;
}
/* Generate an update event to reload the Prescaler and the Repetition counter
values immediately */
TIMx->EGR = TIM_PSCReloadMode_Immediate;
}
/**
* @brief Initializes the TIMx Channel1 according to the specified
* parameters in the TIM_OCInitStruct.
* @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral.
* @param TIM_OCInitStruct: pointer to a TIM_OCInitTypeDef structure
* that contains the configuration information for the specified TIM peripheral.
* @retval None
*/
void TIM_OC1Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct)
{
uint16_t tmpccmrx =
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于STM32F103RCT6的IIC通信的手势传感器PAJ7620U2数据采集,串口打印显示手势识别结果,基于标准库开发;适用于嵌入式、STM32单片机开发和物联网开发领域的电子信息专业、物联网专业课程设计开发及工程技术人员项目开发。程序模块化开发,内包含串口通信模块能与串口调试助手通信显示采集识别到的手势结果。 接线方式: STM32开发板的PB12、PB13分别与PAJ7620U2(I2C版)的SCL、SDA相连; 实验现象: 用手或物体在PAJ7620U2附近完向上、向下、向左、向右、向前、向后、顺时针、逆时针、挥动等九种手势, 串口助手会实时显示对应的手势名称。
资源推荐
资源详情
资源评论
收起资源包目录
基于STM32F103RCT6的IIC通信的手势传感器PAJ7620U2数据采集,串口打印显示手势识别结果,基于标准库开发 (184个子文件)
Template.uvguix.Administrator 89KB
Template.axf 302KB
stm32f10x_tim.c 106KB
stm32f10x_flash.c 61KB
stm32f10x_rcc.c 50KB
stm32f10x_adc.c 46KB
stm32f10x_i2c.c 44KB
stm32f10x_can.c 44KB
stm32f10x_usart.c 37KB
system_stm32f10x.c 35KB
stm32f10x_fsmc.c 34KB
stm32f10x_spi.c 29KB
stm32f10x_dma.c 29KB
stm32f10x_sdio.c 28KB
stm32f10x_gpio.c 22KB
stm32f10x_dac.c 18KB
core_cm3.c 17KB
stm32f10x_cec.c 11KB
stm32f10x_rtc.c 9KB
stm32f10x_pwr.c 8KB
stm32f10x_bkp.c 8KB
misc.c 7KB
stm32f10x_exti.c 6KB
I2CS.c 6KB
stm32f10x_wwdg.c 5KB
stm32f10x_dbgmcu.c 5KB
stm32f10x_iwdg.c 4KB
stm32f10x_it.c 4KB
PAJ7620U2.c 4KB
USART1.c 3KB
stm32f10x_crc.c 3KB
main.c 1KB
delay.c 839B
stm32f10x_tim.crf 363KB
stm32f10x_can.crf 350KB
stm32f10x_adc.crf 349KB
stm32f10x_rcc.crf 349KB
stm32f10x_flash.crf 349KB
main.crf 348KB
stm32f10x_i2c.crf 348KB
usart1.crf 348KB
stm32f10x_usart.crf 347KB
stm32f10x_fsmc.crf 347KB
stm32f10x_sdio.crf 346KB
stm32f10x_spi.crf 346KB
stm32f10x_gpio.crf 345KB
paj7620u2.crf 345KB
stm32f10x_dma.crf 345KB
i2cs.crf 345KB
stm32f10x_dac.crf 343KB
stm32f10x_cec.crf 343KB
system_stm32f10x.crf 343KB
stm32f10x_rtc.crf 343KB
stm32f10x_bkp.crf 343KB
stm32f10x_pwr.crf 343KB
stm32f10x_exti.crf 342KB
stm32f10x_wwdg.crf 342KB
misc.crf 342KB
stm32f10x_iwdg.crf 342KB
stm32f10x_crc.crf 341KB
delay.crf 341KB
stm32f10x_it.crf 341KB
stm32f10x_dbgmcu.crf 341KB
core_cm3.crf 4KB
stm32f10x_dbgmcu.d 2KB
stm32f10x_flash.d 2KB
stm32f10x_usart.d 2KB
stm32f10x_fsmc.d 2KB
stm32f10x_iwdg.d 2KB
stm32f10x_sdio.d 2KB
stm32f10x_gpio.d 2KB
stm32f10x_exti.d 2KB
stm32f10x_wwdg.d 2KB
system_stm32f10x.d 2KB
stm32f10x_rcc.d 2KB
stm32f10x_dac.d 2KB
stm32f10x_crc.d 2KB
stm32f10x_adc.d 2KB
stm32f10x_pwr.d 2KB
stm32f10x_can.d 2KB
stm32f10x_rtc.d 2KB
stm32f10x_i2c.d 2KB
stm32f10x_bkp.d 2KB
stm32f10x_tim.d 2KB
stm32f10x_spi.d 2KB
stm32f10x_dma.d 2KB
stm32f10x_cec.d 2KB
paj7620u2.d 2KB
stm32f10x_it.d 2KB
main.d 2KB
usart1.d 2KB
i2cs.d 2KB
delay.d 2KB
misc.d 2KB
core_cm3.d 132B
startup_stm32f10x_hd.d 73B
Demo_STM32F103C8_1.0.0.dbgconf 2KB
Demo_STM32F103ZE_1.0.0.dbgconf 2KB
Target_1_STM32F103ZE_1.0.0.dbgconf 2KB
Demo_STM32F103RC_1.0.0.dbgconf 2KB
共 184 条
- 1
- 2
资源评论
jacklood
- 粉丝: 437
- 资源: 35
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功