Skip to main content

Using I2C Commands to Control reSpeaker XVF3800 USB Mic Array with XIAO ESP32S3

Introduction

This section provides the I2C control command list for the ReSpeaker XVF3800, along with I2C read/write examples and hardware signal-path diagrams for the two operating modes. For an application example of controlling the ReSpeaker XVF3800 via the I2C interface, please refer to the Device Control section.

pir

reSpeaker Hardware Signal Path Diagram

I2S Mode Signal Path

pir

Recording Path

The microphones capture raw data, which is processed by the algorithm modules. The processed data is then read by the host controller via the I2S interface.

Playback Path

In I2S mode, the audio playback path is divided into two routes: Host → XVF3800 → DAC and Host → DAC.

1. Host → XVF3800 → DAC

The host controller sends audio data to the XVF3800 via the I2S interface. The data is processed by the Optional Far DSP block, then re-transmitted to the DAC for playback via the I2S bus.

note

For an application example of playback via this path, please refer to the reSpeaker XVF3800 Record and Playback Audio Using I2S section.

2. Host → DAC

The host controller sends audio data directly to the DAC for playback via the I2S interface, bypassing the XVF3800.

note

For an application example of playback via this path, please refer to the reSpeaker XVF3800 Audio Playback and Volume Control via I2C section.

Control Path

The control path, like the playback path, is divided into two routes:

1. Host → XVF3800 → DAC
  • Host ↔ XVF3800 communication: The host acts as the I2C Master and the XVF3800 acts as the I2C Slave. The host uses I2C to configure the XVF3800's Optional Far DSP, Optional PP, GPIO, and other blocks.
  • XVF3800 ↔ DAC communication: The XVF3800 acts as the I2C Master and the DAC acts as the I2C Slave. The XVF3800 controls the DAC playback via I2C.
2. Host → DAC

The host communicates directly with the DAC. The host uses I2C to directly control the DAC for audio playback and volume control.

USB Mode Signal Path

pir

