forked from PAWPAW-Mirror/lib_xua
add pawpaw hid code
This commit is contained in:
@@ -50,6 +50,10 @@ void XUA_Buffer(
|
||||
#if (HID_CONTROLS)
|
||||
, chanend c_hid
|
||||
#endif
|
||||
#ifdef PAWPAW_INOUTHID
|
||||
, chanend c_hid
|
||||
, chanend c_hid_out
|
||||
#endif//#ifdef PAWPAW_INOUTHID
|
||||
, chanend c_aud
|
||||
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) || defined(__DOXYGEN__)
|
||||
, client interface pll_ref_if i_pll_ref
|
||||
@@ -78,6 +82,10 @@ void XUA_Buffer_Ep(chanend c_aud_out,
|
||||
#if (HID_CONTROLS)
|
||||
, chanend c_hid
|
||||
#endif
|
||||
#ifdef PAWPAW_INOUTHID
|
||||
, chanend c_hid
|
||||
, chanend c_hid_out
|
||||
#endif //#ifdef PAWPAW_INOUTHID
|
||||
#ifdef CHAN_BUFF_CTRL
|
||||
, chanend c_buff_ctrl
|
||||
#endif
|
||||
|
||||
@@ -17,6 +17,12 @@
|
||||
unsigned char g_hidData[HID_MAX_DATA_BYTES] = {0U};
|
||||
#endif
|
||||
|
||||
#ifdef PAWPAW_INOUTHID
|
||||
#include "stdio.h"
|
||||
unsigned char g_hidData_in[PAWPAW_CFG_HID_IN_BUFSIZE] = {0};
|
||||
unsigned char g_hidData_out[PAWPAW_CFG_HID_OUT_BUFSIZE] = {0};
|
||||
#endif//#ifdef PAWPAW_INOUTHID
|
||||
|
||||
void GetADCCounts(unsigned samFreq, int &min, int &mid, int &max);
|
||||
#define BUFFER_SIZE_OUT (1028 >> 2)
|
||||
#define BUFFER_SIZE_IN (1028 >> 2)
|
||||
@@ -103,6 +109,10 @@ void XUA_Buffer(
|
||||
#if (HID_CONTROLS )
|
||||
, chanend c_hid
|
||||
#endif
|
||||
#ifdef PAWPAW_INOUTHID
|
||||
, chanend c_hid
|
||||
, chanend c_hid_out
|
||||
#endif//#ifdef PAWPAW_INOUTHID
|
||||
, chanend c_aud
|
||||
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
||||
, client interface pll_ref_if i_pll_ref
|
||||
@@ -137,6 +147,11 @@ void XUA_Buffer(
|
||||
#if XUA_HID_ENABLED
|
||||
, c_hid
|
||||
#endif
|
||||
|
||||
#ifdef PAWPAW_INOUTHID
|
||||
, c_hid
|
||||
, c_hid_out
|
||||
#endif //#ifdef PAWPAW_INOUTHID
|
||||
#ifdef CHAN_BUFF_CTRL
|
||||
, c_buff_ctrl
|
||||
#endif
|
||||
@@ -187,6 +202,11 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
||||
#if(HID_CONTROLS)
|
||||
, chanend c_hid
|
||||
#endif
|
||||
#ifdef PAWPAW_INOUTHID
|
||||
, chanend c_hid
|
||||
, chanend c_hid_out
|
||||
#endif//#ifdef PAWPAW_INOUTHID
|
||||
|
||||
#ifdef CHAN_BUFF_CTRL
|
||||
, chanend c_buff_ctrl
|
||||
#endif
|
||||
@@ -227,6 +247,12 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
||||
#if XUA_HID_ENABLED
|
||||
XUD_ep ep_hid = XUD_InitEp(c_hid);
|
||||
#endif
|
||||
|
||||
#ifdef PAWPAW_INOUTHID
|
||||
XUD_ep ep_hid = XUD_InitEp(c_hid);
|
||||
XUD_ep ep_hid_out = XUD_InitEp(c_hid_out);//dwj+
|
||||
#endif//#ifdef PAWPAW_INOUTHID
|
||||
|
||||
unsigned u_tmp;
|
||||
unsigned sampleFreq = DEFAULT_FREQ;
|
||||
unsigned masterClockFreq = DEFAULT_MCLK_FREQ;
|
||||
@@ -365,6 +391,11 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
||||
i_pll_ref.toggle();
|
||||
#endif
|
||||
|
||||
#ifdef PAWPAW_INOUTHID
|
||||
XUD_SetReady_In(ep_hid, g_hidData_in, PAWPAW_CFG_HID_IN_BUFSIZE);// 上行
|
||||
XUD_SetReady_Out(ep_hid_out,g_hidData_out);// 下行
|
||||
#endif //#ifdef PAWPAW_INOUTHID
|
||||
|
||||
while(1)
|
||||
{
|
||||
XUD_Result_t result;
|
||||
@@ -898,7 +929,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
||||
#endif
|
||||
|
||||
#if XUA_HID_ENABLED
|
||||
/* HID Report Data */
|
||||
/* HID Report Data */
|
||||
case XUD_SetData_Select(c_hid, ep_hid, result):
|
||||
hid_ready_flag = 0U;
|
||||
unsigned reportTime;
|
||||
@@ -910,6 +941,44 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef PAWPAW_INOUTHID
|
||||
case XUD_SetData_Select(c_hid, ep_hid, result):
|
||||
{
|
||||
// debug_printf("HID IN\n");
|
||||
g_hidData_in[0]=0x01;
|
||||
g_hidData_in[1]=0xc1;
|
||||
g_hidData_in[2]=0xd2;
|
||||
g_hidData_in[3]=0xe3;
|
||||
g_hidData_in[4]=0xf4;
|
||||
g_hidData_in[5]=0x05;
|
||||
g_hidData_in[6]=0x06;
|
||||
g_hidData_in[7]=0x07;
|
||||
|
||||
XUD_SetReady_In(ep_hid, g_hidData_in, PAWPAW_CFG_HID_IN_BUFSIZE);
|
||||
}
|
||||
break;
|
||||
|
||||
#if (HID_OUT_REQUIRED)
|
||||
case XUD_GetData_Select(c_hid_out, ep_hid_out,length, result):
|
||||
{
|
||||
XUD_SetReady_Out(ep_hid_out,g_hidData_out);
|
||||
|
||||
// XMOS 获取到的HID数据
|
||||
// g_hidData_out[0]...g_hidData_out[7]
|
||||
// printf("g_hidData_out %d\n",length);
|
||||
// for (size_t i = 0; i < 5; i++)
|
||||
// {
|
||||
// printf("%x ",g_hidData_out[i]);
|
||||
// }
|
||||
// printf("\n",length);
|
||||
|
||||
}
|
||||
break;
|
||||
#endif //#if (HID_OUT_REQUIRED)
|
||||
|
||||
#endif//#ifdef PAWPAW_INOUTHID
|
||||
|
||||
#ifdef MIDI
|
||||
/* Received word from MIDI thread - Check for ACK or Data */
|
||||
case midi_get_ack_or_data(c_midi, is_ack, datum):
|
||||
|
||||
@@ -450,6 +450,30 @@ static unsigned char hidReportDescriptorPtr[] = {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef PAWPAW_INOUTHID
|
||||
#define hidReportDescriptorLength (sizeof(hidReportDescriptorPtr))
|
||||
static unsigned char hidReportDescriptorPtr[] = {
|
||||
0x05, 0x0c, // HID_USAGE_PAGE (Vendor Defined)
|
||||
0x09, 0x01, // USAGE (Undefined)
|
||||
0xa1, 0x01, // COLLECTION (Application)
|
||||
// Report ID if any
|
||||
0x09, 0x02, // USAGE (Undefined)
|
||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
|
||||
0x75, 0x08, // REPORT_SIZE (8)
|
||||
0x95, PAWPAW_CFG_HID_IN_BUFSIZE, // REPORT_COUNT (report_size)
|
||||
0x81, 0x02, // INPUT (Data,Var,Abs)
|
||||
// Output
|
||||
0x09, 0x03, // USAGE (Undefined)
|
||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
|
||||
0x75, 0x08, // REPORT_SIZE (8)
|
||||
0x95, PAWPAW_CFG_HID_OUT_BUFSIZE, // REPORT_COUNT (report_size)
|
||||
0x91, 0x02, // OUTPUT (Data,Var,Abs)
|
||||
0xc0 // END_COLLECTION
|
||||
};
|
||||
#endif //#ifdef PAWPAW_INOUTHID
|
||||
|
||||
|
||||
void XUA_Endpoint0_init(chanend c_ep0_out, chanend c_ep0_in, NULLABLE_RESOURCE(chanend, c_audioControl),
|
||||
chanend c_mix_ctl, chanend c_clk_ctl, chanend c_EANativeTransport_ctrl, CLIENT_INTERFACE(i_dfu, dfuInterface) VENDOR_REQUESTS_PARAMS_DEC_)
|
||||
|
||||
@@ -565,6 +565,10 @@ int main()
|
||||
#if (XUA_HID_ENABLED)
|
||||
, c_xud_in[ENDPOINT_NUMBER_IN_HID]
|
||||
#endif
|
||||
#ifdef PAWPAW_INOUTHID
|
||||
, c_xud_in[ENDPOINT_NUMBER_IN_HID]
|
||||
, c_xud_out[ENDPOINT_NUMBER_OUT_HID]
|
||||
#endif //#ifdef PAWPAW_INOUTHID
|
||||
, c_mix_out
|
||||
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
||||
, i_pll_ref
|
||||
|
||||
Reference in New Issue
Block a user