kinco.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * @Description:
  3. * @version:
  4. * @Author: Joe
  5. * @Date: 2021-11-13 21:55:17
  6. * @LastEditTime: 2021-11-13 21:55:18
  7. */
  8. #ifndef __KINCO_H__
  9. #define __KINCO_H__
  10. #include <rtthread.h>
  11. #include <rtdevice.h>
  12. #include <board.h>
  13. #define SEND_ADCC_EN
  14. #define SEND_MODE_EN
  15. #define SEND_RPM_EN
  16. typedef struct
  17. {
  18. uint8_t mode; /*电机模式*/
  19. uint16_t err; /*故障*/
  20. int16_t rpm; /*转速*/
  21. uint32_t id; /*电机id*/
  22. uint8_t control; /*电机控制字*/
  23. uint8_t acc :1; /*设置好加减速*/
  24. uint8_t dcc :1; /*设置好加减速*/
  25. uint8_t :4;
  26. } MOTOR_TypeDef;
  27. #if defined SEND_ADCC_EN
  28. uint8_t get_motor_acc(void);
  29. uint8_t get_motor_dcc(void);
  30. struct rt_can_msg send_motor_acc(void);
  31. struct rt_can_msg send_motor_dcc(void);
  32. #endif /* SEND_ADCC_EN */
  33. #if defined SEND_MODE_EN
  34. #define mode_pos 0x06
  35. #define mode_speed 0x02
  36. uint8_t get_motor_mode(void);
  37. struct rt_can_msg send_motor_speed_mode(void);
  38. struct rt_can_msg send_motor_control_mode(void) ;
  39. #endif /* SEND_MODE_EN */
  40. #if defined SEND_RPM_EN
  41. void set_motor_rpm(int16_t rpm);
  42. int16_t get_motor_real_rpm(void);
  43. struct rt_can_msg send_motor_rpm(void) ;
  44. #endif /* SEND_RPM_EN */
  45. struct rt_can_msg send_motor_reset(void) ;
  46. uint8_t motor_msg_parse(struct rt_can_msg *msg);
  47. void check_motor_miss(void);
  48. uint8_t get_motor_err(void);
  49. uint8_t get_motor_miss_err(void);
  50. uint8_t motor_init_ok(void);
  51. #endif