Fixed some mistakes made by copyying code.

This commit is contained in:
David Žaitlík 2022-01-09 17:52:55 +01:00
parent 5b8c7d6e17
commit df1a279943
2 changed files with 21 additions and 6 deletions

View File

@ -20,7 +20,7 @@
*/
#define SGP4X_I2C_ADDRESS 0x59
#define SGP4X_MAX_MEAS_DURATION_MS 30
#define SGP4X_MAX_MEAS_DURATION_MS 50
/*
* Return values

View File

@ -30,8 +30,10 @@ int8_t sgp4x_measure_raw_signal (uint16_t * voc_ticks)
int result;
// start measurement
buffer[0] = SGP4X_MEASURE_RAW_SIGNAL >> 8;
buffer[1] = SGP4X_MEASURE_RAW_SIGNAL & 0x00ff;
//buffer[0] = SGP4X_MEASURE_RAW_SIGNAL >> 8;
//buffer[1] = SGP4X_MEASURE_RAW_SIGNAL & 0x00ff;
buffer[0] = 0x26;
buffer[1] = 0x0F;
buffer[2] = 0x80;
buffer[3] = 0x00;
buffer[4] = 0xA2;
@ -105,9 +107,19 @@ int8_t sgp4x_measure_raw_signal_compensated (uint16_t * voc_ticks, uint16_t rela
int8_t sgp4x_execute_self_test ( uint8_t * test_result)
{
uint8_t buffer[16];
int8_t result;
scd4x_send_cmd(SGP4X_EXECUTE_SELF_TEST);
i2c_receive(SGP4X_I2C_ADDRESS << 1, buffer, 3);
result = sgp4x_send_cmd(SGP4X_EXECUTE_SELF_TEST);
if (result != I2C_OK) {
return SGP4X_ERROR;
}
LL_mDelay(350);
result = i2c_receive(SGP4X_I2C_ADDRESS << 1, buffer, 3);
if (result != I2C_OK) {
return SGP4X_ERROR;
}
test_result = buffer[0];
uint8_t test_result_crc = buffer[2];
@ -123,7 +135,10 @@ int8_t sgp4x_get_serial_number ( uint8_t serial[6])
{
uint8_t buffer[16];
scd4x_send_cmd(SGP4X_GET_SERIAL_NUMBER);
sgp4x_send_cmd(SGP4X_GET_SERIAL_NUMBER);
LL_mDelay(5);
i2c_receive(SGP4X_I2C_ADDRESS << 1, buffer, 9);
serial[0] = buffer[0];