////////////////////////////////////////////////////////////////////////////////
/// @file hal_tim.c
/// @author AE TEAM
/// @brief THIS FILE PROVIDES ALL THE TIM FIRMWARE FUNCTIONS.
////////////////////////////////////////////////////////////////////////////////
/// @attention
///
/// THE EXISTING FIRMWARE IS ONLY FOR REFERENCE, WHICH IS DESIGNED TO PROVIDE
/// CUSTOMERS WITH CODING INFORMATION ABOUT THEIR PRODUCTS SO THEY CAN SAVE
/// TIME. THEREFORE, MINDMOTION SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT OR
/// CONSEQUENTIAL DAMAGES ABOUT ANY CLAIMS ARISING OUT OF THE CONTENT OF SUCH
/// HARDWARE AND/OR THE USE OF THE CODING INFORMATION CONTAINED HEREIN IN
/// CONNECTION WITH PRODUCTS MADE BY CUSTOMERS.
///
/// <H2><CENTER>© COPYRIGHT MINDMOTION </CENTER></H2>
////////////////////////////////////////////////////////////////////////////////
// Define to prevent recursive inclusion
#define _HAL_TIM_C_
// Files includes
#include "hal_rcc.h"
#include "hal_tim.h"
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup MM32_Hardware_Abstract_Layer
/// @{
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup TIM_HAL
/// @{
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup TIM_Exported_Functions
/// @{
////////////////////////////////////////////////////////////////////////////////
/// @brief Deinitializes the tim peripheral registers to their default reset values.
/// @param tim: select the TIM peripheral.
/// @retval None.
////////////////////////////////////////////////////////////////////////////////
void TIM_DeInit(TIM_TypeDef* tim)
{
switch (*(u32*)&tim) {
case (u32)TIM1:
exRCC_APB2PeriphReset(RCC_APB2ENR_TIM1);
break;
case (u32)TIM2:
exRCC_APB1PeriphReset(RCC_APB1ENR_TIM2);
break;
case (u32)TIM3:
exRCC_APB1PeriphReset(RCC_APB1ENR_TIM3);
break;
case (u32)TIM14:
exRCC_APB2PeriphReset(RCC_APB2ENR_TIM14);
break;
case (u32)TIM16:
exRCC_APB2PeriphReset(RCC_APB2ENR_TIM16);
break;
case (u32)TIM17:
exRCC_APB2PeriphReset(RCC_APB2ENR_TIM17);
break;
default:
break;
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Initializes the tim Time Base Unit peripheral according to
/// the specified parameters in the init_struct.
/// @param tim: select the TIM peripheral.
/// @param init_struct: pointer to a TIM_TimeBaseInitTypeDef
/// structure that contains the configuration information for the
/// specified TIM peripheral.
/// @retval None.
////////////////////////////////////////////////////////////////////////////////
void TIM_TimeBaseInit(TIM_TypeDef* tim, TIM_TimeBaseInitTypeDef* init_struct)
{
MODIFY_REG(tim->CR1, TIM_CR1_CKD, init_struct->TIM_ClockDivision);
if ((tim == TIM1) || (tim == TIM2) || (tim == TIM3))
MODIFY_REG(tim->CR1, TIM_CR1_CMS | TIM_CR1_DIR, init_struct->TIM_CounterMode);
if ((tim == TIM1) || (tim == TIM16) || (tim == TIM17))
MODIFY_REG(tim->RCR, TIM_RCR_REP, init_struct->TIM_RepetitionCounter);
WRITE_REG(tim->ARR, init_struct->TIM_Period);
WRITE_REG(tim->PSC, init_struct->TIM_Prescaler);
WRITE_REG(tim->EGR, TIM_PSCReloadMode_Immediate);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Initializes the tim Channel1 according to the specified
/// parameters in the init_struct.
/// @param tim: select the TIM peripheral.
/// @param init_struct: pointer to a TIM_OCInitTypeDef structure that
/// contains the configuration information for the specified TIM peripheral.
/// @retval None.
////////////////////////////////////////////////////////////////////////////////
void TIM_OC1Init(TIM_TypeDef* tim, TIM_OCInitTypeDef* init_struct)
{
MODIFY_REG(tim->CCMR1, TIM_CCMR1_OC1M, init_struct->TIM_OCMode);
MODIFY_REG(tim->CCER, TIM_CCER_CC1P | TIM_CCER_CC1EN, \
init_struct->TIM_OCPolarity | init_struct->TIM_OutputState);
WRITE_REG(tim->CCR1, init_struct->TIM_Pulse);
if ((tim == TIM1) || (tim == TIM16) || (tim == TIM17)) {
MODIFY_REG(tim->CCER, TIM_CCER_CC1NP | TIM_CCER_CC1NEN, \
init_struct->TIM_OCNPolarity | init_struct->TIM_OutputNState);
MODIFY_REG(tim->CR2, TIM_CR2_OIS1 | TIM_CR2_OIS1N, \
init_struct->TIM_OCIdleState | init_struct->TIM_OCNIdleState);
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Initializes the tim Channel2 according to the specified
/// parameters in the init_struct.
/// @param tim: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
/// @param init_struct: pointer to a TIM_OCInitTypeDef structure that
/// contains the configuration information for the specified TIM peripheral.
/// @retval None.
////////////////////////////////////////////////////////////////////////////////
void TIM_OC2Init(TIM_TypeDef* tim, TIM_OCInitTypeDef* init_struct)
{
MODIFY_REG(tim->CCMR1, TIM_CCMR1_OC2M, init_struct->TIM_OCMode << 8);
MODIFY_REG(tim->CCER, TIM_CCER_CC2EN | TIM_CCER_CC2P, \
(init_struct->TIM_OCPolarity << 4) | (init_struct->TIM_OutputState << 4));
WRITE_REG(tim->CCR2, init_struct->TIM_Pulse);
if (tim == TIM1) {
MODIFY_REG(tim->CCER, TIM_CCER_CC2NP | TIM_CCER_CC2NEN, \
(init_struct->TIM_OCNPolarity << 4) | (init_struct->TIM_OutputNState << 4));
MODIFY_REG(tim->CR2, TIM_CR2_OIS2 | TIM_CR2_OIS2N, \
(init_struct->TIM_OCIdleState << 2) | (init_struct->TIM_OCNIdleState << 2));
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Initializes the tim Channel3 according to the specified
/// parameters in the init_struct.
/// @param tim: where x can be 1, 2, 3, 4, 5 or 8 to select the TIM peripheral.
/// @param init_struct: pointer to a TIM_OCInitTypeDef structure that
/// contains the configuration information for the specified TIM peripheral.
/// @retval None.
////////////////////////////////////////////////////////////////////////////////
void TIM_OC3Init(TIM_TypeDef* tim, TIM_OCInitTypeDef* init_struct)
{
MODIFY_REG(tim->CCMR2, TIM_CCMR2_OC3M, init_struct->TIM_OCMode);
MODIFY_REG(tim->CCER, TIM_CCER_CC3EN | TIM_CCER_CC3P, \
(init_struct->TIM_OCPolarity << 8) | (init_struct->TIM_OutputState << 8));
WRITE_REG(tim->CCR3, init_struct->TIM_Pulse);
if (tim == TIM1) {
MODIFY_REG(tim->CCER, TIM_CCER_CC3NP | TIM_CCER_CC3NEN, \
(init_struct->TIM_OCNPolarity << 8) | (init_struct->TIM_OutputNState << 8));
MODIFY_REG(tim->CR2, TIM_CR2_OIS3 | TIM_CR2_OIS3N, \
(init_struct->TIM_OCIdleState << 4) | (init_struct->TIM_OCNIdleState << 4));
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief Initializes the tim Channel4 according to the specified
/// parameters in the init_struct.
/// @param tim:select the TIM peripheral.
/// @param init_struct: pointer to a TIM_OCInitTypeDef structure that
/// contains the configuration information for the specified TIM peripheral.
/// @retval None.
////////////////////////////////////////////////////////////////////////////////
void TIM_OC4Init(TIM_TypeDef* tim, TIM_OCInitTypeDef* init_struct)
{
MODIFY_REG(tim->CCMR2, TIM_CCMR2_OC4M, (init_struct->TIM_OCMode) << 8);
MODIFY_REG(tim->CCER, TIM_CCER_CC4EN | TIM_CCER_CC4P, \
没有合适的资源?快使用搜索试试~ 我知道了~
MM32SPIN0280 库函数与例程
共1560个文件
h:643个
c:600个
eww:104个
需积分: 8 2 下载量 102 浏览量
2023-03-30
21:49:37
上传
评论
收藏 3.05MB ZIP 举报
温馨提示
支持 MM32SPIN0280 与 Cortex-M 微控制器软件接口标准(CMSIS),支持 MM32 标准库(Standard peripheral library),支持 IAR 和 MDK 开发,包含丰富的库函数操作和寄存器操作的参考例程。 应用特色: - 宽调速范围:200-16000rpm (4pp+ Reduction Ratio 11:1) - 可靠低速快速启动(LBG+PLL+死区补偿) - 稳定的高速运行(改进的弱磁控制+高速角度补偿) - 快速刹车控制,摇篮洗 - 多样保护:过压、过流、过温、堵转、缺相、过功率、不平衡保护 - 支持衣物重量预估 ,多温度传感器,水位侦测器,排水阀门控制,门锁控制
资源推荐
资源详情
资源评论
收起资源包目录
MM32SPIN0280 库函数与例程 (1560个子文件)
hal_tim.c 84KB
hal_rcc.c 25KB
hal_flash.c 23KB
hal_i2c.c 23KB
hal_spi.c 22KB
spi.c 17KB
dma.c 17KB
hal_uart.c 16KB
hal_adc.c 16KB
i2c.c 16KB
adcx.c 15KB
spi.c 14KB
hal_gpio.c 13KB
spi.c 13KB
adc_tim1trig_dma_multichanit.c 13KB
i2c.c 13KB
spi.c 13KB
spi.c 12KB
spi.c 12KB
i2c.c 12KB
i2c.c 12KB
i2c.c 12KB
hal_dma.c 12KB
adcx.c 11KB
dma.c 11KB
uart_txrx_interrupt.c 11KB
uart_autobaud.c 11KB
system_mm32spin0x_q.c 11KB
spi.c 11KB
i2c.c 11KB
hal_exti.c 11KB
tim1_6steps.c 10KB
spi.c 10KB
spi.c 10KB
adc_dma_temperaturesensor.c 10KB
spi.c 10KB
hal_comp.c 10KB
adc_dma_multichanit.c 9KB
adc_dma_vref.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
sys.c 9KB
共 1560 条
- 1
- 2
- 3
- 4
- 5
- 6
- 16
资源评论
TEL15622383762
- 粉丝: 52
- 资源: 17
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于matlab实现车牌识别程序,和论文,自己做的,做毕业设计的可以看看 .rar
- Windows系统下安装与配置Neo4j的步骤
- 基于matlab实现潮流计算和最优潮流计算的程序1,对毕业设计有一定用处.rar
- 基于大数据学习资源推荐系统的设计与实现(部署视频)-kaic.mp4
- 哈工大形式语言和自动机2022期末含答案
- Windows系统下安装与配置Neo4j的步骤
- 哈希算法(Hash Algorithm)是一种将任意长度的二进制数据映射为较短的、固定长度的二进制值的函数.txt
- Windows系统下安装与配置Neo4j的步骤
- 在二叉树或更复杂的树形结构中,先序输出叶结点.txt
- 列出所有祖先结点的概念通常与树形结构或图论中的节点相关.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功