From 58a99561d0dbc28ba80e7d1e696e16d315b84c85 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 18 Oct 2022 10:28:56 +0100 Subject: [PATCH 1/6] Missing return --- src/qwiic_tmf882x.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qwiic_tmf882x.cpp b/src/qwiic_tmf882x.cpp index 0b5f192..76b4e06 100644 --- a/src/qwiic_tmf882x.cpp +++ b/src/qwiic_tmf882x.cpp @@ -195,7 +195,7 @@ bool QwDevTMF882X::setI2CAddress(uint8_t address) { // Initialized? Is the address legal? if (!_isInitialized || address < 0x08 || address > 0x77) - false; + return false; // is the address the same as already set? if (address == _i2cAddress) From 9fda51f74bc2a88c3b5698d2f73fb6a8ef09eb2c Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 18 Oct 2022 10:29:23 +0100 Subject: [PATCH 2/6] Avoid initialized-out-of-sequence warning-as-error --- src/qwiic_tmf882x.h | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/qwiic_tmf882x.h b/src/qwiic_tmf882x.h index e1f61cc..ceb8796 100644 --- a/src/qwiic_tmf882x.h +++ b/src/qwiic_tmf882x.h @@ -679,13 +679,24 @@ class QwDevTMF882X // Library initialized flag bool _isInitialized; + // Delay for the read sample loop + uint16_t _sampleDelayMS; + + // for managing message output levels + uint8_t _outputSettings; + bool _debug; + + // Callback function pointers + TMF882XMeasurementHandler _measurementHandlerCB; + TMF882XHistogramHandler _histogramHandlerCB; + TMF882XStatsHandler _statsHandlerCB; + TMF882XErrorHandler _errorHandlerCB; + TMF882XMessageHandler _messageHandlerCB; + // I2C things QwI2C *_i2cBus; // pointer to our i2c bus object uint8_t _i2cAddress; // address of the device - // Delay for the read sample loop - uint16_t _sampleDelayMS; - // Structure/state for the underlying TOF SDK tmf882x_tof _TOF; @@ -698,16 +709,4 @@ class QwDevTMF882X // Flag to indicate to the system to stop measurements bool _stopMeasuring; - // Callbacks - // - // Callback function pointers - TMF882XMeasurementHandler _measurementHandlerCB; - TMF882XHistogramHandler _histogramHandlerCB; - TMF882XStatsHandler _statsHandlerCB; - TMF882XErrorHandler _errorHandlerCB; - TMF882XMessageHandler _messageHandlerCB; - - // for managing message output levels - uint8_t _outputSettings; - bool _debug; }; From a1a75eecf6d67ede379de98cf146cc3003681df1 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 18 Oct 2022 10:30:02 +0100 Subject: [PATCH 3/6] Avoid mode may-be-uninitialized warning-as-error --- src/tmf882x_interface.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tmf882x_interface.c b/src/tmf882x_interface.c index 1a905a8..4a9fe55 100644 --- a/src/tmf882x_interface.c +++ b/src/tmf882x_interface.c @@ -96,8 +96,7 @@ int32_t tmf882x_open(struct tmf882x_tof * tof) if (tof->state.ops->open && tof->state.ops->open(&tof->state)) { - tof_err(to_priv(&tof->state), "Error opening mode: %#x", - mode); + tof_err(to_priv(&tof->state), "Error opening mode"); tmf882x_init(tof, to_priv(&tof->state)); return -1; } From df7dd8621fd42a8e2f9190f0e8101406a8e4f646 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 18 Oct 2022 10:32:45 +0100 Subject: [PATCH 4/6] PLEASE CHECK: size is always >= 0. Did you mean size > 0 ? --- src/tmf882x_mode_bl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tmf882x_mode_bl.c b/src/tmf882x_mode_bl.c index 2529a1b..9c6d90c 100644 --- a/src/tmf882x_mode_bl.c +++ b/src/tmf882x_mode_bl.c @@ -128,7 +128,7 @@ int32_t tmf882x_mode_bl_read_status(struct tmf882x_mode_bl *bl, continue; } /* if we have reached here, the command has either succeeded or failed */ - if ( *rdata_size >= 0 ) { + if ( *rdata_size > 0 ) { /* read in data part and csum */ error = tof_i2c_read(priv(bl), BL_REG_CMD_STATUS, rbuf, BL_CALC_RSP_SIZE(*rdata_size)); From cd7abd2cc5f675817f4d1e9f98328dc5e92f3480 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 18 Oct 2022 10:36:17 +0100 Subject: [PATCH 5/6] PLEASE CHECK: should retries be int32_t ? Avoids can't-be-<-0 warning-as-error --- src/tmf882x_mode_app.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tmf882x_mode_app.c b/src/tmf882x_mode_app.c index 6d70877..63fd035 100644 --- a/src/tmf882x_mode_app.c +++ b/src/tmf882x_mode_app.c @@ -417,7 +417,7 @@ static uint8_t get_app_cmd_stat(struct tmf882x_mode_app *app) } static int32_t check_cmd_status(struct tmf882x_mode_app *app, - uint32_t retries) + int32_t retries) { int32_t num_retries; uint8_t status; From e2a22998f2d11823914ab0a8a2cc47cb4076e47a Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 18 Oct 2022 10:37:32 +0100 Subject: [PATCH 6/6] v1.0.1 --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 03f9993..adf6297 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SparkFun Qwiic TMF882X Library -version=1.0.0 +version=1.0.1 author=SparkFun Electronics maintainer=SparkFun Electronics sentence=Library for the SparkFun Qwiic breakout boards for the AMS TMF882X sensor products.