sm4.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //sm4.h - simple 4-axis stepper control
  2. #ifndef _SM4_H
  3. #define _SM4_H
  4. #include <inttypes.h>
  5. #include "config.h"
  6. #if defined(__cplusplus)
  7. extern "C" {
  8. #endif //defined(__cplusplus)
  9. // callback prototype for stop condition (return 0 - continue, return 1 - stop)
  10. typedef uint8_t (*sm4_stop_cb_t)();
  11. // callback prototype for updating position counters
  12. typedef void (*sm4_update_pos_cb_t)(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t de);
  13. // callback prototype for calculating delay
  14. typedef uint16_t (*sm4_calc_delay_cb_t)(uint16_t nd, uint16_t dd);
  15. // callback pointer - stop
  16. extern sm4_stop_cb_t sm4_stop_cb;
  17. // callback pointer - update_pos
  18. extern sm4_update_pos_cb_t sm4_update_pos_cb;
  19. // callback pointer - calc_delay
  20. extern sm4_calc_delay_cb_t sm4_calc_delay_cb;
  21. // returns direction for single axis (0 - positive, 1 - negative)
  22. extern uint8_t sm4_get_dir(uint8_t axis);
  23. // set direction for single axis (0 - positive, 1 - negative)
  24. extern void sm4_set_dir(uint8_t axis, uint8_t dir);
  25. // returns direction of all axes as bitmask (0 - positive, 1 - negative)
  26. extern uint8_t sm4_get_dir_bits(void);
  27. // set direction for all axes as bitmask (0 - positive, 1 - negative)
  28. extern void sm4_set_dir_bits(uint8_t dir_bits);
  29. // step axes by bitmask
  30. extern void sm4_do_step(uint8_t axes_mask);
  31. // xyze linear-interpolated relative move, returns remaining diagonal steps (>0 means stoped)
  32. extern uint16_t sm4_line_xyze_ui(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t de);
  33. extern uint16_t sm4_line_xyz_ui(uint16_t dx, uint16_t dy, uint16_t dz);
  34. #if defined(__cplusplus)
  35. }
  36. #endif //defined(__cplusplus)
  37. #endif //_SM4_H