From 32c63e4c180f605a109119bcf464954105d1a8b4 Mon Sep 17 00:00:00 2001 From: NeoZeng Date: Wed, 23 Nov 2022 22:23:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=BA=9F=E5=BC=83=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HAL_N_Middlewares/Src/main.c | 4 ++-- bsp/bsp_can.c | 19 +------------------ 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/HAL_N_Middlewares/Src/main.c b/HAL_N_Middlewares/Src/main.c index d29b583..3478879 100644 --- a/HAL_N_Middlewares/Src/main.c +++ b/HAL_N_Middlewares/Src/main.c @@ -118,10 +118,10 @@ int main(void){ RC_init(&huart3); DWT_Init(168); Motor_Init_Config_s config = { - .motor_type = M3508, + .motor_type = GM6020, .can_init_config = { .can_handle = &hcan1, - .tx_id = 2}, + .tx_id = 6}, .controller_setting_init_config = {.angle_feedback_source = MOTOR_FEED, .close_loop_type = SPEED_LOOP | ANGLE_LOOP, .speed_feedback_source = MOTOR_FEED, .reverse_flag = MOTOR_DIRECTION_NORMAL}, .controller_param_init_config = {.angle_PID = {.Improve = 0, .Kp = 1, .Ki = 0, .Kd = 0, .DeadBand = 0, .MaxOut = 4000}, .speed_PID = {.Improve = 0, .Kp = 1, .Ki = 0, .Kd = 0, .DeadBand = 0, .MaxOut = 4000}}}; dji_motor_instance *djimotor = DJIMotorInit(config); diff --git a/bsp/bsp_can.c b/bsp/bsp_can.c index 6e06ceb..53e9981 100644 --- a/bsp/bsp_can.c +++ b/bsp/bsp_can.c @@ -29,30 +29,13 @@ static void CANAddFilter(can_instance *_instance) can_filter_conf.FilterMode = CAN_FILTERMODE_IDLIST; can_filter_conf.FilterScale = CAN_FILTERSCALE_16BIT; - can_filter_conf.FilterFIFOAssignment = CAN_RX_FIFO1; + can_filter_conf.FilterFIFOAssignment = (_instance->tx_id & 1) ? CAN_RX_FIFO0 : CAN_RX_FIFO1; can_filter_conf.SlaveStartFilterBank = 14; can_filter_conf.FilterIdLow = _instance->rx_id << 5; - can_filter_conf.FilterIdHigh = _instance->rx_id << 5; - can_filter_conf.FilterMaskIdLow = _instance->rx_id << 5; - can_filter_conf.FilterMaskIdHigh = _instance->rx_id << 5; can_filter_conf.FilterBank = _instance->can_handle == &hcan1 ? (can1_filter_idx++) : (can2_filter_idx++); can_filter_conf.FilterActivation = CAN_FILTER_ENABLE; HAL_CAN_ConfigFilter(_instance->can_handle, &can_filter_conf); - - // CAN_FilterTypeDef can_filter_st; - // can_filter_st.FilterActivation = ENABLE; - // can_filter_st.FilterMode = CAN_FILTERMODE_IDMASK; - // can_filter_st.FilterScale = CAN_FILTERSCALE_32BIT; - // can_filter_st.FilterIdHigh = 0x0000; - // can_filter_st.FilterIdLow = 0x0000; - // can_filter_st.FilterMaskIdHigh = 0x0000; - // can_filter_st.FilterMaskIdLow = 0x0000; - // can_filter_st.FilterBank = 0; - // can_filter_st.FilterFIFOAssignment = CAN_RX_FIFO0; - // HAL_CAN_ConfigFilter(&hcan1, &can_filter_st); - // HAL_CAN_Start(&hcan1); - // HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO0_MSG_PENDING); } /**