MCP9700 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
mcp9700_kconfig.hpp
Go to the documentation of this file.
1
13#ifndef MCP9700_KCONFIG_HPP
14#define MCP9700_KCONFIG_HPP
15
16#ifdef __has_include
17#if __has_include("sdkconfig.h")
18#include "sdkconfig.h"
19#endif
20#endif
21
22#include "mcp9700_types.hpp"
23
24#ifndef CONFIG_MCP9700_ADC_CHANNEL
26#define CONFIG_MCP9700_ADC_CHANNEL 0
27#endif
28#ifndef CONFIG_MCP9700_ADC_FULL_SCALE_MV
31#define CONFIG_MCP9700_ADC_FULL_SCALE_MV 3300
32#endif
33#ifndef CONFIG_MCP9700_SAMPLES
35#define CONFIG_MCP9700_SAMPLES 8
36#endif
37#ifndef CONFIG_MCP9700_SAMPLE_INTERVAL_US
40#define CONFIG_MCP9700_SAMPLE_INTERVAL_US 100
41#endif
42#ifndef CONFIG_MCP9700_OFFSET_CAL_MC
45#define CONFIG_MCP9700_OFFSET_CAL_MC 0
46#endif
47#ifndef CONFIG_MCP9700_CUSTOM_V0_MV
49#define CONFIG_MCP9700_CUSTOM_V0_MV 0
50#endif
51#ifndef CONFIG_MCP9700_CUSTOM_TC_UV_PER_C
53#define CONFIG_MCP9700_CUSTOM_TC_UV_PER_C 0
54#endif
55#ifndef CONFIG_MCP9700_CUSTOM_MIN_MC
57#define CONFIG_MCP9700_CUSTOM_MIN_MC 0
58#endif
59#ifndef CONFIG_MCP9700_CUSTOM_MAX_MC
61#define CONFIG_MCP9700_CUSTOM_MAX_MC 0
62#endif
63#ifndef CONFIG_MCP9700_CUSTOM_ACCURACY_MIN_MC
65#define CONFIG_MCP9700_CUSTOM_ACCURACY_MIN_MC 0
66#endif
67#ifndef CONFIG_MCP9700_CUSTOM_ACCURACY_MAX_MC
69#define CONFIG_MCP9700_CUSTOM_ACCURACY_MAX_MC 0
70#endif
71
72namespace mcp9700 {
73
74namespace detail {
75
77constexpr Variant KconfigVariant() noexcept {
78#if defined(CONFIG_MCP9700_VARIANT_CUSTOM)
79 return Variant::Custom;
80#elif defined(CONFIG_MCP9700_VARIANT_MCP9700A)
81 return Variant::Mcp9700A;
82#elif defined(CONFIG_MCP9700_VARIANT_MCP9700B)
83 return Variant::Mcp9700B;
84#elif defined(CONFIG_MCP9700_VARIANT_MCP9701A)
85 return Variant::Mcp9701A;
86#elif defined(CONFIG_MCP9700_VARIANT_MCP9701)
87 return Variant::Mcp9701;
88#else
89 return Variant::Mcp9700;
90#endif
91}
92
93} // namespace detail
94
102constexpr Config KconfigDefaults() noexcept {
103 Config c{};
104 c.channel = static_cast<uint8_t>(CONFIG_MCP9700_ADC_CHANNEL);
105 c.variant = detail::KconfigVariant();
106#if defined(CONFIG_MCP9700_HIGH_TEMPERATURE)
107 c.range = TemperatureClass::High;
108#endif
109 if (c.variant == Variant::Custom) {
110 c.custom.v0_mv = static_cast<uint32_t>(CONFIG_MCP9700_CUSTOM_V0_MV);
111 c.custom.tc_uv_per_c = static_cast<uint32_t>(CONFIG_MCP9700_CUSTOM_TC_UV_PER_C);
112 c.custom.min_mc = static_cast<int32_t>(CONFIG_MCP9700_CUSTOM_MIN_MC);
113 c.custom.max_mc = static_cast<int32_t>(CONFIG_MCP9700_CUSTOM_MAX_MC);
114 c.custom.accuracy_min_mc = static_cast<int32_t>(CONFIG_MCP9700_CUSTOM_ACCURACY_MIN_MC);
115 c.custom.accuracy_max_mc = static_cast<int32_t>(CONFIG_MCP9700_CUSTOM_ACCURACY_MAX_MC);
116 }
117 c.adc_full_scale_mv = static_cast<uint32_t>(CONFIG_MCP9700_ADC_FULL_SCALE_MV);
118 c.samples = static_cast<uint16_t>(CONFIG_MCP9700_SAMPLES);
119 c.sample_interval_us = static_cast<uint32_t>(CONFIG_MCP9700_SAMPLE_INTERVAL_US);
120 c.offset_cal_mc = static_cast<int32_t>(CONFIG_MCP9700_OFFSET_CAL_MC);
121 return c;
122}
123
124} // namespace mcp9700
125
126#endif // MCP9700_KCONFIG_HPP
Variant
Which part of the family is wired up: one of the five datasheet devices, or Custom.
Definition mcp9700_types.hpp:177
@ Mcp9701
400 mV at 0 C, 19.5 mV/C, -10 to +125 C, accuracy +-4 C.
@ Mcp9701A
As the MCP9701 with the +-2 C grade (0 to +70 C).
@ Mcp9700A
As the MCP9700 with the +-2 C grade (0 to +70 C).
#define CONFIG_MCP9700_CUSTOM_V0_MV
Definition mcp9700_kconfig.hpp:49
#define CONFIG_MCP9700_ADC_CHANNEL
Definition mcp9700_kconfig.hpp:26
#define CONFIG_MCP9700_CUSTOM_ACCURACY_MIN_MC
Definition mcp9700_kconfig.hpp:65
#define CONFIG_MCP9700_OFFSET_CAL_MC
Definition mcp9700_kconfig.hpp:45
#define CONFIG_MCP9700_CUSTOM_MAX_MC
Definition mcp9700_kconfig.hpp:61
#define CONFIG_MCP9700_SAMPLES
Definition mcp9700_kconfig.hpp:35
#define CONFIG_MCP9700_ADC_FULL_SCALE_MV
Definition mcp9700_kconfig.hpp:31
#define CONFIG_MCP9700_SAMPLE_INTERVAL_US
Definition mcp9700_kconfig.hpp:40
#define CONFIG_MCP9700_CUSTOM_ACCURACY_MAX_MC
Definition mcp9700_kconfig.hpp:69
#define CONFIG_MCP9700_CUSTOM_MIN_MC
Definition mcp9700_kconfig.hpp:57
#define CONFIG_MCP9700_CUSTOM_TC_UV_PER_C
Definition mcp9700_kconfig.hpp:53
Public types of the MCP970x driver: errors, Result<T>, the variant table, configuration,...
The MCP970x driver: everything it declares lives here; internals in detail.
Definition mcp9700.hpp:24
constexpr Config KconfigDefaults() noexcept
The configuration menuconfig selected, on top of the datasheet defaults.
Definition mcp9700_kconfig.hpp:102
Everything EnsureInitialized() uses. Config{} is an MCP9700 on a 12 bit, 3.3 V ADC.
Definition mcp9700_types.hpp:274
uint8_t channel
Passed to ReadVoltageMv() unchanged.
Definition mcp9700_types.hpp:275