leducp commented on PR #10902: URL: https://github.com/apache/nuttx/pull/10902#issuecomment-1761553966
> > > @leducp really cool idea! > > > Please include later an apps/example/stepper and some basic documentation > > > > > > Do you have any advice to show how to integrate it in a board? For now I have a raw example in the rp2040_bringup.c file, but this is temporary and shall not be merged. I could add snippet in a documentation file maybe? Or in the example folder? > > Just some basic application example to control the direction, then number of steps to each direction and also changing the micro-stepping values. Just print some text before executing each action to let the user know what is supposed to happen. ```c int main(int argc, FAR char *argv[]) { int rc; if (argc < 2) { printf("usage: stepper count (positive: CW, negative: CCW)"); return 1; } int count = atoi(argv[1]); int fd = open("/dev/stepper0", O_RDWR); if (fd < 0) { printf("Oops: %s\n", strerror(errno)); exit(1); } printf("GO -> %d\n", count); rc = ioctl(fd, STEPIOC_MICROSTEPPING, 8); if (rc < 0) { printf("STEPIOC_MICROSTEPPING: %s\n", strerror(errno)); exit(2); } struct stepper_state_s state; struct stepper_job_s job; job.steps = count; job.speed = 8000; /* step / s */ rc = write(fd, &job, sizeof(struct stepper_job_s)); /* blocking */ if (rc != sizeof(struct stepper_job_s)) { printf("write: %s\n", strerror(errno)); } rc = read(fd, &state, sizeof(struct stepper_state_s)); if (rc != sizeof(struct stepper_state_s)) { printf("read: %s\n", strerror(errno)); } printf("Current position: %ld\n", state.position); return 0; } ``` It may need a bit more refine but theses should do the trick I think. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org