Comments (2)
Hi @cskilbeck
I thinks the follow patch can meet you need
diff --git a/components/esp_peripherals/esp_peripherals.c b/components/esp_peripherals/esp_peripherals.c
index 5e141123..b6cb75c4 100644
--- a/components/esp_peripherals/esp_peripherals.c
+++ b/components/esp_peripherals/esp_peripherals.c
@@ -35,6 +35,7 @@
static const char *TAG = "ESP_PERIPH";
+#define DEFAULT_CUS_PERIPH_ID_MAX_NUM (5)
#define DEFAULT_ESP_PERIPH_WAIT_TICK (10/portTICK_RATE_MS)
struct esp_periph {
@@ -62,6 +63,7 @@ typedef struct esp_periph_sets {
bool ext_stack;
bool run;
esp_periph_event_t event_handle;
+ int periph_id[DEFAULT_CUS_PERIPH_ID_MAX_NUM];
STAILQ_HEAD(esp_periph_list_item, esp_periph) periph_list;
} esp_periph_set_t;
@@ -199,6 +201,24 @@ esp_err_t esp_periph_remove_from_set(esp_periph_set_handle_t periph_set_handle,
return ESP_OK;
}
+esp_err_t esp_periph_allocated_periph_id(esp_periph_set_handle_t periph_set_handle, int *periph_id)
+{
+ if (periph_set_handle == NULL) {
+ AUDIO_ERROR(TAG, "Peripherals have not been initialized");
+ return ESP_FAIL;
+ }
+ for (int i = 0; i < DEFAULT_CUS_PERIPH_ID_MAX_NUM; i++) {
+ if (periph_set_handle->periph_id[i] == 0) {
+ *periph_id = i + PERIPH_ID_MAX;
+ periph_set_handle->periph_id[i] = *periph_id;
+ return ESP_OK;
+ }
+ }
+ ESP_LOGE(TAG, "Have no enough periph id space");
+ *periph_id = -1;
+ return ESP_FAIL;
+}
+
esp_err_t esp_periph_set_destroy(esp_periph_set_handle_t periph_set_handle)
{
if (periph_set_handle == NULL) {
diff --git a/components/esp_peripherals/include/esp_peripherals.h b/components/esp_peripherals/include/esp_peripherals.h
index 0ea9dbad..ed1fb3a5 100644
--- a/components/esp_peripherals/include/esp_peripherals.h
+++ b/components/esp_peripherals/include/esp_peripherals.h
@@ -54,7 +54,8 @@ typedef enum {
PERIPH_ID_GPIO_ISR = AUDIO_ELEMENT_TYPE_PERIPH + 14,
PERIPH_ID_WS2812 = AUDIO_ELEMENT_TYPE_PERIPH + 15,
PERIPH_ID_AW2013 = AUDIO_ELEMENT_TYPE_PERIPH + 16,
- PERIPH_ID_LCD = AUDIO_ELEMENT_TYPE_PERIPH + 17
+ PERIPH_ID_LCD = AUDIO_ELEMENT_TYPE_PERIPH + 17,
+ PERIPH_ID_MAX = AUDIO_ELEMENT_TYPE_PERIPH + 18
} esp_periph_id_t;
/**
@@ -239,6 +240,20 @@ esp_err_t esp_periph_set_list_destroy(esp_periph_set_handle_t periph_set_handle)
*/
esp_err_t esp_periph_remove_from_set(esp_periph_set_handle_t periph_set_handle, esp_periph_handle_t periph);
+/**
+ * @brief Allocated a peripheral id from the periph_set.
+ *
+ * Note: This function is used to get a peripheral id from the periph_set, and this periph id not include in the esp_periph_id_t
+ *
+ * @param periph_set_handle The esp_periph_set_handle_t instance
+ * @param periph_id The peripheral identifier
+ *
+ * @return
+ * - ESP_OK
+ * - ESP_FAIL
+ */
+esp_err_t esp_periph_allocated_periph_id(esp_periph_set_handle_t periph_set_handle, int *periph_id);
+
/**
* @brief Call this function to change periph_set waiting time.
*
from esp-adf.
Looks good, thanks!
from esp-adf.
Related Issues (20)
- English documentation is broken (AUD-5447) HOT 2
- ESP32 LyraT keeps ringing after hanging up SIP call (AUD-5459) HOT 6
- input key service causes esp_timer to consume 50% of CPU time on ESP-LyraTv4.3 (AUD-5465) HOT 1
- (932) MPEG_READER: Not find an effective frame, line:857 (AUD-5468) HOT 2
- how to run (master)adf on the board esp32s3lcd evboard2(800x480)? (AUD-5537) HOT 5
- esp32_s3_korvo2_v3开发板如何设置MIC麦克风的增益大小 (AUD-5476) HOT 2
- Setting afe_mode=SR_MODE_HIGH_PERF caused watchdog (AUD-5480) HOT 2
- 怎么实现通过MQTT流播放WAV和编码WAV (AUD-5500) HOT 1
- ESP32-LyraTD-MSC v2.2 can not control the volumes when run the example "get-started/play_mp3_control" (AUD-5501) HOT 1
- play bt source, mp3 decoder crash (AUD-5505) HOT 1
- A lot of "deprecated" in VoIP example (AUD-5517) HOT 1
- To configure DTMF RTP events duration and volume. (AUD-5521) HOT 4
- To trigger actions on DTMF rtp events' start and end. (AUD-5522) HOT 6
- examples\advanced_examples\algorithm 这个例程中,请问下如何获取到 aec和ns后的音频数据呢 (AUD-5526) HOT 3
- Examples give warnings and not work (AUD-5538) HOT 6
- ESP-ADF does not get recognized in VSCode after install (AUD-5539) HOT 4
- 关于AEC信号延迟调整的问题,如果让参考信号更靠前 (AUD-5540) HOT 1
- I2C 驱动提示冲突(AUD-5547) HOT 2
- 使用pipeline_spiffs_mp3和pipeline_wav_amr_sdcard例程时喇叭会有破音的 (AUD-5550) HOT 4
- 关于VOIP AEC效果问题请教,如何可以让AEC质量变得更好? (AUD-5559) HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp-adf.