Open FFBoard
Open source force feedback firmware
ADS111X_AnalogSource Class Reference

#include <ADS111X.h>

Inheritance diagram for ADS111X_AnalogSource:
ADS111X AnalogSource CommandHandler AnalogAxisProcessing cpp_freertos::Thread I2CDevice ChoosableClass PersistentStorage

Public Member Functions

 ADS111X_AnalogSource ()
 
 ~ADS111X_AnalogSource ()
 
void saveFlash ()
 
void restoreFlash ()
 
void Run ()
 
void i2cRxCompleted (I2CPort *port)
 
void i2cTxCompleted (I2CPort *port)
 
void i2cError (I2CPort *port)
 
std::vector< int32_t > * getAxes ()
 
virtual const ClassIdentifier getInfo ()
 
std::string getHelpstring ()
 
const ClassType getClassType () override
 returns the used classchooser selection id of this instance More...
 
void initialize ()
 
CommandStatus command (const ParsedCommand &cmd, std::vector< CommandReply > &replies)
 
- Public Member Functions inherited from ADS111X
 ADS111X (I2CPort &port, uint8_t address=0x48)
 
virtual ~ADS111X ()
 
void readRegIT (const uint8_t reg, uint16_t *data)
 
void writeRegIT (const uint8_t reg, uint16_t data)
 
uint16_t readReg (const uint8_t reg)
 
void writeReg (const uint8_t reg, uint16_t data)
 
void startConversion (uint8_t channel, bool differential=false)
 
void setGain (uint16_t gain)
 
void setDatarate (uint16_t rate)
 
void startI2CTransfer (I2CPort *port)
 
void endI2CTransfer (I2CPort *port)
 
void setThresh (uint16_t loTh, uint16_t hiTh)
 
- Public Member Functions inherited from I2CDevice
 I2CDevice ()
 
virtual ~I2CDevice ()
 
- Public Member Functions inherited from AnalogSource
 AnalogSource ()
 
virtual ~AnalogSource ()
 
- Public Member Functions inherited from ChoosableClass
virtual ~ChoosableClass ()
 
uint16_t getSelectionID ()
 
- Public Member Functions inherited from PersistentStorage
 PersistentStorage ()
 
virtual ~PersistentStorage ()
 
void restoreFlashDelayed ()
 
- Public Member Functions inherited from CommandHandler
 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 CmdHandlerInfogetCommandHandlerInfo ()
 
virtual bool isValidCommandId (uint32_t cmdid, uint32_t ignoredFlags=0, uint32_t requiredFlag=0)
 
virtual CmdHandlerCommanddefgetCommandFromName (const std::string &cmd, uint32_t ignoredFlags=0)
 
