aboutsummaryrefslogtreecommitdiff
path: root/stm32f091/sensor.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-10-12 13:27:37 +0200
committerlonkaars <loek@pipeframe.xyz>2022-10-12 13:27:37 +0200
commit73cbdf3f6b8d64d528a7b999d1d29fa87dfa6e7f (patch)
treea2c894b49d6c5f012a6f19b4fbb6fb6eb33b7f66 /stm32f091/sensor.c
parentfbb6a5a1570666ad283afac6e545c578e65475b8 (diff)
add more missing code from bjorn
Diffstat (limited to 'stm32f091/sensor.c')
-rw-r--r--stm32f091/sensor.c14
1 files changed, 13 insertions, 1 deletions
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() {