BMP581 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
bmp581_kconfig.hpp
Go to the documentation of this file.
1
20#ifndef BMP581_KCONFIG_HPP
21#define BMP581_KCONFIG_HPP
22
23#ifdef __has_include
24#if __has_include("sdkconfig.h")
25#include "sdkconfig.h"
26#endif
27#endif
28
29#include <cstdint>
30#include <utility>
31
32#include "bmp581_types.hpp"
33
34#ifndef CONFIG_BMP581_PRESSURE_OVERSAMPLING
36#define CONFIG_BMP581_PRESSURE_OVERSAMPLING 1
37#endif
38#ifndef CONFIG_BMP581_TEMPERATURE_OVERSAMPLING
40#define CONFIG_BMP581_TEMPERATURE_OVERSAMPLING 1
41#endif
42#ifndef CONFIG_BMP581_STARTUP_TIMEOUT_MS
45#define CONFIG_BMP581_STARTUP_TIMEOUT_MS 10
46#endif
47#ifndef CONFIG_BMP581_DATA_READY_TIMEOUT_MS
50#define CONFIG_BMP581_DATA_READY_TIMEOUT_MS 2000
51#endif
52
53namespace bmp581 {
54
60constexpr Oversampling OversamplingFromSamples(int32_t samples) noexcept {
61 uint32_t code = 0U;
62 for (uint32_t i = 1U; i < 8U; ++i) {
63 if (std::cmp_greater_equal(samples, uint32_t{1} << i)) {
64 code = i;
65 }
66 }
67 return static_cast<Oversampling>(code); // 0 to 7: every value is an enumerator
68}
69
74constexpr Config KconfigDefaults() noexcept {
75 Config c{};
78#if defined(CONFIG_BMP581_DATA_READY) && CONFIG_BMP581_DATA_READY
79 c.source_data_ready = true;
80#endif
81 c.startup_timeout_ms = CONFIG_BMP581_STARTUP_TIMEOUT_MS;
82 c.data_ready_timeout_ms = CONFIG_BMP581_DATA_READY_TIMEOUT_MS;
83 return c;
84}
85
86static_assert(OversamplingFromSamples(1) == Oversampling::X1);
87static_assert(OversamplingFromSamples(100) == Oversampling::X64);
88static_assert(OversamplingFromSamples(1000) == Oversampling::X128);
89
90} // namespace bmp581
91
92#endif // BMP581_KCONFIG_HPP
#define CONFIG_BMP581_STARTUP_TIMEOUT_MS
Definition bmp581_kconfig.hpp:45
#define CONFIG_BMP581_TEMPERATURE_OVERSAMPLING
Definition bmp581_kconfig.hpp:40
#define CONFIG_BMP581_PRESSURE_OVERSAMPLING
Definition bmp581_kconfig.hpp:36
#define CONFIG_BMP581_DATA_READY_TIMEOUT_MS
Definition bmp581_kconfig.hpp:50
Public types of the BMP581 driver: errors, Result<T>, configuration, measurements and the datasheet's...
Oversampling
Oversampling ratio, OSR_CONFIG.osr_p and osr_t (section 7.33).
Definition bmp581_types.hpp:229
@ X128
128 samples.
@ X1
1 sample. Reset value.
The BMP581 driver: everything it declares lives here; internals in detail.
Definition bmp581.hpp:32
constexpr Oversampling OversamplingFromSamples(int32_t samples) noexcept
The oversampling setting for a number of samples, rounded down to a power of two.
Definition bmp581_kconfig.hpp:60
constexpr Config KconfigDefaults() noexcept
The configuration menuconfig selected, on top of the datasheet defaults.
Definition bmp581_kconfig.hpp:74
Everything EnsureInitialized() and ApplyConfig() write to the chip.
Definition bmp581_types.hpp:411
Oversampling pressure_oversampling
OSR_CONFIG.osr_p.
Definition bmp581_types.hpp:413