@@ -64,7 +64,8 @@ int I2CEEBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)
64
64
65
65
auto *charBuffer = reinterpret_cast <char *>(buffer);
66
66
67
- auto const handler = [&](const bd_addr_t &pagedStart, const bd_size_t &pagedLength, const uint8_t &page) -> int
67
+ auto const handler = [&](const bd_addr_t &pagedStart, const bd_size_t &pagedLength,
68
+ const uint8_t &pagedDeviceAddress) -> int
68
69
{
69
70
_i2c->start ();
70
71
@@ -108,7 +109,8 @@ int I2CEEBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size
108
109
109
110
auto const *charBuffer = reinterpret_cast <char const *>(buffer);
110
111
111
- auto const handler = [&](const bd_addr_t &pagedStart, const bd_size_t &pagedLength, const uint8_t &page) -> int
112
+ auto const handler = [&](const bd_addr_t &pagedStart, const bd_size_t &pagedLength,
113
+ const uint8_t &pagedDeviceAddress) -> int
112
114
{
113
115
// While we have some more data to write.
114
116
while (size > 0 ) {
@@ -207,7 +209,7 @@ int I2CEEBlockDevice::do_paged(const bd_addr_t &startAddress,
207
209
{
208
210
// This helper is only used for eight bit mode.
209
211
if (!this ->_address_is_eight_bit ) {
210
- return handler (startAddress, length, 0 );
212
+ return handler (startAddress, length, get_paged_device_address ( 0 ) );
211
213
}
212
214
213
215
auto currentStartAddress = startAddress;
@@ -222,8 +224,9 @@ int I2CEEBlockDevice::do_paged(const bd_addr_t &startAddress,
222
224
bd_addr_t const currentReadEndAddressExclusive = std::min (nextPageBegin, startAddress + length);
223
225
bd_size_t const currentLength = currentReadEndAddressExclusive - currentStartAddress;
224
226
bd_addr_t const pagedBegin = currentStartAddress - (currentPage * pageSize);
227
+ uint8_t const pagedDeviceAddress = get_paged_device_address (currentPage);
225
228
226
- auto const handlerReturn = handler (pagedBegin, currentLength, currentPage );
229
+ auto const handlerReturn = handler (pagedBegin, currentLength, pagedDeviceAddress );
227
230
if (handlerReturn != BD_ERROR_OK)
228
231
{
229
232
return handlerReturn;
0 commit comments