I have found some bugs mainly in the description README.md file and want to describe each of them here:
First, I have tested the code and implemented my code with the following devices:
* STM32WL55 nucleo board connected with I2C bus, a LoRaWAN thing, which I could share as FOSS when it is released with a new hardware.
* Beagle Board Black with Debian 10.7 and connected to i2c-1 (/dev/i2c-1) and i2c-2 too.
I have tested the library with defined BME280_FLOAT_ENABLE, also tested with BME280_64BIT_ENABLE and BME280_32BIT_ENABLE.
1. Very obviously the description on README.md is no longer up to date, also the inclusion of the write and read functions for the respective bus is faulty.
1.1 The user_delay_ms should be user_delay_us in microseconds due to the new delay function.
1.2 The default implementation of the compensation function is double precision floating point, i.e. BME280_FLOAT_ENABLE is set (former BME280_64BIT_ENABLE).
1.3 The function user_spi_write() and the function user_spi_read() has a parameter which is of type const uint8_t *reg_data (former it was only type of uint8_t *reg_data).
The function bme280_cal_meas_delay() should deliver also a value in us (microseconds) instead of ms (milliseconds), that makes it more easier and overall consistent.
2.1 The change of the user function user_delay_ms to user_delay_us() which gets a period amount of wait in microseconds. So the function bme280_cal_meas_delay() becomes smaller, we get rid off the division through 1000 (constant BME280_MEAS_SCALING_FACTOR).
2.2 I deleted this constant BME280_MEAS_SCALING_FACTOR in the bme280_defs.h file.
As a positive side effect, the two examples (linux_userspace.c and bsd_userspace.c) do not need to be adjusted with microseconds either.
3. Example linux_userspace.c
3.1 I had trouble to compile this example on another machine, like the beagle bone black board. I updated the code, which needs the ioctl procedure, unfortunately I do not own a Raspbi.
3.2 In the code, the id.dev_addr selection must be before and not after the call of the line ioctl() which already uses the device address (0x76 or 0x77) - former it was not defined, so I struggled with the distributed code.
3.3 Added an error handling for malloc function, which IMHO is necessary. Added error handling for read and write functions.
I published a pull request at github (#88)
Solved! Go to Solution.