M5UnitUnified 0.2.0 git rev:9e1ffe1
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;
51} // namespace attribute
52
53} // namespace types
54
55namespace gpio {
60enum class Mode : uint8_t {
61 Input,
62 Output,
63 Pullup,
64 InputPullup,
65 Pulldown,
66 InputPulldown,
67 OpenDrain,
68 OutputOpenDrain,
69 Analog,
70 // RMT access
71 RmtRX = 0x80,
72 RmtTX,
73 RmtRXTX,
74};
75
80struct adapter_config_t {
82 struct config_t {
83 uint32_t tick_ns{};
84 gpio_num_t gpio_num{};
85 uint8_t mem_blocks{};
87 bool with_dma{};
88 };
89
92 uint16_t loop_count{1};
95 bool loop_enabled{};
96 // bool carrier_enabled{}; ///< Enable carrier modulation (not commonly used)
97 };
100 uint16_t ring_buffer_size{};
104 // bool eof_flag{}; ///< Use RX EOF detection via timeout (v2 feature)
105 };
106
110};
111
112// Alias
113#if defined(M5_UNIT_UNIFIED_USING_RMT_V2)
114using m5_rmt_item_t = rmt_symbol_word_t;
115#else
116using m5_rmt_item_t = rmt_item32_t;
117#endif
118
119} // namespace gpio
120
121} // namespace unit
122} // namespace m5
123#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:82
uint32_t tick_ns
RMT tick resolution (in nanoseconds)
Definition types.hpp:83
bool with_dma
Use DMA (v2 only)
Definition types.hpp:87
uint8_t mem_blocks
RMT memory block count (v1) or symbol blocks (v2)
Definition types.hpp:85
bool invert_signal
Invert input/output logic level.
Definition types.hpp:86
gpio_num_t gpio_num
GPIO pin number.
Definition types.hpp:84
For RX.
Definition types.hpp:99
uint16_t ring_buffer_size
Ring buffer size for RX (bytes, v1 only)
Definition types.hpp:100
bool filter_enabled
Enable input signal filter.
Definition types.hpp:103
uint16_t idle_ticks_threshold
RX idle threshold (in ticks for v1, in us for v2)
Definition types.hpp:102
uint16_t filter_ticks_threshold
Filter: min valid pulse duration (in ticks)
Definition types.hpp:101
For TX.
Definition types.hpp:91
bool loop_enabled
Loop mode (TX repeats automatically)
Definition types.hpp:95
uint16_t loop_count
Number of times to loop (v2 only, ignored if loop_enabled=false)
Definition types.hpp:92
bool idle_output_enabled
Enable output when idle (idle_level applies)
Definition types.hpp:93
bool idle_level_high
Idle level HIGH if true, LOW otherwise.
Definition types.hpp:94
Mode mode
Operating mode (RmtRX.RmtTx,RmtRXTX)
Definition types.hpp:107
tx_config_t tx
For TX.
Definition types.hpp:109
rx_config_t rx
For RX.
Definition types.hpp:108
unsigned long elapsed_time_t
Elapsed time unit (ms)
Definition types.hpp:42
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:114
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:60
category_t
Unit category (used for static class determination)
Definition types.hpp:35
@ UnitLED
Derived from UnitLED.