Personal fork of the library for direct control instead of library control
Dependents: Thesis_Rotating_Platform
Fork of X_NUCLEO_IHM01A1 by
Diff: Components/l6474/l6474_class.h
- Revision:
- 5:d3c78f12a78d
- Parent:
- 4:83a1eb397a65
- Child:
- 6:a47569fc7534
--- a/Components/l6474/l6474_class.h Fri Nov 13 12:56:06 2015 +0000 +++ b/Components/l6474/l6474_class.h Wed Nov 18 18:41:55 2015 +0000 @@ -108,13 +108,13 @@ *--------------------------------------------------------------------*/ flagInterruptCallback = 0; errorHandlerCallback = 0; - memset(spiTxBursts, 0, L6474_CMD_ARG_MAX_NB_BYTES); - memset(spiRxBursts, 0, L6474_CMD_ARG_MAX_NB_BYTES); spiPreemtionByIsr = 0; isrFlag = 0; //devicePrm = 0; deviceInstance = numberOfDevices; numberOfDevices++; + memset(spiTxBursts, 0, L6474_CMD_ARG_MAX_NB_BYTES * MAX_NUMBER_OF_DEVICES * sizeof(uint8_t)); + memset(spiRxBursts, 0, L6474_CMD_ARG_MAX_NB_BYTES * MAX_NUMBER_OF_DEVICES * sizeof(uint8_t)); } /** @@ -175,11 +175,6 @@ return (signed int) L6474_GetMark(); } - virtual direction_t GetDirection(void) - { - return (direction_t) L6474_GetDirection(); - } - virtual unsigned int GetSpeed(void) { return (unsigned int) L6474_GetCurrentSpeed(); @@ -205,6 +200,11 @@ return (unsigned int) L6474_GetDeceleration(); } + virtual direction_t GetDirection(void) + { + return (direction_t) (L6474_GetDirection() == FORWARD ? StepperMotor::FWD : StepperMotor::BWD); + } + virtual void SetParameter(unsigned int parameter, unsigned int value) { L6474_CmdSetParam((unsigned int) parameter, (unsigned int) value); @@ -220,11 +220,6 @@ L6474_SetMark(); } - virtual void SetDirection(direction_t direction) - { - L6474_SetDirection((direction_t) direction); - } - virtual void SetMaxSpeed(unsigned int speed) { L6474_SetMaxSpeed((unsigned int) speed); @@ -262,12 +257,12 @@ virtual void Run(direction_t direction) { - L6474_Run((direction_t) direction); + L6474_Run((motorDir_t) (direction == StepperMotor::FWD ? FORWARD : BACKWARD)); } virtual void Move(direction_t direction, unsigned int steps) { - L6474_Move((direction_t) direction, (unsigned int) steps); + L6474_Move((motorDir_t) (direction == StepperMotor::FWD ? FORWARD : BACKWARD), (unsigned int) steps); } virtual void SoftStop(void) @@ -290,6 +285,11 @@ return (uint8_t) L6474_GetFwVersion(); } + virtual void SetDirection(direction_t direction) + { + L6474_SetDirection((motorDir_t) (direction == StepperMotor::FWD ? FORWARD : BACKWARD)); + } + virtual void StepClockHandler(void) { L6474_StepClockHandler(); @@ -425,8 +425,8 @@ void L6474_GoMark(void); //Move to the Mark position void L6474_GoTo(int32_t targetPosition); //Go to the specified position void L6474_HardStop(void); //Stop the motor and disable the power bridge - void L6474_Move(direction_t direction, uint32_t stepCount); //Move the motor of the specified number of steps - void L6474_Run(direction_t direction); //Run the motor + void L6474_Move(motorDir_t direction, uint32_t stepCount); //Move the motor of the specified number of steps + void L6474_Run(motorDir_t direction); //Run the motor bool L6474_SetAcceleration(uint16_t newAcc); //Set the acceleration in pps^2 bool L6474_SetDeceleration(uint16_t newDec); //Set the deceleration in pps^2 void L6474_SetHome(void); //Set current position to be the home position @@ -443,8 +443,8 @@ void L6474_CmdSetParam(uint32_t param, uint32_t value); //Send the L6474_SET_PARAM command uint16_t L6474_ReadStatusRegister(void); //Read the L6474_STATUS register without clearing the flags void L6474_SelectStepMode(motorStepMode_t stepMod); //Step mode selection - direction_t L6474_GetDirection(void); //Get the direction of rotation - void L6474_SetDirection(direction_t direction); //Set the direction of rotation + motorDir_t L6474_GetDirection(void); //Get the direction of rotation + void L6474_SetDirection(motorDir_t direction); //Set the direction of rotation void L6474_ApplySpeed(uint16_t newSpeed); void L6474_ComputeSpeedProfile(uint32_t nbSteps); int32_t L6474_ConvertPosition(uint32_t abs_position_reg); @@ -511,7 +511,7 @@ */ void L6474_Delay(uint32_t delay) { - /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs */ + /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs.*/ wait_ms(delay); } @@ -520,7 +520,7 @@ */ void L6474_EnableIrq(void) { - /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs */ + /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs.*/ __enable_irq(); } @@ -529,7 +529,7 @@ */ void L6474_DisableIrq(void) { - /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs */ + /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs.*/ __disable_irq(); } @@ -539,7 +539,7 @@ */ void L6474_PwmSetFreq(uint16_t newFreq) { - /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs */ + /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs.*/ double period = 1.0f / newFreq; pwm.period(period); pwm.write(0.5f); @@ -554,7 +554,7 @@ */ void L6474_PwmInit(void) { - /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs */ + /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs.*/ } /* @@ -562,7 +562,7 @@ */ void L6474_PwmStop(void) { - /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs */ + /* TO BE IMPLEMENTED BY USING TARGET PLATFORM'S APIs.*/ pwm.write(0.0f); ticker.detach(); } @@ -655,13 +655,13 @@ *------------------------------------------------------------------------*/ void (*flagInterruptCallback)(void); void (*errorHandlerCallback)(uint16_t error); - uint8_t spiTxBursts[L6474_CMD_ARG_MAX_NB_BYTES]; - uint8_t spiRxBursts[L6474_CMD_ARG_MAX_NB_BYTES]; bool spiPreemtionByIsr; bool isrFlag; deviceParams_t devicePrm; + uint8_t deviceInstance; static uint8_t numberOfDevices; - uint8_t deviceInstance; + static uint8_t spiTxBursts[L6474_CMD_ARG_MAX_NB_BYTES][MAX_NUMBER_OF_DEVICES]; + static uint8_t spiRxBursts[L6474_CMD_ARG_MAX_NB_BYTES][MAX_NUMBER_OF_DEVICES]; }; #endif // __L6474_CLASS_H