In USB mode, there is only one data path: Host → XVF3800 → DAC, which is divided into two segments: Host → XVF3800 and XVF3800 → DAC.

  • Host ↔ XVF3800: Communication is via USB. Both the audio data (the raw data captured by the microphones, which is processed by the algorithm modules) and the control data (for configuring the XVF3800's Optional Far DSP, Optional PP, GPIO, and other blocks) are transmitted over USB.

  • XVF3800 ↔ DAC: Communication is via I2C and I2S. The XVF3800 acts as the I2C Master and I2S Master to control the DAC for audio playback.

note

For an application example of playback via this path, please refer to the reSpeaker XVF3800 Control with Python section.

I2C Frame Format

Write Operation

[resid] [cmd] [write_byte_num] [data...]
FieldDescription
residResource ID
cmdCommand ID
write_byte_numNumber of data bytes to write
data...Data bytes to be written

Read Operation (write command first, then read response):

Step 1 (Write): [resid] [cmd | 0x80] [read_len + 1]
Step 2 (Read): [status] [data...]
FieldDescription
cmd|0x80Command ID with the MSB set to 1, indicating a read operation
read_len + 1Expected number of bytes to read (+1 for the status byte)
statusResponse status byte (0 = success, 64 = retry)
data...Returned data bytes
note

For the detailed I2C command list, please refer to the I2C Command List section.

Arduino Read And Write Example

#define XMOS_ADDR 0x2C  // XVF3800 I2C 7-bit Address

Write

void xmos_write_bytes(uint8_t resid, uint8_t cmd, uint8_t *value, uint8_t write_byte_num) {
Wire.beginTransmission(XMOS_ADDR);
Wire.write(resid);
Wire.write(cmd);
Wire.write(write_byte_num);
for (uint8_t i = 0; i < write_byte_num; i++) {
Wire.write(value[i]);
}
Wire.endTransmission();
}

Read

bool xmos_read_bytes(uint8_t resid, uint8_t cmd, uint8_t *buffer, uint8_t read_len, uint8_t *status) {
Wire.beginTransmission(XMOS_ADDR);
Wire.write(resid);
Wire.write(cmd | 0x80);
Wire.write(read_len + 1); // +1 for status byte
uint8_t result = Wire.endTransmission();

if (result != 0) {
Serial.print("I2C Write Error: ");
Serial.println(result);
return false;
}

Wire.requestFrom(XMOS_ADDR, (uint8_t)(read_len + 1));
if (Wire.available() < read_len + 1) {
Serial.println("I2C Read Error: Not enough data received.");
return false;
}

*status = Wire.read(); // First byte is status (0 = success, 64 = retry)
for (uint8_t i = 0; i < read_len; i++) {
buffer[i] = Wire.read();
}

return true;
}

Read Firmware Version Example

#include <Wire.h>

#define XMOS_ADDR 0x2C // XVF3800 I2C 7-bit Address

#define APPLICATION_SERVICER_RESID 48 // ResID = 48 (Application Servicer)
#define VERSION_CMD 0 // CmdID = 0 (VERSION)
#define VERSION_NUM_BYTES 3 // 3 bytes: MAJOR, MINOR, PATCH

void setup() {
Serial.begin(115200);
while (!Serial);
Wire.begin();
delay(1000);
Serial.println("XVF3800 Firmware Version Read Test Starting...");
}

void loop() {
uint8_t version[VERSION_NUM_BYTES] = {0};
uint8_t status = 0xFF;

// Read 3 bytes: [MAJOR] [MINOR] [PATCH]
bool success = xmos_read_bytes(APPLICATION_SERVICER_RESID, VERSION_CMD,
version, VERSION_NUM_BYTES, &status);

if (success && status == 0) {
Serial.print("Firmware Version: v");
Serial.print(version[0]); // MAJOR
Serial.print(".");
Serial.print(version[1]); // MINOR
Serial.print(".");
Serial.println(version[2]); // PATCH
Serial.print(" (Status byte: 0x");
Serial.print(status, HEX);
Serial.println(")");
} else {
Serial.print("Read failed. Status byte: 0x");
Serial.println(status, HEX);
}

delay(2000);
}

bool xmos_read_bytes(uint8_t resid, uint8_t cmd, uint8_t *buffer, uint8_t read_len, uint8_t *status) {
Wire.beginTransmission(XMOS_ADDR);
Wire.write(resid);
Wire.write(cmd | 0x80);
Wire.write(read_len + 1); // +1 for status byte
uint8_t result = Wire.endTransmission();

if (result != 0) {
Serial.print("I2C Write Error: ");
Serial.println(result);
return false;
}

Wire.requestFrom(XMOS_ADDR, (uint8_t)(read_len + 1));
if (Wire.available() < read_len + 1) {
Serial.println("I2C Read Error: Not enough data received.");
return false;
}

*status = Wire.read(); // First byte is status (0 = success, 64 = retry)
for (uint8_t i = 0; i < read_len; i++) {
buffer[i] = Wire.read();
}

return true;
}

Expected Output

pir

note

For an application example of controlling the ReSpeaker XVF3800 via the I2C interface, please refer to the Device Control section.

I2C Command List

ResID List

Servicer NameResIDHexDescription
PP Servicer (Post-Processing)170x11AGC, limiter, noise suppression, echo suppression
GPO Servicer (GPIO/LED/DOA)200x14GPO read/write, LED effect/color/speed/brightness, DOA
AEC Servicer (Acoustic Echo Cancellation)330x21AEC filter, beam, azimuth, RT60
Audio Manager350x23Gain, I2S, channel selection, output routing
Application Servicer (System)480x30Version, reboot, config save, USB bit depth

CmdID List

ResID = 48 — Application Servicer (System Control)

NameCmdIDDirectionData TypeValuesBytesDescription
VERSION0rouint833Firmware version (MAJOR, MINOR, PATCH)
BLD_MSG1rochar5050Build message (build config name)
BLD_HOST2rochar3030CI build host info
BLD_REPO_HASH3rochar4040GIT hash
BLD_MODIFIED4rochar66Whether firmware was modified
BOOT_STATUS5rochar33Boot mode (SPI/JTAG/FLASH)
TEST_CORE_BURN6rwuint811Core stress test (reboots chip)
REBOOT7wouint811Reboot chip, restore default params
USB_BIT_DEPTH8rwuint822USB bit depth (16/24/32), USB Mode only
SAVE_CONFIGURATION9wouint811Save current config to flash
CLEAR_CONFIGURATION10wouint811Clear config, restore defaults
AIC3104_HP_LEVEL11rwuint811Headphone output level [0..9]
AIC3104_LINEOUT_LEVEL12rwuint811Line output level [0..9]

ResID = 20 — GPO Servicer (GPIO and LED Control)

NameCmdIDDirectionData TypeValuesBytesDescription
GPO_READ_VALUES0rouint855Read all GPO pin levels
GPO_WRITE_VALUE1wouint822Set specified GPO pin level
GPO_PORT_PIN_INDEX2rwuint3228GPO port/pin index
GPO_PIN_VAL3wouint833Write specified port pin value
GPO_PIN_ACTIVE_LEVEL4rwuint3214Active level (1=high, 0=low)
LED_EFFECT12rwuint811LED effect (0=off 1=breathing 2=rainbow 3=solid 4=DOA 5=ring)
LED_BRIGHTNESS13rwuint811LED brightness
LED_GAMMIFY14rwuint811Gamma correction (0=off 1=on)
LED_SPEED15rwuint811LED speed
LED_COLOR16rwuint3214LED color (RGB)
LED_DOA_COLOR17rwuint3228DOA mode color (base color + DOA color)
DOA_VALUE18rouint1624DOA angle (0-359) + voice detection flag
LED_RING_COLOR19rwuint321248Ring mode per-LED color

ResID = 33 — AEC Servicer (Acoustic Echo Cancellation)

NameCmdIDDirectionData TypeValuesBytesDescription
AEC_AECPATHCHANGE0roint3214AEC path change detection (0,1)
AEC_HPFONOFF1rwint3214High-pass filter (0=off 1=70Hz 2=125Hz 3=150Hz 4=180Hz)
AEC_AECSILENCELEVEL2rwfloat28Silence threshold [0.0..1.0]
AEC_AECCONVERGED3roint3214AEC converged (0,1)
AEC_AECEMPHASISONOFF4rwint3214Pre/de-emphasis (0=off 1=on 2=on_eq)
AEC_FAR_EXTGAIN5rwfloat14Far-end external gain (dB)
AEC_PCD_COUPLINGI6rwfloat14PCD sensitivity [0.0..1.0]
AEC_PCD_MINTHR7rwfloat14PCD min threshold [0.0..0.02]
AEC_PCD_MAXTHR8rwfloat14PCD max threshold [0.025..0.2]
AEC_RT609rofloat14RT60 reverberation estimate [0.250..0.900] sec
AEC_ASROUTONOFF35rwint3214ASR output switch (0=residual 1=ASR processed)
AEC_ASROUTGAIN36rwfloat14ASR output gain [0.0..1000.0]
AEC_FIXEDBEAMSONOFF37rwint3214Fixed beam mode switch (0,1)
AEC_FIXEDBEAMNOISETHR38rwfloat28Fixed beam noise threshold [0.0..1.0]
SHF_BYPASS70rwuint811AEC bypass
AEC_NUM_MICS71roint3214Number of microphones
AEC_NUM_FARENDS72roint3214Number of far-end references
AEC_MIC_ARRAY_TYPE73roint3214Mic array type (1=linear 2=square)
AEC_MIC_ARRAY_GEO74rofloat1248Mic array geometry (3D XYZ coordinates)
AEC_AZIMUTH_VALUES75roradians416Azimuth (beam1/2/free/auto)
TEST_AEC_DISABLE_CONTROL76wouint3214Disable AEC control (test only)
AEC_CURRENT_IDLE_TIME77rouint3214Current idle time (10ns tick)
AEC_MIN_IDLE_TIME78rouint3214Min idle time (10ns tick)
AEC_RESET_MIN_IDLE_TIME79wouint3214Reset min idle time
AEC_SPENERGY_VALUES80rofloat416Speech energy (beam1/2/free/auto)
AEC_FIXEDBEAMSAZIMUTH_VALUES81rwradians28Fixed beam azimuth
AEC_FIXEDBEAMSELEVATION_VALUES82rwradians28Fixed beam elevation
AEC_FIXEDBEAMSGATING83rwuint811Fixed beam gating switch
SPECIAL_CMD_AEC_FAR_MIC_INDEX90woint3228AEC filter read index (trigger command)
SPECIAL_CMD_AEC_FILTER_COEFF_START_OFFSET91rwint3214Filter coefficient start offset
SPECIAL_CMD_AEC_FILTER_COEFFS92rwfloat1560AEC filter coefficient read/write
SPECIAL_CMD_AEC_FILTER_LENGTH93roint3214AEC filter length
AEC_FILTER_CMD_ABORT94woint3214Abort filter read/write state machine

ResID = 35 — Audio Manager (Audio Management)

NameCmdIDDirectionData TypeValuesBytesDescription
AUDIO_MGR_MIC_GAIN0rwfloat14Microphone gain (before SHF)
AUDIO_MGR_REF_GAIN1rwfloat14Reference gain (before SHF)
AUDIO_MGR_CURRENT_IDLE_TIME2roint3214Current idle time (10ns tick)
AUDIO_MGR_MIN_IDLE_TIME3roint3214Min idle time (10ns tick)
AUDIO_MGR_RESET_MIN_IDLE_TIME4woint3214Reset min idle time
MAX_CONTROL_TIME5roint3214Max control time
RESET_MAX_CONTROL_TIME6woint3214Reset max control time
I2S_CURRENT_IDLE_TIME7roint3214I2S current idle time
I2S_MIN_IDLE_TIME8roint3214I2S min idle time
I2S_RESET_MIN_IDLE_TIME9woint3214Reset I2S idle time
I2S_INPUT_PACKED10rwuint811I2S/USB input packed mode
AUDIO_MGR_SELECTED_AZIMUTHS11roradians28Selected beam azimuth (process DOA + auto-select DOA)
AUDIO_MGR_SELECTED_CHANNELS12rwuint822Selected output channels
AUDIO_MGR_OP_PACKED13rwuint822L/R output packed status
AUDIO_MGR_OP_UPSAMPLE14rwuint822L/R output upsampling status
AUDIO_MGR_OP_L15rwuint822L channel category and source (= OP_L_PK0)
AUDIO_MGR_OP_L_PK016rwuint822L channel packed source 0
AUDIO_MGR_OP_L_PK117rwuint822L channel packed source 1
AUDIO_MGR_OP_L_PK218rwuint822L channel packed source 2
AUDIO_MGR_OP_R19rwuint822R channel category and source (= OP_R_PK0)
AUDIO_MGR_OP_R_PK020rwuint822R channel packed source 0
AUDIO_MGR_OP_R_PK121rwuint822R channel packed source 1
AUDIO_MGR_OP_R_PK222rwuint822R channel packed source 2
AUDIO_MGR_OP_ALL23rwuint81212All L/R packed source settings
I2S_INACTIVE24rouint811I2S active (0=active 1=inactive)
AUDIO_MGR_FAR_END_DSP_ENABLE25rwuint811Far-end DSP switch
AUDIO_MGR_SYS_DELAY26rwint3214Reference signal delay (samples)
I2S_DAC_DSP_ENABLE27rwuint811DAC far-end DSP switch

ResID = 17 — PP Servicer (Post-Processing: AGC/Noise/Echo)

NameCmdIDDirectionData TypeValuesBytesDescription
PP_AGCONOFF10rwint3214AGC switch (0,1)
PP_AGCMAXGAIN11rwfloat14AGC max gain [1.0..1000.0]
PP_AGCDESIREDLEVEL12rwfloat14AGC target power [1e-8..1.0]
PP_AGCGAIN13rwfloat14AGC current gain [1.0..1000.0]
PP_AGCTIME14rwfloat14AGC time constant [0.5..4.0] sec
PP_AGCFASTTIME15rwfloat14AGC fast decay time [0.05..4.0] sec
PP_AGCALPHAFASTGAIN16rwfloat14Fast mode gain threshold [0.0..1000.0]
PP_AGCALPHASLOW17rwfloat14Slow memory parameter [0.0..1.0]
PP_AGCALPHAFAST18rwfloat14Fast memory parameter [0.0..1.0]
PP_LIMITONOFF19rwint3214Limiter switch (0,1)
PP_LIMITPLIMIT20rwfloat14Limiter max power [1e-8..1.0]
PP_MIN_NS21rwfloat14Steady-state noise gain floor [0.0..1.0]
PP_MIN_NN22rwfloat14Non-steady-state noise gain floor [0.0..1.0]
PP_ECHOONOFF23rwint3214Echo suppression switch (0,1)
PP_GAMMA_E24rwfloat14Echo over-subtraction factor [0.0..2.0]
PP_GAMMA_ETAIL25rwfloat14Tail echo over-subtraction factor [0.0..2.0]
PP_GAMMA_ENL26rwfloat14Nonlinear echo over-subtraction factor [0.0..5.0]
PP_NLATTENONOFF27rwint3214Nonlinear echo attenuation switch (0,1)
PP_NLAEC_MODE28rwint3214Nonlinear AEC training mode (0=normal 1=training 2=training2)
PP_MGSCALE29rwfloat312Min gain scale (max,min,cur)
PP_FMIN_SPEINDEX30rwfloat14Double-talk frequency boundary [0.0..7999.0]
PP_DTSENSITIVE31rwint3214Double-talk sensitivity [0..5, 10..15]
PP_ATTNS_MODE32rwint3214Non-speech extra attenuation switch (0,1)
PP_ATTNS_NOMINAL33rwfloat14Nominal speech attenuation [0.0..1.0]
PP_ATTNS_SLOPE34rwfloat14Attenuation slope [0.0..5.0]
PP_CURRENT_IDLE_TIME70rouint3214PP current idle time (10ns tick)
PP_MIN_IDLE_TIME71rouint3214PP min idle time (10ns tick)
PP_RESET_MIN_IDLE_TIME72wouint3214Reset PP min idle time
PP_NL_MODEL_CMD_ABORT94woint3214Abort NL model read/write state machine
PP_EQUALIZATION_CMD_ABORT100woint3214Abort equalizer read/write state machine

Tech Support & Product Discussion

Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.

Loading Comments...