arduino-audio-driver
Loading...
Searching...
No Matches
ESP32S3AISmartSpeaker.h
Go to the documentation of this file.
1#pragma once
6
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 // SPI SD: CS is active LOW. Select the card permanently, so that SdFat
93 // works with chipSelect = -1 (SD_CHIP_SELECT_MODE 0). With
94 // SD_CHIP_SELECT_MODE 1 the sketch can toggle EXIO4 via sdCsWrite().
95 if (sd_active) {
96 AD_LOGD("Activate SD CS");
97 tca9555.digitalWrite(EXIO4, false); // activate SD CS (active low)
98 }
99 // activate SDMMC
100 if (sdmmc_active) {
101#if defined(ARDUINO)
102 AD_LOGD("Activate SDMMC");
103 if (!SD_MMC.setPins(40, 42, 41, -1, -1, -1)) {
104 AD_LOGE("SDMMC setPins failed");
105 }
106 tca9555.digitalWrite(EXIO4, true); // SD mode: DAT3/CS must be HIGH
107#else
108 AD_LOGE("SDMMC only supported in Arduino");
109#endif
110 }
111 return rc;
112 }
113
115
116 protected:
118#endif
119
120};
121
124
128
129} // 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
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
DriverDeviceInfo(const DriverDeviceInfo &)=delete
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
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:114
TCA9555 tca9555
Definition ESP32S3AISmartSpeaker.h:117
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
static PinsESP32S3AISmartSpeakerClass PinsESP32S3AISmartSpeaker
Definition ESP32S3AISmartSpeaker.h:123
static AudioDriverCombined AudioDriverES8311_ES7210(AudioDriverES8311, AudioDriverES7210)
static AudioBoard ESP32S3AISmartSpeaker
Definition ESP32S3AISmartSpeaker.h:126
@ PA
Definition DriverCommon.h:348
@ SD
Definition DriverCommon.h:352
@ KEY
Definition DriverCommon.h:351
@ CODEC
Definition DriverCommon.h:353
@ LED
Definition DriverCommon.h:350
@ EXPANDER
Definition DriverCommon.h:358
@ Output
Definition DriverCommon.h:333
@ InputActiveLow
Definition DriverCommon.h:330
Namespace for audio driver components.
Definition AudioBoard.h:5
InfoSPI PinsSPI
Definition IDriverDeviceInfo.h:113
struct audio_driver::SPIClass SPI