Mon, 24 Jun 2024 17:09:07 +0200
Added new files and remove obsolete.
0 | 1 | /* |
2 | * MIT License | |
3 | * | |
4 | * Copyright (c) 2017 David Antliff | |
5 | * Copyright (c) 2017 Chris Morgan <chmorgan@gmail.com> | |
6 | * | |
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
8 | * of this software and associated documentation files (the "Software"), to deal | |
9 | * in the Software without restriction, including without limitation the rights | |
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
11 | * copies of the Software, and to permit persons to whom the Software is | |
12 | * furnished to do so, subject to the following conditions: | |
13 | * | |
14 | * The above copyright notice and this permission notice shall be included in all | |
15 | * copies or substantial portions of the Software. | |
16 | * | |
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
23 | * SOFTWARE. | |
24 | */ | |
25 | ||
129 | 26 | /** |
27 | * @file | |
28 | * @brief Interface definitions for ESP32 RMT driver used to communicate with devices | |
29 | * on the One Wire Bus. | |
30 | * | |
31 | * This is the recommended driver. | |
32 | */ | |
33 | ||
0 | 34 | #pragma once |
35 | #ifndef OWB_RMT_H | |
36 | #define OWB_RMT_H | |
37 | ||
38 | #include "freertos/FreeRTOS.h" | |
39 | #include "freertos/queue.h" | |
129 | 40 | |
41 | #include "driver/rmt_tx.h" | |
42 | #include "driver/rmt_rx.h" | |
43 | ||
44 | #include "owb.h" // for tyoe OneWireBus | |
0 | 45 | |
46 | #ifdef __cplusplus | |
47 | extern "C" { | |
48 | #endif | |
49 | ||
129 | 50 | /** |
51 | * @brief RMT driver information | |
52 | */ | |
0 | 53 | typedef struct |
54 | { | |
129 | 55 | rmt_channel_handle_t tx_channel_handle; ///< RMT transmit channel, allocated by RMT driver |
56 | rmt_channel_handle_t rx_channel_handle; ///< RMT receive channel, allocated by RMT driver | |
57 | rmt_encoder_handle_t copy_encoder_handle; ///< RMT built-in data encoder that sends pre-defined symbols | |
58 | rmt_encoder_handle_t bytes_encoder_handle; ///< RMT built-in data encoder that converts bits into symbols | |
59 | rmt_symbol_word_t *rx_buffer; ///< RMT receive channel symbol buffer | |
60 | size_t rx_buffer_size_in_bytes; ///< Size of the RMT received buffer, in bytes | |
61 | QueueHandle_t rx_queue; ///< xQueue to receive RMT symbols from the `on_recv_done` callback | |
62 | int gpio; ///< OneWireBus GPIO | |
63 | OneWireBus bus; ///< OneWireBus instance (see owb.h) | |
0 | 64 | } owb_rmt_driver_info; |
65 | ||
66 | /** | |
67 | * @brief Initialise the RMT driver. | |
129 | 68 | * @param[in] info Pointer to an uninitialized owb_rmt_driver_info structure. |
69 | * Note: the structure must remain in scope for the lifetime of this component. | |
70 | * @param[in] gpio_num The GPIO number to use as the One Wire bus data line. | |
71 | * @param tx_channel NOW IGNORED: the new RMT driver allocates channels dynamically. | |
72 | * @param rx_channel NOW IGNORED: the new RMT driver allocates channels dynamically. | |
73 | * @return OneWireBus *, pass this into the other OneWireBus public API functions | |
0 | 74 | */ |
129 | 75 | OneWireBus* owb_rmt_initialize(owb_rmt_driver_info * info, gpio_num_t gpio_num, |
76 | /*rmt_channel_t*/ int tx_channel, /* rmt_channel_t*/ int rx_channel); | |
77 | ||
78 | ||
79 | /** | |
80 | * @brief Legacy RMT channel IDs. | |
81 | * | |
82 | * These are no longer used for anything. They are defined here purely so | |
83 | * that code written for the old rmt driver can still compile. | |
84 | */ | |
85 | typedef enum { | |
86 | RMT_CHANNEL_0, /*!< RMT channel number 0 */ | |
87 | RMT_CHANNEL_1, /*!< RMT channel number 1 */ | |
88 | RMT_CHANNEL_2, /*!< RMT channel number 2 */ | |
89 | RMT_CHANNEL_3, /*!< RMT channel number 3 */ | |
90 | #if SOC_RMT_CHANNELS_PER_GROUP > 4 | |
91 | RMT_CHANNEL_4, /*!< RMT channel number 4 */ | |
92 | RMT_CHANNEL_5, /*!< RMT channel number 5 */ | |
93 | RMT_CHANNEL_6, /*!< RMT channel number 6 */ | |
94 | RMT_CHANNEL_7, /*!< RMT channel number 7 */ | |
95 | #endif | |
96 | RMT_CHANNEL_MAX /*!< Number of RMT channels */ | |
97 | } rmt_channel_t; | |
98 | ||
0 | 99 | |
100 | #ifdef __cplusplus | |
101 | } | |
102 | #endif | |
103 | ||
104 | #endif // OWB_RMT_H |