From a0ab44067fd1d7a2ee031ea9d037b6353115debb Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Mon, 13 Mar 2023 13:35:23 +0000 Subject: [PATCH] BMP280: Avoid runtime memory allocation. --- drivers/bmp280/bmp280.cpp | 5 ++++- drivers/bmp280/bmp280.hpp | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/bmp280/bmp280.cpp b/drivers/bmp280/bmp280.cpp index 019f3b2e..28b2e2f8 100644 --- a/drivers/bmp280/bmp280.cpp +++ b/drivers/bmp280/bmp280.cpp @@ -11,7 +11,10 @@ namespace pimoroni { gpio_pull_up(interrupt); } - device.intf_ptr = new i2c_intf_ptr{.i2c = i2c, .address = address}; + i2c_interface.i2c = i2c; + i2c_interface.address = address; + + device.intf_ptr = &i2c_interface; device.intf = BMP280_I2C_INTF; device.read = (bmp280_com_fptr_t)&read_bytes; device.write = (bmp280_com_fptr_t)&write_bytes; diff --git a/drivers/bmp280/bmp280.hpp b/drivers/bmp280/bmp280.hpp index 02249b0c..1a1d3b68 100644 --- a/drivers/bmp280/bmp280.hpp +++ b/drivers/bmp280/bmp280.hpp @@ -25,6 +25,8 @@ namespace pimoroni { bool status; }; + i2c_intf_ptr i2c_interface; + bool debug = false; bool init();