@@ -64,7 +64,8 @@ int I2CEEBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)
6464
6565 auto *charBuffer = reinterpret_cast <char *>(buffer);
6666
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
6869 {
6970 _i2c->start ();
7071
@@ -108,7 +109,8 @@ int I2CEEBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size
108109
109110 auto const *charBuffer = reinterpret_cast <char const *>(buffer);
110111
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
112114 {
113115 // While we have some more data to write.
114116 while (size > 0 ) {
@@ -207,7 +209,7 @@ int I2CEEBlockDevice::do_paged(const bd_addr_t &startAddress,
207209{
208210 // This helper is only used for eight bit mode.
209211 if (!this ->_address_is_eight_bit ) {
210- return handler (startAddress, length, 0 );
212+ return handler (startAddress, length, get_paged_device_address ( 0 ) );
211213 }
212214
213215 auto currentStartAddress = startAddress;
@@ -222,8 +224,9 @@ int I2CEEBlockDevice::do_paged(const bd_addr_t &startAddress,
222224 bd_addr_t const currentReadEndAddressExclusive = std::min (nextPageBegin, startAddress + length);
223225 bd_size_t const currentLength = currentReadEndAddressExclusive - currentStartAddress;
224226 bd_addr_t const pagedBegin = currentStartAddress - (currentPage * pageSize);
227+ uint8_t const pagedDeviceAddress = get_paged_device_address (currentPage);
225228
226- auto const handlerReturn = handler (pagedBegin, currentLength, currentPage );
229+ auto const handlerReturn = handler (pagedBegin, currentLength, pagedDeviceAddress );
227230 if (handlerReturn != BD_ERROR_OK)
228231 {
229232 return handlerReturn;
0 commit comments