|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
Namespaces | |
| namespace | chrono |
| ESP-IDF C++ chrono utilities. | |
| namespace | i2c |
| I2C master driver classes. | |
| namespace | lcd |
| LCD driver classes. | |
| namespace | log |
| namespace | spi |
| SPI driver classes. | |
Classes | |
| struct | dma_allocator |
| STL-compatible allocator for DMA-capable memory. More... | |
| struct | dram_allocator |
| STL-compatible allocator for internal DRAM. More... | |
| class | error_category |
| Error category for IDFXX and ESP-IDF error codes. More... | |
| class | event_base |
| Typed event base template. More... | |
| class | event_group |
| Type-safe inter-task event group for bit-level synchronization. More... | |
| class | event_loop |
| Base class for event loops. More... | |
| struct | event_type |
| Combines an event base with a specific event ID. More... | |
| class | flags |
| Type-safe set of flags from a scoped enum. More... | |
| class | gpio |
| A GPIO pin. More... | |
| class | nvs |
| Non-Volatile Storage handle. More... | |
| class | queue |
| Type-safe inter-task message queue. More... | |
| struct | spiram_allocator |
| STL-compatible allocator for external PSRAM (SPI RAM). More... | |
| class | task |
| Task lifecycle management. More... | |
| class | timer |
| High-resolution timer with microsecond precision. More... | |
| class | user_event_loop |
| User-created event loop with manual dispatch. More... | |
Concepts | |
| concept | flag_enum |
| Concept for enums that have opted into flag operators. | |
Typedefs | |
| template<typename T > | |
| using | result = std::expected< T, std::error_code > |
| result type wrapping a value or error code. | |
| template<typename IdEnum > | |
| using | event_callback = std::move_only_function< void(event_base< IdEnum > base, IdEnum id, void *event_data) const > |
| Callback type for event listeners. | |
Enumerations | |
| enum class | core_id : unsigned int { core_id::core_0 = 0 } |
| Identifies a specific CPU core. More... | |
| enum class | errc : esp_err_t { fail = -1 , no_mem = 0x101 , invalid_arg = 0x102 , invalid_state = 0x103 , invalid_size = 0x104 , not_found = 0x105 , not_supported = 0x106 , timeout = 0x107 , invalid_response = 0x108 , invalid_crc = 0x109 , invalid_version = 0x10A , invalid_mac = 0x10B , not_finished = 0x10C , not_allowed = 0x10D } |
| IDFXX error codes. More... | |
| enum class | memory_type : uint32_t { memory_type::internal = MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT , memory_type::spiram = MALLOC_CAP_SPIRAM } |
| Memory region type for heap allocations. More... | |
| enum class | wait_mode { wait_mode::any , wait_mode::all } |
| Specifies whether to wait for any or all of the requested bits. More... | |
| enum class | intr_flag : int { none = 0 , level1 = 1u << 1 , level2 = 1u << 2 , level3 = 1u << 3 , level4 = 1u << 4 , level5 = 1u << 5 , level6 = 1u << 6 , nmi = 1u << 7 , shared = 1u << 8 , edge = 1u << 9 , iram = 1u << 10 , intr_disabled = 1u << 11 } |
| Interrupt allocation flags. More... | |
| enum class | intr_cpu_affinity_t { automatic = ESP_INTR_CPU_AFFINITY_AUTO , cpu_0 = ESP_INTR_CPU_AFFINITY_0 , cpu_1 = ESP_INTR_CPU_AFFINITY_1 } |
| Interrupt CPU core affinity. More... | |
Functions | |
| std::string | to_string (core_id c) |
| Returns a string representation of a CPU core identifier. | |
| const error_category & | default_category () noexcept |
| Returns a reference to the IDFXX error category singleton. | |
| std::error_code | make_error_code (errc e) noexcept |
| Creates a std::error_code from an idfxx::errc value. | |
| std::error_code | make_error_code (esp_err_t e) noexcept |
| Creates a std::error_code from a general esp_err_t value. | |
| template<typename E > requires std::is_error_code_enum_v<E> | |
| constexpr std::unexpected< std::error_code > | error (E e) noexcept |
| Creates an unexpected error from an error code enum. | |
| template<typename E > requires std::is_error_condition_enum_v<E> | |
| constexpr std::unexpected< std::error_code > | error (E e) noexcept |
| Creates an unexpected error from an error condition enum. | |
| std::unexpected< std::error_code > | error (esp_err_t e) noexcept |
| Creates an unexpected error from an esp_err_t value. | |
| std::unexpected< std::error_code > | error (std::error_code ec) noexcept |
| Creates an unexpected error from a std::error_code. | |
| result< void > | wrap (esp_err_t e) |
| Wraps an esp_err_t into a result<void>. | |
| template<typename T > | |
| T | unwrap (result< T > result) |
| Throws a std::system_error if the result is an error. | |
| template<> | |
| void | unwrap (result< void > result) |
| template<typename T , typename Callback > requires std::invocable<Callback, std::error_code> && std::same_as<std::invoke_result_t<Callback, std::error_code>, void> | |
| void | abort_on_error (result< T > result, Callback &&on_error) |
| Aborts the program if the result contains an error. | |
| template<typename T > | |
| void | abort_on_error (result< T > result) |
| Aborts the program if the result contains an error. | |
| template<flag_enum E> | |
| flags (E) -> flags< E > | |
| Class template argument deduction guide. | |
| template<flag_enum E> | |
| constexpr flags< E > | operator| (E a, E b) noexcept |
| Combines two enum values into a flags object. | |
| template<flag_enum E> | |
| constexpr flags< E > | operator& (E a, E b) noexcept |
| Intersects two enum values into a flags object. | |
| template<flag_enum E> | |
| constexpr flags< E > | operator^ (E a, E b) noexcept |
| Toggles two enum values into a flags object. | |
| template<flag_enum E> | |
| constexpr flags< E > | operator~ (E a) noexcept |
| Computes the bitwise complement of an enum value. | |
| template<flag_enum E> | |
| std::string | to_string (flags< E > f) |
| Returns a hexadecimal string representation of a flags value. | |
| template<typename T , typename U > | |
| bool | operator== (const dram_allocator< T > &, const dram_allocator< U > &) |
| Equality comparison for dram_allocator. | |
| template<typename T , typename U > | |
| bool | operator!= (const dram_allocator< T > &, const dram_allocator< U > &) |
| Inequality comparison for dram_allocator. | |
| template<typename T , typename U > | |
| bool | operator== (const spiram_allocator< T > &, const spiram_allocator< U > &) |
| Equality comparison for spiram_allocator. | |
| template<typename T , typename U > | |
| bool | operator!= (const spiram_allocator< T > &, const spiram_allocator< U > &) |
| Inequality comparison for spiram_allocator. | |
| template<typename T , typename U > | |
| bool | operator== (const dma_allocator< T > &, const dma_allocator< U > &) |
| Equality comparison for dma_allocator. | |
| template<typename T , typename U > | |
| bool | operator!= (const dma_allocator< T > &, const dma_allocator< U > &) |
| Inequality comparison for dma_allocator. | |
| template<typename Rep , typename Period > | |
| void | delay (const std::chrono::duration< Rep, Period > &duration) |
| Delay for the specified duration. | |
| template<typename Clock , typename Duration > | |
| void | delay_until (const std::chrono::time_point< Clock, Duration > &target) |
| Delays until the specified time point. | |
| void | yield () noexcept |
| Yields execution to other ready tasks of equal priority. | |
| void | yield_from_isr (bool higher_priority_task_woken=true) noexcept |
| Requests a context switch from ISR context. | |
| template<typename IdEnum > | |
| event_type (event_base< IdEnum >, IdEnum) -> event_type< IdEnum > | |
| result< void > | try_configure_gpios (const gpio::config &cfg, std::vector< gpio > gpios) |
| Configures multiple GPIOs with the same settings. | |
| template<typename... Gpios> | |
| result< void > | try_configure_gpios (const gpio::config &cfg, Gpios &&... gpios) |
| Configures multiple GPIOs with the same settings. | |
| void | configure_gpios (const gpio::config &cfg, std::vector< gpio > gpios) |
| Configures multiple GPIOs with the same settings. | |
| template<typename... Gpios> | |
| void | configure_gpios (const gpio::config &cfg, Gpios &&... gpios) |
| Configures multiple GPIOs with the same settings. | |
| std::string | to_string (gpio g) |
| Returns a string representation of a GPIO pin. | |
| constexpr int | intr_cpu_affinity_to_core_id (intr_cpu_affinity_t cpu_affinity) |
| Convert esp_intr_cpu_affinity_t to CPU core ID. | |
| const nvs::error_category & | nvs_category () noexcept |
| Returns a reference to the NVS error category singleton. | |
| std::error_code | make_error_code (nvs::errc e) noexcept |
| Creates an error code from an idfxx::nvs::errc value. | |
| std::unexpected< std::error_code > | nvs_error (esp_err_t e) noexcept |
| Creates an unexpected error from an ESP-IDF error code, mapping to NVS error codes where possible. | |
Variables | |
| template<typename E > | |
| constexpr bool | enable_flags_operators = false |
| Opt-in trait for enabling flag operators on an enum. | |
| constexpr flags< intr_flag > | intr_flag_lowmed = intr_flag::level1 | intr_flag::level2 | intr_flag::level3 |
| Low and medium priority levels (1-3). These can be handled in C / C++. | |
| constexpr flags< intr_flag > | intr_flag_high |
| High priority levels (4-6 and NMI). These require assembly handlers. | |
| constexpr flags< intr_flag > | intr_flag_levelmask = intr_flag_lowmed | intr_flag_high |
| Mask of all interrupt level flags. | |
GPIO Constants | |
Predefined GPIO instances for direct use. Available GPIOs depend on the target chip. | |
| constexpr gpio | gpio_nc = gpio_constant<GPIO_NUM_NC>::value |
| constexpr gpio | gpio_0 = gpio_constant<0>::value |
| constexpr gpio | gpio_1 = gpio_constant<1>::value |
| constexpr gpio | gpio_2 = gpio_constant<2>::value |
| constexpr gpio | gpio_3 = gpio_constant<3>::value |
| constexpr gpio | gpio_4 = gpio_constant<4>::value |
| constexpr gpio | gpio_5 = gpio_constant<5>::value |
| constexpr gpio | gpio_6 = gpio_constant<6>::value |
| constexpr gpio | gpio_7 = gpio_constant<7>::value |
| constexpr gpio | gpio_8 = gpio_constant<8>::value |
| constexpr gpio | gpio_9 = gpio_constant<9>::value |
| constexpr gpio | gpio_10 = gpio_constant<10>::value |
| constexpr gpio | gpio_11 = gpio_constant<11>::value |
| constexpr gpio | gpio_12 = gpio_constant<12>::value |
| constexpr gpio | gpio_13 = gpio_constant<13>::value |
| constexpr gpio | gpio_14 = gpio_constant<14>::value |
| constexpr gpio | gpio_15 = gpio_constant<15>::value |
| constexpr gpio | gpio_16 = gpio_constant<16>::value |
| constexpr gpio | gpio_17 = gpio_constant<17>::value |
| constexpr gpio | gpio_18 = gpio_constant<18>::value |
| constexpr gpio | gpio_19 = gpio_constant<19>::value |
| constexpr gpio | gpio_20 = gpio_constant<20>::value |
| constexpr gpio | gpio_21 = gpio_constant<21>::value |
| constexpr gpio | gpio_22 = gpio_constant<22>::value |
| constexpr gpio | gpio_23 = gpio_constant<23>::value |
| constexpr gpio | gpio_24 = gpio_constant<24>::value |
| constexpr gpio | gpio_25 = gpio_constant<25>::value |
| constexpr gpio | gpio_26 = gpio_constant<26>::value |
| constexpr gpio | gpio_27 = gpio_constant<27>::value |
| constexpr gpio | gpio_28 = gpio_constant<28>::value |
| constexpr gpio | gpio_29 = gpio_constant<29>::value |
| constexpr gpio | gpio_30 = gpio_constant<30>::value |
| constexpr gpio | gpio_31 = gpio_constant<31>::value |
| constexpr gpio | gpio_32 = gpio_constant<32>::value |
| constexpr gpio | gpio_33 = gpio_constant<33>::value |
| constexpr gpio | gpio_34 = gpio_constant<34>::value |
| constexpr gpio | gpio_35 = gpio_constant<35>::value |
| constexpr gpio | gpio_36 = gpio_constant<36>::value |
| constexpr gpio | gpio_37 = gpio_constant<37>::value |
| constexpr gpio | gpio_38 = gpio_constant<38>::value |
| constexpr gpio | gpio_39 = gpio_constant<39>::value |
| constexpr gpio | gpio_40 = gpio_constant<40>::value |
| constexpr gpio | gpio_41 = gpio_constant<41>::value |
| constexpr gpio | gpio_42 = gpio_constant<42>::value |
| constexpr gpio | gpio_43 = gpio_constant<43>::value |
| constexpr gpio | gpio_44 = gpio_constant<44>::value |
| constexpr gpio | gpio_45 = gpio_constant<45>::value |
| constexpr gpio | gpio_46 = gpio_constant<46>::value |
| constexpr gpio | gpio_47 = gpio_constant<47>::value |
| constexpr gpio | gpio_48 = gpio_constant<48>::value |
| using idfxx::result = typedef std::expected<T, std::error_code> |
|
strong |
IDFXX error codes.
These error codes are compatible with ESP-IDF error codes and can be used with std::error_code through the IDFXX error category.
|
strong |
Interrupt CPU core affinity.
This type specify the CPU core that the peripheral interrupt is connected to.
Definition at line 23 of file intr_types.hpp.
|
strong |
Interrupt allocation flags.
Type-safe interrupt allocation flags. These flags control interrupt priority levels, sharing behavior, and handler requirements.
Priority levels 1-3 (lowmed) can use C / C++ handlers. Levels 4-6 and NMI require assembly handlers and must pass NULL as the handler function.
Definition at line 35 of file intr_alloc.hpp.
|
inline |
|
inline |
Aborts the program if the result contains an error.
This overload invokes an optional callback before aborting, allowing for error logging or cleanup. The callback is invoked inline without type erasure, enabling zero-overhead error handling.
| T | The success value type. |
| Callback | The callback type (deduced). |
| result | The result to check. |
| on_error | Function called with the error code before aborting. Must be a valid callable (not null for function wrappers). |
|
noexcept |
Returns a reference to the IDFXX error category singleton.
This follows the standard library pattern (like std::generic_category()).
Referenced by make_error_code().
|
constexprnoexcept |
Creates an unexpected error from an error code enum.
Convenience helper for returning errors from functions that return idfxx::result<T>. Works with any registered error code enum (idfxx::errc, nvs::errc, etc.) via ADL make_error_code.
| E | An error code enum type registered via std::is_error_code_enum. |
| e | The error code enum value. |
Definition at line 142 of file error.hpp.
Referenced by idfxx::event_group< E >::make(), idfxx::queue< T >::make(), idfxx::gpio::try_get_drive_capability(), idfxx::timer::try_start_once(), idfxx::timer::try_start_once(), idfxx::timer::try_start_once(), idfxx::timer::try_start_once(), idfxx::timer::try_start_periodic(), idfxx::timer::try_start_periodic(), and wrap().
|
constexprnoexcept |
Creates an unexpected error from an error condition enum.
Convenience helper for returning errors from functions that return idfxx::result<T>. Works with any registered error condition enum (std::errc, etc.) via ADL make_error_code.
| E | An error condition enum type registered via std::is_error_condition_enum. |
| e | The error condition enum value. |
Definition at line 168 of file error.hpp.
References make_error_code().
|
inlinenoexcept |
Creates an unexpected error from an esp_err_t value.
Convenience helper for returning errors from functions that return idfxx::result<T>. Converts the ESP-IDF error code to a std::error_code using make_error_code.
| e | The ESP-IDF error code. |
Definition at line 182 of file error.hpp.
References make_error_code().
|
inlinenoexcept |
Creates an unexpected error from a std::error_code.
Convenience helper for propagating errors between result types with different value types.
| ec | The error code. |
| idfxx::flags | ( | E | ) | -> flags< E > |
Class template argument deduction guide.
Allows flags to be constructed without explicit template arguments:
|
constexpr |
Convert esp_intr_cpu_affinity_t to CPU core ID.
Definition at line 31 of file intr_types.hpp.
|
inlinenoexcept |
Creates a std::error_code from an idfxx::errc value.
Definition at line 99 of file error.hpp.
References default_category().
|
noexcept |
Creates a std::error_code from a general esp_err_t value.
Maps common ESP-IDF error codes to corresponding idfxx::errc values, or returns an std::error_code with idfxx::errc::fail for unknown ESP-IDF error codes.
|
inlinenoexcept |
Creates an error code from an idfxx::nvs::errc value.
Definition at line 326 of file nvs.hpp.
References nvs_category().
|
noexcept |
Returns a reference to the NVS error category singleton.
Referenced by make_error_code().
|
noexcept |
Creates an unexpected error from an ESP-IDF error code, mapping to NVS error codes where possible.
Converts the ESP-IDF error code to an NVS-specific error code if a mapping exists, otherwise falls back to the default IDFXX error category.
| e | The ESP-IDF error code. |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
inline |
Returns a hexadecimal string representation of a flags value.
| E | The flag enum type (must satisfy flag_enum concept). |
| f | The flags value to convert. |
Definition at line 365 of file flags.hpp.
References idfxx::flags< E >::value().
|
inline |
Throws a std::system_error if the result is an error.
| T | The success value type. |
| result | The result to check. |
| std::system_error | if the result is an error. |
Definition at line 237 of file error.hpp.
Referenced by idfxx::nvs::commit(), configure_gpios(), configure_gpios(), idfxx::event_loop::create_system(), idfxx::nvs::flash::deinit(), idfxx::nvs::flash::deinit(), idfxx::event_loop::destroy_system(), idfxx::task::detach(), idfxx::lcd::panel::display_on(), idfxx::nvs::flash::erase(), idfxx::nvs::erase(), idfxx::nvs::flash::erase(), idfxx::nvs::erase_all(), idfxx::nvs::get_blob(), idfxx::gpio::get_drive_capability(), idfxx::nvs::get_string(), idfxx::nvs::get_value(), idfxx::gpio::hold_disable(), idfxx::gpio::hold_enable(), idfxx::nvs::flash::init(), idfxx::nvs::flash::init(), idfxx::nvs::flash::init(), idfxx::nvs::flash::init(), idfxx::nvs::flash::init(), idfxx::nvs::flash::init(), idfxx::gpio::input_enable(), idfxx::gpio::intr_disable(), idfxx::gpio::intr_enable(), idfxx::gpio::isr_handler_add(), idfxx::gpio::isr_handler_add(), idfxx::gpio::isr_handler_remove(), idfxx::gpio::isr_handler_remove_all(), idfxx::task::join(), idfxx::task::join(), idfxx::task::join_until(), idfxx::task::kill(), idfxx::event_loop::listener_add(), idfxx::event_loop::listener_add(), idfxx::event_loop::listener_add(), idfxx::event_loop::listener_remove(), idfxx::lcd::panel::mirror(), idfxx::task::notify(), idfxx::queue< T >::peek(), idfxx::queue< T >::peek(), idfxx::queue< T >::peek_until(), idfxx::event_loop::post(), idfxx::event_loop::post(), idfxx::event_loop::post(), idfxx::event_loop::post(), idfxx::i2c::master_bus::probe(), idfxx::gpio::pulldown_disable(), idfxx::gpio::pulldown_enable(), idfxx::gpio::pullup_disable(), idfxx::gpio::pullup_enable(), idfxx::i2c::master_device::read_register(), idfxx::i2c::master_device::read_register(), idfxx::i2c::master_device::read_register(), idfxx::i2c::master_device::read_register(), idfxx::i2c::master_device::read_register(), idfxx::i2c::master_device::read_register(), idfxx::i2c::master_device::read_register(), idfxx::i2c::master_device::read_register(), idfxx::i2c::master_device::read_register(), idfxx::i2c::master_device::read_register(), idfxx::queue< T >::receive(), idfxx::queue< T >::receive(), idfxx::i2c::master_device::receive(), idfxx::i2c::master_device::receive(), idfxx::i2c::master_device::receive(), idfxx::i2c::master_device::receive(), idfxx::i2c::master_device::receive(), idfxx::i2c::master_device::receive(), idfxx::queue< T >::receive_until(), idfxx::timer::restart(), idfxx::task::resume(), idfxx::user_event_loop::run(), idfxx::queue< T >::send(), idfxx::queue< T >::send(), idfxx::queue< T >::send_to_front(), idfxx::queue< T >::send_to_front(), idfxx::queue< T >::send_to_front_until(), idfxx::queue< T >::send_until(), idfxx::nvs::set_blob(), idfxx::nvs::set_blob(), idfxx::gpio::set_direction(), idfxx::gpio::set_drive_capability(), idfxx::gpio::set_intr_type(), idfxx::task::set_priority(), idfxx::gpio::set_pull_mode(), idfxx::nvs::set_string(), idfxx::nvs::set_value(), idfxx::gpio::sleep_sel_disable(), idfxx::gpio::sleep_sel_enable(), idfxx::gpio::sleep_set_direction(), idfxx::gpio::sleep_set_pull_mode(), idfxx::task::spawn(), idfxx::task::spawn(), idfxx::timer::start_once(), idfxx::timer::start_once(), idfxx::timer::start_once(), idfxx::timer::start_once(), idfxx::timer::start_once(), idfxx::timer::start_once(), idfxx::timer::start_periodic(), idfxx::timer::start_periodic(), idfxx::timer::start_periodic(), idfxx::timer::stop(), idfxx::task::suspend(), idfxx::lcd::panel::swap_xy(), idfxx::event_group< E >::sync(), idfxx::event_group< E >::sync(), idfxx::event_group< E >::sync_until(), idfxx::i2c::master_device::transmit(), idfxx::i2c::master_device::transmit(), idfxx::i2c::master_device::transmit(), idfxx::i2c::master_device::transmit(), idfxx::event_group< E >::wait(), idfxx::event_group< E >::wait(), idfxx::event_group< E >::wait_until(), idfxx::gpio::wakeup_disable(), idfxx::gpio::wakeup_enable(), idfxx::i2c::master_device::write_register(), idfxx::i2c::master_device::write_register(), idfxx::i2c::master_device::write_register(), idfxx::i2c::master_device::write_register(), idfxx::i2c::master_device::write_register(), idfxx::i2c::master_device::write_register(), idfxx::i2c::master_device::write_register(), idfxx::i2c::master_device::write_register(), idfxx::i2c::master_device::write_registers(), idfxx::i2c::master_device::write_registers(), idfxx::i2c::master_device::write_registers(), and idfxx::i2c::master_device::write_registers().
|
inline |
Wraps an esp_err_t into a result<void>.
| e | The esp_err_t value to wrap. |
Definition at line 216 of file error.hpp.
References error().
Referenced by idfxx::gpio::try_get_drive_capability(), idfxx::event_loop::try_post(), idfxx::event_loop::try_post(), idfxx::timer::try_restart(), idfxx::user_event_loop::try_run(), idfxx::timer::try_start_once(), idfxx::timer::try_start_once(), idfxx::timer::try_start_periodic(), and idfxx::timer::try_stop().
|
inlineconstexpr |
High priority levels (4-6 and NMI). These require assembly handlers.
Definition at line 61 of file intr_alloc.hpp.
|
inlineconstexpr |
Mask of all interrupt level flags.
Definition at line 65 of file intr_alloc.hpp.
|
inlineconstexpr |
Low and medium priority levels (1-3). These can be handled in C / C++.
Definition at line 58 of file intr_alloc.hpp.