|
17 | 17 | #include "sfTkError.h" |
18 | 18 | #include "sfTkIBus.h" |
19 | 19 | #include "sfTkISerial.h" |
| 20 | +#include "sfToolkit.h" |
20 | 21 | // clang-format on |
21 | 22 |
|
22 | 23 | const uint8_t ksfTkBusTypeSerialBus = 0x03; |
@@ -81,24 +82,30 @@ class sfTkISerialBus : sfTkIBus |
81 | 82 | * @param data The data to buffer to read into |
82 | 83 | * @param numBytes The length of the data buffer |
83 | 84 | * @param readBytes[out] The number of bytes read |
| 85 | + * @param read_delay After sending the address, delay in milliseconds before reading the data |
84 | 86 | * @return sfTkError_t Returns ksfTkErrOk on success, or ksfTkErrFail code |
85 | 87 | */ |
86 | 88 | virtual sfTkError_t readRegister(uint8_t *devReg, size_t regLength, uint8_t *data, size_t numBytes, |
87 | | - size_t &readBytes) override |
| 89 | + size_t &readBytes, uint32_t read_delay = 0) override |
88 | 90 | { |
89 | 91 | // Buffer valid? |
90 | 92 | if (!data) |
91 | 93 | return ksfTkErrBusNullBuffer; |
92 | 94 |
|
| 95 | + if (devReg == nullptr || regLength == 0) |
| 96 | + return ksfTkErrInvalidParam; |
| 97 | + |
93 | 98 | sfTkError_t retVal = ksfTkErrOk; |
94 | 99 |
|
95 | 100 | // Do we have a register? If so, write it, else skip. |
96 | | - if (devReg != nullptr && regLength > 0) |
97 | | - retVal = write(devReg, regLength); |
| 101 | + retVal = write(devReg, regLength); |
98 | 102 |
|
99 | 103 | if (retVal != ksfTkErrOk) |
100 | 104 | return retVal; |
101 | 105 |
|
| 106 | + if (read_delay) |
| 107 | + sftk_delay_ms(read_delay); |
| 108 | + |
102 | 109 | // Read the data. |
103 | 110 | retVal = read(data, numBytes, readBytes); |
104 | 111 |
|
|
0 commit comments