/**
******************************************************************************
* @file stm32f10x_tim.c
* @author MCD Application Team
* @version V3.5.0
* @date 11-March-2011
* @brief This file provides all the TIM firmware functions.
******************************************************************************
* @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>© COPYRIGHT 2011 STMicroelectronics</center></h2>
******************************************************************************
*/
/* 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 = 0, tmpccer = 0, tmpc
没有合适的资源?快使用搜索试试~ 我知道了~
基于stm32开发的双轮平衡自动循迹小车+源代码+文档说明
共278个文件
h:58个
c:52个
d:48个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 2 下载量 179 浏览量
2023-12-02
20:35:51
上传
评论
收藏 9.75MB ZIP 举报
温馨提示
- ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。
资源推荐
资源详情
资源评论
收起资源包目录
基于stm32开发的双轮平衡自动循迹小车+源代码+文档说明 (278个子文件)
MiniBalance.uvguix.Administrator 135KB
MiniBalance.axf 742KB
MiniBalance.uvgui_passoni.bak 175KB
MiniBalance_uvopt.bak 33KB
MiniBalance_uvproj.bak 25KB
keilkill.bat 372B
stm32f10x_tim.c 104KB
inv_mpu.c 79KB
inv_mpu.c 79KB
stm32f10x_flash.c 59KB
inv_mpu_dmp_motion_driver.c 55KB
inv_mpu_dmp_motion_driver.c 55KB
stm32f10x_rcc.c 49KB
stm32f10x_adc.c 45KB
stm32f10x_i2c.c 43KB
stm32f10x_can.c 43KB
stm32f10x_usart.c 36KB
system_stm32f10x.c 35KB
stm32f10x_fsmc.c 34KB
stm32f10x_spi.c 29KB
stm32f10x_dma.c 28KB
stm32f10x_sdio.c 27KB
stm32f10x_gpio.c 22KB
stm32f10x_dac.c 18KB
core_cm3.c 16KB
control.c 16KB
timer.c 13KB
oled.c 13KB
stm32f10x_cec.c 11KB
MPU6050.c 11KB
IOI2C.c 10KB
MPU6050.c 10KB
stm32f10x_pwr.c 8KB
stm32f10x_rtc.c 8KB
stm32f10x_bkp.c 8KB
stmflash.c 7KB
misc.c 7KB
LED.C 7KB
stm32f10x_exti.c 7KB
delay.c 6KB
stm32f10x_wwdg.c 5KB
usart3.c 5KB
usart.c 5KB
sys.c 5KB
stm32f10x_dbgmcu.c 5KB
encoder.c 5KB
stm32f10x_iwdg.c 5KB
stm32f10x_it.c 4KB
motor.c 4KB
MiniBalance.c 3KB
key.c 3KB
stm32f10x_crc.c 3KB
show.c 3KB
adc.c 3KB
DataScope_DP.C 3KB
DataScope_DP.C 3KB
filter.c 2KB
exti.c 2KB
inv_mpu.crf 431KB
inv_mpu_dmp_motion_driver.crf 423KB
oled.crf 420KB
control.crf 418KB
ioi2c.crf 416KB
mpu6050.crf 415KB
timer.crf 414KB
led.crf 414KB
sys.crf 414KB
usart.crf 413KB
stmflash.crf 413KB
motor.crf 413KB
key.crf 413KB
adc.crf 412KB
delay.crf 412KB
minibalance.crf 412KB
usart3.crf 412KB
exti.crf 412KB
stm32f10x_tim.crf 361KB
stm32f10x_can.crf 348KB
stm32f10x_adc.crf 346KB
stm32f10x_rcc.crf 346KB
stm32f10x_flash.crf 346KB
stm32f10x_i2c.crf 345KB
stm32f10x_usart.crf 345KB
stm32f10x_fsmc.crf 345KB
stm32f10x_sdio.crf 343KB
stm32f10x_spi.crf 343KB
stm32f10x_gpio.crf 343KB
stm32f10x_dma.crf 342KB
stm32f10x_dac.crf 341KB
stm32f10x_cec.crf 341KB
system_stm32f10x.crf 340KB
stm32f10x_bkp.crf 340KB
stm32f10x_pwr.crf 340KB
stm32f10x_rtc.crf 340KB
stm32f10x_exti.crf 340KB
stm32f10x_wwdg.crf 339KB
misc.crf 339KB
stm32f10x_iwdg.crf 339KB
stm32f10x_crc.crf 339KB
stm32f10x_it.crf 339KB
共 278 条
- 1
- 2
- 3
资源评论
- 2301_797858902024-06-25超级好的资源,很值得参考学习,对我启发很大,支持!
- 2301_769757912024-04-28内容与描述一致,超赞的资源,值得借鉴的内容很多,支持!奋斗奋斗再奋斗的ajie2024-05-05感谢下载,不懂的可以私聊
奋斗奋斗再奋斗的ajie
- 粉丝: 1218
- 资源: 2589
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- c语言连连看游戏源码.zip
- c语言模拟快打旋风游戏源码.zip
- Delphi虚拟打印机源码
- c语言配有图片和音乐的打字母游戏.zip
- c语言拼图游戏源码.zip
- c语言青蛙过河小游戏.zip
- chuzhan-1.39.1-241130093624.apk.zip
- Scratch中我的世界源码
- c语言情人节的红玫瑰.zip
- 开源ThingLinks物联网一体化平台,高性能、高吞吐量、高扩展性的物联网平台!单机可以支持百万链接,同时支持自定义扩展功能,功能非常强大,采用netty作为通信层组件,支持插件化开发集成!
- c语言扔香蕉的大猩猩.zip
- 西门子1200 1500系列PLC 脉冲伺服功能块集成 该功能块集成了运动控制块 手自动 报警 报警处理 触摸屏关联 将功能块发挥到了极致 完美诠释了功能块的的意义 功能块的颠覆者
- Minecraft主题光标
- c语言商品销售系统源码.zip
- OC-Dialect线上多语言(多列表) 1.原理解析
- Visual Basic范例开发大全
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功