Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code compatibility readme with write functions #82

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ The sensor driver package includes bme280.c, bme280.h and bme280_defs.h files.
SPI 3-wire is currently not supported in the API.
## Usage guide
### Initializing the sensor
To initialize the sensor, user need to create a device structure. User can do this by
creating an instance of the structure bme280_dev. After creating the device strcuture, user
To initialize the sensor, user need to create a device structure. User can do this by
creating an instance of the structure bme280_dev. After creating the device strcuture, user
need to fill in the various parameters as shown below.

#### Example for SPI 4-Wire
Expand All @@ -40,7 +40,7 @@ dev.intf_ptr = &dev_addr;
dev.intf = BME280_SPI_INTF;
dev.read = user_spi_read;
dev.write = user_spi_write;
dev.delay_ms = user_delay_ms;
dev.delay_us = user_delay_us;

rslt = bme280_init(&dev);
```
Expand All @@ -54,7 +54,7 @@ dev.intf_ptr = &dev_addr;
dev.intf = BME280_I2C_INTF;
dev.read = user_i2c_read;
dev.write = user_i2c_write;
dev.delay_ms = user_delay_ms;
dev.delay_us = user_delay_us;

rslt = bme280_init(&dev);
```
Expand All @@ -72,7 +72,7 @@ By default, 64 bit variant is used in the API. If the user wants 32 bit variant,
macro BME280_64BIT_ENABLE in bme280_defs.h file.

### Sensor data units
> The sensor data units depends on the following macros being enabled or not,
> The sensor data units depends on the following macros being enabled or not,
> (in bme280_defs.h file or as compiler macros)
> * BME280_FLOAT_ENABLE
> * BME280_64BIT_ENABLE
Expand Down Expand Up @@ -112,7 +112,7 @@ int8_t stream_sensor_data_forced_mode(struct bme280_dev *dev)
settings_sel = BME280_OSR_PRESS_SEL | BME280_OSR_TEMP_SEL | BME280_OSR_HUM_SEL | BME280_FILTER_SEL;

rslt = bme280_set_sensor_settings(settings_sel, dev);

/*Calculate the minimum delay required between consecutive measurement based upon the sensor enabled
* and the oversampling configuration. */
req_delay = bme280_cal_meas_delay(&dev->settings);
Expand All @@ -122,7 +122,7 @@ int8_t stream_sensor_data_forced_mode(struct bme280_dev *dev)
while (1) {
rslt = bme280_set_sensor_mode(BME280_FORCED_MODE, dev);
/* Wait for the measurement to complete and print data @25Hz */
dev->delay_ms(req_delay, dev->intf_ptr);
dev->delay_us(req_delay, dev->intf_ptr);
rslt = bme280_get_sensor_data(BME280_ALL, &comp_data, dev);
print_sensor_data(&comp_data);
}
Expand Down Expand Up @@ -164,7 +164,7 @@ int8_t stream_sensor_data_normal_mode(struct bme280_dev *dev)
printf("Temperature, Pressure, Humidity\r\n");
while (1) {
/* Delay while the sensor completes a measurement */
dev->delay_ms(70, dev->intf_ptr);
dev->delay_us(70, dev->intf_ptr);
rslt = bme280_get_sensor_data(BME280_ALL, &comp_data, dev);
print_sensor_data(&comp_data);
}
Expand All @@ -185,11 +185,11 @@ void print_sensor_data(struct bme280_data *comp_data)
### Templates for function pointers
``` c

void user_delay_ms(uint32_t period, void *intf_ptr)
void user_delay_us(uint32_t period, void *intf_ptr)
{
/*
* Return control or wait,
* for a period amount of milliseconds
* for a period amount of microseconds
*/
}

Expand Down Expand Up @@ -219,7 +219,7 @@ int8_t user_spi_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *in
return rslt;
}

int8_t user_spi_write(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf_ptr)
int8_t user_spi_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len, void *intf_ptr)
{
int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */

Expand Down Expand Up @@ -272,7 +272,7 @@ int8_t user_i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *in
return rslt;
}

int8_t user_i2c_write(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf_ptr)
int8_t user_i2c_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len, void *intf_ptr)
{
int8_t rslt = 0; /* Return 0 for Success, non-zero for failure */

Expand Down
2 changes: 1 addition & 1 deletion bme280.c
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ int8_t bme280_compensate_data(uint8_t sensor_comp,
}

/*!
* @brief This API is used to calculate the maximum delay in milliseconds required for the
* @brief This API is used to calculate the maximum delay in microseconds required for the
* temperature/pressure/humidity(which ever at enabled) measurement to complete.
*/
uint32_t bme280_cal_meas_delay(const struct bme280_settings *settings)
Expand Down
4 changes: 2 additions & 2 deletions bme280.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,13 @@ int8_t bme280_compensate_data(uint8_t sensor_comp,
* \code
* uint32_t bme280_cal_meas_delay(const struct bme280_settings *settings);
* \endcode
* @brief This API is used to calculate the maximum delay in milliseconds required for the
* @brief This API is used to calculate the maximum delay in microseconds required for the
* temperature/pressure/humidity(which ever are enabled) measurement to complete.
* The delay depends upon the number of sensors enabled and their oversampling configuration.
*
* @param[in] settings : contains the oversampling configurations.
*
* @return delay required in milliseconds.
* @return delay required in microseconds.
*
*/
uint32_t bme280_cal_meas_delay(const struct bme280_settings *settings);
Expand Down
2 changes: 1 addition & 1 deletion bme280_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
#define BME280_MEAS_OFFSET UINT16_C(1250)
#define BME280_MEAS_DUR UINT16_C(2300)
#define BME280_PRES_HUM_MEAS_OFFSET UINT16_C(575)
#define BME280_MEAS_SCALING_FACTOR UINT16_C(1000)
#define BME280_MEAS_SCALING_FACTOR UINT16_C(1)

/**\name Standby duration selection macros */
#define BME280_STANDBY_TIME_0_5_MS (0x00)
Expand Down