Skip to content

Fix I2C constructor #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/LIS2MDLSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@
* @param i2c object of an helper class which handles the I2C peripheral
* @param address the address of the component's instance
*/
LIS2MDLSensor::LIS2MDLSensor(TwoWire *i2c, uint8_t address) : dev_i2c(i2c), address(address)
LIS2MDLSensor::LIS2MDLSensor(TwoWire *i2c) : dev_i2c(i2c)
{
dev_spi = NULL;
reg_ctx.write_reg = LIS2MDL_io_write;
reg_ctx.read_reg = LIS2MDL_io_read;
reg_ctx.handle = (void *)this;
mag_is_enabled = 0;
address = LIS2MDL_I2C_ADD;
mag_is_enabled = 0U;
}

/** Constructor
Expand All @@ -67,8 +68,8 @@ LIS2MDLSensor::LIS2MDLSensor(SPIClass *spi, int cs_pin, uint32_t spi_speed) : de
reg_ctx.read_reg = LIS2MDL_io_read;
reg_ctx.handle = (void *)this;
dev_i2c = NULL;
address = 0;
mag_is_enabled = 0;
address = 0U;
mag_is_enabled = 0U;
}

/**
Expand Down Expand Up @@ -187,7 +188,7 @@ LIS2MDLStatusTypeDef LIS2MDLSensor::Enable()
return LIS2MDL_ERROR;
}

mag_is_enabled = 1;
mag_is_enabled = 1U;

return LIS2MDL_OK;
}
Expand All @@ -210,7 +211,7 @@ LIS2MDLStatusTypeDef LIS2MDLSensor::Disable()
return LIS2MDL_ERROR;
}

mag_is_enabled = 0;
mag_is_enabled = 0U;

return LIS2MDL_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion src/LIS2MDLSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ typedef struct
class LIS2MDLSensor
{
public:
LIS2MDLSensor(TwoWire *i2c, uint8_t address=LIS2MDL_I2C_ADD);
LIS2MDLSensor(TwoWire *i2c);
LIS2MDLSensor(SPIClass *spi, int cs_pin, uint32_t spi_speed=2000000);
LIS2MDLStatusTypeDef begin();
LIS2MDLStatusTypeDef end();
Expand Down