You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.3 KiB
57 lines
1.3 KiB
/* |
|
* bme280.h |
|
* |
|
* Created on: Feb 26, 2023 |
|
* Author: Daniel Peter Chokola |
|
* License: Beerware - Use this code however you'd like. If you find it |
|
* useful you can buy me a beer some time. |
|
*/ |
|
|
|
#ifndef BME280_H_ |
|
#define BME280_H_ |
|
|
|
/* Includes */ |
|
#include <stdint.h> |
|
#include "spi.h" |
|
|
|
/* Definitions */ |
|
#define BME280_CAL_LEN (32u) |
|
|
|
/* Data Structures */ |
|
typedef struct bme280_s { |
|
SPI_HandleTypeDef *hspi; |
|
GPIO_TypeDef *port; |
|
uint16_t pin; |
|
union __attribute__((packed, aligned(1))) bme280_calib_u { |
|
uint8_t byte[BME280_CAL_LEN]; |
|
struct __attribute__((packed, aligned(1))) bme280_calib_s { |
|
uint16_t cal_t1; |
|
int16_t cal_t2; |
|
int16_t cal_t3; |
|
uint16_t cal_p1; |
|
int16_t cal_p2; |
|
int16_t cal_p3; |
|
int16_t cal_p4; |
|
int16_t cal_p5; |
|
int16_t cal_p6; |
|
int16_t cal_p7; |
|
int16_t cal_p8; |
|
int16_t cal_p9; |
|
uint8_t cal_h1; |
|
int16_t cal_h2; |
|
uint8_t cal_h3; |
|
int16_t cal_h4; |
|
int16_t cal_h5; |
|
int8_t cal_h6; |
|
} field; |
|
} cal; |
|
int32_t t_fine; |
|
} bme280_t; |
|
|
|
/* Function Prototypes */ |
|
int32_t bme280_init(bme280_t *bme280, SPI_HandleTypeDef *hspi, GPIO_TypeDef *port, uint16_t pin); |
|
int32_t bme280_temp_get(bme280_t *bme280); |
|
int32_t bme280_press_get(bme280_t *bme280); |
|
int32_t bme280_hum_get(bme280_t *bme280); |
|
|
|
#endif /* BME280_H_ */
|
|
|