![]() |
Open FFBoard
Open source force feedback firmware
|
#include <MotorPWM.h>
Public Member Functions | |
| MotorPWM () | |
| virtual | ~MotorPWM () |
| const ClassIdentifier | getInfo () |
| void | turn (int16_t power) |
| void | stopMotor () |
| void | startMotor () |
| void | setPwmSpeed (SpeedPWM_DRV spd) |
| SpeedPWM_DRV | getPwmSpeed () |
| void | setMode (ModePWM_DRV mode) |
| ModePWM_DRV | getMode () |
| void | saveFlash () |
| void | restoreFlash () |
| CommandStatus | command (const ParsedCommand &cmd, std::vector< CommandReply > &replies) |
| virtual std::string | getHelpstring () |
| void | setPWM (uint32_t value, uint8_t ccr) |
Public Member Functions inherited from MotorDriver | |
| MotorDriver () | |
| virtual | ~MotorDriver () |
| const ClassType | getClassType () override |
| returns the used classchooser selection id of this instance | |
| virtual void | emergencyStop (bool reset=false) |
| virtual bool | motorReady () |
| virtual Encoder * | getEncoder () |
| virtual void | setEncoder (std::shared_ptr< Encoder > &encoder) |
| virtual bool | hasIntegratedEncoder () |
Public Member Functions inherited from ChoosableClass | |
| virtual | ~ChoosableClass () |
| uint16_t | getSelectionID () |
Public Member Functions inherited from CommandHandler | |
| virtual const ClassType | getClassType () |
| CommandHandler (const char *clsname, uint16_t clsid, uint8_t instance=0) | |
| virtual | ~CommandHandler () |
| virtual bool | hasCommands () |
| virtual void | setCommandsEnabled (bool enable) |
| void | registerCommands () |
| virtual CommandStatus | internalCommand (const ParsedCommand &cmd, std::vector< CommandReply > &replies) |
| virtual std::string | getCommandsHelpstring () |
| virtual std::string | getCsvHelpstring () |
| virtual uint8_t | getCommandHandlerInstance () |
| void | broadcastCommandReply (CommandReply reply, uint32_t cmdId, CMDtype type) |
| void | sendCommandReplyAsync (CommandReply reply, uint32_t cmdId, CMDtype type, CommandInterface *interface=nullptr) |
| virtual uint16_t | getCommandHandlerID () |
| virtual CmdHandlerInfo * | getCommandHandlerInfo () |
| virtual bool | isValidCommandId (uint32_t cmdid, uint32_t ignoredFlags=0, uint32_t requiredFlag=0) |
| virtual CmdHandlerCommanddef * | getCommandFromName (const std::string &cmd, uint32_t ignoredFlags=0) |
| virtual CmdHandlerCommanddef * | getCommandFromId (const uint32_t id, uint32_t ignoredFlags=0) |
| template<typename ID> | |
| void | registerCommand (const char *cmd, const ID cmdid, const char *help=nullptr, uint32_t flags=0) |
Public Member Functions inherited from PersistentStorage | |
| PersistentStorage () | |
| virtual | ~PersistentStorage () |
| void | restoreFlashDelayed () |
Static Public Member Functions | |
| static bool | isCreatable () |
Static Public Member Functions inherited from ChoosableClass | |
| static bool | isCreatable () |
Static Public Member Functions inherited from CommandHandler | |
| static void | logSerial (std::string string) |
| Send a log formatted sequence. | |
| static void | logSerialDebug (std::string string) |
| Send a log formatted sequence if debug is on. | |
| static bool | logsEnabled () |
| static void | setLogsEnabled (bool enabled) |
| static uint32_t | getClassIdFromName (const char *name) |
| static const char * | getClassNameFromId (const uint32_t id) |
| static CommandHandler * | getHandlerFromHandlerId (const uint16_t cmdhandlerID) |
| static CommandHandler * | getHandlerFromId (const uint16_t id, const uint8_t instance=0xFF) |
| static CommandHandler * | getHandlerFromClassName (const char *name, const uint8_t instance=0xFF) |
| static std::vector< CommandHandler * > | getHandlersFromClassName (const char *name) |
| static std::vector< CommandHandler * > | getHandlersFromId (const uint16_t id) |
| static bool | isInHandlerList (CommandHandler *handler) |
| static std::string | getAllHelpstrings () |
| static std::vector< CommandHandler * > & | getCommandHandlers () |
| template<typename TVal> | |
| static CommandStatus | handleGetSet (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value) |
| template<typename TVal, class cls, class cls1> | |
| static CommandStatus | handleGetSetFunc (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value, void(cls1::*setfunc)(TVal), cls *obj) |
| template<typename TVal, class cls, class cls1, class cls2> | |
| static CommandStatus | handleGetFuncSetFunc (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal(cls1::*getfunc)(), void(cls2::*setfunc)(TVal), cls *obj) |
| template<typename TVal, class cls, class cls1> | |
| static CommandStatus | handleGetFuncSet (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value, TVal(cls1::*getfunc)(), cls *obj) |
Static Public Member Functions inherited from PersistentStorage | |
| static std::vector< PersistentStorage * > & | getFlashHandlers () |
| static void | restoreFlashStartupCb () |
Static Public Attributes | |
| static ClassIdentifier | info |
| static bool | pwmDriverInUse = false |
| static PWMConfig & | config |
Static Public Attributes inherited from MotorDriver | |
| static ClassIdentifier | info ={.name = "None" , .id=CLSID_MOT_NONE, .visibility = ClassVisibility::visible} |
| static const std::vector< class_entry< MotorDriver > > | all_drivers |
Static Public Attributes inherited from ChoosableClass | |
| static ClassIdentifier | info |
Static Public Attributes inherited from CommandHandler | |
| static bool | logEnabled = true |
Private Types | |
| enum class | MotorPWM_commands : uint32_t { mode , freq , dir } |
Static Private Member Functions | |
| static std::pair< uint16_t, uint16_t > | freqToPeriodPsc (uint32_t freq) |
Private Attributes | |
| float | tFreq = 1 |
| int32_t | period = 20000 |
| int32_t | prescaler = 95 |
| bool | invertDir = false |
| SpeedPWM_DRV | pwmspeed = SpeedPWM_DRV::LOW |
| ModePWM_DRV | mode = ModePWM_DRV::CENTERED_PWM |
| bool | active = false |
Static Private Attributes | |
| static const PWMConfig | timerConfig |
Additional Inherited Members | |
Protected Member Functions inherited from CommandHandler | |
| void | setInstance (uint8_t instance) |
| virtual void | addCommandHandler () |
| virtual void | removeCommandHandler () |
Static Protected Member Functions inherited from CommandHandler | |
| static std::vector< uint16_t > & | getCommandHandlerIds () |
Protected Attributes inherited from MotorDriver | |
| std::shared_ptr< Encoder > | drvEncoder = std::make_shared<Encoder>() |
Protected Attributes inherited from ChoosableClass | |
| uint16_t | selectionId |
| Should only be written by ClassChooser during creation. | |
Protected Attributes inherited from CommandHandler | |
| bool | commandsEnabled = true |
| std::vector< CmdHandlerCommanddef > | registeredCommands |
| CmdHandlerInfo | cmdHandlerInfo |
Protected Attributes inherited from PersistentStorage | |
| bool | restoreDelayedFlag = false |
Static Protected Attributes inherited from PersistentStorage | |
| static bool | startupComplete = false |
Contains motor drivers methods based on PWM generation.
Can output different types of PWM signals based on a torque input.
Definition at line 54 of file MotorPWM.h.
|
strongprivate |
| Enumerator | |
|---|---|
| mode | |
| freq | |
| dir | |
Definition at line 55 of file MotorPWM.h.
| MotorPWM::MotorPWM | ( | ) |
Definition at line 35 of file MotorPWM.cpp.
|
virtual |
Definition at line 48 of file MotorPWM.cpp.
|
virtual |
| [in] | cmd | The parsed command to be executed. |
| [out] | replies | A vector to return one or multiple reply objects into. Replies to the interface will be generated based on the reply objects. A string reply may not contain start, end and separation markers: [,],| Other characters are allowed. |
Reimplemented from CommandHandler.
Definition at line 248 of file MotorPWM.cpp.
|
staticprivate |
Calculates period and prescaler for a timer based on frequency
Definition at line 113 of file MotorPWM.cpp.
|
inlinevirtual |
Returns a description of this class
Reimplemented from CommandHandler.
Definition at line 80 of file MotorPWM.h.
|
virtual |
Reimplemented from MotorDriver.
Definition at line 26 of file MotorPWM.cpp.
| ModePWM_DRV MotorPWM::getMode | ( | ) |
Definition at line 242 of file MotorPWM.cpp.
| SpeedPWM_DRV MotorPWM::getPwmSpeed | ( | ) |
Definition at line 197 of file MotorPWM.cpp.
|
static |
Definition at line 30 of file MotorPWM.cpp.
|
virtual |
Should be implemented to restore settings. This is not automatically called and should be called when appropriate.
Reimplemented from PersistentStorage.
Definition at line 212 of file MotorPWM.cpp.
|
virtual |
Called when the user uses the "save" command and presses the save button in the configurator Automatically called by the command parser thread for every class that inherits from PersistentStorage
Reimplemented from PersistentStorage.
Definition at line 204 of file MotorPWM.cpp.
| void MotorPWM::setMode | ( | ModePWM_DRV | mode | ) |
Definition at line 237 of file MotorPWM.cpp.
| void MotorPWM::setPWM | ( | uint32_t | value, |
| uint8_t | ccr ) |
Updates pwm pulse length
Definition at line 184 of file MotorPWM.cpp.
| void MotorPWM::setPwmSpeed | ( | SpeedPWM_DRV | spd | ) |
Setup the timer for different frequency presets.
Definition at line 123 of file MotorPWM.cpp.
|
virtual |
Enable the motor driver
Reimplemented from MotorDriver.
Definition at line 226 of file MotorPWM.cpp.
|
virtual |
Disable the motor driver
Reimplemented from MotorDriver.
Definition at line 231 of file MotorPWM.cpp.
|
virtual |
Turn the motor with positive/negative power. Range should be full signed 16 bit A value of 0 should have no torque. The sign is the direction.
Reimplemented from MotorDriver.
Definition at line 59 of file MotorPWM.cpp.
|
private |
Definition at line 97 of file MotorPWM.h.
|
static |
Definition at line 86 of file MotorPWM.h.
|
static |
Definition at line 22 of file MotorPWM.h.
|
private |
Definition at line 92 of file MotorPWM.h.
|
private |
Definition at line 96 of file MotorPWM.h.
|
private |
Definition at line 89 of file MotorPWM.h.
|
private |
Definition at line 90 of file MotorPWM.h.
|
static |
Definition at line 84 of file MotorPWM.h.
|
private |
Definition at line 95 of file MotorPWM.h.
|
private |
Definition at line 88 of file MotorPWM.h.
|
staticprivate |
The timer channels are mapped in the cpp_target_config files
Definition at line 102 of file MotorPWM.h.