@@ -119,8 +119,11 @@ FastAccelStepper* FastAccelStepperEngine::stepperConnectToPin(
119
119
_stepper_cnt++;
120
120
121
121
FastAccelStepper* s = &fas_stepper[fas_stepper_num];
122
+ bool success = s->init (this , fas_stepper_num, step_pin);
123
+ if (!success) {
124
+ return NULL ;
125
+ }
122
126
_stepper[fas_stepper_num] = s;
123
- s->init (this , fas_stepper_num, step_pin);
124
127
for (uint8_t i = 0 ; i < MAX_STEPPER; i++) {
125
128
FastAccelStepper* sx = _stepper[i];
126
129
if (sx) {
@@ -501,7 +504,7 @@ bool FastAccelStepper::usesAutoEnablePin(uint8_t pin) {
501
504
return false ;
502
505
}
503
506
504
- void FastAccelStepper::init (FastAccelStepperEngine* engine, uint8_t num,
507
+ bool FastAccelStepper::init (FastAccelStepperEngine* engine, uint8_t num,
505
508
uint8_t step_pin) {
506
509
#if (TEST_MEASURE_ISR_SINGLE_FILL == 1)
507
510
// For run time measurement
@@ -522,20 +525,14 @@ void FastAccelStepper::init(FastAccelStepperEngine* engine, uint8_t num,
522
525
_rg.init ();
523
526
524
527
_queue_num = num;
525
- fas_queue[_queue_num].init (_queue_num, step_pin);
526
- #if defined(SUPPORT_RP_PICO)
527
- bool ok = fas_queue[_queue_num].claim_pio_sm (engine);
528
- if (ok) {
529
- fas_queue[_queue_num].setupSM ();
530
- fas_queue[_queue_num].connect ();
531
- }
532
- #endif
528
+ bool success = fas_queue[_queue_num].init (engine, _queue_num, step_pin);
533
529
#if defined(SUPPORT_ESP32_PULSE_COUNTER) && (ESP_IDF_VERSION_MAJOR == 5)
534
530
_attached_pulse_unit = NULL ;
535
531
#endif
536
532
#if defined(SUPPORT_ESP32_PULSE_COUNTER) && (ESP_IDF_VERSION_MAJOR == 4)
537
533
_attached_pulse_cnt_unit = -1 ;
538
534
#endif
535
+ return success;
539
536
}
540
537
uint8_t FastAccelStepper::getStepPin () { return _stepPin; }
541
538
void FastAccelStepper::setDirectionPin (uint8_t dirPin, bool dirHighCountsUp,
0 commit comments