71 s8 BMP280_I2C_bus_read(
u8 dev_addr,
u8 reg_addr,
u8 *reg_data,
u8 cnt);
80 s8 BMP280_I2C_bus_write(
u8 dev_addr,
u8 reg_addr,
u8 *reg_data,
u8 cnt);
89 s8 BMP280_SPI_bus_write(
u8 dev_addr,
u8 reg_addr,
u8 *reg_data,
u8 cnt);
96 s8 BMP280_SPI_bus_read(
u8 dev_addr,
u8 reg_addr,
u8 *reg_data,
u8 cnt);
100 s8 I2C_routine(
void);
101 s8 SPI_routine(
void);
107 void BMP280_delay_msek(
u32 msek);
112 s32 bmp280_data_readout_template(
void);
127 s32 bmp280_data_readout_template(
void)
130 u8 v_standby_time_u8 = BMP280_INIT_VALUE;
134 s32 v_data_uncomp_tem_s32 = BMP280_INIT_VALUE;
136 s32 v_data_uncomp_pres_s32 = BMP280_INIT_VALUE;
138 s32 v_actual_temp_s32 = BMP280_INIT_VALUE;
140 u32 v_actual_press_u32 = BMP280_INIT_VALUE;
144 s32 v_data_uncomp_tem_combined_s32 = BMP280_INIT_VALUE;
146 s32 v_data_uncomp_pres_combined_s32 = BMP280_INIT_VALUE;
148 s32 v_actual_temp_combined_s32 = BMP280_INIT_VALUE;
150 u32 v_actual_press_combined_u32 = BMP280_INIT_VALUE;
153 s32 com_rslt = ERROR;
236 &v_data_uncomp_tem_combined_s32);
240 &v_actual_temp_combined_s32);
264 s8 I2C_routine(
void) {
272 bmp280.bus_write = BMP280_I2C_bus_write;
273 bmp280.bus_read = BMP280_I2C_bus_read;
274 bmp280.
dev_addr = BMP280_I2C_ADDRESS2;
277 return BMP280_INIT_VALUE;
284 s8 SPI_routine(
void) {
292 bmp280.bus_write = BMP280_SPI_bus_write;
293 bmp280.bus_read = BMP280_SPI_bus_read;
296 return BMP280_INIT_VALUE;
301 #define I2C_BUFFER_LEN 8
302 #define SPI_BUFFER_LEN 5
303 #define BUFFER_LENGTH 0xFF
304 #define SPI_READ 0x80
305 #define SPI_WRITE 0x7F
306 #define BMP280_DATA_INDEX 1
307 #define BMP280_ADDRESS_INDEX 2
325 s32 iError = BMP280_INIT_VALUE;
326 u8 array[I2C_BUFFER_LEN];
327 u8 stringpos = BMP280_INIT_VALUE;
328 array[BMP280_INIT_VALUE] = reg_addr;
329 for (stringpos = BMP280_INIT_VALUE; stringpos < cnt; stringpos++) {
330 array[stringpos + BMP280_DATA_INDEX] = *(reg_data + stringpos);
357 s8 BMP280_I2C_bus_read(
u8 dev_addr,
u8 reg_addr,
u8 *reg_data,
u8 cnt)
359 s32 iError = BMP280_INIT_VALUE;
360 u8 array[I2C_BUFFER_LEN] = {BMP280_INIT_VALUE};
361 u8 stringpos = BMP280_INIT_VALUE;
362 array[BMP280_INIT_VALUE] = reg_addr;
372 for (stringpos = BMP280_INIT_VALUE; stringpos < cnt; stringpos++) {
373 *(reg_data + stringpos) = array[stringpos];
385 s8 BMP280_SPI_bus_read(
u8 dev_addr,
u8 reg_addr,
u8 *reg_data,
u8 cnt)
387 s32 iError=BMP280_INIT_VALUE;
388 u8 array[SPI_BUFFER_LEN]={BUFFER_LENGTH};
393 array[BMP280_INIT_VALUE] = reg_addr|SPI_READ;
411 for (stringpos = BMP280_INIT_VALUE; stringpos < cnt; stringpos++) {
412 *(reg_data + stringpos) = array[stringpos+BMP280_DATA_INDEX];
425 s8 BMP280_SPI_bus_write(
u8 dev_addr,
u8 reg_addr,
u8 *reg_data,
u8 cnt)
427 s32 iError = BMP280_INIT_VALUE;
428 u8 array[SPI_BUFFER_LEN * BMP280_ADDRESS_INDEX];
429 u8 stringpos = BMP280_INIT_VALUE;
430 u8 index = BMP280_INIT_VALUE;
432 for (stringpos = BMP280_INIT_VALUE; stringpos < cnt; stringpos++) {
435 index = stringpos * BMP280_ADDRESS_INDEX;
436 array[index] = (reg_addr++) & SPI_WRITE;
437 array[index + BMP280_DATA_INDEX] = *(reg_data + stringpos);
453 void BMP280_delay_msek(
u32 msek)
BMP280_RETURN_FUNCTION_TYPE bmp280_init(struct bmp280_t *bmp280)
This function is used for initialize the bus read and bus write functions and assign the chip id and ...
BMP280_RETURN_FUNCTION_TYPE bmp280_read_uncomp_pressure_temperature(s32 *v_uncomp_pressure_s32, s32 *v_uncomp_temperature_s32)
reads uncompensated pressure and temperature
BMP280_RETURN_FUNCTION_TYPE bmp280_set_power_mode(u8 v_power_mode_u8)
This API used to set the Operational Mode from the sensor in the register 0xF4 bit 0 and 1...
BMP280_RETURN_FUNCTION_TYPE bmp280_get_standby_durn(u8 *v_standby_durn_u8)
This API used to Read the standby duration time from the sensor in the register 0xF5 bit 5 to 7...
u32 bmp280_compensate_pressure_int32(s32 v_uncomp_pressure_s32)
Reads actual pressure from uncompensated pressure and returns the value in Pascal(Pa) ...
BMP280 Sensor Driver Support Header File.
BMP280_RETURN_FUNCTION_TYPE bmp280_read_uncomp_temperature(s32 *v_uncomp_temperature_s32)
This API is used to read uncompensated temperature in the registers 0xFA, 0xFB and 0xFC...
void(* delay_msec)(BMP280_MDELAY_DATA_TYPE)
BMP280_RETURN_FUNCTION_TYPE bmp280_read_uncomp_pressure(s32 *v_uncomp_pressure_s32)
This API is used to read uncompensated pressure. in the registers 0xF7, 0xF8 and 0xF9.
BMP280_RETURN_FUNCTION_TYPE bmp280_read_pressure_temperature(u32 *v_pressure_u32, s32 *v_temperature_s32)
This API reads the true pressure and temperature.
BMP280_RETURN_FUNCTION_TYPE bmp280_set_work_mode(u8 v_work_mode_u8)
This API is used to write the working mode of the sensor.
s32 bmp280_compensate_temperature_int32(s32 v_uncomp_temperature_s32)
Reads actual temperature from uncompensated temperature.
BMP280_RETURN_FUNCTION_TYPE bmp280_set_standby_durn(u8 v_standby_durn_u8)
This API used to Read the standby duration time from the sensor in the register 0xF5 bit 5 to 7...
This structure holds BMP280 initialization parameters.