初始化
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
#include "main.h"
|
||||
#include "Can.h"
|
||||
#include "Filter.h"
|
||||
#include "Timer.h"
|
||||
#include "adc.h"
|
||||
#include "initial.h"
|
||||
#include "systick.h"
|
||||
#include "tle5012b.h"
|
||||
|
||||
// 全局变量定义
|
||||
CurrentKalman kalman(0.0f, 0.0026f, 4.8f, 0.0001f, 1e-6f, 0.02f);
|
||||
CircularBuffer buffer;
|
||||
int main(void) {
|
||||
systick_config();
|
||||
adc_config();
|
||||
dma_config();
|
||||
// 调试串口初始化
|
||||
USART0_init();
|
||||
|
||||
User_timer_init();
|
||||
// CAN初始化
|
||||
// CAN_transmiter CAN0_transmiter;
|
||||
// 初始化CAN硬件
|
||||
can_gpio_init();
|
||||
can_config();
|
||||
|
||||
// 初始化CAN回环测试
|
||||
can_loopback_init();
|
||||
can_loopback_test();
|
||||
|
||||
// TLI5012B初始化
|
||||
tle5012b_gpio_init();
|
||||
tle5012b_spi_init();
|
||||
cdd_TLI5012_Init();
|
||||
|
||||
can_trasnmit_message_struct g_transmit_message;
|
||||
can_receive_message_struct g_receive_message;
|
||||
FlagStatus can0_receive_flag;
|
||||
|
||||
// CAN发送初始化
|
||||
can_struct_para_init(CAN_TX_MESSAGE_STRUCT, &g_transmit_message);
|
||||
g_transmit_message.tx_sfid = 0x00;
|
||||
g_transmit_message.tx_efid = 0x00;
|
||||
g_transmit_message.tx_ft = CAN_FT_DATA;
|
||||
g_transmit_message.tx_ff = CAN_FF_EXTENDED;
|
||||
g_transmit_message.tx_dlen = 8;
|
||||
g_transmit_message.fd_flag = 0;
|
||||
g_transmit_message.fd_brs = 1;
|
||||
g_transmit_message.fd_esi = 0;
|
||||
|
||||
// CAN接收初始化
|
||||
can_struct_para_init(CAN_RX_MESSAGE_STRUCT, &g_receive_message);
|
||||
|
||||
/* print out the clock frequency of system, AHB, APB1 and APB2 */
|
||||
printf("\r\nCK_SYS is %d", rcu_clock_freq_get(CK_SYS));
|
||||
printf("\r\nCK_AHB is %d", rcu_clock_freq_get(CK_AHB));
|
||||
printf("\r\nCK_APB1 is %d", rcu_clock_freq_get(CK_APB1));
|
||||
printf("\r\nCK_APB2 is %d", rcu_clock_freq_get(CK_APB2));
|
||||
|
||||
// TLI5012B测试
|
||||
Test_TLI5012B();
|
||||
|
||||
while (1) {
|
||||
/* delay a time in milliseconds */
|
||||
delay_1ms(10);
|
||||
/* 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());
|
||||
// g_transmit_message.tx_efid = 0x201;
|
||||
// g_transmit_message.tx_data[0] = 0xaa;
|
||||
// g_transmit_message.tx_data[1] = 0xbb;
|
||||
// g_transmit_message.tx_data[2] = 0xcc;
|
||||
// g_transmit_message.tx_data[3] = 0xdd;
|
||||
// g_transmit_message.tx_data[4] = 0xee;
|
||||
// g_transmit_message.tx_data[5] = 0xff;
|
||||
// g_transmit_message.tx_data[6] = 0x00;
|
||||
// g_transmit_message.tx_data[7] = 0x11;
|
||||
// g_transmit_message.tx_data[8] = 0x22;
|
||||
// g_transmit_message.tx_data[9] = 0x33;
|
||||
// g_transmit_message.tx_data[10] = 0x44;
|
||||
// g_transmit_message.tx_data[11] = 0x55;
|
||||
printf("\r\n can0 transmit data: ");
|
||||
for (u8 i = 0U; i < g_transmit_message.tx_dlen; i++) {
|
||||
printf(" %02x", g_transmit_message.tx_data[i]);
|
||||
}
|
||||
/* transmit message */
|
||||
can_message_transmit(CAN0, &g_transmit_message);
|
||||
|
||||
// Set_Pwm(0, 1500);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user