diff --git a/Core/Src/usart.c b/Core/Src/usart.c index 82d84f0..8baef17 100644 --- a/Core/Src/usart.c +++ b/Core/Src/usart.c @@ -103,7 +103,7 @@ void MX_USART6_UART_Init(void) /* USER CODE END USART6_Init 1 */ huart6.Instance = USART6; - huart6.Init.BaudRate = 115200; + huart6.Init.BaudRate = 4000000; huart6.Init.WordLength = UART_WORDLENGTH_8B; huart6.Init.StopBits = UART_STOPBITS_1; huart6.Init.Parity = UART_PARITY_NONE; diff --git a/User/Module/up.c b/User/Module/up.c index d0fbc35..4f5b4d0 100644 --- a/User/Module/up.c +++ b/User/Module/up.c @@ -12,7 +12,8 @@ int8_t up_init(UP_t *u,const UP_Param_t *param,float target_freq) { u->param = param; /*初始化参数 */ - + + GO_M8010_init(); PID_init (&u->pid.VESC_5065_M1 ,PID_POSITION ,&(u->param ->VESC_5065_M1_param )); PID_init (&u->pid.VESC_5065_M2 ,PID_POSITION ,&(u->param ->VESC_5065_M2_param )); diff --git a/User/bsp/crc16.c b/User/bsp/crc16.c index 2d9de2a..5cbd9ab 100644 --- a/User/bsp/crc16.c +++ b/User/bsp/crc16.c @@ -48,3 +48,15 @@ bool CRC16_Verify(const uint8_t *buf, size_t len) { ((const uint16_t *)((const uint8_t *)buf + (len % 2)))[len / sizeof(uint16_t) - 1]; } + +uint16_t do_crc_table(uint8_t *ptr, int len) +{ + uint16_t crc = 0x0000; + + while(len--) + { + crc = (crc >> 8) ^ crc16_tab[(crc ^ *ptr++) & 0xff]; + } + + return crc; +} diff --git a/User/bsp/crc16.h b/User/bsp/crc16.h index dc54b30..d145252 100644 --- a/User/bsp/crc16.h +++ b/User/bsp/crc16.h @@ -12,6 +12,7 @@ extern "C" { uint16_t CRC16_Calc(const uint8_t *buf, size_t len, uint16_t crc); bool CRC16_Verify(const uint8_t *buf, size_t len); +uint16_t do_crc_table(uint8_t *ptr, int len); #ifdef __cplusplus } diff --git a/User/device/GO_M8010_6_Driver.c b/User/device/GO_M8010_6_Driver.c index c713447..7fa159d 100644 --- a/User/device/GO_M8010_6_Driver.c +++ b/User/device/GO_M8010_6_Driver.c @@ -7,7 +7,7 @@ #include GO_Motorfield GO_motor_info[GO_NUM];//存放电机数据 -const float gravit_const =9.81;//计算前馈力矩有关 +static const float gravit_const =9.81;//计算前馈力矩有关 //数据处理函数 static void GO_M8010_recv_data(uint8_t* Temp_buffer); @@ -38,7 +38,7 @@ void GO_M8010_init (){ //暂存接收数据 -static uint8_t Temp_buffer[16]; +uint8_t Temp_buffer[16]; void USART6_RxCompleteCallback(void ) { @@ -79,12 +79,12 @@ void uartTxCB(UART_HandleTypeDef *huart) *@input[in] K_W 速度环kp *@note 控制公式 : t = T + (设定位置 - 实际位置)*K_P + (设定速度 - 实际速度)*K_W */ + GO_Motorfield* motor; void GO_M8010_send_data(UART_HandleTypeDef *huart, int id,int rev,float T,float Pos, float W,float K_P,float K_W) { // a pointer to target motor - GO_Motorfield* motor; motor = GO_motor_info+id; //这个rev是干啥的 @@ -130,7 +130,7 @@ void GO_M8010_send_data(UART_HandleTypeDef *huart, int id,int rev,float T,float // interrupt buffer sending HAL_UART_Transmit_IT(huart,motor->buffer,sizeof(motor->buffer)); - osDelay(100); + osDelay(1000); HAL_UART_Receive_DMA(huart, Temp_buffer, 16);//有无都可以 diff --git a/User/device/GO_M8010_6_Driver.h b/User/device/GO_M8010_6_Driver.h index a717882..b3cb95e 100644 --- a/User/device/GO_M8010_6_Driver.h +++ b/User/device/GO_M8010_6_Driver.h @@ -35,23 +35,22 @@ typedef struct uint16_t k_pos; // �����ؽڸն�ϵ�� unit: 0.0-1.0 (q15) uint16_t k_spd; // �����ؽ�����ϵ�� unit: 0.0-1.0 (q15) -} RIS_Comd_t; // ���Ʋ��� 12Byte - +} RIS_Comd_t; /** - * @brief �������ݰ���ʽ + * * */ typedef struct { - uint8_t head[2]; // ��ͷ 2Byte - RIS_Mode_t mode; // �������ģʽ 1Byte - RIS_Comd_t comd; // ����������� 12Byte - uint16_t CRC16; // CRC 2Byte + uint8_t head[2]; + RIS_Mode_t mode; + RIS_Comd_t comd; + uint16_t CRC16; -} ControlData_t; // ������������ 17Byte +} ControlData_t; diff --git a/User/device/can_use.h b/User/device/can_use.h index 049762a..129b0c2 100644 --- a/User/device/can_use.h +++ b/User/device/can_use.h @@ -102,7 +102,6 @@ typedef struct { BSP_CAN_t chassis5065; BSP_CAN_t motor3508; BSP_CAN_t pitch6020; - BSP_CAN_t sick; } CAN_Params_t; diff --git a/User/task/up_task.c b/User/task/up_task.c index 2b1738d..79da392 100644 --- a/User/task/up_task.c +++ b/User/task/up_task.c @@ -55,8 +55,11 @@ void Task_up(void *argument) // GM6020_control(&UP, 100) ; // UP_M2006_angle(&UP, 180); // UP_M3508_speed(&UP, 500); -// VESC_M5065_Control(&UP, 1000); + VESC_M5065_Control(&UP, 00); ALL_Motor_Control(&UP,&UP_CAN_out); +// GO_M8010_send_data(&huart6, 0,0,0,5,10,0.12,0.08); + osDelay(1); + /*imu数据获取*/ osMessageQueueGet(task_runtime.msgq.imu.eulr, &UP.pos088.imu_eulr, NULL, 0);