![]() |
Open FFBoard
Open source force feedback firmware
|
#include <MtEncoderSPI.h>
Public Member Functions | |
| MtEncoderSPI () | |
| virtual | ~MtEncoderSPI () |
| const ClassIdentifier | getInfo () |
| EncoderType | getEncoderType () |
| void | Run () |
| void | restoreFlash () override |
| void | saveFlash () override |
| int32_t | getPos () override |
| uint32_t | getCpr () override |
| int32_t | getPosAbs () override |
| void | setPos (int32_t pos) |
| void | initSPI () |
| void | updateAngleStatus () |
| bool | updateAngleStatusCb () |
| CommandStatus | command (const ParsedCommand &cmd, std::vector< CommandReply > &replies) |
| void | setCsPin (uint8_t cspin) |
| void | setMode (MtEncoderSPI_mode mode) |
Public Member Functions inherited from Encoder | |
| Encoder () | |
| virtual | ~Encoder () |
| virtual float | getPos_f () |
| virtual float | getPosAbs_f () |
| virtual const ClassType | getClassType () override |
| returns the used classchooser selection id of this instance | |
Public Member Functions inherited from ChoosableClass | |
| virtual | ~ChoosableClass () |
| uint16_t | getSelectionID () |
Public Member Functions inherited from SPIDevice | |
| SPIDevice (SPIPort &port, OutputPin csPin) | |
| SPIDevice (SPIPort &port, SPIConfig &spiConfig) | |
| virtual | ~SPIDevice () |
| void | assertChipSelect () |
| void | clearChipSelect () |
| virtual bool | updateCSPin (OutputPin &csPin) |
| virtual void | spiTxCompleted (SPIPort *port) |
| virtual void | spiRxCompleted (SPIPort *port) |
| virtual void | spiRequestError (SPIPort *port) |
| virtual void | beginSpiTransfer (SPIPort *port) |
| virtual void | endSpiTransfer (SPIPort *port) |
| virtual SPIConfig * | getSpiConfig () |
Public Member Functions inherited from PersistentStorage | |
| PersistentStorage () | |
| virtual | ~PersistentStorage () |
| void | restoreFlashDelayed () |
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 | getHelpstring () |
| 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) |
Static Public Member Functions | |
| static bool | isCreatable () |
Static Public Member Functions inherited from ChoosableClass | |
| static bool | isCreatable () |
Static Public Member Functions inherited from PersistentStorage | |
| static std::vector< PersistentStorage * > & | getFlashHandlers () |
| static void | restoreFlashStartupCb () |
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 Attributes | |
| static bool | inUse = false |
| static ClassIdentifier | info |
Static Public Attributes inherited from Encoder | |
| static ClassIdentifier | info ={.name = "None" , .id=CLSID_ENCODER_NONE, .visibility = ClassVisibility::visible} |
| static const std::vector< class_entry< Encoder > > | all_encoders |
Static Public Attributes inherited from ChoosableClass | |
| static ClassIdentifier | info |
Static Public Attributes inherited from CommandHandler | |
| static bool | logEnabled = true |
Private Types | |
| enum class | MtEncoderSPI_commands : uint32_t { cspin , pos , errors , mode } |
| enum class | MtEncoderSPI_mode : uint8_t { mt6825 , mt6835 } |
Private Member Functions | |
| uint8_t | readSpi (uint16_t addr) |
| void | writeSpi (uint16_t addr, uint8_t data) |
| void | spiTxRxCompleted (SPIPort *port) |
Private Member Functions inherited from cpp_freertos::Thread | |
| Thread (const std::string Name, uint16_t StackDepth, UBaseType_t Priority) | |
| Thread (const char *Name, uint16_t StackDepth, UBaseType_t Priority) | |
| Thread (uint16_t StackDepth, UBaseType_t Priority) | |
| bool | Start () |
| virtual | ~Thread () |
| TaskHandle_t | GetHandle () |
| void | Suspend () |
| void | Resume () |
| void | ResumeFromISR () |
| void | Notify () |
| void | NotifyFromISR () |
| uint32_t | WaitForNotification (TickType_t Timeout=portMAX_DELAY) |
| UBaseType_t | GetPriority () |
| UBaseType_t | GetPriorityFromISR () |
| void | SetPriority (UBaseType_t NewPriority) |
| std::string | GetName () |
| char * | GetName () |
| virtual void | Cleanup () |
| void | Delay (const TickType_t Delay) |
| void | DelayUntil (const TickType_t Period) |
| void | ResetDelayUntil () |
| bool | Wait (ConditionVariable &Cv, Mutex &CvLock, TickType_t Timeout=portMAX_DELAY) |
Private Attributes | |
| bool | nomag = false |
| bool | overspeed = false |
| int32_t | lastAngleInt = 0 |
| int32_t | curAngleInt = 0 |
| int32_t | curPos = 0 |
| int32_t | rotations = 0 |
| int32_t | offset = 0 |
| uint8_t | cspin = 0 |
| bool | updateInProgress = false |
| uint32_t | errors = 0 |
| uint8_t | txbuf [6] = {0} |
| uint8_t | rxbuf [6] = {0} |
| uint8_t | rxbuf_t [6] = {0} |
| cpp_freertos::BinarySemaphore | requestNewDataSem = cpp_freertos::BinarySemaphore(false) |
| cpp_freertos::BinarySemaphore | waitForUpdateSem = cpp_freertos::BinarySemaphore(false) |
| MtEncoderSPI_mode | mode = MtEncoderSPI_mode::mt6825 |
| const uint8_t | POLY = 0x07 |
Static Private Attributes | |
| static std::array< uint8_t, 256 > | tableCRC |
Additional Inherited Members | |
Protected Member Functions inherited from SPIDevice | |
| virtual void | setSpiConfig (SPIConfig config) |
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 Encoder | |
| uint32_t | cpr = 0 |
Protected Attributes inherited from ChoosableClass | |
| uint16_t | selectionId |
| Should only be written by ClassChooser during creation. | |
Protected Attributes inherited from SPIDevice | |
| SPIPort & | spiPort |
| SPIConfig | spiConfig |
Protected Attributes inherited from PersistentStorage | |
| bool | restoreDelayedFlag = false |
Protected Attributes inherited from CommandHandler | |
| bool | commandsEnabled = true |
| std::vector< CmdHandlerCommanddef > | registeredCommands |
| CmdHandlerInfo | cmdHandlerInfo |
Static Protected Attributes inherited from PersistentStorage | |
| static bool | startupComplete = false |
Static Private Member Functions inherited from cpp_freertos::Thread | |
| static void | Yield () |
| static void | StartScheduler () |
| static void | EndScheduler () |
Definition at line 20 of file MtEncoderSPI.h.
|
strongprivate |
| Enumerator | |
|---|---|
| cspin | |
| pos | |
| errors | |
| mode | |
Definition at line 21 of file MtEncoderSPI.h.
|
strongprivate |
| Enumerator | |
|---|---|
| mt6825 | |
| mt6835 | |
Definition at line 24 of file MtEncoderSPI.h.
| MtEncoderSPI::MtEncoderSPI | ( | ) |
Definition at line 24 of file MtEncoderSPI.cpp.
|
virtual |
Definition at line 46 of file MtEncoderSPI.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 266 of file MtEncoderSPI.cpp.
|
overridevirtual |
Gets the amount of counts per full rotation of the encoder
Reimplemented from Encoder.
Definition at line 242 of file MtEncoderSPI.cpp.
|
inlinevirtual |
Returns the type of the encoder. Must override this and NOT return NONE in other classes
Reimplemented from Encoder.
Definition at line 36 of file MtEncoderSPI.h.
|
virtual |
Reimplemented from Encoder.
Definition at line 18 of file MtEncoderSPI.cpp.
|
overridevirtual |
Returns the encoder position as raw counts
Reimplemented from Encoder.
Definition at line 226 of file MtEncoderSPI.cpp.
|
overridevirtual |
Returns absolute positions without offsets for absolute encoders. Otherwise it returns getPos
Reimplemented from Encoder.
Definition at line 231 of file MtEncoderSPI.cpp.
| void MtEncoderSPI::initSPI | ( | ) |
Definition at line 102 of file MtEncoderSPI.cpp.
|
inlinestatic |
Definition at line 34 of file MtEncoderSPI.h.
|
private |
MT encoder reads 1 byte and transmits 1 byte back after that
Definition at line 112 of file MtEncoderSPI.cpp.
|
overridevirtual |
Should be implemented to restore settings. This is not automatically called and should be called when appropriate.
Reimplemented from PersistentStorage.
Definition at line 51 of file MtEncoderSPI.cpp.
|
virtual |
Implementation of your actual thread code. You must override this function.
Implements cpp_freertos::Thread.
Definition at line 68 of file MtEncoderSPI.cpp.
|
overridevirtual |
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 60 of file MtEncoderSPI.cpp.
| void MtEncoderSPI::setCsPin | ( | uint8_t | cspin | ) |
Definition at line 94 of file MtEncoderSPI.cpp.
| void MtEncoderSPI::setMode | ( | MtEncoderSPI::MtEncoderSPI_mode | mode | ) |
Definition at line 253 of file MtEncoderSPI.cpp.
|
virtual |
Change the position of the encoder Can be used to reset the center
Reimplemented from Encoder.
Definition at line 137 of file MtEncoderSPI.cpp.
|
privatevirtual |
Reimplemented from SPIDevice.
Definition at line 142 of file MtEncoderSPI.cpp.
| void MtEncoderSPI::updateAngleStatus | ( | ) |
Reads the angle and diagnostic registers in burst mode
Definition at line 155 of file MtEncoderSPI.cpp.
| bool MtEncoderSPI::updateAngleStatusCb | ( | ) |
Definition at line 172 of file MtEncoderSPI.cpp.
|
private |
Definition at line 126 of file MtEncoderSPI.cpp.
|
private |
Definition at line 73 of file MtEncoderSPI.h.
|
private |
Definition at line 69 of file MtEncoderSPI.h.
|
private |
Definition at line 70 of file MtEncoderSPI.h.
|
private |
Definition at line 75 of file MtEncoderSPI.h.
|
static |
Definition at line 14 of file MtEncoderSPI.h.
|
static |
Definition at line 31 of file MtEncoderSPI.h.
|
private |
Definition at line 68 of file MtEncoderSPI.h.
|
private |
Definition at line 84 of file MtEncoderSPI.h.
|
private |
Definition at line 66 of file MtEncoderSPI.h.
|
private |
Definition at line 72 of file MtEncoderSPI.h.
|
private |
Definition at line 67 of file MtEncoderSPI.h.
|
private |
Definition at line 87 of file MtEncoderSPI.h.
|
private |
Definition at line 81 of file MtEncoderSPI.h.
|
private |
Definition at line 71 of file MtEncoderSPI.h.
|
private |
Definition at line 79 of file MtEncoderSPI.h.
|
private |
Definition at line 80 of file MtEncoderSPI.h.
|
staticprivate |
Definition at line 86 of file MtEncoderSPI.h.
|
private |
Definition at line 78 of file MtEncoderSPI.h.
|
private |
Definition at line 74 of file MtEncoderSPI.h.
|
private |
Definition at line 82 of file MtEncoderSPI.h.