|
|
|
@ -154,15 +154,21 @@ bool SF_MoveMotorToZeroPosition(SF_Handle_t instance){ |
|
|
|
// move out of sensor
|
|
|
|
// move out of sensor
|
|
|
|
while(SF_GetMagSensorAtZeroPosition((SF_t*)instance) == true){ |
|
|
|
while(SF_GetMagSensorAtZeroPosition((SF_t*)instance) == true){ |
|
|
|
McuULN2003_IncStep(((SF_t*)instance)->motor); |
|
|
|
McuULN2003_IncStep(((SF_t*)instance)->motor); |
|
|
|
|
|
|
|
#ifdef McuLib_CONFIG_SDK_USE_FREERTOS |
|
|
|
vTaskDelay(pdMS_TO_TICKS(20)); |
|
|
|
vTaskDelay(pdMS_TO_TICKS(20)); |
|
|
|
//McuWait_Waitms(20);
|
|
|
|
#else |
|
|
|
|
|
|
|
McuWait_Waitms(20); |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// turn until sensor is on and not reached one full rotation already (timeout)
|
|
|
|
// turn until sensor is on and not reached one full rotation already (timeout)
|
|
|
|
while(SF_GetMagSensorAtZeroPosition((SF_t*)instance) == false && numStepsMoved < SPLITFLAP_STEPS_ONE_ROUND ){ |
|
|
|
while(SF_GetMagSensorAtZeroPosition((SF_t*)instance) == false && numStepsMoved < SPLITFLAP_STEPS_ONE_ROUND ){ |
|
|
|
McuULN2003_IncStep(((SF_t*)instance)->motor); |
|
|
|
McuULN2003_IncStep(((SF_t*)instance)->motor); |
|
|
|
|
|
|
|
#ifdef McuLib_CONFIG_SDK_USE_FREERTOS |
|
|
|
vTaskDelay(pdMS_TO_TICKS(20)); |
|
|
|
vTaskDelay(pdMS_TO_TICKS(20)); |
|
|
|
//McuWait_Waitms(20);
|
|
|
|
#else |
|
|
|
|
|
|
|
McuWait_Waitms(20); |
|
|
|
|
|
|
|
#endif |
|
|
|
numStepsMoved++; |
|
|
|
numStepsMoved++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -170,8 +176,11 @@ bool SF_MoveMotorToZeroPosition(SF_Handle_t instance){ |
|
|
|
if(numStepsMoved < SPLITFLAP_STEPS_ONE_ROUND){ |
|
|
|
if(numStepsMoved < SPLITFLAP_STEPS_ONE_ROUND){ |
|
|
|
for(int i=0; i < offsetSteps; i++){ |
|
|
|
for(int i=0; i < offsetSteps; i++){ |
|
|
|
McuULN2003_IncStep(((SF_t*)instance)->motor); |
|
|
|
McuULN2003_IncStep(((SF_t*)instance)->motor); |
|
|
|
vTaskDelay(pdMS_TO_TICKS(20)); |
|
|
|
#ifdef McuLib_CONFIG_SDK_USE_FREERTOS |
|
|
|
//McuWait_Waitms(20);
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(20)); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
McuWait_Waitms(20); |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
McuULN2003_SetPos(((SF_t*)instance)->motor, 0); |
|
|
|
McuULN2003_SetPos(((SF_t*)instance)->motor, 0); |
|
|
|
@ -209,8 +218,11 @@ void SF_MoveSteps(SF_Handle_t instance, uint32_t steps){ |
|
|
|
if(McuULN2003_StepCallback(((SF_t*)instance)->motor, true)){ |
|
|
|
if(McuULN2003_StepCallback(((SF_t*)instance)->motor, true)){ |
|
|
|
steps--; |
|
|
|
steps--; |
|
|
|
} |
|
|
|
} |
|
|
|
vTaskDelay(pdMS_TO_TICKS(1)); |
|
|
|
#ifdef McuLib_CONFIG_SDK_USE_FREERTOS |
|
|
|
//McuWait_Waitms(1);
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(20)); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
McuWait_Waitms(20); |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
McuULN2003_AccelerationEnd(((SF_t*)instance)->motor); |
|
|
|
McuULN2003_AccelerationEnd(((SF_t*)instance)->motor); |
|
|
|
|
|
|
|
|
|
|
|
|