|
-
-
- #ifndef STEPPER_H
- #define STEPPER_H
-
- #include <stdint.h>
- #include "periph/gpio.h"
- #include "periph/uart.h"
- #include "sensor.h"
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #define STEPPER_PARAM_VEL_MAX (25)
- #define STEPPER_PARAM_ACC_MAX (200)
- #define STEPPER_PARAM_VELOCITY_DEFAULT (0)
- #define STEPPER_PARAM_MICROSTEP_DEFAULT (16)
- #define STEPPER_PARAM_DIVISION_DEFAULT (200)
- #define STEPPER_PARAM_ANGLE_DEFAULT (0)
- #define STEPPER_PARAM_HOMING_ANGLE_DEFAULT (20)
-
- /**
- * @brief Status and error codes
- */
- enum {
- STEPPER_OK = 0,
- STEPPER_NO = -1,
- };
-
- /**
- * @brief Direction for stepper
- */
- typedef enum {
- STEPPER_FORWARD = 0x0,
- STEPPER_REVERSE = 0x1,
- } stepper_direction_t;
-
- /**
- * @brief Data structure holding the device parameters needed for initialization
- */
- typedef struct {
- gpio_t step_pin;
- gpio_t dir_pin;
- uint8_t uart;
- uint8_t vel_max;
- uint8_t acc_max;
- uint8_t microstep;
- uint16_t division;
- float angle;
- float velocity;
- sensor_t sensor;
- float homing_angle;
- } stepper_params_t;
-
- /**
- * @brief Device Descriptor for Stepper controller
- */
- typedef struct {
- stepper_params_t p;
- } stepper_t;
-
- int stepper_init(stepper_t *dev, const stepper_params_t *params);
-
- int stepper_set_velocity(stepper_t *dev, float *velocity);
-
- int stepper_homing(stepper_t *dev);
-
- int stepper_get_angle(stepper_t *dev, float *angle);
-
- int stepper_step(stepper_t *dev, stepper_direction_t *direction);
-
-
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* STEPPER_H */
|