forked from PAWPAW-Mirror/lib_xua
Add XUA_Endpoint0_setStrTable() function
This commit is contained in:
@@ -41,9 +41,9 @@ void XUA_Endpoint0_setVendorId(unsigned short vid);
|
|||||||
void XUA_Endpoint0_setProductId(unsigned short pid);
|
void XUA_Endpoint0_setProductId(unsigned short pid);
|
||||||
|
|
||||||
|
|
||||||
/** Function to set the Vendor ID value
|
/** Function to set the Vendor string
|
||||||
*
|
*
|
||||||
* \param vid vendor ID value to set
|
* \param vendor_str vendor string to set
|
||||||
*/
|
*/
|
||||||
#ifdef __XC__
|
#ifdef __XC__
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -53,6 +53,11 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/** Function to set the Product string
|
||||||
|
*
|
||||||
|
* \param product_str product string to set
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef __XC__
|
#ifdef __XC__
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@@ -86,21 +91,17 @@ char* XUA_Endpoint0_getProductStr();
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/** Function to get the Vendor ID value
|
/** Function to get the Vendor string
|
||||||
*
|
*
|
||||||
* \return Vendor ID value
|
* \return Vendor string
|
||||||
*/
|
*/
|
||||||
unsigned short XUA_Endpoint0_getVendorId();
|
unsigned short XUA_Endpoint0_getVendorId();
|
||||||
|
|
||||||
/** Function to get the Product ID value
|
/** Function to get the Product string
|
||||||
*
|
*
|
||||||
* \return Product ID value
|
* \return Product string
|
||||||
*/
|
*/
|
||||||
unsigned short XUA_Endpoint0_getProductId();
|
unsigned short XUA_Endpoint0_getProductId();
|
||||||
|
|
||||||
unsigned short XUA_Endpoint0_getBcdDevice();
|
|
||||||
|
|
||||||
void XUA_Endpoint0_setBcdDevice(unsigned short bcdDevice);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -28,6 +28,11 @@
|
|||||||
#if DSD_CHANS_DAC > 0
|
#if DSD_CHANS_DAC > 0
|
||||||
#include "dsd_support.h"
|
#include "dsd_support.h"
|
||||||
#endif
|
#endif
|
||||||
|
#define DEBUG_UNIT XUA_EP0
|
||||||
|
#ifndef DEBUG_PRINT_ENABLE_XUA_EP0
|
||||||
|
#define DEBUG_PRINT_ENABLE_XUA_EP0 1
|
||||||
|
#endif // DEBUG_PRINT_ENABLE_XUA_EP0
|
||||||
|
#include "debug_print.h"
|
||||||
|
|
||||||
#include "xua_usb_params_funcs.h"
|
#include "xua_usb_params_funcs.h"
|
||||||
|
|
||||||
@@ -217,79 +222,74 @@ void XUA_Endpoint0_setVendorId(unsigned short vid) {
|
|||||||
devDesc_Audio2.idVendor = vid;
|
devDesc_Audio2.idVendor = vid;
|
||||||
#endif // AUDIO_CLASS == 1}
|
#endif // AUDIO_CLASS == 1}
|
||||||
}
|
}
|
||||||
#include "print.h"
|
void concatenateAndCopyStrings(char* string1, char* string2, char* string_buffer) {
|
||||||
void copyCombinedStrings(char* string1, char* string2, char* string_buffer) {
|
uint32_t string_size = MIN(strlen(string1), XUA_MAX_STR_LEN-1);
|
||||||
uint32_t string_size = MIN(strlen(string1), MAX_STRING_SIZE);
|
|
||||||
memset(string_buffer, 0, MAX_STRING_SIZE);
|
memset(string_buffer, 0, XUA_MAX_STR_LEN);
|
||||||
memcpy(string_buffer, string1, string_size);
|
memcpy(string_buffer, string1, string_size);
|
||||||
string_size = MIN(strlen(string1)+1, MAX_STRING_SIZE);
|
|
||||||
if (string_size<MAX_STRING_SIZE) {
|
|
||||||
memcpy(string_buffer+strlen(string1), " ", 1);
|
if (string_size==XUA_MAX_STR_LEN-1) {
|
||||||
} else {
|
string_buffer[XUA_MAX_STR_LEN-1] = '\0';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
string_size = MIN(strlen(string1)+1+strlen(string2), MAX_STRING_SIZE);
|
uint32_t total_string_size = MIN(strlen(string1)+strlen(string2), XUA_MAX_STR_LEN-1);
|
||||||
if (string_size>MAX_STRING_SIZE) {
|
if (total_string_size==XUA_MAX_STR_LEN-1) {
|
||||||
memcpy(string_buffer+strlen(string1)+1, string2, MAX_STRING_SIZE-strlen(string1)-1);
|
string_size = XUA_MAX_STR_LEN-1-strlen(string1);
|
||||||
} else {
|
} else {
|
||||||
memcpy(string_buffer+strlen(string1)+1, string2, strlen(string2));
|
string_size = strlen(string1);
|
||||||
}
|
}
|
||||||
|
memcpy(string_buffer+strlen(string1), string2, string_size);
|
||||||
|
string_buffer[total_string_size] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
void XUA_Endpoint0_setStrTable() {
|
||||||
|
// update Vendor string
|
||||||
|
concatenateAndCopyStrings(g_vendor_str, "", g_strTable.vendorStr);
|
||||||
|
#if (AUDIO_CLASS == 2)
|
||||||
|
concatenateAndCopyStrings(g_vendor_str, " Clock Selector", g_strTable.clockSelectorStr);
|
||||||
|
concatenateAndCopyStrings(g_vendor_str, " Internal Clock", g_strTable.internalClockSourceStr);
|
||||||
|
#endif
|
||||||
|
#if SPDIF_RX
|
||||||
|
concatenateAndCopyStrings(g_vendor_str, " S/PDIF Clock", g_strTable.spdifClockSourceStr);
|
||||||
|
#endif
|
||||||
|
#if ADAT_RX
|
||||||
|
concatenateAndCopyStrings(g_vendor_str, " ADAT Clock", g_strTable.adatClockSourceStr);
|
||||||
|
#endif
|
||||||
|
#if (XUA_DFU_EN == 1)
|
||||||
|
concatenateAndCopyStrings(g_vendor_str, " DFU", g_strTable.dfuStr);
|
||||||
|
#endif
|
||||||
|
#ifdef USB_CONTROL_DESCS
|
||||||
|
concatenateAndCopyStrings(g_vendor_str, " Control", g_strTable.ctrlStr);
|
||||||
|
#endif
|
||||||
|
#ifdef MIDI
|
||||||
|
concatenateAndCopyStrings(g_vendor_str, " MIDI Out", g_strTable.midiOutStr);
|
||||||
|
concatenateAndCopyStrings(g_vendor_str, " MIDI In", g_strTable.midiInStr);
|
||||||
|
#endif
|
||||||
|
// update product string
|
||||||
|
#if (AUDIO_CLASS_FALLBACK) || (AUDIO_CLASS == 1)
|
||||||
|
concatenateAndCopyStrings(g_product_str, "", g_strTable.productStr_Audio1);
|
||||||
|
concatenateAndCopyStrings(g_product_str, "", g_strTable.outputInterfaceStr_Audio1);
|
||||||
|
concatenateAndCopyStrings(g_product_str, "", g_strTable.inputInterfaceStr_Audio1);
|
||||||
|
concatenateAndCopyStrings(g_product_str, "", g_strTable.usbInputTermStr_Audio1);
|
||||||
|
concatenateAndCopyStrings(g_product_str, "", g_strTable.usbOutputTermStr_Audio1);
|
||||||
|
#elif (AUDIO_CLASS == 2)
|
||||||
|
concatenateAndCopyStrings(g_product_str, "", g_strTable.productStr_Audio2);
|
||||||
|
concatenateAndCopyStrings(g_product_str, "", g_strTable.outputInterfaceStr_Audio2);
|
||||||
|
concatenateAndCopyStrings(g_product_str, "", g_strTable.inputInterfaceStr_Audio2);
|
||||||
|
concatenateAndCopyStrings(g_product_str, "", g_strTable.usbInputTermStr_Audio2);
|
||||||
|
concatenateAndCopyStrings(g_product_str, "", g_strTable.usbOutputTermStr_Audio2);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void XUA_Endpoint0_setVendorStr(char* vendor_str) {
|
void XUA_Endpoint0_setVendorStr(char* vendor_str) {
|
||||||
uint32_t string_size = MIN(strlen(vendor_str), MAX_STRING_SIZE);
|
debug_printf("XUA_Endpoint0_setVendorStr() with string %s", vendor_str);
|
||||||
|
concatenateAndCopyStrings(vendor_str, "", g_vendor_str);
|
||||||
memset(g_strTable.vendorStr, 0, MAX_STRING_SIZE);
|
|
||||||
memcpy(g_strTable.vendorStr, vendor_str, string_size);
|
|
||||||
#if (AUDIO_CLASS == 2)
|
|
||||||
copyCombinedStrings(g_strTable.clockSelectorStr, vendor_str, "Clock Selector");
|
|
||||||
copyCombinedStrings(g_strTable.internalClockSourceStr, vendor_str, "Internal Clock");
|
|
||||||
#endif
|
|
||||||
#if SPDIF_RX
|
|
||||||
copyCombinedStrings(g_strTable.spdifClockSourceStr, vendor_str, "S/PDIF Clock");
|
|
||||||
#endif
|
|
||||||
#if ADAT_RX
|
|
||||||
copyCombinedStrings(g_strTable.adatClockSourceStr, vendor_str, "ADAT Clock");
|
|
||||||
#endif
|
|
||||||
#if (XUA_DFU_EN == 1)
|
|
||||||
copyCombinedStrings(g_strTable.dfuStr, vendor_str, "DFU");
|
|
||||||
#endif
|
|
||||||
#ifdef USB_CONTROL_DESCS
|
|
||||||
copyCombinedStrings(g_strTable.ctrlStr, vendor_str, "Control");
|
|
||||||
#endif
|
|
||||||
#ifdef MIDI
|
|
||||||
copyCombinedStrings(g_strTable.midiOutStr, vendor_str, "MIDI Out");
|
|
||||||
copyCombinedStrings(g_strTable.midiInStr, vendor_str, "MIDI In");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XUA_Endpoint0_setProductStr(char* product_str) {
|
void XUA_Endpoint0_setProductStr(char* product_str) {
|
||||||
uint32_t string_size = MIN(strlen(product_str), MAX_STRING_SIZE);
|
debug_printf("XUA_Endpoint0_setProductStr() with string %s", product_str);
|
||||||
#if (AUDIO_CLASS_FALLBACK) || (AUDIO_CLASS == 1)
|
concatenateAndCopyStrings(product_str, "", g_product_str);
|
||||||
memset(g_strTable.productStr_Audio1, 0, MAX_STRING_SIZE);
|
|
||||||
memset(g_strTable.outputInterfaceStr_Audio1, 0, MAX_STRING_SIZE);
|
|
||||||
memset(g_strTable.inputInterfaceStr_Audio1, 0, MAX_STRING_SIZE);
|
|
||||||
memset(g_strTable.usbInputTermStr_Audio1, 0, MAX_STRING_SIZE);
|
|
||||||
memset(g_strTable.usbOutputTermStr_Audio1, 0, MAX_STRING_SIZE);
|
|
||||||
|
|
||||||
memcpy(g_strTable.productStr_Audio1, product_str, string_size);
|
|
||||||
memcpy(g_strTable.outputInterfaceStr_Audio1, product_str, string_size);
|
|
||||||
memcpy(g_strTable.inputInterfaceStr_Audio1, product_str, string_size);
|
|
||||||
memcpy(g_strTable.usbInputTermStr_Audio1, product_str, string_size);
|
|
||||||
memcpy(g_strTable.usbOutputTermStr_Audio1, product_str, string_size);
|
|
||||||
#elif (AUDIO_CLASS == 2)
|
|
||||||
memset(g_strTable.productStr_Audio2, 0, MAX_STRING_SIZE);
|
|
||||||
memset(g_strTable.outputInterfaceStr_Audio2, 0, MAX_STRING_SIZE);
|
|
||||||
memset(g_strTable.inputInterfaceStr_Audio2, 0, MAX_STRING_SIZE);
|
|
||||||
memset(g_strTable.usbInputTermStr_Audio2, 0, MAX_STRING_SIZE);
|
|
||||||
memset(g_strTable.usbOutputTermStr_Audio2, 0, MAX_STRING_SIZE);
|
|
||||||
|
|
||||||
memcpy(g_strTable.productStr_Audio1, product_str, string_size);
|
|
||||||
memcpy(g_strTable.outputInterfaceStr_Audio2, product_str, string_size);
|
|
||||||
memcpy(g_strTable.inputInterfaceStr_Audio2, product_str, string_size);
|
|
||||||
memcpy(g_strTable.usbInputTermStr_Audio2, product_str, string_size);
|
|
||||||
memcpy(g_strTable.usbOutputTermStr_Audio2, product_str, string_size);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char* XUA_Endpoint0_getVendorStr() {
|
char* XUA_Endpoint0_getVendorStr() {
|
||||||
@@ -356,6 +356,8 @@ void XUA_Endpoint0_init(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioCont
|
|||||||
ep0_out = XUD_InitEp(c_ep0_out);
|
ep0_out = XUD_InitEp(c_ep0_out);
|
||||||
ep0_in = XUD_InitEp(c_ep0_in);
|
ep0_in = XUD_InitEp(c_ep0_in);
|
||||||
|
|
||||||
|
XUA_Endpoint0_setStrTable();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Dont need to init globals.. */
|
/* Dont need to init globals.. */
|
||||||
/* Init tables for volumes (+ 1 for master) */
|
/* Init tables for volumes (+ 1 for master) */
|
||||||
|
|||||||
@@ -20,15 +20,18 @@
|
|||||||
#include "iap2.h" /* Defines iAP EA Native Transport protocol name */
|
#include "iap2.h" /* Defines iAP EA Native Transport protocol name */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_STRING_SIZE (32)
|
|
||||||
|
|
||||||
#define APPEND_VENDOR_STR(x) VENDOR_STR" "#x
|
#define APPEND_VENDOR_STR(x) VENDOR_STR" "#x
|
||||||
|
|
||||||
#define APPEND_PRODUCT_STR_A2(x) PRODUCT_STR_A2 " "#x
|
#define APPEND_PRODUCT_STR_A2(x) PRODUCT_STR_A2 " "#x
|
||||||
|
|
||||||
#define APPEND_PRODUCT_STR_A1(x) PRODUCT_STR_A1 " "#x
|
#define APPEND_PRODUCT_STR_A1(x) PRODUCT_STR_A1 " "#x
|
||||||
|
|
||||||
#define STR_TABLE_ENTRY(name) char name[MAX_STRING_SIZE]
|
#define STR_TABLE_ENTRY(name) char * name
|
||||||
|
|
||||||
|
// XUA_DESCR_EMPTY_STRING is used in the g_strTable to set the maximum size of the table entries
|
||||||
|
#define XUA_DESCR_EMPTY_STRING "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||||
|
// The value below must match the length of XUA_DESCR_EMPTY_STRING.
|
||||||
|
#define XUA_MAX_STR_LEN (32)
|
||||||
|
|
||||||
#define ISO_EP_ATTRIBUTES_ASYNCH 0x05 //ISO, ASYNCH, DATA EP
|
#define ISO_EP_ATTRIBUTES_ASYNCH 0x05 //ISO, ASYNCH, DATA EP
|
||||||
#define ISO_EP_ATTRIBUTES_ADAPTIVE 0x09 //ISO, ADAPTIVE, DATA EP
|
#define ISO_EP_ATTRIBUTES_ADAPTIVE 0x09 //ISO, ADAPTIVE, DATA EP
|
||||||
@@ -319,42 +322,42 @@ typedef struct
|
|||||||
StringDescTable_t g_strTable =
|
StringDescTable_t g_strTable =
|
||||||
{
|
{
|
||||||
.langID = "\x09\x04", /* US English */
|
.langID = "\x09\x04", /* US English */
|
||||||
.vendorStr = VENDOR_STR,
|
.vendorStr = XUA_DESCR_EMPTY_STRING,//VENDOR_STR,
|
||||||
.serialStr = "",
|
.serialStr = "",
|
||||||
#if (AUDIO_CLASS == 2)
|
#if (AUDIO_CLASS == 2)
|
||||||
.productStr_Audio2 = PRODUCT_STR_A2,
|
.productStr_Audio2 = XUA_DESCR_EMPTY_STRING,
|
||||||
.outputInterfaceStr_Audio2 = APPEND_PRODUCT_STR_A2(),
|
.outputInterfaceStr_Audio2 = XUA_DESCR_EMPTY_STRING,
|
||||||
.inputInterfaceStr_Audio2 = APPEND_PRODUCT_STR_A2(),
|
.inputInterfaceStr_Audio2 = XUA_DESCR_EMPTY_STRING,
|
||||||
.usbInputTermStr_Audio2 = APPEND_PRODUCT_STR_A2(),
|
.usbInputTermStr_Audio2 = XUA_DESCR_EMPTY_STRING,
|
||||||
.usbOutputTermStr_Audio2 = APPEND_PRODUCT_STR_A2(),
|
.usbOutputTermStr_Audio2 = XUA_DESCR_EMPTY_STRING,
|
||||||
#endif
|
#endif
|
||||||
#if (AUDIO_CLASS_FALLBACK) || (AUDIO_CLASS == 1)
|
#if (AUDIO_CLASS_FALLBACK) || (AUDIO_CLASS == 1)
|
||||||
|
|
||||||
.productStr_Audio1 = PRODUCT_STR_A1,
|
.productStr_Audio1 = XUA_DESCR_EMPTY_STRING,
|
||||||
.outputInterfaceStr_Audio1 = APPEND_PRODUCT_STR_A1(),
|
.outputInterfaceStr_Audio1 = XUA_DESCR_EMPTY_STRING,
|
||||||
.inputInterfaceStr_Audio1 = APPEND_PRODUCT_STR_A1(),
|
.inputInterfaceStr_Audio1 = XUA_DESCR_EMPTY_STRING,
|
||||||
.usbInputTermStr_Audio1 = APPEND_PRODUCT_STR_A1(),
|
.usbInputTermStr_Audio1 = XUA_DESCR_EMPTY_STRING,
|
||||||
.usbOutputTermStr_Audio1 = APPEND_PRODUCT_STR_A1(),
|
.usbOutputTermStr_Audio1 = XUA_DESCR_EMPTY_STRING,
|
||||||
#endif
|
#endif
|
||||||
#if (AUDIO_CLASS == 2)
|
#if (AUDIO_CLASS == 2)
|
||||||
.clockSelectorStr = APPEND_VENDOR_STR(Clock Selector),
|
.clockSelectorStr = XUA_DESCR_EMPTY_STRING,
|
||||||
.internalClockSourceStr = APPEND_VENDOR_STR(Internal Clock),
|
.internalClockSourceStr = XUA_DESCR_EMPTY_STRING,
|
||||||
#if SPDIF_RX
|
#if SPDIF_RX
|
||||||
.spdifClockSourceStr = APPEND_VENDOR_STR(S/PDIF Clock),
|
.spdifClockSourceStr = XUA_DESCR_EMPTY_STRING,
|
||||||
#endif
|
#endif
|
||||||
#if ADAT_RX
|
#if ADAT_RX
|
||||||
.adatClockSourceStr = APPEND_VENDOR_STR(ADAT Clock),
|
.adatClockSourceStr = XUA_DESCR_EMPTY_STRING,
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if (XUA_DFU_EN == 1)
|
#if (XUA_DFU_EN == 1)
|
||||||
.dfuStr = APPEND_VENDOR_STR(DFU),
|
.dfuStr = XUA_DESCR_EMPTY_STRING,
|
||||||
#endif
|
#endif
|
||||||
#ifdef USB_CONTROL_DESCS
|
#ifdef USB_CONTROL_DESCS
|
||||||
.ctrlStr = APPEND_VENDOR_STR(Control),
|
.ctrlStr = XUA_DESCR_EMPTY_STRING,
|
||||||
#endif
|
#endif
|
||||||
#ifdef MIDI
|
#ifdef MIDI
|
||||||
.midiOutStr = APPEND_VENDOR_STR(MIDI Out),
|
.midiOutStr = XUA_DESCR_EMPTY_STRING,
|
||||||
.midiInStr = APPEND_VENDOR_STR(MIDI In),
|
.midiInStr = XUA_DESCR_EMPTY_STRING,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "chanstrings.h"
|
#include "chanstrings.h"
|
||||||
@@ -401,6 +404,12 @@ StringDescTable_t g_strTable =
|
|||||||
.iAP_EANativeTransport_InterfaceStr = IAP2_EA_NATIVE_TRANS_PROTOCOL_NAME,
|
.iAP_EANativeTransport_InterfaceStr = IAP2_EA_NATIVE_TRANS_PROTOCOL_NAME,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
char g_vendor_str[XUA_MAX_STR_LEN] = VENDOR_STR;
|
||||||
|
#if (AUDIO_CLASS == 2)
|
||||||
|
char g_product_str[XUA_MAX_STR_LEN] = PRODUCT_STR_A2;
|
||||||
|
#else
|
||||||
|
char g_product_str[XUA_MAX_STR_LEN] = PRODUCT_STR_A1;
|
||||||
|
#endif
|
||||||
|
|
||||||
/***** Device Descriptors *****/
|
/***** Device Descriptors *****/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user