Skip to content

Commit

Permalink
fix issue with comments - typo
Browse files Browse the repository at this point in the history
  • Loading branch information
gigapod committed Apr 29, 2024
1 parent 70a1a99 commit 34a82e2
Showing 1 changed file with 168 additions and 169 deletions.
337 changes: 168 additions & 169 deletions src/sfeTkArdI2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,229 +35,228 @@ over Inter-Integrated Circuit (I2C) in Arduino

/**
* @brief The sfeTkArdI2C implements an sfeTkII2C interface, defining the Arduino implementation for I2C in the Toolkit
* /
*/

class sfeTkArdI2C : public sfeTkII2C
{
public:
/**--------------------------------------------------------------------------
@brief Constructor
*/
sfeTkArdI2C(void) : _i2cPort(nullptr), _bufferChunkSize{kDefaultBufferChunk}
{
}
/**--------------------------------------------------------------------------
@brief Constructor
@param addr The address of the device
*/
sfeTkArdI2C(uint8_t addr) : sfeTkII2C(addr)
{
}

/**
* @brief copy constructor
*/
sfeTkArdI2C(sfeTkArdI2C const &rhs) : sfeTkII2C(), _i2cPort{rhs._i2cPort}
{
}

/**
* @brief Copy assignment
*
* @param rhs right hand side of the assignment
* @return value of the left hand side of the assignment
*/
sfeTkArdI2C &operator=(const sfeTkArdI2C &rhs)
{
_i2cPort = rhs._i2cPort;
return *this;
}

/**--------------------------------------------------------------------------
@brief Method sets up the required I2C settings.
@note This function provides a default I2C Port.
@retval kSTkErrOk on successful execution.
*/
sfeTkError_t init();

/**--------------------------------------------------------------------------
@brief - address version of the init method
*/
sfeTkError_t init(uint8_t addr);

/**--------------------------------------------------------------------------
@brief Method sets up the required I2C settings.
sfeTkArdI2C(void) : _i2cPort(nullptr), _bufferChunkSize{kDefaultBufferChunk}
{
}
/**--------------------------------------------------------------------------
@brief Constructor
@param wirePort Port for I2C communication.
@param bInit This flag tracks whether the bus has been initialized.
@param addr The address of the device
*/
sfeTkArdI2C(uint8_t addr) : sfeTkII2C(addr)
{
}

/**
* @brief copy constructor
*/
sfeTkArdI2C(sfeTkArdI2C const &rhs) : sfeTkII2C(), _i2cPort{rhs._i2cPort}
{
}

/**
* @brief Copy assignment
*
* @param rhs right hand side of the assignment
* @return value of the left hand side of the assignment
*/
sfeTkArdI2C &operator=(const sfeTkArdI2C &rhs)
{
_i2cPort = rhs._i2cPort;
return *this;
}

@retval kSTkErrOk on successful execution.
*/
sfeTkError_t init(TwoWire &wirePort, uint8_t addr, bool bInit = false);
/**--------------------------------------------------------------------------
@brief Method sets up the required I2C settings.
@note This function provides a default I2C Port.
/**--------------------------------------------------------------------------
@brief A simple ping of the device at the given address.
@note sfeTkIBus interface method
@retval kSTkErrOk on successful execution.
*/
sfeTkError_t init();

@retval kSTkErrOk on success,
*/
sfeTkError_t ping();
/**--------------------------------------------------------------------------
@brief - address version of the init method
*/
sfeTkError_t init(uint8_t addr);

/**--------------------------------------------------------------------------
@brief Write a single byte to the device
@note sfeTkIBus interface method
/**--------------------------------------------------------------------------
@brief Method sets up the required I2C settings.
@param data Data to write.
@param wirePort Port for I2C communication.
@param bInit This flag tracks whether the bus has been initialized.
@retval returns kStkErrOk on success
*/
sfeTkError_t writeByte(uint8_t data);
@retval kSTkErrOk on successful execution.
*/
sfeTkError_t init(TwoWire &wirePort, uint8_t addr, bool bInit = false);

/**--------------------------------------------------------------------------
@brief Write a single byte to the given register
@note sfeTkIBus interface method
/**--------------------------------------------------------------------------
@brief A simple ping of the device at the given address.
@note sfeTkIBus interface method
@param devReg The device's register's address.
@param data Data to write.
@retval kSTkErrOk on success,
*/
sfeTkError_t ping();

@retval returns kStkErrOk on success
*/
sfeTkError_t writeRegisterByte(uint8_t devReg, uint8_t data);
/**--------------------------------------------------------------------------
@brief Write a single byte to the device
@note sfeTkIBus interface method
/**--------------------------------------------------------------------------
@brief Write a single word to the given register
@note sfeTkIBus interface method
@param data Data to write.
@param devReg The device's register's address.
@param data Data to write.
@retval returns kStkErrOk on success
*/
sfeTkError_t writeByte(uint8_t data);

@retval returns kStkErrOk on success
*/
sfeTkError_t writeRegisterWord(uint8_t devReg, uint16_t data);
/**--------------------------------------------------------------------------
@brief Write a single byte to the given register
@note sfeTkIBus interface method
/**--------------------------------------------------------------------------
@brief Writes a number of bytes starting at the given register's address.
@param devReg The device's register's address.
@param data Data to write.
@note sfeTkIBus interface method
@note This method is virtual to allow it to be overridden to support a device that requires a unique impl
@retval returns kStkErrOk on success
*/
sfeTkError_t writeRegisterByte(uint8_t devReg, uint8_t data);

@param devReg The device's register's address.
@param data Data to write.
/**--------------------------------------------------------------------------
@brief Write a single word to the given register
@note sfeTkIBus interface method
@retval kStkErrOk on success
*/
sfeTkError_t writeRegisterRegion(uint8_t devReg, const uint8_t *data, size_t length);
@param devReg The device's register's address.
@param data Data to write.
/**--------------------------------------------------------------------------
@brief Writes a number of bytes starting at the given register's 16-bit address.
@retval returns kStkErrOk on success
*/
sfeTkError_t writeRegisterWord(uint8_t devReg, uint16_t data);

@param devAddr The device's 16-bit address/pin
param devReg The device's register's address.
@param data Data to write.
/**--------------------------------------------------------------------------
@brief Writes a number of bytes starting at the given register's address.
@retval sfeTkError_t kSTkErrOk on successful execution
@note sfeTkIBus interface method
@note This method is virtual to allow it to be overridden to support a device that requires a unique impl
*/
sfeTkError_t writeRegister16Region(uint16_t devReg, const uint8_t *data, size_t length);
@param devReg The device's register's address.
@param data Data to write.
/**--------------------------------------------------------------------------
@brief Reads a byte of data from the given register.
@retval kStkErrOk on success
*/
sfeTkError_t writeRegisterRegion(uint8_t devReg, const uint8_t *data, size_t length);

@note sfeTkIBus interface method
/**--------------------------------------------------------------------------
@brief Writes a number of bytes starting at the given register's 16-bit address.
@param devReg The device's register's address.
@param data Data to read.
@param devAddr The device's 16-bit address/pin
param devReg The device's register's address.
@param data Data to write.
@retval kStkErrOk on success
*/
sfeTkError_t readRegisterByte(uint8_t devReg, uint8_t &data);
@retval sfeTkError_t kSTkErrOk on successful execution
/**--------------------------------------------------------------------------
@brief Reads a word of data from the given register.
*/
sfeTkError_t writeRegister16Region(uint16_t devReg, const uint8_t *data, size_t length);

@note sfeTkIBus interface method
/**--------------------------------------------------------------------------
@brief Reads a byte of data from the given register.
@param devReg The device's register's address.
@param data Data to read.
@note sfeTkIBus interface method
@retval kSTkErrOk on success
*/
sfeTkError_t readRegisterWord(uint8_t devReg, uint16_t &data);
@param devReg The device's register's address.
@param data Data to read.
/**--------------------------------------------------------------------------
@brief Reads a block of data from the given register.
@retval kStkErrOk on success
*/
sfeTkError_t readRegisterByte(uint8_t devReg, uint8_t &data);

@note sfeTkIBus interface method
@note This method is virtual to allow it to be overridden to support a device that requires a unique impl
/**--------------------------------------------------------------------------
@brief Reads a word of data from the given register.
@param devReg The device's register's address.
@param data Data being read.
@param numBytes Number of bytes to read.
@param[out] readBytes - Number of bytes read
@note sfeTkIBus interface method
@param devReg The device's register's address.
@param data Data to read.
@retval kSTkErrOk on success
*/
sfeTkError_t readRegisterRegion(uint8_t devReg, uint8_t *data, size_t numBytes, size_t &readBytes);
@retval kSTkErrOk on success
*/
sfeTkError_t readRegisterWord(uint8_t devReg, uint16_t &data);

/**--------------------------------------------------------------------------
@brief Reads a block of data from the given 16-bit register address.
/**--------------------------------------------------------------------------
@brief Reads a block of data from the given register.
@param reg The device's 16 bit register's address.
@param data Data to write.
@param numBytes - length of data
@param[out] readBytes - number of bytes read
@note sfeTkIBus interface method
@note This method is virtual to allow it to be overridden to support a device that requires a unique impl
@retval int returns kSTkErrOk on success, or kSTkErrFail code
@param devReg The device's register's address.
@param data Data being read.
@param numBytes Number of bytes to read.
@param[out] readBytes - Number of bytes read
*/
sfeTkError_t readRegister16Region(uint16_t reg, uint8_t *data, size_t numBytes, size_t &readBytes);
// Buffer size chunk getter/setter
/**--------------------------------------------------------------------------
@brief set the buffer chunk size
@retval kSTkErrOk on success
*/
sfeTkError_t readRegisterRegion(uint8_t devReg, uint8_t *data, size_t numBytes, size_t &readBytes);

@note default size is 32
/**--------------------------------------------------------------------------
@brief Reads a block of data from the given 16-bit register address.
@param theChunk the new size - must be > 0
@param reg The device's 16 bit register's address.
@param data Data to write.
@param numBytes - length of data
@param[out] readBytes - number of bytes read
*/
void setBufferChunkSize(size_t theChunk)
{
if (theChunk > 0)
_bufferChunkSize = theChunk;
}
@retval int returns kSTkErrOk on success, or kSTkErrFail code
/**--------------------------------------------------------------------------
@brief set the buffer chunk size
*/
sfeTkError_t readRegister16Region(uint16_t reg, uint8_t *data, size_t numBytes, size_t &readBytes);

@retval The current chunk size
// Buffer size chunk getter/setter
/**--------------------------------------------------------------------------
@brief set the buffer chunk size
*/
size_t bufferChunkSize(void)
{
return _bufferChunkSize;
}
@note default size is 32
protected:
// note: The wire port is protected, allowing access if a sub-class is
// created to implement a special read/write routine
//
/** The actual Arduino i2c port */
TwoWire *_i2cPort;
@param theChunk the new size - must be > 0
private:
sfeTkError_t writeRegisterRegionAddress(uint8_t *devReg, size_t regLength, const uint8_t *data, size_t length);
*/
void setBufferChunkSize(size_t theChunk)
{
if (theChunk > 0)
_bufferChunkSize = theChunk;
}

sfeTkError_t readRegisterRegionAnyAddress(uint8_t *devReg, size_t regLength, uint8_t *data, size_t numBytes,
size_t &readBytes);
/**--------------------------------------------------------------------------
@brief set the buffer chunk size
/** Default buffer chunk size*/
static constexpr size_t kDefaultBufferChunk = 32;
@retval The current chunk size
/** The I2C buffer chunker - chunk size*/
size_t _bufferChunkSize;
}
;
*/
size_t bufferChunkSize(void)
{
return _bufferChunkSize;
}

protected:
// note: The wire port is protected, allowing access if a sub-class is
// created to implement a special read/write routine
//
/** The actual Arduino i2c port */
TwoWire *_i2cPort;

private:
sfeTkError_t writeRegisterRegionAddress(uint8_t *devReg, size_t regLength, const uint8_t *data, size_t length);

sfeTkError_t readRegisterRegionAnyAddress(uint8_t *devReg, size_t regLength, uint8_t *data, size_t numBytes,
size_t &readBytes);

/** Default buffer chunk size*/
static constexpr size_t kDefaultBufferChunk = 32;

/** The I2C buffer chunker - chunk size*/
size_t _bufferChunkSize;
};

0 comments on commit 34a82e2

Please sign in to comment.