Skip to content
Closed
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
15 changes: 15 additions & 0 deletions src/ISM330DHCXSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ ISM330DHCXSensor::ISM330DHCXSensor(SPIClass *spi, int cs_pin, uint32_t spi_speed
*/
ISM330DHCXStatusTypeDef ISM330DHCXSensor::Init()
{
/* Check sensor ID: this checks that we can communicate with the sensor */

uint8_t Id;

/* Get the Id; note this is not enough per se depending on the I2C implementation */
if (ReadID(&Id) != ISM330DHCX_OK) {
return ISM330DHCX_ERROR;
}

/* Check that we actually got back the right ID; this should return an error even if
the I2C implementation does not complain in case of no response. */
if (Id != ISM330DHCX_ID) {
return ISM330DHCX_ERROR;
}

/* SW reset */
if (ism330dhcx_reset_set(&(reg_ctx), PROPERTY_ENABLE) != ISM330DHCX_OK) {
return ISM330DHCX_ERROR;
Expand Down