Skip to content

Commit

Permalink
Fix astyle
Browse files Browse the repository at this point in the history
  • Loading branch information
boomer41 committed Feb 17, 2020
1 parent 76a177f commit 08e0720
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ int I2CEEBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)

auto *charBuffer = reinterpret_cast<char *>(buffer);

auto const handler = [&](const bd_addr_t &pagedStart, const bd_size_t &pagedLength,
const uint8_t &pagedDeviceAddress) -> int
{
auto const handler = [&](const bd_addr_t &pagedStart, const bd_size_t &pagedLength, const uint8_t &pagedDeviceAddress) -> int {
_i2c->start();

if (1 != _i2c->write(pagedDeviceAddress))
Expand Down Expand Up @@ -110,9 +108,7 @@ int I2CEEBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size

auto const *charBuffer = reinterpret_cast<char const *>(buffer);

auto const handler = [&](const bd_addr_t &pagedStart, const bd_size_t &pagedLength,
const uint8_t &pagedDeviceAddress) -> int
{
auto const handler = [&](const bd_addr_t &pagedStart, const bd_size_t &pagedLength, const uint8_t &pagedDeviceAddress) -> int {
// While we have some more data to write.
while (size > 0)
{
Expand All @@ -126,12 +122,12 @@ int I2CEEBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size
return BD_ERROR_DEVICE_ERROR;
}

if (!_address_is_eight_bit && 1 != _i2c->write((char) (pagedStart >> 8u)))
if (!_address_is_eight_bit && 1 != _i2c->write((char)(pagedStart >> 8u)))
{
return BD_ERROR_DEVICE_ERROR;
}

if (1 != _i2c->write((char) (addr & 0xffu)))
if (1 != _i2c->write((char)(addr & 0xffu)))
{
return BD_ERROR_DEVICE_ERROR;
}
Expand All @@ -148,7 +144,8 @@ int I2CEEBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size

int err = _sync();

if (err) {
if (err)
{
return err;
}

Expand Down Expand Up @@ -224,8 +221,7 @@ int I2CEEBlockDevice::do_paged(const bd_addr_t &startAddress,

auto const pageSize = 256;
bd_size_t lengthDone = 0;
while (lengthDone != length)
{
while (lengthDone != length) {
/* Integer division => Round down */
uint8_t const currentPage = currentStartAddress / pageSize;
bd_addr_t const nextPageBegin = (currentPage + 1) * pageSize;
Expand All @@ -249,8 +245,7 @@ int I2CEEBlockDevice::do_paged(const bd_addr_t &startAddress,

uint8_t I2CEEBlockDevice::get_paged_device_address(const uint8_t &page)
{
if (!this->_address_is_eight_bit)
{
if (!this->_address_is_eight_bit) {
return this->_i2c_addr;
}
else
Expand All @@ -265,8 +260,7 @@ uint8_t I2CEEBlockDevice::get_paged_device_address(const uint8_t &page)
uint8_t i = 1;
uint8_t addressMask = 0;
auto p = page;
while (p != 0u)
{
while (p != 0u) {
addressMask |= (1u << i);
p >>= 1u;
i++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ class I2CEEBlockDevice : public BlockDevice {

int _sync();

using paged_handler = std::function<
int(const bd_addr_t &address, const bd_size_t &length, const uint8_t &deviceAddress)>;
using paged_handler = std::function<int(const bd_addr_t &address, const bd_size_t &length, const uint8_t &deviceAddress)>;

/**
* Executes a handler across page boundaries for eight bit mode.
Expand Down

0 comments on commit 08e0720

Please sign in to comment.