13b0c4526a08f148e770b5e51e78db6e030aafc2
Chip-cn-dat/everest-semi-dat/ES8311-dat/ES8311-SDK-dat/ES8311-code-1/ES8311-code-1.ino
| ... | ... | @@ -0,0 +1,69 @@ |
| 1 | +#include "AudioTools.h" |
|
| 2 | +#include "AudioBoard.h" |
|
| 3 | + |
|
| 4 | +// 1. Define your pins clearly |
|
| 5 | +#define I2S_BCLK 5 |
|
| 6 | +#define I2S_LRCK 4 |
|
| 7 | +#define I2S_DOUT 6 |
|
| 8 | +#define I2S_MCLK 2 |
|
| 9 | + |
|
| 10 | +#define I2C_SDA 18 |
|
| 11 | +#define I2C_SCL 19 |
|
| 12 | + |
|
| 13 | +using namespace audio_driver; |
|
| 14 | +using namespace audio_tools; |
|
| 15 | + |
|
| 16 | +// 2. Use the correct class: DriverPins |
|
| 17 | +DriverPins my_pins; |
|
| 18 | + |
|
| 19 | +// 3. Initialize the board with the driver and pins |
|
| 20 | +AudioBoard board(AudioDriverES8311, my_pins); |
|
| 21 | + |
|
| 22 | +// 4. Define Audio Tools objects |
|
| 23 | +AudioInfo info(44100, 1, 16); // Mono, 44.1kHz, 16-bit |
|
| 24 | +SineWaveGenerator<int16_t> sineWave; |
|
| 25 | +GeneratedSoundStream<int16_t> sound(sineWave); |
|
| 26 | +I2SStream i2s; |
|
| 27 | +StreamCopy copier(i2s, sound); |
|
| 28 | + |
|
| 29 | +void setup() |
|
| 30 | +{ |
|
| 31 | + Serial.begin(115200); |
|
| 32 | + |
|
| 33 | + // Define I2S Pins for the driver |
|
| 34 | + my_pins.addI2S(PinFunction::CODEC, I2S_MCLK, I2S_BCLK, I2S_LRCK, I2S_DOUT); |
|
| 35 | + |
|
| 36 | + // Initialize Wire and add to pins for the driver |
|
| 37 | + Wire.begin(I2C_SDA, I2C_SCL); |
|
| 38 | + my_pins.addI2C(PinFunction::CODEC, Wire); |
|
| 39 | + |
|
| 40 | + // Start the board (I2C configuration of ES8311) |
|
| 41 | + if (!board.begin()) |
|
| 42 | + { |
|
| 43 | + Serial.println("Failed to initialize ES8311 Board!"); |
|
| 44 | + while (true) |
|
| 45 | + ; |
|
| 46 | + } |
|
| 47 | + board.setVolume(0.8); // Set volume (0.0 to 1.0) |
|
| 48 | + Serial.println("ES8311 Driver Initialized."); |
|
| 49 | + |
|
| 50 | + // Configure I2S for Audio Tools |
|
| 51 | + auto config = i2s.defaultConfig(TX_MODE); |
|
| 52 | + config.pin_bck = I2S_BCLK; |
|
| 53 | + config.pin_ws = I2S_LRCK; |
|
| 54 | + config.pin_data = I2S_DOUT; |
|
| 55 | + config.pin_mck = I2S_MCLK; |
|
| 56 | + config.copyFrom(info); |
|
| 57 | + i2s.begin(config); |
|
| 58 | + |
|
| 59 | + // Start generator |
|
| 60 | + sineWave.begin(info, 440); // 440Hz Sine Wave |
|
| 61 | + sound.begin(); |
|
| 62 | + |
|
| 63 | + Serial.println("Streaming Sine Wave to ES8311..."); |
|
| 64 | +} |
|
| 65 | + |
|
| 66 | +void loop() |
|
| 67 | +{ |
|
| 68 | + copier.copy(); |
|
| 69 | +} |
Chip-cn-dat/everest-semi-dat/ES8311-dat/ES8311-dat.md
| ... | ... | @@ -37,6 +37,7 @@ http://www.everest-semi.com/pdf/ES8311%20PB.pdf |
| 37 | 37 | ## pins to ESP32-S3 |
| 38 | 38 | |
| 39 | 39 | ESP32S3开发板(16MFLASH) - ES8311-NS4150B-CODEC音频模块 - 说明 |
| 40 | + |
|
| 40 | 41 | GPIO_NUM_5 -- SDA -- 串口数据信号线 |
| 41 | 42 | GPIO_NUM_4 -- SCL -- 串行数据位时钟/DMIC位时钟 |
| 42 | 43 | GPIO_NUM_6 -- MCLK -- 主时钟 |
SDK-dat/vscode-dat/vscode-dat.md
| ... | ... | @@ -23,6 +23,34 @@ https://github.com/Microsoft/vscode-arduino.git |
| 23 | 23 | https://github.com/microsoft/vscode-serial-monitor.git |
| 24 | 24 | |
| 25 | 25 | |
| 26 | +example |
|
| 27 | +```json |
|
| 28 | +{ |
|
| 29 | + "configurations": [ |
|
| 30 | + { |
|
| 31 | + "name": "Win32", |
|
| 32 | + "includePath": [ |
|
| 33 | + "${workspaceFolder}/**", |
|
| 34 | + "D:\\arduino-1.8.19-windows\\arduino-1.8.19\\hardware\\arduino\\avr\\libraries\\**", |
|
| 35 | + "E:\\Git-category\\Git-Arduino\\arduino-main2\\libraries\\**" |
|
| 36 | + ], |
|
| 37 | + "defines": [ |
|
| 38 | + "_DEBUG", |
|
| 39 | + "UNICODE", |
|
| 40 | + "_UNICODE" |
|
| 41 | + ], |
|
| 42 | + "windowsSdkVersion": "10.0.19041.0", |
|
| 43 | + "compilerPath": "cl.exe", |
|
| 44 | + "cStandard": "c17", |
|
| 45 | + "cppStandard": "c++17", |
|
| 46 | + "intelliSenseMode": "windows-msvc-x64" |
|
| 47 | + } |
|
| 48 | + ], |
|
| 49 | + "version": 4 |
|
| 50 | +} |
|
| 51 | +``` |
|
| 52 | + |
|
| 53 | + |
|
| 26 | 54 | |
| 27 | 55 | ## developer extensions |
| 28 | 56 |
Tech-dat/media-dat/video-dat/video-dat.md
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # video-dat |
| 3 | 3 | |
| 4 | 4 | |
| 5 | -- [[audio-dat]] - [[image-dat]] - [[video-dat]] - [[media-dat]] |
|
| 5 | +- [[audio-dat]] - [[image-dat]] - [[video-dat]] - [[media-dat]] - [[codec-dat]] |
|
| 6 | 6 | |
| 7 | 7 | |
| 8 | 8 |
Tech-dat/tech-dat.md
| ... | ... | @@ -91,7 +91,7 @@ |
| 91 | 91 | |
| 92 | 92 | - [[encryption-dat]] |
| 93 | 93 | |
| 94 | - |
|
| 94 | +- [[vscode-dat]] |
|
| 95 | 95 | |
| 96 | 96 | |
| 97 | 97 | ### network |