30 static volatile uint32_t *stepper_ptrs = NULL;
32 #define STEPPER_REG_CONFIG 0
34 #define STEPPER_REG_STEPS 1
35 #define STEPPER_REG_CUR_STEPS 1
37 #define STEPPER_REG_PERIOD 2
38 #define STEPPER_REG_CUR_PERIOD 2
40 #define STEPPER_REG_DUTY 3
41 #define STEPPER_REG_CUR_DUTY 3
43 #define STEPPER_REG_NXT_STEPS 4
44 #define STEPPER_REG_NXT_PERIOD 5
45 #define STEPPER_REG_NXT_DUTY 6
46 #define STEPPER_REG_COUNT 7
48 #define MIN_PULSE 0x10
49 #define MIN_PERIOD (0x30 * 64)
70 if (stepper_ptrs != NULL) {
71 pynq_error(
"Stepper library is already initialized\n");
73 stepper_ptrs =
arm_shared_init(&(stepper_handles), axi_stepper_0, 4096);
85 if (stepper_ptrs == NULL) {
86 pynq_error(
"STEPPER has not been initialized.\n");
92 if (stepper_ptrs == NULL) {
93 pynq_error(
"STEPPER has not been initialized.\n");
100 if (stepper_ptrs == NULL) {
101 pynq_error(
"STEPPER has not been initialized.\n");
110 if (stepper_ptrs == NULL) {
111 pynq_error(
"STEPPER has not been initialized.\n");
118 if (stepper_ptrs == NULL) {
119 pynq_error(
"STEPPER has not been initialized.\n");
121 volatile steps *stp =
126 if (now.step_l == 0 && now.step_r == 0) {
133 if (stepper_ptrs == NULL) {
134 pynq_error(
"STEPPER has not been initialized.\n");
136 volatile steps *stp =
139 now.dir_r = (right < 0) ? 0 : 1;
140 now.dir_l = (left < 0) ? 0 : 1;
141 now.step_r = abs(right);
142 now.step_l = abs(left);
148 if (stepper_ptrs == NULL) {
149 pynq_error(
"STEPPER has not been initialized.\n");
152 pynq_error(
"STEPPER speed is invalid. Should be atleast %u ticks",
164 if (stepper_ptrs == NULL) {
165 pynq_error(
"STEPPER has not been initialized.\n");
167 volatile steps *stp =
172 if (now.dir_l == 0) {
177 if (now.dir_r == 0) {
178 *right = -now.step_r;