M5UnitUnified 0.5.8 git rev:47d29eb
Loading...
Searching...
No Matches
types.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
10#ifndef M5_UNIT_COMPONENT_TYPES_HPP
11#define M5_UNIT_COMPONENT_TYPES_HPP
12
13#include <cstdint>
14#include <type_traits>
16#if defined(ESP_PLATFORM)
17#if defined(M5_UNIT_UNIFIED_USING_RMT_V2)
18#include <driver/rmt_types.h>
19#else
20#include <soc/rmt_struct.h>
21#endif
22#include <driver/gpio.h>
23#endif // ESP_PLATFORM
24
25namespace m5 {
26namespace unit {
31namespace types {
32
37enum class category_t {
38 None,
39 UnitLED,
40};
41
42using uid_t = uint32_t;
43using attr_t = uint32_t;
44using elapsed_time_t = unsigned long;
45
46namespace attribute {
49constexpr attr_t AccessI2C = 0x00000001;
50constexpr attr_t AccessGPIO = 0x00000002;
51constexpr attr_t AccessUART = 0x00000004;
52constexpr attr_t AccessSPI = 0x00000008;
54} // namespace attribute
55
56} // namespace types
57
58#if defined(ESP_PLATFORM)
59namespace gpio {
64enum class Mode : uint8_t {
65 Input,
66 Output,
67 Pullup,
68 InputPullup,
69 Pulldown,
70 InputPulldown,
71 OpenDrain,
72 OutputOpenDrain,
73 Analog,
74 // RMT access
75 RmtRX = 0x80,
76 RmtTX,
77 RmtRXTX,
78};
79
84struct adapter_config_t {
86 struct config_t {
87 uint32_t tick_ns{};
88 gpio_num_t gpio_num{};
89 uint8_t mem_blocks{};
90 bool invert_signal{};
91 bool with_dma{};
92 };
93
95 struct tx_config_t : config_t {
96 uint16_t loop_count{1};
97 bool idle_output_enabled{};
98 bool idle_level_high{};
99 bool loop_enabled{};
100 // bool carrier_enabled{}; ///< Enable carrier modulation (not commonly used)
101 };
103 struct rx_config_t : config_t {
104 uint16_t ring_buffer_size{};
105 uint16_t filter_ticks_threshold{};
106 uint16_t idle_ticks_threshold{};
107 bool filter_enabled{};
108 // bool eof_flag{}; ///< Use RX EOF detection via timeout (v2 feature)
109 };
110
111 Mode mode{};
112 rx_config_t rx{};
113 tx_config_t tx{};
114};
115
116// Alias
117#if defined(M5_UNIT_UNIFIED_USING_RMT_V2)
118using m5_rmt_item_t = rmt_symbol_word_t;
119#else
120using m5_rmt_item_t = rmt_item32_t;
121#endif
122
123} // namespace gpio
124#endif // ESP_PLATFORM
125
126} // namespace unit
127} // namespace m5
128#endif
Identification of functions to be used.
Top level namespace of M5Stack.
Definition test_helper.hpp:20
Type and enumerator definitions.
Unit-related namespace.
unsigned long elapsed_time_t
Elapsed time unit (ms), same type as m5::utility::elapsed_time_t.
Definition types.hpp:44
constexpr attr_t AccessSPI
SPI Accessible Unit.
Definition types.hpp:52
uint32_t attr_t
Component attribute bits.
Definition types.hpp:43
uint32_t uid_t
Component unique identifier.
Definition types.hpp:42
constexpr attr_t AccessUART
UART Accessible Unit.
Definition types.hpp:51
constexpr attr_t AccessGPIO
GPIO Accessible Unit.
Definition types.hpp:50
constexpr attr_t AccessI2C
I2C Accessible Unit.
Definition types.hpp:49
category_t
Unit category (used for static class determination)
Definition types.hpp:37
@ UnitLED
Derived from UnitLED.