diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f2aa6a1e..fc73742f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -20,6 +20,7 @@ lib_xua Change Log * CHANGE HID report descriptor to use generic events instead of GPI events, to report Key-phrase detection as AC Search, and to report end-call detection as AC Stop + * ADDED: Ability to read or modify vendor and product IDs 0.2.1 ----- diff --git a/lib_xua/api/xua_endpoint0.h b/lib_xua/api/xua_endpoint0.h index ed3ffda2..c741225f 100644 --- a/lib_xua/api/xua_endpoint0.h +++ b/lib_xua/api/xua_endpoint0.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011-2018, XMOS Ltd, All rights reserved +// Copyright (c) 2011-2020, XMOS Ltd, All rights reserved #ifndef _XUA_ENDPOINT0_H_ #define _XUA_ENDPOINT0_H_ @@ -28,5 +28,29 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioCtrl, chanend ?c_mix_ctl,chanend ?c_clk_ctl, chanend ?c_EANativeTransport_ctr, client interface i_dfu ?dfuInterface VENDOR_REQUESTS_PARAMS_DEC_); +/** Function to set the Vendor ID value + * + * \param vid vendor ID value to set +*/ +void XUA_Endpoint0_setVendorId(unsigned short vid); + +/** Function to set the Product ID value + * + * \param pid Product ID value to set +*/ +void XUA_Endpoint0_setProductId(unsigned short pid); + +/** Function to get the Vendor ID value + * + * \return Vendor ID value +*/ +unsigned short XUA_Endpoint0_getVendorId(); + +/** Function to get the Product ID value + * + * \return Product ID value +*/ +unsigned short XUA_Endpoint0_getProductId(); + #endif #endif diff --git a/lib_xua/src/core/endpoint0/xua_endpoint0.c b/lib_xua/src/core/endpoint0/xua_endpoint0.c index 91576287..e62f5fb8 100755 --- a/lib_xua/src/core/endpoint0/xua_endpoint0.c +++ b/lib_xua/src/core/endpoint0/xua_endpoint0.c @@ -1,4 +1,4 @@ -// Copyright (c) 2011-2019, XMOS Ltd, All rights reserved +// Copyright (c) 2011-2020, XMOS Ltd, All rights reserved /** * @brief Implements endpoint zero for an USB Audio 1.0/2.0 device * @author Ross Owen, XMOS Semiconductor @@ -207,6 +207,42 @@ const unsigned g_chanCount_In_HS[INPUT_FORMAT_COUNT] = {HS_STREAM_FORMAT_I XUD_ep ep0_out; XUD_ep ep0_in; +void XUA_Endpoint0_setVendorId(unsigned short vid) { +#if (AUDIO_CLASS == 1) + devDesc_Audio1.idVendor = vid; +#else + devDesc_Audio2.idVendor = vid; +#endif // AUDIO_CLASS == 1} +} + +void XUA_Endpoint0_setProductId(unsigned short pid) { +#if (AUDIO_CLASS == 1) + devDesc_Audio1.idProduct = pid; +#else + devDesc_Audio2.idProduct = pid; +#endif // AUDIO_CLASS == 1} +} + +unsigned short XUA_Endpoint0_getVendorId() { + unsigned short vid; +#if (AUDIO_CLASS == 1) + vid = devDesc_Audio1.idVendor; +#else + vid = devDesc_Audio2.idVendor; +#endif // AUDIO_CLASS == 1} + return vid; +} + +unsigned short XUA_Endpoint0_getProductId() { + unsigned short pid; +#if (AUDIO_CLASS == 1) + pid = devDesc_Audio1.idProduct; +#else + pid = devDesc_Audio2.idProduct; +#endif // AUDIO_CLASS == 1} + return pid; +} + void XUA_Endpoint0_init(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, chanend c_mix_ctl, chanend c_clk_ctl, chanend c_EANativeTransport_ctrl, CLIENT_INTERFACE(i_dfu, dfuInterface) VENDOR_REQUESTS_PARAMS_DEC_) {