#ifndef __GO_M8010_6_H #define __GO_M8010_6_H #ifdef __cplusplus extern "C"{ #endif #include "main.h" #include "crc_ccitt.h" #include "usart.h" #include "string.h" #include #define GO_NUM 2 /** * @brief ���ģʽ������Ϣ * */ typedef struct { uint8_t id :4; // ���ID: 0,1...,14 15��ʾ�����е���㲥����(��ʱ�޷���) uint8_t status :3; // ����ģʽ: 0.���� 1.FOC�ջ� 2.������У׼ 3.���� uint8_t none :1; // ����λ } RIS_Mode_t /*__attribute__((packed))*/; // ����ģʽ 1Byte /** * @brief ���״̬������Ϣ * */ typedef struct { int16_t tor_des; // �����ؽ����Ť�� unit: N.m (q8) int16_t spd_des; // �����ؽ�����ٶ� unit: rad/s (q7) int32_t pos_des; // �����ؽ����λ�� unit: rad (q15) uint16_t k_pos; // �����ؽڸն�ϵ�� unit: 0.0-1.0 (q15) uint16_t k_spd; // �����ؽ�����ϵ�� unit: 0.0-1.0 (q15) } RIS_Comd_t; // ���Ʋ��� 12Byte /** * @brief �������ݰ���ʽ * */ typedef struct { uint8_t head[2]; // ��ͷ 2Byte RIS_Mode_t mode; // �������ģʽ 1Byte RIS_Comd_t comd; // ����������� 12Byte uint16_t CRC16; // CRC 2Byte } ControlData_t; // ������������ 17Byte typedef struct { unsigned short id; // ���ID��0xBB����ȫ����� why������f�������е���� unsigned short mode; // 0:����, 5:����ת��, 10:�ջ�FOC���� why������1�ջ���2У׼�� uint16_t correct; // ���������Ƿ����� ��1 ������0�������� int MError; // ������ 0.���� 1.���� 2.���� 3.��ѹ 4.���������� int Temp; // �¶� float tar_pos; // target position float tar_w; // target speed float T; // ��ǰʵ�ʵ��������� float W; // ��ǰʵ�ʵ���ٶȣ����٣� float Pos; // ��ǰ���λ�� int footForce; // They dont even know what 7 is this so we dont update this uint8_t buffer[17]; uint8_t Rec_buffer[16]; ControlData_t motor_send_data; }GO_Motorfield; /** *@brief �����ʼ�� */ void GO_M8010_init(void); /** *@brief go���Ϳ������� *@input[in] huart ���ô���ָ�� *@input[in] id ���ص��id *@input[in] rev ��ʱ��֪����ɶ�õģ�githubΪ�ش�issue *@input[in] T ���أ���λN��m *@input[in] Pos Ŀ��λ�ã���λrad *@input[in] W Ŀ���ٶȣ���λrad/s *@input[in] K_P λ�û���kp *@input[in] K_W �ٶȻ�kp *@note ���ƹ�ʽ �� t = T + ���趨λ�� - ʵ��λ�ã�*K_P + ���趨�ٶ� - ʵ���ٶȣ�*K_W */ void GO_M8010_send_data(UART_HandleTypeDef *huart,int id, int rev,float T,float W,float Pos,float K_P,float K_W); /** *@brief �û��Զ��崮�ڷ�������жϻص����� */ void uartTxCB(UART_HandleTypeDef *huart); //��λ��Ͽ��� void basic_ForceControl (UART_HandleTypeDef *huart, int id, float bias, float length, float mass, float tar_pos, float tar_w, float K_P,float K_W); /** *@brief go���Ϳ������� *@input[in] id ���ص��id *@revtal ���ص������ָ�� */ GO_Motorfield* getGoPoint(uint8_t id); #ifdef __cplusplus } #endif #endif /*__GO_M8010_6_H */