30static 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
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;
void arm_shared_close(arm_shared *handle)
void * arm_shared_init(arm_shared *handle, const uint32_t address, const uint32_t length)
void stepper_enable(void)
void stepper_get_steps(int16_t *left, int16_t *right)
void stepper_destroy(void)
void stepper_disable(void)
void stepper_steps(int16_t left, int16_t right)
bool stepper_steps_done(void)
void stepper_set_speed(uint16_t left, uint16_t right)
#define STEPPER_REG_CUR_STEPS
union __attribute__((packed))
#define STEPPER_REG_PERIOD
#define STEPPER_REG_CONFIG