M5UnitUnified 0.3.0 git rev:6b3818b
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(M5_UNIT_UNIFIED_USING_RMT_V2)
17#include <driver/rmt_types.h>
18#else
19#include <soc/rmt_struct.h>
20#endif
21#include <driver/gpio.h>
22
23namespace m5 {
24namespace unit {
29namespace types {
30
35enum class category_t {
36 None,
37 UnitLED,
38};
39
40using uid_t = uint32_t;
41using attr_t = uint32_t;
42using elapsed_time_t = unsigned long;
43
44namespace attribute {
47constexpr attr_t AccessI2C = 0x00000001;
48constexpr attr_t AccessGPIO = 0x00000002;
49constexpr attr_t AccessUART = 0x00000004;
50constexpr attr_t AccessSPI = 0x00000008;
52} // namespace attribute
53
54} // namespace types
55
56namespace gpio {
61enum class Mode : uint8_t {
62 Input,
63 Output,
64 Pullup,
65 InputPullup,
66 Pulldown,
67 InputPulldown,
68 OpenDrain,
69 OutputOpenDrain,
70 Analog,
71 // RMT access
72 RmtRX = 0x80,
73 RmtTX,
74 RmtRXTX,
75};
76
81struct adapter_config_t {
83 struct config_t {
84 uint32_t tick_ns{};
85 gpio_num_t gpio_num{};
86 uint8_t mem_blocks{};
88 bool with_dma{};
89 };
90
93 uint16_t loop_count{1};
96 bool loop_enabled{};
97 // bool carrier_enabled{}; ///< Enable carrier modulation (not commonly used)
98 };
101 uint16_t ring_buffer_size{};
105 // bool eof_flag{}; ///< Use RX EOF detection via timeout (v2 feature)
106 };
107
111};
112
113// Alias
114#if defined(M5_UNIT_UNIFIED_USING_RMT_V2)
115using m5_rmt_item_t = rmt_symbol_word_t;
116#else
117using m5_rmt_item_t = rmt_item32_t;
118#endif
119
120} // namespace gpio
121
122} // namespace unit
123} // namespace m5
124#endif
Identification of functions to be used.
Top level namespace of M5stack.
Definition test_helper.hpp:18
Type and enumerator definitions.
Unit-related namespace.
common
Definition types.hpp:83
uint32_t tick_ns
RMT tick resolution (in nanoseconds)
Definition types.hpp:84
bool with_dma
Use DMA (v2 only)
Definition types.hpp:88
uint8_t mem_blocks
RMT memory block count (v1) or symbol blocks (v2)
Definition types.hpp:86
bool invert_signal
Invert input/output logic level.
Definition types.hpp:87
gpio_num_t gpio_num
GPIO pin number.
Definition types.hpp:85
For RX.
Definition types.hpp:100
uint16_t ring_buffer_size
Ring buffer size for RX (bytes, v1 only)
Definition types.hpp:101
bool filter_enabled
Enable input signal filter.
Definition types.hpp:104
uint16_t idle_ticks_threshold
RX idle threshold (in ticks for v1, in us for v2)
Definition types.hpp:103
uint16_t filter_ticks_threshold
Filter: min valid pulse duration (in ticks)
Definition types.hpp:102
For TX.
Definition types.hpp:92
bool loop_enabled
Loop mode (TX repeats automatically)
Definition types.hpp:96
uint16_t loop_count
Number of times to loop (v2 only, ignored if loop_enabled=false)
Definition types.hpp:93
bool idle_output_enabled
Enable output when idle (idle_level applies)
Definition types.hpp:94
bool idle_level_high
Idle level HIGH if true, LOW otherwise.
Definition types.hpp:95
Mode mode
Operating mode (RmtRX.RmtTx,RmtRXTX)
Definition types.hpp:108
tx_config_t tx
For TX.
Definition types.hpp:110
rx_config_t rx
For RX.
Definition types.hpp:109
unsigned long elapsed_time_t
Elapsed time unit (ms)
Definition types.hpp:42
constexpr attr_t AccessSPI
SPI Accessible Unit.
Definition types.hpp:50
uint32_t attr_t
Component attribute bits.
Definition types.hpp:41
rmt_symbol_word_t m5_rmt_item_t
Alias for RMT item.
Definition types.hpp:115
uint32_t uid_t
Component unique identifier.
Definition types.hpp:40
constexpr attr_t AccessUART
UART Accessible Unit.
Definition types.hpp:49
constexpr attr_t AccessGPIO
GPIO Accessible Unit.
Definition types.hpp:48
constexpr attr_t AccessI2C
I2C Accessible Unit.
Definition types.hpp:47
Mode
Pin mode.
Definition types.hpp:61
category_t
Unit category (used for static class determination)
Definition types.hpp:35
@ UnitLED
Derived from UnitLED.