diff --git a/bmx280.c b/bmx280.c index 573907d..1dbb626 100644 --- a/bmx280.c +++ b/bmx280.c @@ -417,10 +417,12 @@ esp_err_t bmx280_getMode(bmx280_t* bmx280, bmx280_mode_t* mode) switch (ctrl_mes) { default: - return ctrl_mes; + *mode = ctrl_mes; break; case (BMX280_MODE_FORCE + 1): - return BMX280_MODE_FORCE; + *mode = BMX280_MODE_FORCE; break; } + + return ESP_OK; } bool bmx280_isSampling(bmx280_t* bmx280) diff --git a/include/bmx280.h b/include/bmx280.h index 4580d68..77b1fda 100644 --- a/include/bmx280.h +++ b/include/bmx280.h @@ -85,9 +85,12 @@ esp_err_t bmx280_readout(bmx280_t *bmx280, int32_t *temperature, uint32_t *press */ static inline void bmx280_readout2float(int32_t* tin, uint32_t *pin, uint32_t *hin, float *tout, float *pout, float *hout) { - *tout = (float)*tin * 0.01f; - *pout = (float)*pin * (1.0f/256.0f); - *hout = (*hin == UINT32_MAX) ? -1.0f : (float)*hin * (1.0f/1024.0f); + if (tin && tout) + *tout = (float)*tin * 0.01f; + if (pin && pout) + *pout = (float)*pin * (1.0f/256.0f); + if (hin && hout) + *hout = (*hin == UINT32_MAX) ? -1.0f : (float)*hin * (1.0f/1024.0f); } /**