0

我有一个非常令人沮丧的问题,因为它看起来简单而琐碎。我尝试使用带有 Arduino IDE 1.8.15 的 adafruit 分线板“Adafruit I2S MEMS Microphone Breakout”和“Adafruit Feather Huzzah ESP8266”。我安装了 esp8266 板,我可以上传简单的草图。但我想使用上面提到的麦克风来查看 Arduino IDE 串行监视器上的输出(比如这里https://www.youtube.com/watch?v=m8LwPNXqK9o)。

1.) 但是如果我尝试在“没有这样的文件或目录”中包含“#include <driver/I2S.h>”,则草图已经崩溃。我无法在线找到驱动程序文件夹应该在哪里的答案,如果库应该在那里以及如何修复它。2.) 如果我只是做一个像“#include <I2S.h>”这样的包含,IDE 找不到它应该知道的变量类型。

1.) 草图:

#include <driver/I2S.h>
#define I2S_WS 5
#define I2S_SD 4
#define I2S_SCK 14

#define I2S_PORT I2S_NUM_0

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

void i2s_install(){
  
static const int i2s_num = 0; // i2s port number

 const i2s_config_t i2s_config = {
    .mode = i2s_mode_t(I2S_MODE_MASTER | I2S_MODE_RX),
    .sample_rate = 44100,
    .bits_per_sample = i2s_bits_per_sample(16),
    .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
    .communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_STAND_I2S | I2S_COMM_FORMAT_I2S_MSB),
    .intr_alloc_flags = 0, // default interrupt priority
    .dma_buf_count = 8,
    .dma_buf_len = 64,
    .use_apll = false
  };
  
  i2s_driver_install(I2S_PORT, &i2s_config, 0, NULL);
}

void i2s_setpin(){
 const i2s_pin_config_t pin_config = {
      .bck_io_num = I2S_SCK,
      .ws_io_num = I2S_WS,
      .data_out_num = -1,
      .data_in_num = I2S_SD
  };
  
  i2s_set_pin(I2S_PORT, &pin_config);
}

错误:

Arduino: 1.8.15 (Windows 10), Board: "Adafruit Feather HUZZAH ESP8266, 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

neuerVersuch_i2smic:1:10: fatal error: driver/I2S.h: No such file or directory

    1 | #include <driver/I2S.h>

      |          ^~~~~~~~~~~~~~

compilation terminated.

exit status 1

driver/I2S.h: No such file or directory

2.)

草图:

#include <I2S.h>
#define I2S_WS 5
#define I2S_SD 4
#define I2S_SCK 14

#define I2S_PORT I2S_NUM_0

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

void i2s_install(){
  
static const int i2s_num = 0; // i2s port number

 const i2s_config_t i2s_config = {
    .mode = i2s_mode_t(I2S_MODE_MASTER | I2S_MODE_RX),
    .sample_rate = 44100,
    .bits_per_sample = i2s_bits_per_sample(16),
    .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
    .communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_STAND_I2S | I2S_COMM_FORMAT_I2S_MSB),
    .intr_alloc_flags = 0, // default interrupt priority
    .dma_buf_count = 8,
    .dma_buf_len = 64,
    .use_apll = false
  };
  
  i2s_driver_install(I2S_PORT, &i2s_config, 0, NULL);
}

void i2s_setpin(){
 const i2s_pin_config_t pin_config = {
      .bck_io_num = I2S_SCK,
      .ws_io_num = I2S_WS,
      .data_out_num = -1,
      .data_in_num = I2S_SD
  };
  
  i2s_set_pin(I2S_PORT, &pin_config);
}

错误:

Arduino: 1.8.15 (Windows 10), Board: "Adafruit Feather HUZZAH ESP8266, 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

D:\Dateien\Uni\Semesterprojekte\04 Talk to me\huzzah testing\neuerVersuch_i2smic\neuerVersuch_i2smic.ino: In function 'void i2s_install()':

neuerVersuch_i2smic:22:8: error: 'i2s_config_t' does not name a type

   22 |  const i2s_config_t i2s_config = {

      |        ^~~~~~~~~~~~

neuerVersuch_i2smic:6:18: error: 'I2S_NUM_0' was not declared in this scope

    6 | #define I2S_PORT I2S_NUM_0

      |                  ^~~~~~~~~

D:\Dateien\Uni\Semesterprojekte\04 Talk to me\huzzah testing\neuerVersuch_i2smic\neuerVersuch_i2smic.ino:34:22: note: in expansion of macro 'I2S_PORT'

   34 |   i2s_driver_install(I2S_PORT, &i2s_config, 0, NULL);

      |                      ^~~~~~~~

neuerVersuch_i2smic:34:33: error: 'i2s_config' was not declared in this scope

   34 |   i2s_driver_install(I2S_PORT, &i2s_config, 0, NULL);

      |                                 ^~~~~~~~~~

neuerVersuch_i2smic:34:3: error: 'i2s_driver_install' was not declared in this scope

   34 |   i2s_driver_install(I2S_PORT, &i2s_config, 0, NULL);

      |   ^~~~~~~~~~~~~~~~~~

D:\Dateien\Uni\Semesterprojekte\04 Talk to me\huzzah testing\neuerVersuch_i2smic\neuerVersuch_i2smic.ino: In function 'void i2s_setpin()':

neuerVersuch_i2smic:38:8: error: 'i2s_pin_config_t' does not name a type

   38 |  const i2s_pin_config_t pin_config = {

      |        ^~~~~~~~~~~~~~~~

neuerVersuch_i2smic:6:18: error: 'I2S_NUM_0' was not declared in this scope

    6 | #define I2S_PORT I2S_NUM_0

      |                  ^~~~~~~~~

D:\Dateien\Uni\Semesterprojekte\04 Talk to me\huzzah testing\neuerVersuch_i2smic\neuerVersuch_i2smic.ino:45:15: note: in expansion of macro 'I2S_PORT'

   45 |   i2s_set_pin(I2S_PORT, &pin_config);

      |               ^~~~~~~~

neuerVersuch_i2smic:45:26: error: 'pin_config' was not declared in this scope

   45 |   i2s_set_pin(I2S_PORT, &pin_config);

      |                          ^~~~~~~~~~

neuerVersuch_i2smic:45:3: error: 'i2s_set_pin' was not declared in this scope; did you mean 'i2s_setpin'?

   45 |   i2s_set_pin(I2S_PORT, &pin_config);

      |   ^~~~~~~~~~~

      |   i2s_setpin

exit status 1

'i2s_config_t' does not name a type
4

0 回答 0