diff --git a/stm32-stepper-root/stepper_h7/CM7/Core/Src/Stepper/stepper.c b/stm32-stepper-root/stepper_h7/CM7/Core/Src/Stepper/stepper.c index e224646..c2a9f5b 100644 --- a/stm32-stepper-root/stepper_h7/CM7/Core/Src/Stepper/stepper.c +++ b/stm32-stepper-root/stepper_h7/CM7/Core/Src/Stepper/stepper.c @@ -33,7 +33,7 @@ int StepperConsoleFunction( int argc, char** argv, void* ctx ) } else if ( strcmp(argv[0], "reset") == 0 ) { - init_stepper(NULL, NULL, NULL); + reset_stepper(h); } else { @@ -76,7 +76,7 @@ void StepDriverReset(void* pGPO, const int ena){ } void StepLibraryDelay(unsigned int ms){ - HAL_Delay(ms); + vTaskDelay(pdMS_TO_TICKS(ms)); } // 1) Funktion schreiben (oben in stepper.c, vor init_stepper) @@ -91,9 +91,9 @@ static int StepLibraryStep( void* pPWM, int dir, unsigned int numPulses ){ for(unsigned int i = 0; i < numPulses; i++){ HAL_GPIO_WritePin(STEP_PULSE_GPIO_Port, STEP_PULSE_Pin, GPIO_PIN_SET); - HAL_Delay(1); + vTaskDelay(pdMS_TO_TICKS(1)); HAL_GPIO_WritePin(STEP_PULSE_GPIO_Port, STEP_PULSE_Pin, GPIO_PIN_RESET); - HAL_Delay(1); + vTaskDelay(pdMS_TO_TICKS(1)); } return 0; } @@ -123,6 +123,11 @@ L6474_Handle_t init_stepper(void* pIO, void* pGPO, void* pPWM){ //p.cancelStep = StepTimerCancelAsync; L6474_Handle_t s = L6474_CreateInstance(&p, pIO, pGPO, pPWM); + return s; +} + +void reset_stepper(L6474_Handle_t s){ + L6474_BaseParameter_t b; L6474_SetBaseParameter(&b); // sinnvolle Standardwerte b.stepMode = smMICRO4; @@ -136,22 +141,4 @@ L6474_Handle_t init_stepper(void* pIO, void* pGPO, void* pPWM){ result |= L6474_Initialize(s, &b); result |= L6474_SetPowerOutputs(s, 1); - - - // in case we have no error, we can enable the drivers - // and then we step a bit - if ( result == 0 ) - { - result |= L6474_StepIncremental(s, 10000 ); - } - else - { - // error handling - - } - return s; -} - -void reset_stepper(){ - } diff --git a/stm32-stepper-root/stepper_h7/CM7/Core/Src/main.c b/stm32-stepper-root/stepper_h7/CM7/Core/Src/main.c index 94d6875..fc2c64b 100644 --- a/stm32-stepper-root/stepper_h7/CM7/Core/Src/main.c +++ b/stm32-stepper-root/stepper_h7/CM7/Core/Src/main.c @@ -307,6 +307,7 @@ int main(void) //Konsole ConsoleHandle_t c = CONSOLE_CreateInstance( 4*configMINIMAL_STACK_SIZE, configMAX_PRIORITIES - 5 ); + L6474_Handle_t stepper1 = init_stepper(NULL, NULL, NULL); CONSOLE_RegisterCommand(c, "capability", "prints a specified string of capability bits", CapabilityFunc, NULL); @@ -315,7 +316,7 @@ int main(void) fabi, NULL); CONSOLE_RegisterCommand(c, "stepper", "stepper command", - StepperConsoleFunction, NULL); + StepperConsoleFunction, stepper1); //Spindle init_spindle(c, 9000, -9000, 1600); diff --git a/stm32-stepper-root/stepper_h7/CM7/stepper_h7_CM7 Debug.launch b/stm32-stepper-root/stepper_h7/CM7/stepper_h7_CM7 Debug.launch index 7517d70..15a3640 100644 --- a/stm32-stepper-root/stepper_h7/CM7/stepper_h7_CM7 Debug.launch +++ b/stm32-stepper-root/stepper_h7/CM7/stepper_h7_CM7 Debug.launch @@ -46,9 +46,9 @@ - + - +