2024-11-07 17:24:19 +08:00
|
|
|
/**
|
|
|
|
****************************************************************************************************
|
|
|
|
* @file bsp_delay.c
|
|
|
|
* @author
|
|
|
|
* @version V1.0
|
|
|
|
* @date 2024-02-10
|
|
|
|
* @brief main
|
|
|
|
****************************************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*app*********************************************************************************************/
|
2024-11-11 11:45:58 +08:00
|
|
|
//#include "app_demo.h"
|
2024-11-07 17:24:19 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*kit*********************************************************************************************/
|
|
|
|
#include "kit_debug.h"
|
|
|
|
|
|
|
|
/*bsp*********************************************************************************************/
|
|
|
|
#include "bsp_delay.h"
|
|
|
|
#include "bsp_led.h"
|
|
|
|
#include "bsp_task.h"
|
|
|
|
|
|
|
|
/*drv*********************************************************************************************/
|
|
|
|
#include "drv_sys.h"
|
|
|
|
#include "drv_usart.h"
|
2024-11-20 15:33:37 +08:00
|
|
|
#include "drv_gpio.h"
|
2024-11-07 17:24:19 +08:00
|
|
|
/*uC/OS-III*********************************************************************************************/
|
|
|
|
#include "os.h"
|
|
|
|
|
2024-11-20 15:33:37 +08:00
|
|
|
uint8_t canbuf[8];
|
|
|
|
uint8_t rxlen = 0;
|
|
|
|
uint8_t res;
|
2024-11-07 17:24:19 +08:00
|
|
|
OS_TCB StartTask1_TCB; /* 任务控制块 */
|
|
|
|
|
|
|
|
void poll_start_task1_init(void)
|
|
|
|
{
|
2024-11-11 17:18:25 +08:00
|
|
|
HAL_Init(); /* 初始化HAL库 */
|
2024-11-07 17:24:19 +08:00
|
|
|
sys_stm32_clock_init(336, 8, 2, 7); /* 设置时钟,168Mhz */
|
|
|
|
delay_init(168); /* 延时初始化 */
|
2024-11-20 15:33:37 +08:00
|
|
|
usart_init(115200); /* 串口初始化为115200 */
|
|
|
|
led_init(); /* 初始化LED */
|
|
|
|
InitGPIOs(); /* 初始化GPIO */
|
|
|
|
// uint32_t userBaudRate = 115200; // 这里可以设置用户需要的波特率
|
|
|
|
InitUARTs(115200); // 使用用户指定的波特率初始化UART
|
|
|
|
can_init(CAN_SJW_1TQ, CAN_BS2_6TQ, CAN_BS1_7TQ, 6, CAN_MODE_LOOPBACK); /* CAN初始化, 正常模式, 波特率500Kbps */
|
|
|
|
|
2024-11-07 17:24:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void poll_start_task1_handler(uint32_t baseTime)
|
|
|
|
{
|
|
|
|
task1(baseTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
void poll_start_task2_handler(uint32_t baseTime)
|
|
|
|
{
|
|
|
|
task2(baseTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// name,id,_prio,_period,_,_timeout,init_call,_ask_call,stack_size
|
|
|
|
TASK_STATIC_INIT_CCM(poll_start_task1, 1, 2, 500, 2000, poll_start_task1_init, poll_start_task1_handler, 400);
|
|
|
|
TASK_STATIC_INIT_CCM(poll_start_task2, 2, 5, 1000, 2000, NULL, poll_start_task2_handler, 400);
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
2024-11-20 15:33:37 +08:00
|
|
|
// for (i = 0; i < 8; i++)
|
|
|
|
// {
|
|
|
|
// canbuf[i] = 1 + i; /* 填充发送缓冲区 */
|
|
|
|
// }
|
|
|
|
// res = can_send_msg(0X66, canbuf, 8); /* ID = 0X66, 发送8个字节 */
|
|
|
|
// rxlen = can_receive_msg(0X66, canbuf); /* CAN ID = 0X66, 接收数据查询 */
|
|
|
|
// delay_ms(10);
|
2024-11-07 17:24:19 +08:00
|
|
|
|
|
|
|
|
2024-11-20 15:33:37 +08:00
|
|
|
// OS_ERR err;
|
|
|
|
//// KIT_DEBUG_PRINTF("12323 \r\n");
|
|
|
|
// /* 关闭所有中断 */
|
|
|
|
// CPU_IntDis();
|
|
|
|
//
|
|
|
|
// KIT_DEBUG_PRINTF("BMS start \r\n");
|
|
|
|
|
|
|
|
// /* 初始化uC/OS-III */
|
|
|
|
// OSInit(&err);
|
|
|
|
//
|
|
|
|
// bsp_task_creat(&poll_start_task1,(uint8_t *)"poll_start_task1");
|
|
|
|
// bsp_task_creat(&poll_start_task2,(uint8_t *)"poll_start_task2");
|
|
|
|
|
|
|
|
// /* 开始任务调度 */
|
|
|
|
// OSStart(&err);
|
2024-11-07 17:24:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|