upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
Go to the source code of this file.
Data Structures | |
struct | _bmp280_context |
Typedefs | |
typedef struct _bmp280_context * | bmp280_context |
bmp280_context bmp280_init | ( | int | bus, |
int | addr, | ||
int | cs | ||
) |
BMP280 initialization.
This driver supports both the BMP280 and the BME280. The BME280 adds a humidity sensor. The device type is detected automatically by querying the chip id register.
Both I2C and SPI accesses are supported. For SPI, set the addr to -1, and specify a positive integer representing the Chip Select (CS) pin for the cs argument. If you are using a hardware CS pin you cannot control (Intel Edison), then you can connect the proper pin to the hardware CS pin on your MCU and supply -1 for cs. The default operating mode is I2C.
bus | I2C or SPI bus to use. |
address | The I2C address for this device. Use -1 for SPI. |
cs | The gpio pin to use for the SPI Chip Select. Use -1 for I2C, or for SPI with a hardware controlled pin. |
void bmp280_close | ( | bmp280_context | dev | ) |
BMP280 close function.
dev | Device context. |
upm_result_t bmp280_update | ( | const bmp280_context | dev | ) |
Update the internal stored values from sensor data.
dev | Device context. |
uint8_t bmp280_get_chip_id | ( | const bmp280_context | dev | ) |
Return the chip ID.
dev | Device context. |
void bmp280_reset | ( | const bmp280_context | dev | ) |
Reset the sensor, as if by a power-on-reset.
dev | Device context. |
float bmp280_get_temperature | ( | const bmp280_context | dev | ) |
Return the current measured temperature. Note, this is not ambient temperature - this is the temperature used to fine tune the pressure measurement. bmp280_update() must have been called prior to calling this method.
dev | Device context. |
float bmp280_get_humidity | ( | const bmp280_context | dev | ) |
Return the current measured relative humidity (bme280 only). bmp280_update() must have been called prior to calling this method. For a bmp280, the returned value will always be 0.
dev | Device context. |
float bmp280_get_pressure | ( | const bmp280_context | dev | ) |
Return the current measured pressure in Pascals (Pa). bmp280_update() must have been called prior to calling this method.
dev | Device context. |
void bmp280_set_sea_level_pressure | ( | const bmp280_context | dev, |
float | seaLevelhPA | ||
) |
Set the default Sea Level Pressure in hectoPascals (hPA). A default of 1013.25 (101325 Pa) is set during bmp280_init(). This value is used for altitude computation.
dev | Device context. |
seaLevelhPA | The pressure at sea level in hectoPascals (hPa). |
float bmp280_get_altitude | ( | const bmp280_context | dev | ) |
Return the current computed altitude in meters. bmp280_update() must have been called prior to calling this method.
Computing this value requires knowing the pressure at sea level. bmp280_init() sets this by default to 1013.25 hPA. Use bmp280_set_sea_level_pressure() to change this value.
dev | Device context. |
void bmp280_set_usage_mode | ( | const bmp280_context | dev, |
BMP280_USAGE_MODE_T | mode | ||
) |
Set a general usage mode. This function can be used to configure the filters and oversampling for a particular use case. These setting are documented in the BMP280 datasheet. The default mode set in the bmp280_init() function is BMP280_USAGE_MODE_INDOOR_NAV, the highest resolution mode.
dev | Device context. |
mode | One of the BMP280_USAGE_MODE_T values. |
void bmp280_set_oversample_rate_temperature | ( | const bmp280_context | dev, |
BMP280_OSRS_T_T | rate | ||
) |
Set the temperature sensor oversampling parameter. See the data sheet for details. This value can be automatically set to a suitable value by using one of the predefined modes for bmp280_set_usage_mode().
dev | Device context. |
rate | One of the BMP280_OSRS_T_T values. |
void bmp280_set_oversample_rate_pressure | ( | const bmp280_context | dev, |
BMP280_OSRS_P_T | rate | ||
) |
Set the pressure sensor oversampling parameter. See the data sheet for details. This value can be automatically set to a suitable value by using one of the predefined modes for bmp280_set_usage_mode().
dev | Device context. |
rate | One of the BMP280_OSRS_P_T values. |
void bmp280_set_oversample_rate_humidity | ( | const bmp280_context | dev, |
BME280_OSRS_H_T | rate | ||
) |
Set the humidity sensor oversampling parameter (BME280 only). See the data sheet for details. This value can be automatically set to a suitable value by using one of the predefined modes for bmp280_set_usage_mode().
dev | Device context. |
rate | One of the BME280_OSRS_H_T values. |
void bmp280_set_timer_standby | ( | const bmp280_context | dev, |
BMP280_T_SB_T | tsb | ||
) |
Set the timer standby value. When in NORMAL operating mode, this timer governs how long the chip will wait before performing a measurement. See the data sheet for details.
dev | Device context. |
tsb | One of the BMP280_T_SB_T values. |
void bmp280_set_filter | ( | const bmp280_context | dev, |
BMP280_FILTER_T | filter | ||
) |
Set the IIR filtering parameter. See the data sheet for details. This value can be automatically set to a suitable value by using one of the predefined modes for bmp280_set_usage_mode().
dev | Device context. |
filter | One of the BMP280_FILTER_T values. |
void bmp280_set_measure_mode | ( | const bmp280_context | dev, |
BMP280_MODES_T | mode | ||
) |
Set the default measuring mode. Basic values are forced, sleep, and normal. See the data sheet for details. This value can be automatically set to a suitable value by using one of the predefined modes for bmp280_set_usage_mode().
dev | Device context. |
mode | One of the BMP280_MODES_T values. |
uint8_t bmp280_get_status | ( | const bmp280_context | dev | ) |
Return the value of the BMP280_REG_STATUS register.
dev | Device context. |
uint8_t bmp280_read_reg | ( | const bmp280_context | dev, |
uint8_t | reg | ||
) |
Read a register.
dev | Device context. |
reg | The register to read |
int bmp280_read_regs | ( | const bmp280_context | dev, |
uint8_t | reg, | ||
uint8_t * | buffer, | ||
int | len | ||
) |
Read contiguous registers into a buffer. This is a low level function, and should not be used unless you know what you are doing.
dev | Device context. |
buffer | The buffer to store the results |
len | The number of registers to read |
upm_result_t bmp280_write_reg | ( | const bmp280_context | dev, |
uint8_t | reg, | ||
uint8_t | val | ||
) |
Write to a register. This is a low level function, and should not be used unless you know what you are doing.
dev | Device context. |
reg | The register to write to |
val | The value to write |
typedef struct _bmp280_context * bmp280_context |
Device context