arduino-audio-driver
Loading...
Searching...
No Matches
ESP32S3AISmartSpeaker.h
Go to the documentation of this file.
1#pragma once
7#include "AudioBoard.h"
8#if defined(ARDUINO)
9#include "FS.h"
10#include "SD_MMC.h"
11#endif
12
13#if !defined(IS_ZEPHYR)
14#define EXIO1 1000
15#define EXIO2 1001
16#define EXIO3 1002
17#define EXIO4 1003
18#define EXIO5 1004
19#define EXIO6 1005
20#define EXIO7 1006
21#define EXIO8 1007
22#define EXIO9 1008
23#define EXIO10 1009
24#define EXIO11 1010
25#define EXIO12 1011
26#define EXIO13 1012
27#define EXIO14 1013
28#define EXIO15 1014
29#define EXIO16 1015
30#endif
31
32
33namespace audio_driver {
34
41 public:
43#if defined(IS_ZEPHYR)
44 // setup TCA9555 GPIO expander
45 gpio.setAltGPIO(tca9555, 1000);
46 // add i2c codec pins: scl, sda, port, frequency
47 addI2C(PinFunction::EXPANDER, DEVICE_DT_GET(DT_ALIAS(i2c_1)));
48 // add i2s pins: mclk, bck, ws,data_out, data_in ,(port)
49 addI2S(PinFunction::CODEC, DEVICE_DT_GET(DT_ALIAS(i2s_1)));
50
51 // add other pins
52 addPin(PinFunction::KEY, GPIO_DT_SPEC_GET(DT_ALIAS(key_1), gpios),
54 addPin(PinFunction::KEY, GPIO_DT_SPEC_GET(DT_ALIAS(key_2), gpios),
56 addPin(PinFunction::KEY, GPIO_DT_SPEC_GET(DT_ALIAS(key_3), gpios),
58 addPin(PinFunction::PA, GPIO_DT_SPEC_GET(DT_ALIAS(pa), gpios),
60 addPin(PinFunction::SD, GPIO_DT_SPEC_GET(DT_ALIAS(sd), gpios),
61 PinLogic::Output); // SD CS
62 addPin(PinFunction::LED, GPIO_DT_SPEC_GET(DT_ALIAS(led), gpios),
64#else
65 // setup TCA9555 GPIO expander
66 gpio.setAltGPIO(tca9555, 1000);
67 // CLK, MISO (DATA), MOSI (CMD), CS
68 PinsSPI sd{PinFunction::SD, 40, 41, 42, -1, SPI};
69
70 addSPI(sd);
71 // add i2c codec pins: scl, sda, port, frequency
73 // addI2C(PinFunction::CODEC, 10, 11);
74 // add i2s pins: mclk, bck, ws,data_out, data_in ,(port)
75 addI2S(PinFunction::CODEC, 12, 13, 14, 16, 15);
76
77 // add other pins
84#endif
85 }
86
87#if !defined(IS_ZEPHYR)
88
89 bool begin() override {
90 AD_LOGD("PinsESP32S3AISmartSpeakerClass::begin");
91 bool rc = DriverDeviceInfo::begin();
92 // activate SD CS
93 if (sd_active) {
94 AD_LOGD("Activate SD CS");
95 tca9555.digitalWrite(EXIO4, true); // activate SD CS
96 }
97 // activate SDMMC
98 if (sdmmc_active) {
99#if defined(ARDUINO)
100 AD_LOGD("Activate SDMMC");
101 if (!SD_MMC.setPins(40, 42, 41, -1, -1, -1)) {
102 AD_LOGE("SDMMC setPins failed");
103 }
104 tca9555.digitalWrite(EXIO4, true); // deactivate SD CS
105#else
106 AD_LOGE("SDMMC only supported in Arduino");
107#endif
108 }
109 return rc;
110 }
111
113
114 protected:
116#endif
117
118};
119
122
126
127} // namespace audio_driver
#define EXIO4
Definition ESP32S3AISmartSpeaker.h:17
#define EXIO12
Definition ESP32S3AISmartSpeaker.h:25
#define EXIO9
Definition ESP32S3AISmartSpeaker.h:22
#define EXIO11
Definition ESP32S3AISmartSpeaker.h:24
#define EXIO10
Definition ESP32S3AISmartSpeaker.h:23
#define AD_LOGD(...)
Definition Logger.h:12
#define AD_LOGE(...)
Definition Logger.h:15
Defitintion for audio board pins and an audio driver.
Definition AudioBoard.h:13
All pins for i2s, spi, i2c and other pins.
Definition DriverDeviceInfo.h:20
bool sdmmc_active
Definition DriverDeviceInfo.h:273
GPIOExt gpio
Definition DriverDeviceInfo.h:271
virtual bool begin()
Sets up all pins e.g. by calling pinMode()
Definition DriverDeviceInfo.h:193
bool addI2C(InfoI2C pin)
Definition DriverDeviceInfo.h:56
bool addI2S(InfoI2S pin)
Definition DriverDeviceInfo.h:26
bool addPin(InfoGPIO pin)
Definition DriverDeviceInfo.h:86
bool sd_active
Definition DriverDeviceInfo.h:272
bool addSPI(InfoSPI pin)
Definition DriverDeviceInfo.h:41
void setAltGPIO(API_GPIO &gpioExt, int offset=1000)
Definition GPIOExt.h:62
Pins for ESP32 S3 AI Smart Speaker - use the PinsESP32S3AISmartSpeaker object! We support the TCA9555...
Definition ESP32S3AISmartSpeaker.h:40
PinsESP32S3AISmartSpeakerClass()
Definition ESP32S3AISmartSpeaker.h:42
TCA9555 & getTCA9555()
Definition ESP32S3AISmartSpeaker.h:112
TCA9555 tca9555
Definition ESP32S3AISmartSpeaker.h:115
bool begin() override
Sets up all pins e.g. by calling pinMode()
Definition ESP32S3AISmartSpeaker.h:89
Driver for the TCA9555 I2C I/O expander (header-only).
Definition TCA9555.h:25
bool digitalWrite(GpioPin pin, bool value) override
Set the output state of a pin.
Definition TCA9555.h:72
static PinsESP32S3AISmartSpeakerClass PinsESP32S3AISmartSpeaker
Definition ESP32S3AISmartSpeaker.h:121
static AudioDriverCombined AudioDriverES8311_ES7210(AudioDriverES8311, AudioDriverES7210)
static AudioBoard ESP32S3AISmartSpeaker
Definition ESP32S3AISmartSpeaker.h:124
Namespace for audio driver components.
Definition AudioBoard.h:5
struct audio_driver::SPIClass SPI
SPI pins: In Arduino we initialize the SPI, on other platform we just provide the pin information.
Definition IDriverDeviceInfo.h:76