Skip to content

XU316 and MCU Communication Protocol Command Macro Definitions

Document Description

This document provides command macro definitions related to the XU316 and MCU communication protocol, mainly including the following content:

  1. Communication frame format definitions
  2. MCU command data length definitions
  3. Communication protocol command word enumerations
  4. Audio format and type definitions
  5. Command data structure definitions

These macro definitions and data structures are the foundation of XU316-MCU communication. Developers need to correctly understand and use these definitions to implement communication functionality.

Communication Frame Format

Basic Frame Format Definitions

#define FRAME_HEADER_H 0x55
#define FRAME_HEADER_L 0xAA
#define PROTOCOL_VERSION 0x01
#define PROTOCOL_VERSION_RX 0x03

Command Data Length Definitions

XU316 Command Data Length

#define CMD00_XU316_DATA_LEN 0x11 // 0x00 Command: Start boot (boot options)
#define CMD01_XU316_DATA_LEN 0x00 // 0x01 Command: Read product information (60-byte firmware info)
#define CMD02_XU316_DATA_LEN 0x00 // 0x02 Command: Read power-on configuration (14-byte config parameters)
#define CMD03_XU316_DATA_LEN 0x00 // 0x03 Command: Get audio mode (5-byte mode parameters)
#define CMD04_XU316_DATA_LEN 0x00 // 0x04 Command: Get user configuration (14-byte user settings)
#define CMD05_XU316_DATA_LEN 0x15 // 0x05 Command: Boot complete (no data field)

#define CMDF1_XU316_DATA_LEN 0x03 // 0xF1 Command: Version query (3-byte version info)

#define CMD20_XU316_DATA_LEN 0x14 // 0x20 Command: Set volume
#define CMD21_XU316_DATA_LEN 0x00 // 0x21 Command: Audio effect mode
#define CMD22_XU316_DATA_LEN 0x02 // 0x22 Command: Device status query
#define CMD23_XU316_DATA_LEN 0x00 // 0x23 Command: Bluetooth control
#define CMD24_XU316_DATA_LEN 0x02 // 0x24 Command: Send playback volume
#define CMD25_XU316_DATA_LEN 0x01 // 0x25 Command: Send recording volume
#define CMD27_XU316_DATA_LEN 0x00 // 0x27 Command: Special unmute (no data field)
#define CMD28_XU316_DATA_LEN 0x01 // 0x28 Command: Audio format delay setting (1-byte parameter)

#define CMD_HID_TRANSPARENT_DATA_LEN 0x39 // 0xEE Command: HID transparent/OTA upgrade (57 bytes)

MCU Command Data Length

#define CMD00_MCU_DATA_LEN 0x01 // 0x00 Command: Start boot (boot options)
#define CMD01_MCU_DATA_LEN 0x3C // 0x01 Command: Read product information (60-byte firmware info)
#define CMD02_MCU_DATA_LEN 0x0E // 0x02 Command: Read power-on configuration (14-byte config parameters)
#define CMD03_MCU_DATA_LEN 0x05 // 0x03 Command: Get audio mode (5-byte mode parameters)
#define CMD04_MCU_DATA_LEN 0x0E // 0x04 Command: Get user configuration (14-byte user settings)
#define CMD05_MCU_DATA_LEN 0x00 // 0x05 Command: Boot complete (no data field)

#define CMDF1_MCU_DATA_LEN 0x00 // 0xF1 Command: Version query (no data field)

#define CMD20_MCU_DATA_LEN 0x00 // 0x20 Command: Set volume
#define CMD21_MCU_DATA_LEN 0x01 // 0x21 Command: Audio effect mode
#define CMD22_MCU_DATA_LEN 0x00 // 0x22 Command: Device status query
#define CMD23_MCU_DATA_LEN 0x05 // 0x23 Command: Set audio mode
#define CMD24_MCU_DATA_LEN 0x00 // 0x24 Command: Send playback volume
#define CMD25_MCU_DATA_LEN 0x00 // 0x25 Command: Send recording volume
#define CMD27_MCU_DATA_LEN 0x00 // 0x27 Command: Special unmute (no data field)
#define CMD28_MCU_DATA_LEN 0x00 // 0x28 Command: Audio format delay setting (no data field)

