Files
Motor_v2/Robot_V2/main.cpp
T

58 lines
1.5 KiB
C++

#include "main.h"
#include "Can.h"
#include "Filter.h"
#include "Timer.h"
#include "adc.h"
#include "initial.h"
#include "sys/initial.h"
#include "systick.h"
#include "core_cm4.h"
#include "tle5012b.h"
#include <cinttypes>
#include <cstdio>
// 全局变量定义
CurrentKalman kalman(0.0f, 0.0026f, 4.8f, 0.0001f, 1e-6f, 0.02f);
CircularBuffer buffer;
CAN_transmiter CAN0_transmiter;
int main(void) {
systick_config(); // 系统时钟初始化
USART0_init(); // 调试串口初始化
User_timer_init(); // Timer初始化
adc_config(); // ADC初始化
dma_config(); // DMA采样ADC初始化
tle5012b_gpio_init(); // TLI5012B初始化
tle5012b_spi_init();
// cdd_TLI5012_Init();
watchdog_init(1000);
// 初始化CAN回环测试
// can_loopback_init();
while (1) {
/* clear the FWDGT reset flag */
fwdgt_counter_reload();
// can_loopback_test();
// /* value print */
// printf(" the temperature data is %2.2f degrees Celsius\r\n",
// get_mcu_temp());
// printf(" the drv_temperature data is %2.2f degrees Celsius\r\n",
// get_drv_temp());
// printf(" the U current data is %2.2f mA\r\n",get_current('U'));
// printf(" the V current data is %2.2f mA\r\n",get_current('V'));
// printf(" the W current data is %2.2f mA\r\n",get_current('W'));
// printf(" the VBUS is %2.2f V\r\n",get_vbus_voltage());
// printf("\n----------------------------------------------------\n");
delay_1ms(200);
// TLI5012B测试
// Test_TLI5012B();
Set_Pwm(0, 1500);
}
}