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.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Diff: Components/l6474/l6474_class.h
- Revision:
- 1:b38ebb8ea286
- Parent:
- 0:2887415a46cd
- Child:
- 4:83a1eb397a65
--- a/Components/l6474/l6474_class.h Wed Oct 14 15:12:18 2015 +0000
+++ b/Components/l6474/l6474_class.h Fri Oct 16 13:30:06 2015 +0000
@@ -76,11 +76,6 @@
#include "../Interfaces/Motor_class.h"
-/* Functions -----------------------------------------------------------------*/
-
-extern void PWMCallback(void);
-
-
/* Classes -------------------------------------------------------------------*/
/** Class representing a L6474 component.
@@ -290,6 +285,11 @@
L6474_StepClockHandler();
}
+ virtual void WaitWhileActive(void)
+ {
+ L6474_WaitWhileActive();
+ }
+
virtual void CmdDisable(void)
{
L6474_CmdDisable();
@@ -403,41 +403,42 @@
* DrvStatusTypeDef COMPONENT_EnableFeature(void); //(2) *
* DrvStatusTypeDef COMPONENT_ComputeAverage(void); //(3) *
*------------------------------------------------------------------------*/
- void L6474_AttachErrorHandler(void (*callback)(uint16_t error)); //Attach a user callback to the error handler
- void L6474_AttachFlagInterrupt(void (*callback)(void)); //Attach a user callback to the flag Interrupt
- DrvStatusTypeDef L6474_Init(MOTOR_InitTypeDef *init); //Start the L6474 library
- DrvStatusTypeDef L6474_ReadID(uint8_t *id); //Read Id to get driver instance
- uint16_t L6474_GetAcceleration(void); //Return the acceleration in pps^2
- uint16_t L6474_GetCurrentSpeed(void); //Return the current speed in pps
- uint16_t L6474_GetDeceleration(void); //Return the deceleration in pps^2
- motorState_t L6474_GetDeviceState(void); //Return the device state
- uint8_t L6474_GetFwVersion(void); //Return the FW version
- int32_t L6474_GetMark(void); //Return the mark position
- uint16_t L6474_GetMaxSpeed(void); //Return the max speed in pps
- uint16_t L6474_GetMinSpeed(void); //Return the min speed in pps
- int32_t L6474_GetPosition(void); //Return the ABS_POSITION (32b signed)
- void L6474_GoHome(void); //Move to the home position
- 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(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
- void L6474_SetMark(void); //Set current position to be the Markposition
- bool L6474_SetMaxSpeed(uint16_t newMaxSpeed); //Set the max speed in pps
- bool L6474_SetMinSpeed(uint16_t newMinSpeed); //Set the min speed in pps
- bool L6474_SoftStop(void); //Progressively stops the motor
- void L6474_CmdDisable(void); //Send the L6474_DISABLE command
- void L6474_CmdEnable(void); //Send the L6474_ENABLE command
- uint32_t L6474_CmdGetParam(uint32_t param); //Send the L6474_GET_PARAM command
- uint16_t L6474_CmdGetStatus(void); //Send the L6474_GET_STATUS command
- void L6474_CmdNop(void); //Send the L6474_NOP command
- 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
- void L6474_SetDirection(motorDir_t direction); //Set the L6474 direction pin
+ void L6474_AttachErrorHandler(void (*callback)(uint16_t error)); //Attach a user callback to the error handler
+ void L6474_AttachFlagInterrupt(void (*callback)(void)); //Attach a user callback to the flag Interrupt
+ DrvStatusTypeDef L6474_Init(MOTOR_InitTypeDef *init); //Start the L6474 library
+ DrvStatusTypeDef L6474_ReadID(uint8_t *id); //Read Id to get driver instance
+ uint16_t L6474_GetAcceleration(void); //Return the acceleration in pps^2
+ uint16_t L6474_GetCurrentSpeed(void); //Return the current speed in pps
+ uint16_t L6474_GetDeceleration(void); //Return the deceleration in pps^2
+ motorState_t L6474_GetDeviceState(void); //Return the device state
+ uint8_t L6474_GetFwVersion(void); //Return the FW version
+ int32_t L6474_GetMark(void); //Return the mark position
+ uint16_t L6474_GetMaxSpeed(void); //Return the max speed in pps
+ uint16_t L6474_GetMinSpeed(void); //Return the min speed in pps
+ int32_t L6474_GetPosition(void); //Return the ABS_POSITION (32b signed)
+ void L6474_GoHome(void); //Move to the home position
+ 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(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
+ void L6474_SetMark(void); //Set current position to be the Markposition
+ bool L6474_SetMaxSpeed(uint16_t newMaxSpeed); //Set the max speed in pps
+ bool L6474_SetMinSpeed(uint16_t newMinSpeed); //Set the min speed in pps
+ bool L6474_SoftStop(void); //Progressively stops the motor
+ void L6474_WaitWhileActive(void); //Wait for the device state becomes Inactive
+ void L6474_CmdDisable(void); //Send the L6474_DISABLE command
+ void L6474_CmdEnable(void); //Send the L6474_ENABLE command
+ uint32_t L6474_CmdGetParam(uint32_t param); //Send the L6474_GET_PARAM command
+ uint16_t L6474_CmdGetStatus(void); //Send the L6474_GET_STATUS command
+ void L6474_CmdNop(void); //Send the L6474_NOP command
+ 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
+ void L6474_SetDirection(motorDir_t direction); //Set the L6474 direction pin
void L6474_ApplySpeed(uint16_t newSpeed);
void L6474_ComputeSpeedProfile(uint32_t nbSteps);
int32_t L6474_ConvertPosition(uint32_t abs_position_reg);
@@ -536,7 +537,7 @@
double period = 1.0f / newFreq;
pwm.period(period);
pwm.write(0.5f);
- ticker.attach(&PWMCallback, period);
+ ticker.attach(this, &L6474::L6474_StepClockHandler, period);
}
/*