Skip to content

Commit d165a99

Browse files
committed
update to driver version 1.1.0
update main.c to changed sensor API, initiaize driver with i2c address, update signature for sensirion_i2c_hal_read/write
1 parent a94f3c6 commit d165a99

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

sample-implementations/RaspberryPi_Pico/main.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ int main(void) {
2424
gpio_pull_up(sda_pin);
2525
gpio_pull_up(scl_pin);
2626

27+
// Initialize driver with i2c address
28+
scd4x_init(SCD41_I2C_ADDR_62);
29+
2730
int status;
2831

2932
// Stop any ongoing measurement.
@@ -34,15 +37,13 @@ int main(void) {
3437
}
3538

3639
// Get serial number.
37-
uint16_t one;
38-
uint16_t two;
39-
uint16_t three;
40-
status = scd4x_get_serial_number(&one, &two, &three);
40+
uint16_t serial_number[3] = {0};
41+
status = scd4x_get_serial_number(serial_number, 3);
4142
if (status) {
4243
printf("Unable to get sensor serial number. Error: %d\n", status);
4344
return status;
4445
}
45-
printf("Sensor serial number is: 0x%x 0x%x 0x%x\n", (int)one, (int)two, (int)three);
46+
printf("Sensor serial number is: 0x%x 0x%x 0x%x\n", (int)serial_number[0], (int)serial_number[1], (int)serial_number[2]);
4647

4748
// Start the readings.
4849
status = scd4x_start_periodic_measurement();
@@ -57,9 +58,9 @@ int main(void) {
5758
bool dataReady;
5859
do {
5960
sleep_ms(10);
60-
status = scd4x_get_data_ready_flag(&dataReady);
61+
status = scd4x_get_data_ready_status(&dataReady);
6162
if (status) {
62-
printf("Unable to get sensor readiness flag. Error %d.\n", status);
63+
printf("Unable to get sensor readiness status. Error %d.\n", status);
6364
return status;
6465
}
6566
} while (!dataReady);

sample-implementations/RaspberryPi_Pico/sensirion_i2c_hal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
* @param count number of bytes to read from I2C and store in the buffer
4747
* @returns 0 on success, error code otherwise
4848
*/
49-
int8_t sensirion_i2c_hal_read(uint8_t address, uint8_t* data, uint16_t count) {
49+
int8_t sensirion_i2c_hal_read(uint8_t address, uint8_t* data, uint8_t count) {
5050
const bool nostop = true; // master retains control of the bus after the read
5151
return !i2c_read_blocking(i2c_default, address, data, count, nostop);
5252
}
@@ -63,7 +63,7 @@ int8_t sensirion_i2c_hal_read(uint8_t address, uint8_t* data, uint16_t count) {
6363
* @returns 0 on success, error code otherwise
6464
*/
6565
int8_t sensirion_i2c_hal_write(uint8_t address, const uint8_t* data,
66-
uint16_t count) {
66+
uint8_t count) {
6767
const bool nostop = true; // master retains control of the bus after the write
6868
return !i2c_write_blocking(i2c_default, address, data, count, nostop);
6969
}

0 commit comments

Comments
 (0)