#define CMD_HID_TRANSPARENT_MCU_DATA_LEN 0x39 // 0xEE Command: HID transparent/OTA upgrade (57 bytes)

Communication Protocol Command Definitions

Command Word Enumeration

typedef enum
{
    /****** Basic Control Commands (0x00-0x05) ******/
    CMD_STARTUP = 0x00,          // System startup
    CMD_GET_PRODUCT_INFO = 0x01, // Product information query
    CMD_GET_BOOT_CFG = 0x02,     // Power-on configuration read
    CMD_GET_AUD_MODE = 0x03,     // Audio mode get
    CMD_GET_USER_CFG = 0x04,     // User configuration get
    CMD_STARTUP_COMPLETE = 0x05, // Boot complete notification

    CMD_GET_VERSION = 0xF1,        // Version query

    /****** Business Control Commands (0x20-0x2F) ******/
    CMD_REPORT_STATUS = 0x20,   // Status report
    CMD_MEDIA_CONTROL = 0x21,   // Media control
    CMD_SET_PLAY_FORMAT = 0x22, // Audio format setting
    CMD_SET_AUDIO_MODE = 0x23,  // Audio mode setting
    CMD_SET_PLAY_VOL = 0x24,    // Playback volume setting
    CMD_SET_REC_VOL = 0x25,     // Recording volume setting
    CMD_SPECIAL_UNMUTE = 0x27,  // Special unmute
    CMD_SET_AUDIO_FORMAT_DELAY = 0x28, // Audio format delay setting

    CMD_HID_TRANSPARENT = 0xEE, // HID transparent/OTA upgrade command

    CMD_COUNT = CMD_SET_REC_VOL + 1 // Total number of currently supported commands

} mcu_command_t;

Boot Option Enumeration (Bitmask Mode)

Note

Boot Option Enumeration (Bitmask Mode) Uses uint8_t to ensure single-byte storage, supports multiple option combinations

typedef enum
{
    BOOT_OPTION_USE_DEFAULTS = 0x00,      // Use all default configurations
    BOOT_OPTION_UPDATE_BASIC_INFO = 0x01, // Update basic product information (bit0)
    BOOT_OPTION_UPDATE_POWER_CFG = 0x02,  // Update power-on configuration information (bit1)
    BOOT_OPTION_UPDATE_OTHER_CFG = 0x04   // Reserved configuration, currently unused (bit2)
} boot_option_t;

Media Control Enumeration

typedef enum
{
    MEDIA_KEY_VOLUME_UP = 0x00,    // Volume increase
    MEDIA_KEY_VOLUME_DOWN = 0x01,  // Volume decrease
    MEDIA_KEY_PLAY_PAUSE = 0x02,   // Play/Pause
    MEDIA_KEY_NEXT_TRACK = 0x03,   // Next track
    MEDIA_KEY_PREV_TRACK = 0x04,   // Previous track
    MEDIA_KEY_FAST_FORWARD = 0x05, // Fast forward
    MEDIA_KEY_REWIND = 0x06,       // Rewind
    MEDIA_KEY_MUTE = 0x07          // Mute toggle

    // Reserved for expansion (0x08-0xFF reserved for protocol)

} media_control_t;

Audio Format Definitions

Note

Audio Stream Format Enumeration (Compatible with AES67-2020 Standard) Explicitly specifies underlying type as uint8_t to ensure 1-byte storage

Audio Stream Format Enumeration

