mirror of
https://github.com/utkumaden/esp-idf-bmx280
synced 2026-01-20 05:42:20 +01:00
Compare commits
7 Commits
35f236ce03
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93e47861b3 | ||
|
|
1e18e7a815 | ||
|
|
91c142fd5d | ||
|
|
55e1ccc3c9 | ||
| b48a6e2fa9 | |||
|
|
2dc752e074 | ||
|
|
744b34a9f3 |
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.1)
|
cmake_minimum_required(VERSION 3.17)
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
idf_component_register(
|
idf_component_register(
|
||||||
SRCS bmx280.c
|
SRCS bmx280.c
|
||||||
|
|||||||
5
Kconfig
5
Kconfig
@@ -12,13 +12,14 @@ menu "BMX280 Options"
|
|||||||
bool "I2C Master Driver (i2c_master.h)"
|
bool "I2C Master Driver (i2c_master.h)"
|
||||||
help
|
help
|
||||||
Use I2C Master Driver (i2c_master.h) for ESP-IDF >= 5.3.
|
Use I2C Master Driver (i2c_master.h) for ESP-IDF >= 5.3.
|
||||||
|
endchoice
|
||||||
|
|
||||||
config BMX280_I2C_CLK_SPEED_HZ
|
config BMX280_I2C_CLK_SPEED_HZ
|
||||||
int "I2C Clock Speed (Hz)"
|
int "I2C Clock Speed (Hz)"
|
||||||
default 100000
|
default 100000
|
||||||
range 1000 400000
|
range 1000 400000
|
||||||
help
|
help
|
||||||
Set the I2C clock speed in Hz.
|
Set the I2C clock speed in Hz. Only applies to the new I2C Master driver.
|
||||||
endchoice
|
|
||||||
|
|
||||||
choice BMX280_EXPECT_DEVICE
|
choice BMX280_EXPECT_DEVICE
|
||||||
prompt "Installed Sensor Model"
|
prompt "Installed Sensor Model"
|
||||||
|
|||||||
18
bmx280.c
18
bmx280.c
@@ -338,12 +338,6 @@ static esp_err_t bmx280_probe(bmx280_t *bmx280)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static esp_err_t bmx280_reset(bmx280_t *bmx280)
|
|
||||||
{
|
|
||||||
const static uint8_t din[] = { BMX280_RESET_VEC };
|
|
||||||
return bmx280_write(bmx280, BMX280_REG_RESET, din, sizeof din);
|
|
||||||
}
|
|
||||||
|
|
||||||
static esp_err_t bmx280_calibrate(bmx280_t *bmx280)
|
static esp_err_t bmx280_calibrate(bmx280_t *bmx280)
|
||||||
{
|
{
|
||||||
// Honestly, the best course of action is to read the high and low banks
|
// Honestly, the best course of action is to read the high and low banks
|
||||||
@@ -448,10 +442,16 @@ bmx280_t* bmx280_create_master(i2c_master_bus_handle_t bus_handle)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
esp_err_t bmx280_reset(bmx280_t *bmx280)
|
||||||
|
{
|
||||||
|
const static uint8_t din[] = { BMX280_RESET_VEC };
|
||||||
|
return bmx280_write(bmx280, BMX280_REG_RESET, din, sizeof din);
|
||||||
|
}
|
||||||
|
|
||||||
void bmx280_close(bmx280_t *bmx280)
|
void bmx280_close(bmx280_t *bmx280)
|
||||||
{
|
{
|
||||||
#if CONFIG_USE_I2C_MASTER_DRIVER
|
#if CONFIG_USE_I2C_MASTER_DRIVER
|
||||||
if(bmx280->i2c_dev!=NULL)
|
if(bmx280 != NULL && bmx280->i2c_dev != NULL)
|
||||||
i2c_master_bus_rm_device(bmx280->i2c_dev);
|
i2c_master_bus_rm_device(bmx280->i2c_dev);
|
||||||
#endif
|
#endif
|
||||||
free(bmx280);
|
free(bmx280);
|
||||||
@@ -634,7 +634,7 @@ esp_err_t bmx280_readout(bmx280_t *bmx280, int32_t *temperature, uint32_t *press
|
|||||||
return error;
|
return error;
|
||||||
|
|
||||||
*temperature = BME280_compensate_T_int32(bmx280,
|
*temperature = BME280_compensate_T_int32(bmx280,
|
||||||
(buffer[0] << 12) | (buffer[1] << 4) | (buffer[0] >> 4)
|
(buffer[0] << 12) | (buffer[1] << 4) | (buffer[2] >> 4)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -644,7 +644,7 @@ esp_err_t bmx280_readout(bmx280_t *bmx280, int32_t *temperature, uint32_t *press
|
|||||||
return error;
|
return error;
|
||||||
|
|
||||||
*pressure = BME280_compensate_P_int64(bmx280,
|
*pressure = BME280_compensate_P_int64(bmx280,
|
||||||
(buffer[0] << 12) | (buffer[1] << 4) | (buffer[0] >> 4)
|
(buffer[0] << 12) | (buffer[1] << 4) | (buffer[2] >> 4)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,12 @@ BMXAPI bmx280_t* bmx280_create_legacy(i2c_port_t port);
|
|||||||
#define bmx280_create_master(port) static_assert(0, "You have the wrong driver configuration for using the new I2C master driver.")
|
#define bmx280_create_master(port) static_assert(0, "You have the wrong driver configuration for using the new I2C master driver.")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restart the sensor, effectively puting it into sleep mode.
|
||||||
|
* @param bmx280 The instance to reset.
|
||||||
|
*/
|
||||||
|
esp_err_t bmx280_reset(bmx280_t *bmx280);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy your the instance.
|
* Destroy your the instance.
|
||||||
* @param bmx280 The instance to destroy.
|
* @param bmx280 The instance to destroy.
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ typedef enum bmx280_tstby_t {
|
|||||||
|
|
||||||
typedef enum bmx280_iirf_t {
|
typedef enum bmx280_iirf_t {
|
||||||
BMX280_IIR_NONE = 0x0,
|
BMX280_IIR_NONE = 0x0,
|
||||||
BMX280_IIR_X1,
|
|
||||||
BMX280_IIR_X2,
|
BMX280_IIR_X2,
|
||||||
BMX280_IIR_X4,
|
BMX280_IIR_X4,
|
||||||
BMX280_IIR_X8,
|
BMX280_IIR_X8,
|
||||||
@@ -126,7 +125,7 @@ typedef struct bmx280_config_t {
|
|||||||
#elif (CONFIG_BMX280_DEFAULT_STANDBY_10M)
|
#elif (CONFIG_BMX280_DEFAULT_STANDBY_10M)
|
||||||
#define BMX280_DEFAULT_STANDBY BME280_STANDBY_10M
|
#define BMX280_DEFAULT_STANDBY BME280_STANDBY_10M
|
||||||
#else
|
#else
|
||||||
#define BMX280_DEFAULT_STANDBY BMX280_STANDBY_20M
|
#define BMX280_DEFAULT_STANDBY BME280_STANDBY_20M
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (CONFIG_BMX280_DEFAULT_IIR_NONE)
|
#if (CONFIG_BMX280_DEFAULT_IIR_NONE)
|
||||||
|
|||||||
Reference in New Issue
Block a user