MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / getID

Method getID

libraries/SGP30/SGP30.cpp:66–89  ·  view source on GitHub ↗

INITIAL VERSION - needs optimization

Source from the content-addressed store, hash-verified

64
65// INITIAL VERSION - needs optimization
66bool SGP30::getID()
67{
68 _command(0x3682);
69 delay(1);
70 if (_wire->requestFrom(_address, (uint8_t)9) == 9)
71 {
72 for (uint8_t i = 0, j = 0; i < 3; i++)
73 {
74 _id[j++] = _wire->read();
75 _id[j++] = _wire->read();
76 uint8_t crc = _wire->read();
77 uint16_t val = _id[j-2] * 256 + _id[j-1];
78 if (_CRC8(val) != crc)
79 {
80 _error = SGP30_ERROR_CRC;
81 return false;
82 }
83 }
84 _error = SGP30_OK;
85 return true;
86 }
87 _error = SGP30_ERROR_I2C;
88 return false;
89}
90
91
92// expect to return 0x0022

Callers

nothing calls this directly

Calls 1

readMethod · 0.45

Tested by

no test coverage detected