From 73cbdf3f6b8d64d528a7b999d1d29fa87dfa6e7f Mon Sep 17 00:00:00 2001 From: lonkaars Date: Wed, 12 Oct 2022 13:27:37 +0200 Subject: add more missing code from bjorn --- stm32f091/sensor.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/stm32f091/sensor.c b/stm32f091/sensor.c index 77ade64..d796130 100644 --- a/stm32f091/sensor.c +++ b/stm32f091/sensor.c @@ -7,6 +7,7 @@ #include "backlog.h" #define SI7021_ADDRESS ((uint16_t)(0x40) << 1) +#define BMP280_ADDRESS ((uint16_t)(0x76) << 1) #define REG_TEMP ((uint8_t)(0xE3)) #define REG_HUM ((uint8_t)(0xF5)) @@ -29,7 +30,18 @@ uint8_t ws_sensor_humidity() { } uint8_t ws_sensor_atmospheric_pressure() { - return 0x00; + uint8_t buf[12]; + uint8_t buffer[12]; + int16_t val; + + buf[0]= 0xF4; + buf[1]= 0x07; + buffer[0] = 0xF7; + HAL_I2C_Master_Transmit(&hi2c1, BMP280_ADDRESS, buf , 2, HAL_MAX_DELAY); + HAL_I2C_Mem_Read(&hi2c1, BMP280_ADDRESS, 0xF7, 1, buffer, 2, 100 ); + val = (buffer[0] << 8 | buffer[1]); + + return (uint8_t) val; // TODO: convert with range } void ws_sensor_read() { -- cgit v1.2.3