idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
gpio.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Chris Leishman
3
4#pragma once
5
21#include <idfxx/error>
22#include <idfxx/flags>
23#include <idfxx/intr_alloc>
24
25#include <functional>
26#include <hal/gpio_types.h>
27#include <soc/gpio_num.h>
28#include <soc/soc_caps.h>
29#include <string>
30#include <utility>
31
32namespace idfxx {
33
35template<int N>
36struct gpio_constant;
61class gpio {
62 template<int N>
63 friend struct gpio_constant;
64
65public:
67 enum class level : int {
68 low = 0,
69 high = 1,
70 };
71
81
89
98
108
109#if SOC_GPIO_SUPPORT_PIN_HYS_FILTER
111 enum class hys_ctrl_mode : int {
112#if SOC_GPIO_SUPPORT_PIN_HYS_CTRL_BY_EFUSE
114#endif
117 };
118#endif
119
120 class unique_isr_handle;
121
132 friend class gpio;
133 friend class unique_isr_handle;
134 constexpr isr_handle(gpio_num_t num, uint32_t id)
135 : _num(num)
136 , _id(id) {}
137 gpio_num_t _num;
138 uint32_t _id;
139 };
140
151 public:
158 : _num(GPIO_NUM_NC)
159 , _id(0) {}
160
166 : _num(handle._num)
167 , _id(handle._id) {}
168
174 : _num(std::exchange(other._num, GPIO_NUM_NC))
175 , _id(other._id) {}
176
183 if (this != &other) {
184 if (_num != GPIO_NUM_NC) {
185 gpio{_num}.try_isr_handler_remove(isr_handle{_num, _id});
186 }
187 _num = std::exchange(other._num, GPIO_NUM_NC);
188 _id = other._id;
189 }
190 return *this;
191 }
192
195
200 if (_num != GPIO_NUM_NC) {
201 // Removing the ISR handler will not fail, so we can ignore the result
202 gpio{_num}.try_isr_handler_remove(isr_handle{_num, _id});
203 }
204 }
205
211 auto handle = isr_handle{_num, _id};
212 _num = GPIO_NUM_NC;
213 return handle;
214 }
215
216 private:
217 gpio_num_t _num;
218 uint32_t _id;
219 };
220
230
231public:
233 constexpr gpio()
234 : _num(GPIO_NUM_NC) {}
235
242
243#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
250 [[nodiscard]] explicit gpio(int num);
251#endif
252
254 [[nodiscard]] static constexpr gpio nc() { return gpio{GPIO_NUM_NC}; }
255
257 [[nodiscard]] static constexpr gpio max() { return gpio{static_cast<gpio_num_t>(GPIO_NUM_MAX - 1)}; }
258
259 // Copyable and movable
260 gpio(const gpio&) = default;
261 gpio(gpio&&) = default;
262 gpio& operator=(const gpio&) = default;
263 gpio& operator=(gpio&&) = default;
264
266 [[nodiscard]] constexpr bool operator==(const gpio&) const noexcept = default;
267
269 [[nodiscard]] constexpr bool is_connected() const { return _num != GPIO_NUM_NC && _is_valid_gpio_num(_num); }
270
272 [[nodiscard]] constexpr bool is_output_capable() const { return _is_valid_output_gpio_num(_num); }
273
275 [[nodiscard]] constexpr bool is_digital_io_pin_capable() const { return _is_valid_digital_io_gpio_num(_num); }
276
278 [[nodiscard]] constexpr int num() const { return static_cast<int>(_num); }
279
281 [[nodiscard]] constexpr gpio_num_t idf_num() const { return _num; }
282
290 void reset();
291
292 // Direction and pull configuration
293#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
333#endif
378
379 // Level (input/output)
392 [[nodiscard]] enum level get_level() const;
403
404 // Drive capability
405#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
418#endif
431
432 // ISR service (must be installed before adding handlers)
433#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
458#endif
467 [[nodiscard]] static result<void>
486
487 // ISR handlers
488#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
507 isr_handle isr_handler_add(std::move_only_function<void() const> handler) {
508 return unwrap(try_isr_handler_add(std::move(handler)));
509 }
523 isr_handle isr_handler_add(void (*fn)(void*), void* arg) { return unwrap(try_isr_handler_add(fn, arg)); }
530#endif
547 result<isr_handle> try_isr_handler_add(std::move_only_function<void() const> handler);
572
573 // Interrupt configuration
589
590 // Wakeup configuration
591#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
605#endif
619
620 // Hold configuration (maintains state during sleep/reset)
621#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
644#endif
676
677 // Sleep mode configuration
688#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
695#endif
709
710private:
711 constexpr gpio(gpio_num_t num)
712 : _num(num) {}
713
714 static constexpr bool _is_valid_gpio_num(int num) {
715 return num >= 0 && num < GPIO_NUM_MAX && (SOC_GPIO_VALID_GPIO_MASK & (1ULL << num));
716 }
717 static constexpr bool _is_valid_output_gpio_num(int num) {
718 return num >= 0 && num < GPIO_NUM_MAX && (SOC_GPIO_VALID_OUTPUT_GPIO_MASK & (1ULL << num));
719 }
720 static constexpr bool _is_valid_digital_io_gpio_num(int num) {
721 return num >= 0 && num < GPIO_NUM_MAX && (SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK & (1ULL << num));
722 }
723
724 gpio_num_t _num;
725};
726
746template<typename... Gpios>
748 return try_configure_gpios(cfg, std::vector<gpio>{std::forward<Gpios>(gpios)...});
749}
750#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
760inline void configure_gpios(const gpio::config& cfg, std::vector<gpio> gpios) {
761 unwrap(try_configure_gpios(cfg, std::move(gpios)));
762}
772template<typename... Gpios>
774 unwrap(try_configure_gpios(cfg, std::vector<gpio>{std::forward<Gpios>(gpios)...}));
775}
776#endif
777
779/* Validates at compile time that the GPIO number is valid.
780 * Used internally to create the predefined GPIO constants.
781 */
782template<int N>
783struct gpio_constant {
784 static_assert(N == GPIO_NUM_NC || gpio::_is_valid_gpio_num(N), "Invalid GPIO number");
785 static constexpr gpio value{static_cast<gpio_num_t>(N)};
786};
798inline constexpr gpio gpio_nc = gpio_constant<GPIO_NUM_NC>::value;
799#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 0))
800inline constexpr gpio gpio_0 = gpio_constant<0>::value;
801#endif
802#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 1))
803inline constexpr gpio gpio_1 = gpio_constant<1>::value;
804#endif
805#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 2))
806inline constexpr gpio gpio_2 = gpio_constant<2>::value;
807#endif
808#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 3))
809inline constexpr gpio gpio_3 = gpio_constant<3>::value;
810#endif
811#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 4))
812inline constexpr gpio gpio_4 = gpio_constant<4>::value;
813#endif
814#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 5))
815inline constexpr gpio gpio_5 = gpio_constant<5>::value;
816#endif
817#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 6))
818inline constexpr gpio gpio_6 = gpio_constant<6>::value;
819#endif
820#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 7))
821inline constexpr gpio gpio_7 = gpio_constant<7>::value;
822#endif
823#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 8))
824inline constexpr gpio gpio_8 = gpio_constant<8>::value;
825#endif
826#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 9))
827inline constexpr gpio gpio_9 = gpio_constant<9>::value;
828#endif
829#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 10))
830inline constexpr gpio gpio_10 = gpio_constant<10>::value;
831#endif
832#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 11))
833inline constexpr gpio gpio_11 = gpio_constant<11>::value;
834#endif
835#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 12))
836inline constexpr gpio gpio_12 = gpio_constant<12>::value;
837#endif
838#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 13))
839inline constexpr gpio gpio_13 = gpio_constant<13>::value;
840#endif
841#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 14))
842inline constexpr gpio gpio_14 = gpio_constant<14>::value;
843#endif
844#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 15))
845inline constexpr gpio gpio_15 = gpio_constant<15>::value;
846#endif
847#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 16))
848inline constexpr gpio gpio_16 = gpio_constant<16>::value;
849#endif
850#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 17))
851inline constexpr gpio gpio_17 = gpio_constant<17>::value;
852#endif
853#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 18))
854inline constexpr gpio gpio_18 = gpio_constant<18>::value;
855#endif
856#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 19))
857inline constexpr gpio gpio_19 = gpio_constant<19>::value;
858#endif
859#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 20))
860inline constexpr gpio gpio_20 = gpio_constant<20>::value;
861#endif
862#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 21))
863inline constexpr gpio gpio_21 = gpio_constant<21>::value;
864#endif
865#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 22))
866inline constexpr gpio gpio_22 = gpio_constant<22>::value;
867#endif
868#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 23))
869inline constexpr gpio gpio_23 = gpio_constant<23>::value;
870#endif
871#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 24))
872inline constexpr gpio gpio_24 = gpio_constant<24>::value;
873#endif
874#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 25))
875inline constexpr gpio gpio_25 = gpio_constant<25>::value;
876#endif
877#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 26))
878inline constexpr gpio gpio_26 = gpio_constant<26>::value;
879#endif
880#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 27))
881inline constexpr gpio gpio_27 = gpio_constant<27>::value;
882#endif
883#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 28))
884inline constexpr gpio gpio_28 = gpio_constant<28>::value;
885#endif
886#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 29))
887inline constexpr gpio gpio_29 = gpio_constant<29>::value;
888#endif
889#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 30))
890inline constexpr gpio gpio_30 = gpio_constant<30>::value;
891#endif
892#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 31))
893inline constexpr gpio gpio_31 = gpio_constant<31>::value;
894#endif
895#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 32))
896inline constexpr gpio gpio_32 = gpio_constant<32>::value;
897#endif
898#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 33))
899inline constexpr gpio gpio_33 = gpio_constant<33>::value;
900#endif
901#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 34))
902inline constexpr gpio gpio_34 = gpio_constant<34>::value;
903#endif
904#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 35))
905inline constexpr gpio gpio_35 = gpio_constant<35>::value;
906#endif
907#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 36))
908inline constexpr gpio gpio_36 = gpio_constant<36>::value;
909#endif
910#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 37))
911inline constexpr gpio gpio_37 = gpio_constant<37>::value;
912#endif
913#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 38))
914inline constexpr gpio gpio_38 = gpio_constant<38>::value;
915#endif
916#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 39))
917inline constexpr gpio gpio_39 = gpio_constant<39>::value;
918#endif
919#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 40))
920inline constexpr gpio gpio_40 = gpio_constant<40>::value;
921#endif
922#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 41))
923inline constexpr gpio gpio_41 = gpio_constant<41>::value;
924#endif
925#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 42))
926inline constexpr gpio gpio_42 = gpio_constant<42>::value;
927#endif
928#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 43))
929inline constexpr gpio gpio_43 = gpio_constant<43>::value;
930#endif
931#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 44))
932inline constexpr gpio gpio_44 = gpio_constant<44>::value;
933#endif
934#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 45))
935inline constexpr gpio gpio_45 = gpio_constant<45>::value;
936#endif
937#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 46))
938inline constexpr gpio gpio_46 = gpio_constant<46>::value;
939#endif
940#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 47))
941inline constexpr gpio gpio_47 = gpio_constant<47>::value;
942#endif
943#if (SOC_GPIO_VALID_GPIO_MASK & (1ULL << 48))
944inline constexpr gpio gpio_48 = gpio_constant<48>::value;
945#endif
946
// end of GPIO Constants
948
956[[nodiscard]] inline std::string to_string(gpio g) {
957 if (!g.is_connected()) {
958 return "GPIO_NC";
959 }
960 return "GPIO_" + std::to_string(g.num());
961}
962
970[[nodiscard]] inline std::string to_string(gpio::level l) {
971 return l == gpio::level::high ? "high" : "low";
972}
973
984
// end of idfxx_gpio
986
987} // namespace idfxx
988
989#include "sdkconfig.h"
990#ifdef CONFIG_IDFXX_STD_FORMAT
992#include <algorithm>
993#include <format>
994namespace std {
995template<>
996struct formatter<idfxx::gpio> {
997 constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
998
999 template<typename FormatContext>
1000 auto format(idfxx::gpio g, FormatContext& ctx) const {
1001 auto s = to_string(g);
1002 return std::copy(s.begin(), s.end(), ctx.out());
1003 }
1004};
1005template<>
1006struct formatter<idfxx::gpio::level> {
1007 constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
1008
1009 template<typename FormatContext>
1010 auto format(idfxx::gpio::level l, FormatContext& ctx) const {
1011 auto s = to_string(l);
1012 return std::copy(s.begin(), s.end(), ctx.out());
1013 }
1014};
1015} // namespace std
1017#endif // CONFIG_IDFXX_STD_FORMAT
Handle to a registered ISR handler.
Definition gpio.hpp:131
RAII handle for ISR registration that removes the handler on destruction.
Definition gpio.hpp:150
unique_isr_handle & operator=(unique_isr_handle &&other) noexcept
Move assignment operator.
Definition gpio.hpp:182
unique_isr_handle() noexcept
Constructs an empty unique_isr_handle.
Definition gpio.hpp:157
unique_isr_handle(unique_isr_handle &&other) noexcept
Move constructor.
Definition gpio.hpp:173
~unique_isr_handle()
Destructor.
Definition gpio.hpp:199
unique_isr_handle & operator=(const unique_isr_handle &)=delete
unique_isr_handle(const unique_isr_handle &)=delete
unique_isr_handle(isr_handle handle) noexcept
Constructs from an isr_handle, taking ownership.
Definition gpio.hpp:165
isr_handle release() noexcept
Releases ownership of the handle without removing the ISR.
Definition gpio.hpp:210
A GPIO pin.
Definition gpio.hpp:61
static result< gpio > make(int num)
Creates a validated GPIO pin.
static void uninstall_isr_service()
Uninstalls the GPIO ISR service, freeing related resources.
void set_drive_capability(enum drive_cap strength)
Sets the gpio drive capability.
Definition gpio.hpp:411
result< void > try_pulldown_disable()
Disables the internal pull-down resistor.
void intr_enable()
Enables interrupts for this gpio.
result< void > try_sleep_set_direction(enum mode mode)
Sets GPIO direction at sleep.
result< void > try_wakeup_enable(enum intr_type intr_type)
Enables GPIO wake-up from light sleep.
result< void > try_set_pull_mode(enum pull_mode mode)
Sets the pull resistor mode.
result< void > try_wakeup_disable()
Disables GPIO wake-up.
static result< void > try_install_isr_service(idfxx::intr_levels levels=intr_level_lowmed, idfxx::flags< intr_flag > flags={})
Installs the GPIO ISR service for per-gpio interrupt handlers.
static result< void > try_install_isr_service(idfxx::flags< intr_flag > flags)
Installs the GPIO ISR service with default priority levels.
Definition gpio.hpp:477
void pulldown_enable()
Enables the internal pull-down resistor.
Definition gpio.hpp:326
constexpr bool is_digital_io_pin_capable() const
Returns true if this gpio is a valid digital I/O pin.
Definition gpio.hpp:275
void input_enable()
Enables input on this gpio.
static void deep_sleep_hold_disable()
Disables hold for all digital GPIOs during deep sleep.
void sleep_set_direction(enum mode mode)
Sets GPIO direction at sleep.
Definition gpio.hpp:694
constexpr int num() const
Returns the underlying GPIO pin number.
Definition gpio.hpp:278
void set_intr_type(enum intr_type intr_type)
Sets the interrupt trigger type.
result< drive_cap > try_get_drive_capability() const
Gets the current drive capability.
result< void > try_set_direction(enum mode mode)
Sets the GPIO direction mode.
void sleep_sel_disable()
Disables SLP_SEL to change GPIO status automatically in light sleep.
result< void > try_pullup_enable()
Enables the internal pull-up resistor.
gpio & operator=(const gpio &)=default
enum level get_level() const
Reads the current input level.
void wakeup_disable()
Disables GPIO wake-up.
Definition gpio.hpp:604
friend struct gpio_constant
Definition gpio.hpp:63
result< void > try_isr_handler_remove(isr_handle handle)
Removes a specific ISR handler.
result< void > try_set_drive_capability(enum drive_cap strength)
Sets the gpio drive capability.
void set_pull_mode(enum pull_mode mode)
Sets the pull resistor mode.
Definition gpio.hpp:308
void pulldown_disable()
Disables the internal pull-down resistor.
Definition gpio.hpp:332
static constexpr gpio max()
Returns a GPIO for the highest valid pin number.
Definition gpio.hpp:257
gpio & operator=(gpio &&)=default
void sleep_set_pull_mode(enum pull_mode pull)
Sets pull resistor mode at sleep.
static constexpr gpio nc()
Returns a GPIO representing "not connected".
Definition gpio.hpp:254
result< void > try_hold_disable()
Disables gpio hold function.
void set_level(enum level level)
Sets the output level.
void toggle_level()
Toggles the output level.
void reset()
Resets the gpio to default state.
mode
GPIO direction mode.
Definition gpio.hpp:73
@ disable
Disable input and output.
@ output
Output only.
@ input
Input only.
@ input_output_od
Input and output with open-drain mode.
@ input_output
Input and output.
@ output_od
Output only with open-drain mode.
isr_handle isr_handler_add(std::move_only_function< void() const > handler)
Adds an ISR handler for this gpio.
Definition gpio.hpp:507
constexpr gpio_num_t idf_num() const
Returns the underlying ESP-IDF GPIO number.
Definition gpio.hpp:281
gpio(const gpio &)=default
constexpr gpio()
Constructs a GPIO representing "not connected".
Definition gpio.hpp:233
pull_mode
Pull resistor configuration.
Definition gpio.hpp:83
@ floating
Pin floating.
@ pullup_pulldown
Pin pull up + pull down.
@ pullup
Pin pull up.
@ pulldown
Pin pull down.
result< void > try_hold_enable()
Enables gpio hold function.
static void install_isr_service(idfxx::intr_levels levels=intr_level_lowmed, idfxx::flags< intr_flag > flags={})
Installs the GPIO ISR service for per-gpio interrupt handlers.
Definition gpio.hpp:444
static void install_isr_service(idfxx::flags< intr_flag > flags)
Installs the GPIO ISR service with default priority levels.
Definition gpio.hpp:457
void intr_disable()
Disables interrupts for this gpio.
level
GPIO output/input level.
Definition gpio.hpp:67
@ low
Logic low (0)
@ high
Logic high (1)
void hold_enable()
Enables gpio hold function.
Definition gpio.hpp:634
gpio(int num)
Constructs a validated GPIO pin.
result< isr_handle > try_isr_handler_add(std::move_only_function< void() const > handler)
Adds an ISR handler for this gpio.
void isr_handler_remove_all()
Removes all ISR handlers for this gpio.
constexpr bool operator==(const gpio &) const noexcept=default
Compares two GPIO pins for equality.
constexpr bool is_output_capable() const
Returns true if this gpio supports output mode.
Definition gpio.hpp:272
isr_handle isr_handler_add(void(*fn)(void *), void *arg)
Adds an ISR handler for this gpio.
Definition gpio.hpp:523
gpio(gpio &&)=default
drive_cap
Pin drive capability (output strength).
Definition gpio.hpp:91
@ cap_0
Weak drive capability.
@ cap_default
Medium drive capability.
@ cap_1
Stronger drive capability.
@ cap_2
Medium drive capability.
@ cap_3
Strongest drive capability.
constexpr bool is_connected() const
Returns true if this is a valid GPIO pin.
Definition gpio.hpp:269
void hold_disable()
Disables gpio hold function.
Definition gpio.hpp:643
result< void > try_pullup_disable()
Disables the internal pull-up resistor.
result< isr_handle > try_isr_handler_add(void(*fn)(void *), void *arg)
Adds an ISR handler for this gpio.
void set_direction(enum mode mode)
Sets the GPIO direction mode.
Definition gpio.hpp:300
void wakeup_enable(enum intr_type intr_type)
Enables GPIO wake-up from light sleep.
Definition gpio.hpp:598
result< void > try_pulldown_enable()
Enables the internal pull-down resistor.
void sleep_sel_enable()
Enables SLP_SEL to change GPIO status automatically in light sleep.
enum drive_cap get_drive_capability() const
Gets the current drive capability.
Definition gpio.hpp:417
hys_ctrl_mode
Hysteresis control mode.
Definition gpio.hpp:111
@ soft_enable
Pin input hysteresis enable by software.
@ soft_disable
Pin input hysteresis disable by software.
void pullup_enable()
Enables the internal pull-up resistor.
Definition gpio.hpp:314
void pullup_disable()
Disables the internal pull-up resistor.
Definition gpio.hpp:320
intr_type
Interrupt trigger type.
Definition gpio.hpp:100
@ disable
Disable GPIO interrupt.
@ low_level
Input low level trigger.
@ high_level
Input high level trigger.
@ anyedge
Both rising and falling edge.
@ negedge
Falling edge.
@ posedge
Rising edge.
static void deep_sleep_hold_enable()
Enables hold for all digital GPIOs during deep sleep.
void isr_handler_remove(isr_handle handle)
Removes a specific ISR handler.
Definition gpio.hpp:529
@ efuse
Reset due to efuse error.
std::string to_string(core_id c)
Returns a string representation of a CPU core identifier.
Definition cpu.hpp:52
constexpr gpio gpio_36
Definition gpio.hpp:908
constexpr gpio gpio_11
Definition gpio.hpp:833
void configure_gpios(const gpio::config &cfg, std::vector< gpio > gpios)
Configures multiple GPIOs with the same settings.
Definition gpio.hpp:760
constexpr gpio gpio_33
Definition gpio.hpp:899
constexpr gpio gpio_47
Definition gpio.hpp:941
constexpr gpio gpio_23
Definition gpio.hpp:869
constexpr gpio gpio_8
Definition gpio.hpp:824
constexpr gpio gpio_20
Definition gpio.hpp:860
constexpr gpio gpio_38
Definition gpio.hpp:914
constexpr gpio gpio_39
Definition gpio.hpp:917
constexpr gpio gpio_46
Definition gpio.hpp:938
constexpr gpio gpio_3
Definition gpio.hpp:809
constexpr gpio gpio_16
Definition gpio.hpp:848
constexpr gpio gpio_35
Definition gpio.hpp:905
constexpr gpio gpio_0
Definition gpio.hpp:800
constexpr gpio gpio_4
Definition gpio.hpp:812
constexpr gpio gpio_7
Definition gpio.hpp:821
constexpr gpio gpio_12
Definition gpio.hpp:836
constexpr gpio gpio_13
Definition gpio.hpp:839
constexpr gpio gpio_17
Definition gpio.hpp:851
constexpr gpio gpio_2
Definition gpio.hpp:806
constexpr gpio gpio_29
Definition gpio.hpp:887
constexpr gpio gpio_14
Definition gpio.hpp:842
result< void > try_configure_gpios(const gpio::config &cfg, std::vector< gpio > gpios)
Configures multiple GPIOs with the same settings.
constexpr gpio gpio_21
Definition gpio.hpp:863
constexpr gpio gpio_34
Definition gpio.hpp:902
constexpr gpio gpio_44
Definition gpio.hpp:932
constexpr gpio gpio_18
Definition gpio.hpp:854
constexpr gpio gpio_31
Definition gpio.hpp:893
constexpr gpio gpio_9
Definition gpio.hpp:827
constexpr gpio gpio_41
Definition gpio.hpp:923
constexpr gpio gpio_26
Definition gpio.hpp:878
constexpr gpio gpio_43
Definition gpio.hpp:929
constexpr gpio gpio_25
Definition gpio.hpp:875
constexpr gpio gpio_nc
Definition gpio.hpp:798
constexpr gpio gpio_1
Definition gpio.hpp:803
constexpr gpio gpio_10
Definition gpio.hpp:830
constexpr gpio gpio_30
Definition gpio.hpp:890
constexpr gpio gpio_48
Definition gpio.hpp:944
constexpr gpio gpio_6
Definition gpio.hpp:818
constexpr gpio gpio_22
Definition gpio.hpp:866
constexpr gpio gpio_32
Definition gpio.hpp:896
constexpr gpio gpio_19
Definition gpio.hpp:857
constexpr gpio gpio_5
Definition gpio.hpp:815
constexpr gpio gpio_40
Definition gpio.hpp:920
constexpr gpio gpio_28
Definition gpio.hpp:884
constexpr gpio gpio_24
Definition gpio.hpp:872
constexpr gpio gpio_27
Definition gpio.hpp:881
constexpr gpio gpio_37
Definition gpio.hpp:911
constexpr gpio gpio_45
Definition gpio.hpp:935
constexpr gpio gpio_42
Definition gpio.hpp:926
constexpr gpio gpio_15
Definition gpio.hpp:845
constexpr flags< E > operator~(E a) noexcept
Computes the bitwise complement of an enum value.
Definition flags.hpp:332
T unwrap(result< T > result)
Throws a std::system_error if the result is an error.
Definition error.hpp:307
std::expected< T, std::error_code > result
result type wrapping a value or error code.
Definition error.hpp:120
constexpr intr_levels intr_level_lowmed
Low and medium priority levels (1-3). These can be handled in C / C++.
Configuration parameters for idfxx::gpio_config.
Definition gpio.hpp:222