virtual CmdHandlerCommanddefgetCommandFromId (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 AnalogAxisProcessing
 AnalogAxisProcessing (const uint32_t axisAmount, AnalogSource *analogSource, CommandHandler *cmdHandler=nullptr, bool allowFilters=true, bool allowAutoscale=true, bool allowRawValues=false, bool allowManualScale=false)
 
virtual ~AnalogAxisProcessing ()
 
CommandStatus command (const ParsedCommand &cmd, std::vector< CommandReply > &replies)
 
void setupFilters ()
 
void processAxes (std::vector< int32_t > &buf)
 
AnalogProcessingConfiggetAnalogProcessingConfig ()
 
void setAnalogProcessingConfig (AnalogProcessingConfig conf)
 
template<size_t size>
void restoreMinMaxValues (const std::array< std::pair< uint16_t, uint16_t >, size > &minMaxAddresses)
 
template<size_t size>
void saveMinMaxValues (const std::array< std::pair< uint16_t, uint16_t >, size > &minMaxAddresses)
 
- Public 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 ()
 

Static Public Member Functions

static bool isCreatable ()
 
- Static Public Member Functions inherited from AnalogSource
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. More...
 
static void logSerialDebug (std::string string)
 Send a log formatted sequence if debug is on. More...
 
static bool logsEnabled ()
 
static void setLogsEnabled (bool enabled)
 
static uint32_t getClassIdFromName (const char *name)
 
static const char * getClassNameFromId (const uint32_t id)
 
static CommandHandlergetHandlerFromHandlerId (const uint16_t cmdhandlerID)
 
static CommandHandlergetHandlerFromId (const uint16_t id, const uint8_t instance=0xFF)
 
static CommandHandlergetHandlerFromClassName (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 AnalogAxisProcessing
static AnalogProcessingConfig decodeAnalogProcessingConfFromInt (uint16_t val)
 
static uint16_t encodeAnalogProcessingConfToInt (AnalogProcessingConfig &conf)
 
- Static Public Member Functions inherited from cpp_freertos::Thread
static void Yield ()
 
static void StartScheduler ()
 
static void EndScheduler ()
 

Static Public Attributes

static ClassIdentifier info
 
- Static Public Attributes inherited from AnalogSource
static ClassIdentifier info
 
static const std::vector< class_entry< AnalogSource > > all_analogsources
 
- Static Public Attributes inherited from ChoosableClass
static ClassIdentifier info
 
- Static Public Attributes inherited from CommandHandler
static bool logEnabled = true
 

Private Types

enum class  ADS111X_AnalogSource_commands : uint32_t {
  axes , differential , gain , rate ,
  address
}
 
enum class  ADS111X_AnalogSource_state : uint8_t {
  none , idle , sampling , beginSampling ,
  getsample , readingSample
}
 

Private Member Functions

void setAxes (uint8_t axes, bool differential)
 

Private Attributes

int16_t sampleBuffer
 
uint16_t configRegBuf = 0
 
uint8_t axes =1
 
uint8_t lastAxis = 0
 
uint32_t lastSuccess = 0
 
bool differentialMode = false
 
std::vector< int32_t > rawbuf
 
volatile ADS111X_AnalogSource_state state = ADS111X_AnalogSource_state::none
 

Additional Inherited Members

- Public Attributes inherited from AnalogSource
std::vector< int32_t > buf
 
- Protected Member Functions inherited from CommandHandler
void setInstance (uint8_t instance)
 
virtual void addCommandHandler ()
 
virtual void removeCommandHandler ()
 
- Protected Member Functions inherited from cpp_freertos::Thread
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)
 
- Static Protected Member Functions inherited from CommandHandler
static std::vector< uint16_t > & getCommandHandlerIds ()
 
- Protected Attributes inherited from ADS111X
I2CPortport
 
uint8_t address
 
uint8_t datarate = 4
 
uint8_t gain = 2
 
uint16_t conversions [4] = {0}
 
struct {
   uint16_t   config = 0x8583
 
   uint16_t   lothresh = 0x8000
 
   uint16_t   hithresh = 0x7FFF
 
registers
 
- Protected Attributes inherited from ChoosableClass
uint16_t selectionId
 Should only be written by ClassChooser during creation. More...
 
- Protected Attributes inherited from PersistentStorage
bool restoreDelayedFlag = false
 
- Protected Attributes inherited from CommandHandler
bool commandsEnabled = true
 
std::vector< CmdHandlerCommanddefregisteredCommands
 
CmdHandlerInfo cmdHandlerInfo
 
- Protected Attributes inherited from AnalogAxisProcessing
AnalogProcessingConfig conf
 
const uint32_t axisAmount
 
AnalogSourceanalogSource
 
std::vector< Biquadfilters
 
std::vector< MinMaxPairminMaxVals
 
const float filterF = 30.0/1000.0
 
const float filterQ = 0.5
 
uint32_t filterSamples = 0
 
const uint32_t waitFilterSamples = 500
 
float autorangeScale = 1.05
 
std::vector< int32_t > rawValues
 
- Static Protected Attributes inherited from PersistentStorage
static bool startupComplete = false
 

Detailed Description

Definition at line 64 of file ADS111X.h.

Member Enumeration Documentation

◆ ADS111X_AnalogSource_commands

enum class ADS111X_AnalogSource::ADS111X_AnalogSource_commands : uint32_t
strongprivate
Enumerator
axes 
differential 
gain 
rate 
address 

Definition at line 65 of file ADS111X.h.

◆ ADS111X_AnalogSource_state

enum class ADS111X_AnalogSource::ADS111X_AnalogSource_state : uint8_t
strongprivate
Enumerator
none 
idle 
sampling 
beginSampling 
getsample 
readingSample 

Definition at line 69 of file ADS111X.h.

Constructor & Destructor Documentation

◆ ADS111X_AnalogSource()

ADS111X_AnalogSource::ADS111X_AnalogSource ( )

Definition at line 177 of file ADS111X.cpp.

◆ ~ADS111X_AnalogSource()

ADS111X_AnalogSource::~ADS111X_AnalogSource ( )

Definition at line 189 of file ADS111X.cpp.

Member Function Documentation

◆ command()

CommandStatus ADS111X_AnalogSource::command ( const ParsedCommand cmd,
std::vector< CommandReply > &  replies 
)
virtual
Parameters
[in]cmdThe parsed command to be executed.
[out]repliesA 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 343 of file ADS111X.cpp.

◆ getAxes()

std::vector< int32_t > * ADS111X_AnalogSource::getAxes ( )
virtual

Reimplemented from AnalogSource.

Definition at line 318 of file ADS111X.cpp.

◆ getClassType()

const ClassType ADS111X_AnalogSource::getClassType ( )
inlineoverridevirtual

returns the used classchooser selection id of this instance

Type of this class. Mainclass, motordriver... Should be implemented by the parent class so it is not in the info struct

Reimplemented from AnalogSource.

Definition at line 93 of file ADS111X.h.

◆ getHelpstring()

std::string ADS111X_AnalogSource::getHelpstring ( )
inlinevirtual

Returns a description of this class

Reimplemented from CommandHandler.

Definition at line 91 of file ADS111X.h.

◆ getInfo()

const ClassIdentifier ADS111X_AnalogSource::getInfo ( )
virtual

Implements AnalogSource.

Definition at line 164 of file ADS111X.cpp.

◆ i2cError()

void ADS111X_AnalogSource::i2cError ( I2CPort port)
virtual

Reimplemented from I2CDevice.

Definition at line 223 of file ADS111X.cpp.

◆ i2cRxCompleted()

void ADS111X_AnalogSource::i2cRxCompleted ( I2CPort port)
virtual

i2c complete interrupt signals thread to start next transfer Called when reading the status or a sample

Reimplemented from I2CDevice.

Definition at line 280 of file ADS111X.cpp.

◆ i2cTxCompleted()

void ADS111X_AnalogSource::i2cTxCompleted ( I2CPort port)
virtual

Called when a conversion is started or data sent to the adc

Reimplemented from I2CDevice.

Definition at line 306 of file ADS111X.cpp.

◆ initialize()

void ADS111X_AnalogSource::initialize ( )

Definition at line 214 of file ADS111X.cpp.

◆ isCreatable()

static bool ADS111X_AnalogSource::isCreatable ( )
inlinestatic

Definition at line 90 of file ADS111X.h.

◆ restoreFlash()

void ADS111X_AnalogSource::restoreFlash ( )
virtual

Should be implemented to restore settings. This is not automatically called and should be called when appropriate.

Reimplemented from PersistentStorage.

Definition at line 203 of file ADS111X.cpp.

◆ Run()

void ADS111X_AnalogSource::Run ( )
virtual

Implementation of your actual thread code. You must override this function.

Note
If INCLUDE_vTaskDelete is defined, then you may return from your Run method. This will cause the task to be deleted from FreeRTOS, however you are still responsible to delete the task object. If this is not defined, then retuning from your Run() method will result in an assert.

Implements cpp_freertos::Thread.

Definition at line 229 of file ADS111X.cpp.

◆ saveFlash()

void ADS111X_AnalogSource::saveFlash ( )
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 193 of file ADS111X.cpp.

◆ setAxes()

void ADS111X_AnalogSource::setAxes ( uint8_t  axes,
bool  differential 
)
private

Definition at line 336 of file ADS111X.cpp.

Member Data Documentation

◆ axes

uint8_t ADS111X_AnalogSource::axes =1
private

Definition at line 102 of file ADS111X.h.

◆ configRegBuf

uint16_t ADS111X_AnalogSource::configRegBuf = 0
private

Definition at line 101 of file ADS111X.h.

◆ differentialMode

bool ADS111X_AnalogSource::differentialMode = false
private

Definition at line 105 of file ADS111X.h.

◆ info

ClassIdentifier ADS111X_AnalogSource::info
static
Initial value:
= {
.name = "ADS111X ADC" ,
.id=CLSID_ANALOG_ADS111X,
}

Definition at line 89 of file ADS111X.h.

◆ lastAxis

uint8_t ADS111X_AnalogSource::lastAxis = 0
private

Definition at line 103 of file ADS111X.h.

◆ lastSuccess

uint32_t ADS111X_AnalogSource::lastSuccess = 0
private

Definition at line 104 of file ADS111X.h.

◆ rawbuf

std::vector<int32_t> ADS111X_AnalogSource::rawbuf
private

Definition at line 106 of file ADS111X.h.

◆ sampleBuffer

int16_t ADS111X_AnalogSource::sampleBuffer
private

Definition at line 100 of file ADS111X.h.

◆ state

volatile ADS111X_AnalogSource_state ADS111X_AnalogSource::state = ADS111X_AnalogSource_state::none
private

Definition at line 107 of file ADS111X.h.


The documentation for this class was generated from the following files: