You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.2 KiB

  1. #include "servo_driver.h"
  2. #include "servo_package_process.h"
  3. static servo_obj_t servo[servo_amount] = {
  4. {STS_small_L}, {STS_small_M}, {STS_small_R}, {STS_large_R}, {STS_large_Y},
  5. };
  6. static param_t param;
  7. /**
  8. * @description: ȡ
  9. * @param {uint8_t} servo_id id
  10. * @return {*}
  11. */
  12. servo_obj_t* Get_Servo(uint8_t servo_id) {
  13. if (servo_id > STS_large_Y || servo_id < STS_small_L) {
  14. while(1){
  15. printf("Servo_id dose not exist:%d\n", servo_id);
  16. }
  17. }
  18. printf("Servo id : %d\n", servo_id);
  19. //return &servo[servo_id];
  20. }
  21. /**
  22. * @description:
  23. * @param {servo_obj_t*} servo
  24. * @param {uint8_t} function ʵֹ
  25. * @param {int32_t} param
  26. * @return {*}
  27. */
  28. void servo_drive_single(uint8_t id, uint8_t addr, uint8_t cmd, int16_t *param_data, uint8_t param_count) {
  29. param.addr = addr;
  30. param.data = param_data;
  31. param.count = param_count;
  32. if (!(cmd == W_DATA || cmd == REG_W_DATA)) {
  33. printf("write cmd error :%02X", cmd);
  34. return;
  35. }
  36. Write_oprete(id, cmd, &param);
  37. }
  38. // void servo_drive_multi(servo_obj_t* servo, uint8_t function, int32_t param) {
  39. // servo->reg = function;
  40. // servo->data = param;
  41. // servo->cmd = SYC_W_DATA;
  42. // Write_oprete(servo);
  43. // }