typedef enum
{
    // PCM Sample Rate Formats (0x00-0x10)
    AUDIO_PCM_44100 = 0x00,
    AUDIO_PCM_48000 = 0x01,
    AUDIO_PCM_88200 = 0x02,
    AUDIO_PCM_96000 = 0x03,
    AUDIO_PCM_176400 = 0x04,
    AUDIO_PCM_192000 = 0x05,
    AUDIO_PCM_352800 = 0x06,
    AUDIO_PCM_384000 = 0x07,
    AUDIO_PCM_705600 = 0x08,
    AUDIO_PCM_768000 = 0x09,
    AUDIO_PCM_1441200 = 0x0A,
    AUDIO_PCM_1536000 = 0x0B,
    AUDIO_PCM_32000 = 0x0C,
    AUDIO_PCM_64000 = 0x0D,
    AUDIO_PCM_128000 = 0x0E,
    AUDIO_PCM_256000 = 0x0F,
    AUDIO_PCM_512000 = 0x10,

    // DSD Formats (0x11-0x15)
    AUDIO_DSD_64 = 0x11,
    AUDIO_DSD_128 = 0x12,
    AUDIO_DSD_256 = 0x13,
    AUDIO_DSD_512 = 0x14,
    AUDIO_DSD_1024 = 0x15,

    // MQA Formats (0x16-0x2D)
    AUDIO_MQA_44100 = 0x16,
    AUDIO_MQA_88200 = 0x17,
    AUDIO_MQA_176400 = 0x18,
    AUDIO_MQA_352800 = 0x19,
    AUDIO_MQA_705600 = 0x1A,
    AUDIO_MQA_1411200 = 0x1B,
    AUDIO_MQA_2822400 = 0x1C,
    AUDIO_MQA_5644800 = 0x1D,

    // -- 48kHz Base Series --
    AUDIO_MQA_48000 = 0x1E,
    AUDIO_MQA_96000 = 0x1F,
    AUDIO_MQA_192000 = 0x20,
    AUDIO_MQA_384000 = 0x21,
    AUDIO_MQA_768000 = 0x22,
    AUDIO_MQA_1536000 = 0x23,
    AUDIO_MQA_3072000 = 0x24,
    AUDIO_MQA_6144000 = 0x25,

    // -- Other Base Frequency Series --
    AUDIO_MQA_64000 = 0x26,
    AUDIO_MQA_128000 = 0x27,
    AUDIO_MQA_256000 = 0x28,
    AUDIO_MQA_512000 = 0x29,
    AUDIO_MQA_1024000 = 0x2A,
    AUDIO_MQA_2048000 = 0x2B,
    AUDIO_MQA_4096000 = 0x2C,
    AUDIO_MQA_8192000 = 0x2D,

    // Special Reserved Value
    AUDIO_NO_USED = 0xFF

} audio_format_t;

Audio Type Enumeration

Note

Audio Type Enumeration (Compatible with AES67-2020 Standard) Explicitly specifies underlying type as uint8_t to ensure 1-byte storage

typedef enum
{
    AUDIO_TYPE_PCM = 0x00,        // PCM standard audio
    AUDIO_TYPE_RESERVE = 0x01,    // Protocol reserved field
    AUDIO_TYPE_MQA = 0x02,        // MQA encoded audio
    AUDIO_TYPE_MQB = 0x03,        // MQB encoded audio (secondary extension)
    AUDIO_TYPE_MQA_STUDIO = 0x04, // MQA Studio master quality
    AUDIO_TYPE_DSD = 0x05         // Direct Stream Digital

    // 0x06-0xFF reserved for future expansion

} audio_type_t;

Command Data Structures

Data Structure Definitions

typedef uint8_t byte_pair[2];
// Command data structure
typedef struct __attribute__((packed))
{
    uint8_t boot_option; // 0x00: Boot option data
    // Product basic information
    uint8_t vid_uac1[2];              // UAC1.0 vendor ID
    uint8_t pid_uac1[2];              // UAC1.0 product ID
    uint8_t vid_uac2[2];              // UAC2.0 vendor ID
    uint8_t pid_uac2[2];              // UAC2.0 product ID
    uint8_t product_manufacturer[16]; // Manufacturer name
    uint8_t product_name[16];         // Product name
    uint8_t product_serial[16];       // Serial number
    uint8_t basic_info_crc[4];        // Basic information CRC32
    // User configuration is power-on configuration information and also application runtime parameters
    uint8_t startup_status; // Startup status
    uint8_t audio_mode[5];
    uint8_t mute_duration[2]; // Mute duration (ms)
    uint8_t mic_volume;       // Microphone volume, also recording volume
    uint8_t dac_l_volume;     // Left channel volume (0-255)
    uint8_t dac_r_volume;     // Right channel volume (0-255)
    uint8_t power_cfg_crc[4]; // Power-on configuration CRC32
    // Application runtime parameters
    uint8_t media_control; // Media control command
    uint8_t audio_format;  // Audio format code
    uint8_t audio_type;    // Audio type code
} mcu_data_t;