#include "pwm.h"
void hal_beep_init(void)
{
RCC->MP_AHB4ENSETR |= (0X1 << 1);
RCC->MP_APB1ENSETR |= (0X1 << 2);
GPIOB->MODER &= ~(0x3 << 12);
GPIOB->MODER |= (0x1 << 13);
GPIOB->AFRL &= ~(0xf << 24);
GPIOB->AFRL |= (0x2 << 24);
TIM4->CR1 |= (0x1 << 0);
TIM4->CR1 |= (0X1 << 4);
TIM4->CR1 &= ~(0X3 << 5);
TIM4->CR1 |= (0X1 << 7);
TIM4->CCMR1 &= ~(0X3 << 0);
TIM4->CCMR1 |= (0X1 << 3);
TIM4->CCMR1 &= ~(0X7 << 4);
TIM4->CCMR1 |= (0X6 << 4);
TIM4->CCMR1 &= ~(0X1 << 16);
TIM4->CCER |= (0X3 << 0);
TIM4->CCER &= ~(0X1 << 3);
TIM4->PSC = 208;
TIM4->ARR &= ~(0XFFFF << 0);
TIM4->ARR |= 1000;
TIM4->CCR1 &= ~(0XFFFF << 0);
TIM4->CCR1 |= 500;
}
void hal_fan_init(void)
{
RCC->MP_AHB4ENSETR |= (0X1 << 4);
RCC->MP_APB2ENSETR |= (0X1 << 0);
GPIOE->MODER &= ~(0x3 << 18);
GPIOE->MODER |= (0x2 << 18);
GPIOE->AFRH &= ~(0xf << 4);
GPIOE->AFRH |= (0x1 << 4);
TIM1->BDTR |= (0X1 << 15);
TIM1->PSC = 208;
TIM1->ARR &= ~(0XFFFF << 0);
TIM1->ARR = 1000;
TIM1->CCR1 &= ~(0XFFFF << 0);
TIM1->CCR1 = 100;
TIM1->CCMR1 &= ~(0X3 << 0);
TIM1->CCMR1 |= (0X1 << 3);
TIM1->CCMR1 &= ~(0X7 << 4);
TIM1->CCMR1 |= (0X6 << 4);
TIM1->CCMR1 &= ~(0X1 << 16);
TIM1->CCER |= (0X3 << 0);
TIM1->CCER &= ~(0X1 << 3);
TIM1->CR1 |= (0X1 << 4);
TIM1->CR1 &= ~(0X3 << 5);
TIM1->CR1 |= (0X1 << 7);
TIM1->CR1 |= (0x1 << 0);
}
void hal_motor_init(void)
{
RCC->MP_AHB4ENSETR |= (0X1 << 5);
RCC->MP_APB2ENSETR |= (0X1 << 3);
GPIOF->MODER &= ~(0x3 << 12);
GPIOF->MODER |= (0x1 << 13);
GPIOF->AFRL &= ~(0xf << 24);
GPIOF->AFRL |= (0x1 << 24);
TIM16->CR1 |= (0x1 << 0);
TIM16->CR1 |= (0X1 << 4);
TIM16->CR1 &= ~(0X3 << 5);
TIM16->CR1 |= (0X1 << 7);
TIM16->CCMR1 &= ~(0X3 << 0);
TIM16->CCMR1 |= (0X1 << 3);
TIM16->CCMR1 &= ~(0X7 << 4);
TIM16->CCMR1 |= (0X6 << 4);
TIM16->CCMR1 &= ~(0X1 << 16);
TIM16->CCER |= (0X3 << 0);
TIM16->CCER &= ~(0X1 << 3);
TIM16->BDTR |= (0X1 << 15);
TIM16->PSC = 208;
TIM16->ARR &= ~(0XFFFF << 0);
TIM16->ARR |= 1000;
TIM16->CCR1 &= ~(0XFFFF << 0);
TIM16->CCR1 |= 300;
}
【12/5】
最新推荐文章于 2024-08-14 22:49:08 发布