-
-
Notifications
You must be signed in to change notification settings - Fork 20
Stand‐Alone: Predefined Boards
Phil Schatzmann edited this page Feb 24, 2024
·
8 revisions
You can use this library stand alone w/o the audio tools to initialize the codec chip by using the predefined boards.
E.g. the following code is setting up and starting the codec on an AudioKit board:
#include "AudioBoard.h"
void setup() {
CodecConfig cfg;
cfg.input_device = ADC_INPUT_LINE1;
cfg.utput_device = DAC_OUTPUT_ALL;
cfg.i2s.bits = BIT_LENGTH_16BITS;
cfg.i2s.rate = RATE_44K;
//cfg.i2s.fmt = I2S_NORMAL;
//cfg.i2s.mode = MODE_SLAVE;
AudioKitEs8388V1.begin(cfg);
}
After you have been setting up the codec you can set up I2S and output the audio with your platform specific API. E.g.
As a reference, I show here how the AudioKit has been defined:
// the driver instance
static AudioDriverES8388Class AudioDriverES8388;
// the pins class and instance
class PinsAudioKitEs8388v1Class : public DriverPins {
public:
PinsAudioKitEs8388v1Class() {
// sd pins
addSPI(ESP32PinsSD);
// add i2c codec pins: scl, sda, port, frequency
addI2C(PinFunction::CODEC, 32, 33, 0x20);
// add i2s pins: mclk, bck, ws,data_out, data_in ,(port)
addI2S(PinFunction::CODEC, 0, 27, 25, 26, 35);
// add other pins
addPin(PinFunction::KEY, 36, PinLogic::Input, 1);
addPin(PinFunction::KEY, 13, PinLogic::Input, 2);
addPin(PinFunction::KEY, 19, PinLogic::Input, 3);
addPin(PinFunction::KEY, 23, PinLogic::Input, 4);
addPin(PinFunction::KEY, 18, PinLogic::Input, 5);
addPin(PinFunction::KEY, 5, PinLogic::Input, 6);
addPin(PinFunction::AUXIN_DETECT, 12, PinLogic::InputActiveLow);
addPin(PinFunction::HEADPHONE_DETECT, 39, PinLogic::InputActiveLow);
addPin(PinFunction::PA, 21, PinLogic::Output);
addPin(PinFunction::LED, 22, PinLogic::Output);
}
};
static PinsAudioKitEs8388v1Class PinsAudioKitEs8388v1;
// the board definition
static AudioBoard AudioKitEs8388V1{AudioDriverES8388, PinsAudioKitEs8388v1};