@@ -64,34 +64,34 @@ 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,
68- const uint8_t &pagedDeviceAddress) -> int
69- {
67+ auto const handler = [&](const bd_addr_t &pagedStart, const bd_size_t &pagedLength, const uint8_t &pagedDeviceAddress) -> int {
7068 _i2c->start ();
7169
7270 if (1 != _i2c->write (pagedDeviceAddress))
7371 {
7472 return BD_ERROR_DEVICE_ERROR;
7573 }
7674
77- if (!_address_is_eight_bit && 1 != _i2c->write ((char ) (pagedStart >> 8u )))
75+ if (!_address_is_eight_bit && 1 != _i2c->write ((char )(pagedStart >> 8u )))
7876 {
7977 return BD_ERROR_DEVICE_ERROR;
8078 }
8179
82- if (1 != _i2c->write ((char ) (pagedStart & 0xffu )))
80+ if (1 != _i2c->write ((char )(pagedStart & 0xffu )))
8381 {
8482 return BD_ERROR_DEVICE_ERROR;
8583 }
8684
8785 _i2c->stop ();
8886
8987 auto err = _sync ();
90- if (err) {
88+ if (err)
89+ {
9190 return err;
9291 }
9392
94- if (0 != _i2c->read (_i2c_addr, charBuffer, pagedLength)) {
93+ if (0 != _i2c->read (_i2c_addr, charBuffer, pagedLength))
94+ {
9595 return BD_ERROR_DEVICE_ERROR;
9696 }
9797
@@ -110,9 +110,7 @@ int I2CEEBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size
110110
111111 auto const *charBuffer = reinterpret_cast <char const *>(buffer);
112112
113- auto const handler = [&](const bd_addr_t &pagedStart, const bd_size_t &pagedLength,
114- const uint8_t &pagedDeviceAddress) -> int
115- {
113+ auto const handler = [&](const bd_addr_t &pagedStart, const bd_size_t &pagedLength, const uint8_t &pagedDeviceAddress) -> int {
116114 // While we have some more data to write.
117115 while (size > 0 )
118116 {
@@ -121,25 +119,20 @@ int I2CEEBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size
121119
122120 _i2c->start ();
123121
124- if (1 != _i2c->write (pagedDeviceAddress))
125- {
122+ if (1 != _i2c->write (pagedDeviceAddress)) {
126123 return BD_ERROR_DEVICE_ERROR;
127124 }
128125
129- if (!_address_is_eight_bit && 1 != _i2c->write ((char ) (pagedStart >> 8u )))
130- {
126+ if (!_address_is_eight_bit && 1 != _i2c->write ((char )(pagedStart >> 8u ))) {
131127 return BD_ERROR_DEVICE_ERROR;
132128 }
133129
134- if (1 != _i2c->write ((char ) (addr & 0xffu )))
135- {
130+ if (1 != _i2c->write ((char )(addr & 0xffu ))) {
136131 return BD_ERROR_DEVICE_ERROR;
137132 }
138133
139- for (unsigned i = 0 ; i < chunk; i++)
140- {
141- if (1 != _i2c->write (charBuffer[i]))
142- {
134+ for (unsigned i = 0 ; i < chunk; i++) {
135+ if (1 != _i2c->write (charBuffer[i])) {
143136 return BD_ERROR_DEVICE_ERROR;
144137 }
145138 }
@@ -224,8 +217,7 @@ int I2CEEBlockDevice::do_paged(const bd_addr_t &startAddress,
224217
225218 auto const pageSize = 256 ;
226219 bd_size_t lengthDone = 0 ;
227- while (lengthDone != length)
228- {
220+ while (lengthDone != length) {
229221 /* Integer division => Round down */
230222 uint8_t const currentPage = currentStartAddress / pageSize;
231223 bd_addr_t const nextPageBegin = (currentPage + 1 ) * pageSize;
@@ -235,8 +227,7 @@ int I2CEEBlockDevice::do_paged(const bd_addr_t &startAddress,
235227 uint8_t const pagedDeviceAddress = get_paged_device_address (currentPage);
236228
237229 auto const handlerReturn = handler (pagedBegin, currentLength, pagedDeviceAddress);
238- if (handlerReturn != BD_ERROR_OK)
239- {
230+ if (handlerReturn != BD_ERROR_OK) {
240231 return handlerReturn;
241232 }
242233
@@ -249,12 +240,9 @@ int I2CEEBlockDevice::do_paged(const bd_addr_t &startAddress,
249240
250241uint8_t I2CEEBlockDevice::get_paged_device_address (const uint8_t &page)
251242{
252- if (!this ->_address_is_eight_bit )
253- {
243+ if (!this ->_address_is_eight_bit ) {
254244 return this ->_i2c_addr ;
255- }
256- else
257- {
245+ } else {
258246 // This method uses a dynamically created bit mask for the page given.
259247 // This ensures compatibility with all sizes of ICs.
260248 // E. g. the 512K variants have two user address bits and one page bit.
@@ -265,8 +253,7 @@ uint8_t I2CEEBlockDevice::get_paged_device_address(const uint8_t &page)
265253 uint8_t i = 1 ;
266254 uint8_t addressMask = 0 ;
267255 auto p = page;
268- while (p != 0u )
269- {
256+ while (p != 0u ) {
270257 addressMask |= (1u << i);
271258 p >>= 1u ;
272259 i++;
0 commit comments