From 25670a2049806583b3626bf4235846c4ad119139 Mon Sep 17 00:00:00 2001 From: pschatzmann Date: Fri, 20 Oct 2023 09:46:40 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20doxygen=20from=20@=20pschatzma?= =?UTF-8?q?nn/arduino-audio-tools@2bef4385f403b92ee92f7469e5eb4266357a6c36?= =?UTF-8?q?=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _analog_audio_e_s_p32_v1_8h_source.html | 229 +++++++++--------- ...o__tools_1_1_analog_driver_e_s_p32_v1.html | 6 +- 2 files changed, 122 insertions(+), 113 deletions(-) diff --git a/_analog_audio_e_s_p32_v1_8h_source.html b/_analog_audio_e_s_p32_v1_8h_source.html index 5cbfa492ca..8803f2d703 100644 --- a/_analog_audio_e_s_p32_v1_8h_source.html +++ b/_analog_audio_e_s_p32_v1_8h_source.html @@ -168,7 +168,7 @@
108  bool active = false;
109  bool active_tx = false;
110  bool active_rx = false;
-
111  int timeout = portMAX_DELAY;
+
111  TickType_t timeout = portMAX_DELAY;
112 
114  class IO16Bit : public AudioStream {
115  public:
@@ -178,116 +178,125 @@
119  size_t write(const uint8_t *src, size_t size_bytes) override {
120  TRACED();
121 #ifdef HAS_ESP32_DAC
-
122  size_t result = size_bytes;
-
123  if (dac_continuous_write(self->dac_handle, (uint8_t *)src, size_bytes, &result,
-
124  self->timeout) != ESP_OK) {
-
125  result = 0;
-
126  }
-
127  return size_bytes;
-
128 #else
-
129  return 0;
-
130 #endif
-
131  }
-
132 
-
133  size_t readBytes(uint8_t *dest, size_t size_bytes) override {
-
134  TRACED();
-
135  uint32_t result = size_bytes;
-
136  if(adc_continuous_read(self->adc_handle, dest, size_bytes, &result, self->timeout)!= ESP_OK) {
-
137  result = 0;
-
138  }
-
139  return result;
+
122  size_t result = 0;
+
123 
+
124  // convert signed 16 bit to unsigned 8 bits
+
125  int16_t* data16 = (int16_t*)src;
+
126  uint8_t* data8 = (uint8_t*)src;
+
127  int samples = size_bytes / 2;
+
128  for (int j=0; j < samples; j++){
+
129  data8[j] = (32768u + data16[j]) >> 8;
+
130  }
+
131 
+
132  if (dac_continuous_write(self->dac_handle, data8, samples, &result,
+
133  self->timeout) != ESP_OK) {
+
134  result = 0;
+
135  }
+
136  return size_bytes;
+
137 #else
+
138  return 0;
+
139 #endif
140  }
-
141  protected:
-
142  AnalogDriverESP32V1 *self;
-
143 
-
144  } io{this};
-
145 
-
146  NumberFormatConverterStream converter{io};
-
147 
-
148 #ifdef HAS_ESP32_DAC
-
149 
-
150  bool setup_tx(){
-
151  dac_continuous_config_t cont_cfg = {
-
152  .chan_mask =
-
153  cfg.channels == 1 ? DAC_CHANNEL_MASK_CH0 : DAC_CHANNEL_MASK_ALL,
-
154  .desc_num = (uint32_t)cfg.buffer_count,
-
155  .buf_size = (size_t) cfg.buffer_size,
-
156  .freq_hz = (uint32_t)cfg.sample_rate,
-
157  .offset = 0,
-
158  .clk_src =
-
159  cfg.use_apll
-
160  ? DAC_DIGI_CLK_SRC_APLL
-
161  : DAC_DIGI_CLK_SRC_DEFAULT, // Using APLL as clock source to
-
162  // get a wider frequency range
-
163  .chan_mode = DAC_CHANNEL_MODE_ALTER,
-
164  };
-
165  // Allocate continuous channels
-
166  if (dac_continuous_new_channels(&cont_cfg, &dac_handle) != ESP_OK) {
-
167  LOGE("new_channels");
-
168  return false;
-
169  }
-
170  if (dac_continuous_enable(dac_handle) != ESP_OK) {
-
171  LOGE("enable");
-
172  return false;
-
173  }
-
174  return true;
-
175  }
-
176 
-
177  #else
-
178  bool setup_tx(){
-
179  LOGE("DAC not supported");
-
180  return false;
-
181  }
-
182  #endif
-
183 
-
184 
-
185  bool setup_rx(){
-
186  int max_channels = sizeof(cfg.adc_channels)/sizeof(adc_channel_t);
-
187  if (cfg.channels > max_channels ){
-
188  LOGE("channels: %d, max: %d", cfg.channels, max_channels);
-
189  return false;
-
190  }
-
191  adc_continuous_handle_cfg_t adc_config = {
-
192  .max_store_buf_size = (uint32_t)cfg.buffer_size * cfg.buffer_count,
-
193  .conv_frame_size = (uint32_t)cfg.buffer_size,
-
194  };
-
195  adc_continuous_new_handle(&adc_config, &adc_handle);
-
196 
-
197  adc_continuous_config_t dvig_cfg = {
-
198  .sample_freq_hz = (uint32_t)cfg.sample_rate,
-
199  .conv_mode = (adc_digi_convert_mode_t)cfg.adc_conversion_mode,
-
200  .format = (adc_digi_output_format_t)cfg.adc_output_type,
-
201  };
-
202  adc_digi_pattern_config_t adc_pattern[cfg.channels] = {0};
-
203  adc_continuous_config_t dig_cfg = {};
-
204  dig_cfg.pattern_num = cfg.channels;
-
205  for (int i = 0; i < cfg.channels; i++) {
-
206  uint8_t unit = GET_UNIT(cfg.adc_channels[i]);
-
207  uint8_t ch = cfg.adc_channels[i] & 0x7;
-
208  adc_pattern[i].atten = cfg.adc_attenuation;
-
209  adc_pattern[i].channel = ch;
-
210  adc_pattern[i].unit = unit;
-
211  adc_pattern[i].bit_width = cfg.adc_bit_width;
-
212 
-
213  LOGI("adc_pattern[%d].atten is :%x", i, adc_pattern[i].atten);
-
214  LOGI("adc_pattern[%d].channel is :%x", i, adc_pattern[i].channel);
-
215  LOGI("adc_pattern[%d].unit is :%x", i, adc_pattern[i].unit);
-
216  }
-
217  dig_cfg.adc_pattern = adc_pattern;
-
218  if (adc_continuous_config(adc_handle, &dig_cfg)!=ESP_OK){
-
219  LOGE("adc_continuous_config");
-
220  return false;
-
221  }
-
222  return true;
-
223  }
-
224 
-
225 };
-
226 
-
228 using AnalogDriver = AnalogDriverESP32V1;
-
229 
-
230 } // namespace
-
231 
-
232 #endif
+
141 
+
142  size_t readBytes(uint8_t *dest, size_t size_bytes) override {
+
143  TRACED();
+
144  uint32_t result = size_bytes;
+
145  if(adc_continuous_read(self->adc_handle, dest, size_bytes, &result, self->timeout)!= ESP_OK) {
+
146  result = 0;
+
147  }
+
148  return result;
+
149  }
+
150  protected:
+
151  AnalogDriverESP32V1 *self;
+
152 
+
153  } io{this};
+
154 
+
155  NumberFormatConverterStream converter{io};
+
156 
+
157 #ifdef HAS_ESP32_DAC
+
158 
+
159  bool setup_tx(){
+
160  dac_continuous_config_t cont_cfg = {
+
161  .chan_mask =
+
162  cfg.channels == 1 ? DAC_CHANNEL_MASK_CH0 : DAC_CHANNEL_MASK_ALL,
+
163  .desc_num = (uint32_t)cfg.buffer_count,
+
164  .buf_size = (size_t) cfg.buffer_size,
+
165  .freq_hz = (uint32_t)cfg.sample_rate,
+
166  .offset = 0,
+
167  .clk_src =
+
168  cfg.use_apll
+
169  ? DAC_DIGI_CLK_SRC_APLL
+
170  : DAC_DIGI_CLK_SRC_DEFAULT, // Using APLL as clock source to
+
171  // get a wider frequency range
+
172  .chan_mode = DAC_CHANNEL_MODE_ALTER,
+
173  };
+
174  // Allocate continuous channels
+
175  if (dac_continuous_new_channels(&cont_cfg, &dac_handle) != ESP_OK) {
+
176  LOGE("new_channels");
+
177  return false;
+
178  }
+
179  if (dac_continuous_enable(dac_handle) != ESP_OK) {
+
180  LOGE("enable");
+
181  return false;
+
182  }
+
183  return true;
+
184  }
+
185 
+
186  #else
+
187  bool setup_tx(){
+
188  LOGE("DAC not supported");
+
189  return false;
+
190  }
+
191  #endif
+
192 
+
193 
+
194  bool setup_rx(){
+
195  int max_channels = sizeof(cfg.adc_channels)/sizeof(adc_channel_t);
+
196  if (cfg.channels > max_channels ){
+
197  LOGE("channels: %d, max: %d", cfg.channels, max_channels);
+
198  return false;
+
199  }
+
200  adc_continuous_handle_cfg_t adc_config = {
+
201  .max_store_buf_size = (uint32_t)cfg.buffer_size * cfg.buffer_count,
+
202  .conv_frame_size = (uint32_t)cfg.buffer_size,
+
203  };
+
204  adc_continuous_new_handle(&adc_config, &adc_handle);
+
205 
+
206  adc_continuous_config_t dvig_cfg = {
+
207  .sample_freq_hz = (uint32_t)cfg.sample_rate,
+
208  .conv_mode = (adc_digi_convert_mode_t)cfg.adc_conversion_mode,
+
209  .format = (adc_digi_output_format_t)cfg.adc_output_type,
+
210  };
+
211  adc_digi_pattern_config_t adc_pattern[cfg.channels] = {0};
+
212  adc_continuous_config_t dig_cfg = {};
+
213  dig_cfg.pattern_num = cfg.channels;
+
214  for (int i = 0; i < cfg.channels; i++) {
+
215  uint8_t unit = GET_UNIT(cfg.adc_channels[i]);
+
216  uint8_t ch = cfg.adc_channels[i] & 0x7;
+
217  adc_pattern[i].atten = cfg.adc_attenuation;
+
218  adc_pattern[i].channel = ch;
+
219  adc_pattern[i].unit = unit;
+
220  adc_pattern[i].bit_width = cfg.adc_bit_width;
+
221 
+
222  LOGI("adc_pattern[%d].atten is :%x", i, adc_pattern[i].atten);
+
223  LOGI("adc_pattern[%d].channel is :%x", i, adc_pattern[i].channel);
+
224  LOGI("adc_pattern[%d].unit is :%x", i, adc_pattern[i].unit);
+
225  }
+
226  dig_cfg.adc_pattern = adc_pattern;
+
227  if (adc_continuous_config(adc_handle, &dig_cfg)!=ESP_OK){
+
228  LOGE("adc_continuous_config");
+
229  return false;
+
230  }
+
231  return true;
+
232  }
+
233 
+
234 };
+
235 
+
237 using AnalogDriver = AnalogDriverESP32V1;
+
238 
+
239 } // namespace
+
240 
+
241 #endif
ESP32 specific configuration for i2s input via adc using the adc_continuous API.
Definition: AnalogConfigESP32V1.h:38
Definition: AnalogAudioBase.h:13
writes the int16_t data to the DAC
Definition: AnalogAudioESP32V1.h:114
diff --git a/classaudio__tools_1_1_analog_driver_e_s_p32_v1.html b/classaudio__tools_1_1_analog_driver_e_s_p32_v1.html index e9c7df0608..3615b5c532 100644 --- a/classaudio__tools_1_1_analog_driver_e_s_p32_v1.html +++ b/classaudio__tools_1_1_analog_driver_e_s_p32_v1.html @@ -166,9 +166,9 @@ audio_tools::AnalogDriverESP32V1::IO16Bit this   - -int timeout = portMAX_DELAY -  + +TickType_t timeout = portMAX_DELAY + 

Detailed Description

AnalogAudioStream: A very fast DAC using DMA using the new dac_continuous API.