Microseconds, Readme, Examples, several Fixes #88
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
BME280_driver 3.5.0
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:
I have tested the library with defined BME280_FLOAT_ENABLE, also tested with BME280_64BIT_ENABLE and BME280_32BIT_ENABLE.
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).
bme280c
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.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.