重新配置CAN引脚映射并实现基于DMA的数据收发机制,提升通信效率。增加了DMA通道4和5的中断处理函数,用于接收和发送CAN消息。修改了CAN发送函数以支持DMA传输,并去除了原有的轮询等待机制。 feat(ADC): 重新实现ADC与DMA初始化配置 将ADC和DMA的配置迁移至ADC.cpp文件中,完善了DMA循环采样模式配置及ADC多通道扫描功能。删除了initial.cpp中重复的初始化代码,并修正了相关头文件包含。 chore(headers): 清理冗余头文件引用 多个源文件中删除了不必要的标准库和硬件无关头文件引用,减少编译依赖,提高代码清晰度。
48 lines
1.0 KiB
C++
48 lines
1.0 KiB
C++
#include "initial.h"
|
|
#include "Timer.h"
|
|
#include <stdint.h>
|
|
|
|
|
|
void GPIO_config(void) {
|
|
// 使能GPIOB时钟
|
|
rcu_periph_clock_enable(RCU_GPIOB);
|
|
// 配置PB2为输入引脚,用于读取电机状态
|
|
gpio_init(GPIOB, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, GPIO_PIN_2);
|
|
}
|
|
|
|
/* retarget the C library printf function to the USART */
|
|
u8 USART0_init() {
|
|
gd_eval_com_init(EVAL_COM0);
|
|
return 1;
|
|
}
|
|
|
|
/*!
|
|
\brief configure the watchdog peripheral
|
|
\param[in] none
|
|
\param[out] none
|
|
\retval none
|
|
*/
|
|
u8 watchdog_init(u32 time) {
|
|
u8 status = 0;
|
|
/* configure FWDGT counter clock: 40KHz(IRC40K) / 64 = 0.625 KHz */
|
|
/* time = reload_value / clock_frequency */
|
|
status = fwdgt_config(time * 0.625, FWDGT_PSC_DIV64);
|
|
fwdgt_enable();
|
|
return status;
|
|
}
|
|
/**
|
|
* @brief driver输出初始化
|
|
*/
|
|
void driver_init(void) {
|
|
timer1_gpio_config();
|
|
timer1_pwm_config();
|
|
TIMER3_config();
|
|
}
|
|
|
|
int fputc(int ch, FILE *f) throw() {
|
|
usart_data_transmit(EVAL_COM0, (uint8_t)ch);
|
|
while (RESET == usart_flag_get(EVAL_COM0, USART_FLAG_TBE))
|
|
;
|
|
return ch;
|
|
}
|