Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# VSCode directories
.vscode

8 changes: 6 additions & 2 deletions src/sfeTkArdI2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ sfeTkError_t sfeTkArdI2C::readRegisterRegion(uint8_t devReg, uint8_t *data, size
if (!_i2cPort)
return kSTkErrBusNotInit;

// Buffer valid?
if (!data)
return kSTkErrBusNullBuffer;

readBytes = 0;

uint16_t nOrig = numBytes; // original number of bytes.
Expand Down Expand Up @@ -261,7 +265,7 @@ sfeTkError_t sfeTkArdI2C::readRegisterRegion(uint8_t devReg, uint8_t *data, size

} // end while

readBytes = nOrig - numBytes;
readBytes = nOrig - numBytes; // Bytes read.

return kSTkErrOk;
return (readBytes == nOrig) ? kSTkErrOk : kSTkErrBusUnderRead; // Success
}
7 changes: 4 additions & 3 deletions src/sfeTkArdI2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,12 @@ class sfeTkArdI2C : public sfeTkII2C
@note This method is virtual to allow it to be overridden to support a device that requires a unique impl

@param devReg The device's register's address.
@param data Data to write.
@param numBytes - length of data
@param data Data being read.
@param numBytes Number of bytes to read.
@param[out] readBytes - Number of bytes read

@retval kStkErrOk on success

@retval kSTkErrOk on success
*/
sfeTkError_t readRegisterRegion(uint8_t devReg, uint8_t *data, size_t numBytes, size_t &readBytes);

Expand Down