diff --git a/.vscode/settings.json b/.vscode/settings.json index 3034fdb..46e315a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -42,6 +42,7 @@ "usb_device.h": "c", "vofa_protocol.h": "c", "master_process.h": "c", - "stdint-gcc.h": "c" + "stdint-gcc.h": "c", + "string.h": "c" } } \ No newline at end of file diff --git a/bsp/bsp_can.c b/bsp/bsp_can.c index 0a2fd58..7cbd0b8 100644 --- a/bsp/bsp_can.c +++ b/bsp/bsp_can.c @@ -57,14 +57,14 @@ static void CANServiceInit() /* -----------------------two extern callable function -----------------------*/ -void CANRegister(can_instance* ins,can_instance_config config) +void CANRegister(can_instance *ins, can_instance_config config) { static uint8_t idx; if (!idx) { CANServiceInit(); } - instance[idx]=ins; + instance[idx] = ins; instance[idx]->txconf.StdId = config.tx_id; instance[idx]->txconf.IDE = CAN_ID_STD; @@ -76,9 +76,7 @@ void CANRegister(can_instance* ins,can_instance_config config) instance[idx]->rx_id = config.rx_id; instance[idx]->can_module_callback = config.can_module_callback; - CANAddFilter(instance[idx]); - - return instance[idx++]; + CANAddFilter(instance[idx++]); } void CANTransmit(can_instance *_instance) diff --git a/bsp/bsp_usart.c b/bsp/bsp_usart.c index 7a78b7d..030ab81 100644 --- a/bsp/bsp_usart.c +++ b/bsp/bsp_usart.c @@ -4,9 +4,9 @@ * @brief 串口bsp层的实现 * @version beta * @date 2022-11-01 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "bsp_usart.h" #include "stdlib.h" @@ -30,7 +30,7 @@ static void USARTServiceInit(usart_instance *_instance) void USARTRegister(usart_instance *_instance) { - static instance_idx; + static uint8_t instance_idx; USARTServiceInit(_instance); instance[instance_idx++] = _instance; } diff --git a/modules/algorithm/user_lib.h b/modules/algorithm/user_lib.h index 7f5f940..56f7ca8 100644 --- a/modules/algorithm/user_lib.h +++ b/modules/algorithm/user_lib.h @@ -96,7 +96,7 @@ typedef struct float frame_period; //ʱ���� } ramp_function_source_t; -typedef __packed struct +typedef struct { uint16_t Order; uint32_t Count; diff --git a/modules/imu/ins_task.c b/modules/imu/ins_task.c index d635299..c6fc0df 100644 --- a/modules/imu/ins_task.c +++ b/modules/imu/ins_task.c @@ -15,6 +15,7 @@ #include "QuaternionEKF.h" #include "bsp_temperature.h" #include "spi.h" +#include "user_lib.h" static INS_t INS; IMU_Param_t IMU_Param; diff --git a/modules/master_machine/master_process.h b/modules/master_machine/master_process.h index 408029b..4e79552 100644 --- a/modules/master_machine/master_process.h +++ b/modules/master_machine/master_process.h @@ -8,27 +8,18 @@ #define VISION_RECV_SIZE 36u #define VISION_SEND_SIZE 36u - -typedef struct -{ - -}; - - - /** * @brief 调用此函数初始化和视觉的串口通信 - * + * * @param handle 用于和视觉通信的串口handle(C板上一般为USART1,丝印为USART2,4pin) */ -Vision_Recv_s* VisionInit(UART_HandleTypeDef* handle); +Vision_Recv_s *VisionInit(UART_HandleTypeDef *handle); /** * @brief 发送视觉视觉 - * + * * @param send 视觉需要的数据 */ void VisionSend(Vision_Send_s *send); - #endif // !MASTER_PROCESS_H \ No newline at end of file diff --git a/modules/master_machine/seasky_protocol.c b/modules/master_machine/seasky_protocol.c index 9b43c44..d221ebe 100644 --- a/modules/master_machine/seasky_protocol.c +++ b/modules/master_machine/seasky_protocol.c @@ -139,4 +139,5 @@ uint16_t get_protocol_info(uint8_t *rx_buf, //接收到的原始数据 return pro.cmd_id; } } + return 0; } diff --git a/modules/motor/HT04.c b/modules/motor/HT04.c index a670cc6..38aa69d 100644 --- a/modules/motor/HT04.c +++ b/modules/motor/HT04.c @@ -22,7 +22,7 @@ static void DecodeJoint(can_instance* motor_instance) uint16_t tmp; for (size_t i = 0; i < HT_MOTOR_CNT; i++) { - if(&joint_motor_info[i]->motor_can_instace==motor_instance) + if(joint_motor_info[i]->motor_can_instace==motor_instance) { tmp = (motor_instance->rx_buff[1] << 8) | motor_instance->rx_buff[2]; joint_motor_info[i]->last_ecd=joint_motor_info[i]->ecd; @@ -40,7 +40,8 @@ joint_instance* HTMotorInit(can_instance_config config) { static uint8_t idx; joint_motor_info[idx]=(joint_instance*)malloc(sizeof(joint_instance)); - CANRegister(&joint_motor_info[idx++]->motor_can_instace,config); + CANRegister(joint_motor_info[idx++]->motor_can_instace,config); + return joint_motor_info[idx++]; } void JointControl(joint_instance* _instance,float current) diff --git a/modules/motor/LK9025.c b/modules/motor/LK9025.c index abaa5d7..dc24273 100644 --- a/modules/motor/LK9025.c +++ b/modules/motor/LK9025.c @@ -1,47 +1,47 @@ -#include"LK9025.h" +#include "LK9025.h" -static driven_instance* driven_motor_info[LK_MOTOR_CNT]; +static driven_instance *driven_motor_info[LK_MOTOR_CNT]; -static void DecodeDriven(can_instance* _instance) +static void DecodeDriven(can_instance *_instance) { for (size_t i = 0; i < LK_MOTOR_CNT; i++) { - if(&driven_motor_info[i]->motor_can_instance==_instance) + if (driven_motor_info[i]->motor_can_instance == _instance) { - driven_motor_info[i]->last_ecd = driven_motor_info[i]->ecd; - driven_motor_info[i]->ecd = (uint16_t)((_instance->rx_buff[7]<<8) | _instance->rx_buff[6]); - driven_motor_info[i]->speed_rpm = (uint16_t)(_instance->rx_buff[5] << 8 | _instance->rx_buff[4]); - driven_motor_info[i]->given_current = (uint16_t)(_instance->rx_buff[3] << 8 | _instance->rx_buff[2]); + driven_motor_info[i]->last_ecd = driven_motor_info[i]->ecd; + driven_motor_info[i]->ecd = (uint16_t)((_instance->rx_buff[7] << 8) | _instance->rx_buff[6]); + driven_motor_info[i]->speed_rpm = (uint16_t)(_instance->rx_buff[5] << 8 | _instance->rx_buff[4]); + driven_motor_info[i]->given_current = (uint16_t)(_instance->rx_buff[3] << 8 | _instance->rx_buff[2]); driven_motor_info[i]->temperate = _instance->rx_buff[1]; break; } } } -driven_instance* LKMotroInit(can_instance_config config) +driven_instance *LKMotroInit(can_instance_config config) { static uint8_t idx; - driven_motor_info[idx]=(driven_instance*)malloc(sizeof(driven_instance)); - config.can_module_callback=DecodeDriven; - CANRegister(driven_motor_info[idx++]->motor_can_instance,config); + driven_motor_info[idx] = (driven_instance *)malloc(sizeof(driven_instance)); + config.can_module_callback = DecodeDriven; + CANRegister(driven_motor_info[idx]->motor_can_instance, config); + return driven_motor_info[idx++]; } -void DrivenControl(int16_t motor1_current,int16_t motor2_current) +void DrivenControl(int16_t motor1_current, int16_t motor2_current) { - LIMIT_MIN_MAX(motor1_current, I_MIN, I_MAX); - LIMIT_MIN_MAX(motor2_current, I_MIN, I_MAX); + LIMIT_MIN_MAX(motor1_current, I_MIN, I_MAX); + LIMIT_MIN_MAX(motor2_current, I_MIN, I_MAX); driven_motor_info[0]->motor_can_instance->tx_buff[0] = motor1_current; - driven_motor_info[0]->motor_can_instance->tx_buff[1] = motor1_current>>8; + driven_motor_info[0]->motor_can_instance->tx_buff[1] = motor1_current >> 8; driven_motor_info[0]->motor_can_instance->tx_buff[2] = motor2_current; - driven_motor_info[0]->motor_can_instance->tx_buff[3] = motor2_current>>8; + driven_motor_info[0]->motor_can_instance->tx_buff[3] = motor2_current >> 8; CANTransmit(driven_motor_info[0]->motor_can_instance); } -void SetDrivenMode(driven_mode cmd,uint16_t motor_id) +void SetDrivenMode(driven_mode cmd, uint16_t motor_id) { static uint8_t buf[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00}; // code goes here ... - + // CANTransmit(driven_mode) } - diff --git a/modules/motor/motor_def.h b/modules/motor/motor_def.h index 3ba6e75..076b3b5 100644 --- a/modules/motor/motor_def.h +++ b/modules/motor/motor_def.h @@ -12,6 +12,8 @@ #ifndef MOTOR_DEF_H #define MOTOR_DEF_H +#include "controller.h" + /** * @brief 闭环类型,如果需要多个闭环,则使用或运算 * 例如需要速度环和电流环: CURRENT_LOOP|SPEED_LOOP