Skip to content

Commit d272610

Browse files
committed
convert serial number to integer for printing
1 parent 92d6798 commit d272610

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

example-usage/scd4x_i2c_example_usage.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@
4343

4444
#define sensirion_hal_sleep_us sensirion_i2c_hal_sleep_usec
4545

46-
void print_ushort_array(uint16_t* array, uint16_t len) {
47-
uint16_t i = 0;
48-
printf("0x");
49-
for (; i < len; i++) {
50-
printf("%04x", array[i]);
51-
}
46+
void convert_and_print_serial(uint16_t* serial_raw) {
47+
uint64_t serial_as_int = 0;
48+
sensirion_common_to_integer((uint8_t*)serial_raw, (uint8_t*)&serial_as_int,
49+
LONG_INTEGER, 6);
50+
printf("0x%" PRIx64, serial_as_int);
5251
}
5352

5453
int main(void) {
@@ -81,7 +80,7 @@ int main(void) {
8180
return error;
8281
}
8382
printf("serial number: ");
84-
print_ushort_array(serial_number, 3);
83+
convert_and_print_serial(serial_number);
8584
printf("\n");
8685
//
8786
// If temperature offset and/or sensor altitude compensation

0 commit comments

Comments
 (0)