Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of X_NUCLEO_IHM01A1 by
Diff: Components/l6474/l6474_class.cpp
- Revision:
- 4:83a1eb397a65
- Parent:
- 1:b38ebb8ea286
- Child:
- 5:d3c78f12a78d
--- a/Components/l6474/l6474_class.cpp Fri Oct 16 13:30:06 2015 +0000 +++ b/Components/l6474/l6474_class.cpp Fri Nov 13 12:56:06 2015 +0000 @@ -259,7 +259,7 @@ **********************************************************/ void L6474::L6474_GoTo(int32_t targetPosition) { - motorDir_t direction; + direction_t direction; int32_t steps; /* Eventually deactivate motor */ @@ -277,12 +277,12 @@ if (steps >= 0) { devicePrm.stepsToTake = steps; - direction = FORWARD; + direction = CW; } else { devicePrm.stepsToTake = -steps; - direction = BACKWARD; + direction = CCW; } if (steps != 0) @@ -323,7 +323,7 @@ * @param[in] stepCount Number of steps to perform * @retval None **********************************************************/ -void L6474::L6474_Move(motorDir_t direction, uint32_t stepCount) +void L6474::L6474_Move(direction_t direction, uint32_t stepCount) { /* Eventually deactivate motor */ if (devicePrm.motionState != INACTIVE) @@ -377,7 +377,7 @@ * @param[in] direction FORWARD or BACKWARD * @retval None **********************************************************/ -void L6474::L6474_Run(motorDir_t direction) +void L6474::L6474_Run(direction_t direction) { /* Eventually deactivate motor */ if (devicePrm.motionState != INACTIVE) @@ -792,18 +792,27 @@ } /******************************************************//** + * @brief Get the direction + * @retval direction clockwise or counter-clockwise + **********************************************************/ +StepperMotor::direction_t L6474::L6474_GetDirection(void) +{ + return (devicePrm.direction == FORWARD ? CW : CCW); +} + +/******************************************************//** * @brief Specifies the direction * @param[in] dir FORWARD or BACKWARD * @note The direction change is only applied if the device * is in INACTIVE state * @retval None **********************************************************/ -void L6474::L6474_SetDirection(motorDir_t dir) +void L6474::L6474_SetDirection(direction_t direction) { if (devicePrm.motionState == INACTIVE) { - devicePrm.direction = dir; - L6474_SetDirectionGpio(dir); + devicePrm.direction = (direction == CW ? FORWARD : BACKWARD); + L6474_SetDirectionGpio(direction == CW ? 1 : 0); } }