This commit is contained in:
cbb
2025-12-25 12:07:06 +08:00
commit 26e73f451e
899 changed files with 42812 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
#include "motor.h"
#include "Timer.h"
#include "gd32c10x_eval.h"
#include <cstdio>
/**
* @brief driver输出初始化
*/
void motor_init(void) {
timer1_gpio_config();
timer1_pwm_config();
// 使能GPIOB时钟
rcu_periph_clock_enable(RCU_GPIOB);
// 配置PB2为输入引脚,用于读取电机状态
gpio_init(GPIOB, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, GPIO_PIN_2);
/* 配置GPIOB的PB14为推挽输出 SPICS */
gpio_init(GPIOB, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ,
GPIO_PIN_14 | GPIO_PIN_12);
}
/**
* @brief 电机复位
*/
void motor_reset(void) {
motor_sleep();
printf("motor reseting...\r\n");
motor_resume();
}
/**
* @brief 电机休眠
*/
void motor_sleep(void) { gpio_bit_reset(GPIOB, GPIO_PIN_12); }
/**
* @brief 电机启动
*/
void motor_resume(void) { gpio_bit_set(GPIOB, GPIO_PIN_12); }