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.

71 line
1.2KB

  1. #infdef STEPPER_H
  2. #define STEPPER_H
  3. #include <stdint.h>
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /**
  8. * @brief Status and error codes
  9. */
  10. enum {
  11. STEPPER_OK = 0,
  12. STEPPER_NO = -1,
  13. };
  14. /**
  15. * @brief Direction for stepper
  16. */
  17. typedef enum {
  18. STEPPER_FORWARD = 0x0,
  19. STEPPER_REVERSE = 0x1,
  20. } stepper_direction_t;
  21. /**
  22. * @brief Data structure holding the device parameters needed for initialization
  23. */
  24. typedef struct {
  25. gpio_t step_pin;
  26. gpio_t dir_pin;
  27. uint8_t addr;
  28. uint8_t vel_max;
  29. uint8_t acc_max;
  30. uint8_t microstep;
  31. uint16_t division;
  32. float angle;
  33. float velocity;
  34. sensor_t sensor;
  35. float homing_angle;
  36. } stepper_params_t;
  37. /**
  38. * @brief Device Descriptor for Stepper controller
  39. */
  40. typedef struct {
  41. stepper_params_t p;
  42. } stepper_t
  43. int stepper_init(stepper_t *dev, const stepper_params_t *params);
  44. int stepper_set_velocity(stepper_t *dev, float *velocity);
  45. int stepper_homing(stepper_t *dev);
  46. int stepper_get_angle(stepper_t *dev, float *angle);
  47. int stepper_step(stepper_t *dev, stepper_direction_t *direction);
  48. #ifdef __cplusplus
  49. }
  50. #endif
  51. #endif /* STEPPER_H */