enable volume
This commit is contained in:
@@ -14,12 +14,22 @@
|
||||
#include "xua_hid_report.h"
|
||||
#include "user_hid.h"
|
||||
#include "xua_hid.h"
|
||||
unsigned char g_hidData[HID_MAX_DATA_BYTES] = {0U};
|
||||
// DFU_CONTROL_USB_HID related
|
||||
#define HID_BUTTON_REPORT_ID 0x02
|
||||
#define HID_BUTTON_REPORT_BYTES 2
|
||||
#define HID_PASS_REPORT_ID 0x01
|
||||
#define HID_PASS_REPORT_BYTES 64 // 改动原因:修改为64字节(1字节Report ID + 63字节数据),以支持音量和LED状态上报
|
||||
unsigned char g_hidData[HID_BUTTON_REPORT_BYTES] = {HID_BUTTON_REPORT_ID, 0x0};
|
||||
unsigned char g_hidPassData[HID_PASS_REPORT_BYTES] = {HID_PASS_REPORT_ID, 0x0};
|
||||
unsigned char g_hidData_Down[HID_MAX_OUT_BYTES] = {0U};
|
||||
unsigned char last_hidData = 0;
|
||||
unsigned char last_hidPassData = 0;
|
||||
#endif
|
||||
|
||||
void GetADCCounts(unsigned samFreq, int &min, int &mid, int &max);
|
||||
#define BUFFER_SIZE_OUT (1028 >> 2)
|
||||
#define BUFFER_SIZE_IN (1028 >> 2)
|
||||
unsigned long get_reference_time();
|
||||
|
||||
extern unsigned int g_curSamFreqMultiplier;
|
||||
|
||||
@@ -364,9 +374,10 @@ void XUA_Buffer_Ep(
|
||||
while (!hidIsReportDescriptorPrepared())
|
||||
;
|
||||
|
||||
UserHIDInit();
|
||||
|
||||
unsigned hid_ready_flag = 0U;
|
||||
unsigned hid_ready_id = 0U;
|
||||
unsigned hid_ready_id = 1U;
|
||||
XUD_SetReady_In(ep_hid, g_hidData, HID_BUTTON_REPORT_BYTES); // DFU_CONTROL_USB_HID related
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1207,30 +1218,51 @@ void XUA_Buffer_Ep(
|
||||
|
||||
#endif // ifdef IAP
|
||||
|
||||
#if (0 < HID_CONTROLS)
|
||||
default:
|
||||
#if ( 0 < HID_CONTROLS )
|
||||
|
||||
if (!hid_ready_flag)
|
||||
{
|
||||
static unsigned long btn_start_time = 0, pass_start_time = 0;
|
||||
|
||||
for (unsigned id = hidIsReportIdInUse(); id < hidGetReportIdLimit(); id++)
|
||||
{
|
||||
#if (USE_EX3D == 1)
|
||||
if (hidIsChangePending(id))
|
||||
#else
|
||||
if ( hidIsChangePending(id) || !HidIsSetIdleSilenced(id) )
|
||||
#endif
|
||||
{
|
||||
int hidDataLength = (int) UserHIDGetData(id, g_hidData);
|
||||
XUD_SetReady_In(ep_hid, g_hidData, hidDataLength);
|
||||
unsigned long now = get_reference_time();
|
||||
if (id == 2)
|
||||
{
|
||||
if (btn_start_time == 0)
|
||||
{
|
||||
UserReadHIDButtons(&g_hidData[1]);
|
||||
btn_start_time = now;
|
||||
XUD_SetReady_In(ep_hid, g_hidData, HID_BUTTON_REPORT_BYTES);
|
||||
}
|
||||
if (timeafter(now, btn_start_time + 2000000))
|
||||
{
|
||||
g_hidData[1] = 0;
|
||||
XUD_SetReady_In(ep_hid, g_hidData, HID_BUTTON_REPORT_BYTES);
|
||||
hidClearChangePending(id);
|
||||
btn_start_time = 0;
|
||||
}
|
||||
}
|
||||
if (id == 1)
|
||||
{
|
||||
int hidDataLength = (int) UserHIDGetData(id, g_hidPassData);
|
||||
XUD_SetReady_In(ep_hid, g_hidPassData, hidDataLength);
|
||||
// printf("hidDataLength: %d\n", hidDataLength);
|
||||
|
||||
hid_ready_id = id;
|
||||
hid_ready_flag = 1U;
|
||||
break;
|
||||
}
|
||||
hidClearChangePending(id);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
//::
|
||||
|
||||
#endif
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,14 +31,11 @@ typedef struct hidEvent_t {
|
||||
unsigned value;
|
||||
} hidEvent_t;
|
||||
|
||||
#if defined(USE_EX3D)
|
||||
|
||||
#define HID_MAX_DATA_BYTES ( 64 )
|
||||
#else
|
||||
#define HID_MAX_DATA_BYTES ( 4 )
|
||||
#endif
|
||||
#define HID_MAX_OUT_BYTES ( 65 )
|
||||
#define HID_EVENT_INVALID_ID ( 0x100 )
|
||||
|
||||
#define HID_MAX_OUT_BYTES ( 65 )
|
||||
|
||||
/**
|
||||
* \brief Get the data for the next HID Report
|
||||
@@ -56,6 +53,19 @@ typedef struct hidEvent_t {
|
||||
*/
|
||||
size_t UserHIDGetData( const unsigned id, unsigned char hidData[ HID_MAX_DATA_BYTES ]);
|
||||
|
||||
/* These defines relate to the HID report desc - do not mod */
|
||||
#define HID_CONTROL_PLAYPAUSE_SHIFT 0x00
|
||||
#define HID_CONTROL_NEXT_SHIFT 0x01
|
||||
#define HID_CONTROL_PREV_SHIFT 0x02
|
||||
#define HID_CONTROL_VOLUP_SHIFT 0x03
|
||||
#define HID_CONTROL_VOLDN_SHIFT 0x04
|
||||
#define HID_CONTROL_MUTE_SHIFT 0x05
|
||||
|
||||
void UserReadHIDButtons(unsigned char hidData[]);
|
||||
void UserReadHIDPass(unsigned char hidPassData[]);
|
||||
void UserReadHIDLog(unsigned char hidLogData[]);
|
||||
void user_read_hid_status(unsigned char hidPassData[]);
|
||||
|
||||
/**
|
||||
* \brief Initialize HID processing
|
||||
*/
|
||||
|
||||
@@ -99,8 +99,8 @@ set(APP_COMPILER_FLAGS_ex3d_stereo_2k ${SW_USB_AUDIO_FLAGS} -DI2S_CHANS_DAC=2
|
||||
-DSTREAM_FORMAT_INPUT_2_RESOLUTION_BITS=16
|
||||
-DSTREAM_FORMAT_INPUT_3_RESOLUTION_BITS=16
|
||||
-DNUM_EX3D_CHAN_OUT=2
|
||||
-DINPUT_VOLUME_CONTROL=0
|
||||
-DOUTPUT_VOLUME_CONTROL=0
|
||||
-DINPUT_VOLUME_CONTROL=1
|
||||
-DOUTPUT_VOLUME_CONTROL=1
|
||||
-DSTEREO_2K
|
||||
-DHID_CONTROLS=1)
|
||||
|
||||
@@ -121,8 +121,8 @@ set(APP_COMPILER_FLAGS_ex3d_stereo_8k ${SW_USB_AUDIO_FLAGS} -DI2S_CHANS_DAC=2
|
||||
-DSTREAM_FORMAT_INPUT_2_RESOLUTION_BITS=16
|
||||
-DSTREAM_FORMAT_INPUT_3_RESOLUTION_BITS=16
|
||||
-DNUM_EX3D_CHAN_OUT=2
|
||||
-DINPUT_VOLUME_CONTROL=0
|
||||
-DOUTPUT_VOLUME_CONTROL=0
|
||||
-DINPUT_VOLUME_CONTROL=1
|
||||
-DOUTPUT_VOLUME_CONTROL=1
|
||||
-DSTEREO_8K
|
||||
-DHID_CONTROLS=1)
|
||||
|
||||
@@ -139,6 +139,8 @@ set(APP_COMPILER_FLAGS_ex3d_71_game ${SW_USB_AUDIO_FLAGS} -DI2S_CHANS_DAC=2
|
||||
-DNUM_USB_CHAN_IN=0
|
||||
-DNUM_EX3D_CHAN_OUT=2
|
||||
-DMIN_VOLUME=0xE000
|
||||
-DINPUT_VOLUME_CONTROL=1
|
||||
-DOUTPUT_VOLUME_CONTROL=1
|
||||
-DSPATIAL_GAME
|
||||
-DHID_CONTROLS=1)
|
||||
|
||||
|
||||
@@ -1,391 +0,0 @@
|
||||
|
||||
// Copyright 2011-2023 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#include <xs1.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <platform.h>
|
||||
#include <string.h>
|
||||
#include "dnr_dsp_buf.h"
|
||||
#include "aizip_dnr.h"
|
||||
#include "xassert.h"
|
||||
//#include "agc_interface.h"
|
||||
#include "audio_pipeline_dsp.h"
|
||||
//#include "agc_profiles.h"
|
||||
#include <xcore/channel.h>
|
||||
#include <xcore/port.h>
|
||||
#include "xc_ptr.h"
|
||||
|
||||
extern unsigned g_host_os;
|
||||
|
||||
#if AIZIP_DNR == 1
|
||||
// for AGC
|
||||
//static agc_stage_ctx_t DWORD_ALIGNED agc_stage_state = {};
|
||||
|
||||
static unsigned __attribute__((aligned(4))) dsp_dnr_frame_buf[BUF_SLOT_NUM][DSP_CH_NUM][DNR_DSP_FRAME_SIZE];
|
||||
|
||||
unsigned sample_in_buf_slot = 0;
|
||||
unsigned processing_buf_slot = 1;
|
||||
unsigned sample_out_buf_slot = 2;
|
||||
|
||||
//void agc_init_interface(void)
|
||||
//{
|
||||
// agc_init(&agc_stage_state.state, &AGC_PROFILE_ASR);
|
||||
//}
|
||||
|
||||
void dsp_buf_init()
|
||||
{
|
||||
sample_in_buf_slot = 0;
|
||||
sample_out_buf_slot = 1;
|
||||
processing_buf_slot = 2;
|
||||
}
|
||||
|
||||
static void buf_slot_inc(unsigned *buf_slot_input)
|
||||
{
|
||||
if (*buf_slot_input == BUF_SLOT_NUM - 1)
|
||||
{
|
||||
*buf_slot_input = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*buf_slot_input = *buf_slot_input + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void buf_slot_rotate()
|
||||
{
|
||||
buf_slot_inc(&sample_in_buf_slot);
|
||||
buf_slot_inc(&sample_out_buf_slot);
|
||||
buf_slot_inc(&processing_buf_slot);
|
||||
}
|
||||
|
||||
void write_to_sample_in_buf(unsigned data, unsigned index, unsigned ch)
|
||||
{
|
||||
dsp_dnr_frame_buf[sample_in_buf_slot][ch][index] = data;
|
||||
}
|
||||
|
||||
void read_from_sample_out_buf(unsigned *read_data, unsigned index, unsigned ch)
|
||||
{
|
||||
*read_data = dsp_dnr_frame_buf[sample_out_buf_slot][ch][index];
|
||||
}
|
||||
#if (DNR_50MS == 1)
|
||||
int8_t buffer[21416] __attribute__((aligned(4)));
|
||||
int8_t buffer2[31712] __attribute__((aligned(4)));
|
||||
#else
|
||||
int8_t buffer[4208] __attribute__((aligned(4)));
|
||||
int8_t buffer2[31136] __attribute__((aligned(4)));
|
||||
#endif
|
||||
azp_dnr_pram_t pram = {
|
||||
.buffer1 = buffer,
|
||||
.buffer1_size = sizeof(buffer),
|
||||
.buffer2 = buffer2,
|
||||
.buffer2_size = sizeof(buffer2),
|
||||
.sample_rate = 48000};
|
||||
|
||||
//uint32_t get_reference_time();
|
||||
void Aizip_DNR_init()
|
||||
{
|
||||
int sta = AI_DNR_init(&pram);
|
||||
printf("AI_DNR_init: %d\n",sta);
|
||||
}
|
||||
|
||||
int g_dnr_enable = 1;
|
||||
int g_dnr_level = 200;
|
||||
|
||||
// extern void read_flash_data_partition_offset(uint8_t *data_buf, int32_t start, int32_t len);
|
||||
void start_dsp_processing(unsigned samFreq)
|
||||
{
|
||||
uint32_t t0, t1;
|
||||
static uint32_t start = 0;
|
||||
uint8_t data_buf[1024];
|
||||
static int count = 0;
|
||||
// read_flash_data_partition_offset(data_buf, 0, 100);
|
||||
// printf("Timer --> %d \n\n", get_reference_time()-start);
|
||||
float level = -200;
|
||||
|
||||
if (g_dnr_enable == 1) {
|
||||
if (g_dnr_level >= 0 && g_dnr_level <= 200)
|
||||
level = 0 - g_dnr_level;
|
||||
} else
|
||||
level = 0l;
|
||||
|
||||
// printf("level %d \n", level);
|
||||
setNoisy_mix_factor(level);
|
||||
|
||||
start = t0;
|
||||
#if AIZIP_DNR
|
||||
// Aizip_DNR_Processing((int32_t *)&dsp_dnr_frame_buf[processing_buf_slot][0][0]);
|
||||
//new dnr_50ms lib
|
||||
AI_DNR_Processing((int32_t *)&dsp_dnr_frame_buf[processing_buf_slot][0][0]);
|
||||
#if 0
|
||||
printf("\nbefore \n");
|
||||
for (int j = 0; j < 200; j++)
|
||||
{
|
||||
printf("%x ",dsp_dnr_frame_buf[proc essing_buf_slot][0][j]);
|
||||
if (j % 16 == 0)
|
||||
printf("\n");
|
||||
}
|
||||
printf("=================\n sam rate %d \n",samFreq);
|
||||
#endif
|
||||
// t0 = get_reference_time();
|
||||
// Aizip_DNR_Processing((int32_t *)&dsp_dnr_frame_buf[processing_buf_slot][0][0], samFreq);
|
||||
#if 0
|
||||
t1= get_reference_time();
|
||||
printf("================= \nprocess time %d \n\n", t1 - t0);
|
||||
for (int j = 0; j < 200; j++)
|
||||
{
|
||||
printf("%x ",dsp_dnr_frame_buf[processing_buf_slot][0][j]);
|
||||
if (j % 16 == 0)
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
//chanend_t uc_dsp_to_dnr_t0;
|
||||
//tile 0
|
||||
// all GPO should be handled here
|
||||
/* Write HID Report Data into hidData array
|
||||
*
|
||||
* Bits are as follows:
|
||||
* 0: Play/Pause
|
||||
* 1: Scan Next Track
|
||||
* 2: Scan Prev Track
|
||||
* 3: Volume Up
|
||||
* 4: Volume Down
|
||||
* 5: Mute
|
||||
*/
|
||||
|
||||
#define HID_CONTROL_PLAYPAUSE 0x01
|
||||
#define HID_CONTROL_NEXT 0x02
|
||||
#define HID_CONTROL_PREV 0x04
|
||||
#define HID_CONTROL_VOLUP 0x08
|
||||
#define HID_CONTROL_VOLDN 0x10
|
||||
#define HID_CONTROL_MUTE 0x20
|
||||
|
||||
extern void hid_update(unsigned char hid_data);
|
||||
|
||||
#if defined(__XS2A__)
|
||||
/* Note range 0x7FFC8 - 0x7FFFF guarenteed to be untouched by tools */
|
||||
#warning Building xCORE-200 compatible loader
|
||||
#define FLAG_ADDRESS 0x7ffcc
|
||||
#else
|
||||
/* Note range 0xFFFC8 - 0xFFFFF guarenteed to be untouched by tools */
|
||||
#warning Building xcore.ai compatible loader
|
||||
#define FLAG_ADDRESS 0xfffcc
|
||||
#endif
|
||||
|
||||
/* Store Flag to fixed address */
|
||||
void SetRoleSwitchFlag(unsigned x)
|
||||
{
|
||||
asm volatile("stw %0, %1[0]" :: "r"(x), "r"(FLAG_ADDRESS));
|
||||
}
|
||||
enum { OS_WIN = 1, OS_OTHERS = 2 };
|
||||
extern void device_reboot(void);
|
||||
void dnr_dsp_buffer_task(chanend_t cc_dsp_in, chanend_t cc_dsp_eof, chanend_t cc_mic_level)
|
||||
{
|
||||
port_t p_ctrl_keys = XS1_PORT_8C;
|
||||
// port_t p_ctrl_keys2 = XS1_PORT_8D;
|
||||
|
||||
uint32_t port_ctrl_keys = 0, curr_ctrl_keys = 0, last_ctrl_keys = 0, keys_changed = 0;
|
||||
uint32_t port_ctrl_keys2 =0, curr_ctrl_keys2 = 0, last_ctrl_keys2 = 0, keys_changed2 = 0;
|
||||
|
||||
int debounce_cnt = 0;
|
||||
static unsigned isMute = 0;
|
||||
uint8_t tmp = 0;
|
||||
#if (HID_CONTROLS == 1)
|
||||
unsigned hidData0;
|
||||
// int hid_evt_rst = 0;
|
||||
#endif
|
||||
// channel_t cc_mic = chan_alloc();
|
||||
// chanend_t cc_mic_key = cc_mic.end_a;
|
||||
// cc_mic_level = cc_mic.end_b;
|
||||
#if defined (DEBUG_DNR)
|
||||
uint32_t test_in_buf[3][2][DNR_DSP_FRAME_SIZE] = {0};
|
||||
uint32_t test_out_buf[DNR_DSP_FRAME_SIZE] = {0}; //{0x10000000, 0x30000000, 0x50000000, 0x70000000, 0x90000000, 0xB0000000, 0xD0000000, 0xF0000000};
|
||||
#endif
|
||||
uint32_t muted_buf[DNR_DSP_FRAME_SIZE] = {0};
|
||||
dsp_buf_init();
|
||||
//unsigned samFreq = 48000;
|
||||
//int i;
|
||||
//int j;
|
||||
|
||||
printf("AGC and DNR dsp_task started\n");
|
||||
port_enable(p_ctrl_keys);
|
||||
// port_enable(p_ctrl_keys2);
|
||||
port_ctrl_keys = port_in(p_ctrl_keys);
|
||||
// port_ctrl_keys2 = port_in(p_ctrl_keys2);
|
||||
if ((port_ctrl_keys & KEY_MUTE) == 0) {
|
||||
// mute switch on
|
||||
printf("unmuted\n");
|
||||
isMute = 0;
|
||||
// hid_update(HID_CONTROL_MUTE);
|
||||
} else {
|
||||
printf("muted\n");
|
||||
isMute = 1;
|
||||
// hid_update(HID_CONTROL_VOLUP);
|
||||
}
|
||||
// chan_out_byte(cc_mic_level, (uint8_t) isMute);
|
||||
last_ctrl_keys = ((port_ctrl_keys) & KEY_BITS);
|
||||
// last_ctrl_keys2 = ((port_ctrl_keys2) & KEY_PLAY_VOL_UP);
|
||||
last_ctrl_keys ^= KEY_MUTE;
|
||||
|
||||
unsigned host_os = 0;
|
||||
|
||||
while (1) {
|
||||
unsigned buf_size = DNR_DSP_FRAME_SIZE;
|
||||
|
||||
if (isMute) {
|
||||
for (int i = 0; i < DNR_DSP_FRAME_SIZE/FRAME_SIZE; i++){
|
||||
#if !defined (DEBUG_DNR)
|
||||
chan_in_buf_word(cc_dsp_in, (uint32_t *)(&(dsp_dnr_frame_buf[sample_in_buf_slot][0][i*FRAME_SIZE])), FRAME_SIZE);
|
||||
chan_in_buf_word(cc_dsp_in, (uint32_t *)(&(dsp_dnr_frame_buf[sample_in_buf_slot][1][i*FRAME_SIZE])), FRAME_SIZE);
|
||||
#else
|
||||
chan_in_buf_word(cc_dsp_in, (uint32_t *)(&(test_in_buf[sample_in_buf_slot][0][i*FRAME_SIZE])), FRAME_SIZE);
|
||||
chan_in_buf_word(cc_dsp_in, (uint32_t *)(&(test_in_buf[sample_in_buf_slot][1][i*FRAME_SIZE])), FRAME_SIZE);
|
||||
#endif
|
||||
chan_out_buf_word(cc_dsp_in, (const uint32_t *)(&(muted_buf[i*FRAME_SIZE])), FRAME_SIZE);
|
||||
chan_out_buf_word(cc_dsp_in, (const uint32_t *)(&(muted_buf[i*FRAME_SIZE])), FRAME_SIZE);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < DNR_DSP_FRAME_SIZE/FRAME_SIZE; i++){
|
||||
#if !defined (DEBUG_DNR)
|
||||
chan_in_buf_word(cc_dsp_in, (uint32_t *)(&(dsp_dnr_frame_buf[sample_in_buf_slot][0][i*FRAME_SIZE])), FRAME_SIZE);
|
||||
chan_in_buf_word(cc_dsp_in, (uint32_t *)(&(dsp_dnr_frame_buf[sample_in_buf_slot][1][i*FRAME_SIZE])), FRAME_SIZE);
|
||||
chan_out_buf_word(cc_dsp_in, (const uint32_t *)(&(dsp_dnr_frame_buf[sample_out_buf_slot][0][i*FRAME_SIZE])), FRAME_SIZE);
|
||||
chan_out_buf_word(cc_dsp_in, (const uint32_t *)(&(dsp_dnr_frame_buf[sample_out_buf_slot][1][i*FRAME_SIZE])), FRAME_SIZE);
|
||||
#else
|
||||
chan_in_buf_word(cc_dsp_in, (uint32_t *)(&(test_in_buf[sample_in_buf_slot][0][i*FRAME_SIZE])), FRAME_SIZE);
|
||||
chan_in_buf_word(cc_dsp_in, (uint32_t *)(&(test_in_buf[sample_in_buf_slot][1][i*FRAME_SIZE])), FRAME_SIZE);
|
||||
chan_out_buf_word(cc_dsp_in, (const uint32_t *)(&(test_in_buf[sample_in_buf_slot][0][i*FRAME_SIZE])), FRAME_SIZE);
|
||||
chan_out_buf_word(cc_dsp_in, (const uint32_t *)(&(test_in_buf[sample_in_buf_slot][1][i*FRAME_SIZE])), FRAME_SIZE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
// chan_in_buf_word(cc_dsp_in, (uint32_t *)(dsp_dnr_frame_buf[sample_in_buf_slot]), DSP_CH_NUM * DNR_DSP_FRAME_SIZE);
|
||||
// chan_out_buf_word(cc_dsp_out, (const uint32_t *)(dsp_dnr_frame_buf[sample_out_buf_slot]), DSP_CH_NUM * DNR_DSP_FRAME_SIZE);
|
||||
buf_slot_rotate();
|
||||
//cc_dsp_eof <: 1; //finished data transfer of 1 frame, notify dnr_dsp_proc_task to start processing with slot number
|
||||
chan_out_word(cc_dsp_eof, 1);
|
||||
|
||||
// keys polling (on tile0)
|
||||
// loop here every 2.6ms = 128 samples at 48kHz
|
||||
if (debounce_cnt == DEBOUNCE_TIMEOUT) { // 26ms pollint interval
|
||||
#if defined (HOST_OS_DETECTION)
|
||||
GET_SHARED_GLOBAL(host_os, g_host_os);
|
||||
//#if defined (PHATEN_GSV2)
|
||||
#if (AUDIO_CLASS == 1)
|
||||
if (host_os == OS_WIN) {
|
||||
SetRoleSwitchFlag(OS_WIN);
|
||||
delay_milliseconds(10);
|
||||
device_reboot();
|
||||
}
|
||||
#endif
|
||||
#if (AUDIO_CLASS == 2)
|
||||
if (host_os == OS_OTHERS) {
|
||||
SetRoleSwitchFlag(OS_OTHERS);
|
||||
delay_milliseconds(10);
|
||||
device_reboot();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
debounce_cnt = 0;
|
||||
hidData0 = 0;
|
||||
curr_ctrl_keys = (port_in(p_ctrl_keys)) & KEY_BITS;
|
||||
// curr_ctrl_keys2 = (port_in(p_ctrl_keys2)) & KEY_PLAY_VOL_UP;
|
||||
if (curr_ctrl_keys != last_ctrl_keys) {
|
||||
keys_changed = curr_ctrl_keys ^ last_ctrl_keys;
|
||||
tmp = 0;
|
||||
switch (keys_changed) {
|
||||
case KEY_MIC_VOL_DN:
|
||||
case KEY_MIC_VOL_UP:
|
||||
if ((isMute == 0) && ((curr_ctrl_keys & KEY_MIC_VOL_DN) == 0)) {
|
||||
tmp = KEY_MIC_VOL_DN;
|
||||
//chan_out_byte(cc_mic_level, KEY_MIC_VOL_DN);
|
||||
printf("dn\n");
|
||||
} else {
|
||||
if ((isMute == 0) && ((curr_ctrl_keys & KEY_MIC_VOL_UP) == 0)) {
|
||||
tmp = KEY_MIC_VOL_UP;
|
||||
//chan_out_byte(cc_mic_level, KEY_MIC_VOL_UP);
|
||||
printf("up\n");
|
||||
//int ret = i2c_codec_mic_vol_up();
|
||||
//if (ret == 0) printf("ok\n");
|
||||
}
|
||||
}
|
||||
if (tmp) {
|
||||
chan_out_byte(cc_mic_level, tmp);
|
||||
}
|
||||
break;
|
||||
case KEY_MUTE:
|
||||
if ((curr_ctrl_keys & KEY_MUTE) == 0) {
|
||||
// mute switch off
|
||||
//printf("t0 unmuted\n");
|
||||
isMute = 0;
|
||||
chan_out_byte(cc_mic_level, (uint8_t) UNMUTED_MIC);
|
||||
// hidData0 = HID_CONTROL_MUTE;
|
||||
} else {
|
||||
//printf("t0 muted\n");
|
||||
isMute = 1;
|
||||
chan_out_byte(cc_mic_level, (uint8_t) MUTED_MIC);
|
||||
// hidData0 = HID_CONTROL_VOLUP;
|
||||
}
|
||||
// chan_out_byte(cc_mic_level, (uint8_t) isMute);
|
||||
//hidData0 = HID_CONTROL_MUTE;
|
||||
// hid_evt_rst = 1;
|
||||
break;
|
||||
case KEY_PLAY_VOL_DN:
|
||||
if ((curr_ctrl_keys & KEY_PLAY_VOL_DN) == 0) {
|
||||
hidData0 = HID_CONTROL_VOLDN;
|
||||
}
|
||||
//printf("vol down\n");
|
||||
break;
|
||||
case KEY_PLAY_VOL_UP:
|
||||
if ((curr_ctrl_keys & KEY_PLAY_VOL_UP) == 0) {
|
||||
hidData0 = HID_CONTROL_VOLUP;
|
||||
}
|
||||
//printf("vol up\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
hid_update(hidData0);
|
||||
}
|
||||
last_ctrl_keys = curr_ctrl_keys;
|
||||
} else {
|
||||
debounce_cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern unsigned g_samFreq;
|
||||
extern int g_reduct_dep;
|
||||
void flash_setup(void);
|
||||
void Aizip_DNR_init();
|
||||
void dnr_dsp_proc_task(chanend_t cc_dsp_eof)
|
||||
{
|
||||
unsigned processing_slot_pt;
|
||||
unsigned samFreq = 48000;
|
||||
int reduct_dep = 0, old_rd = 0;
|
||||
// timer tmr;
|
||||
// uint32_t start_time, end_time;
|
||||
// int i;
|
||||
#if AIZIP_DNR
|
||||
Aizip_DNR_init();
|
||||
// flash_setup();
|
||||
#endif
|
||||
while(1) {
|
||||
//cc_dsp_eof :> processing_slot_pt;
|
||||
processing_slot_pt = chan_in_word(cc_dsp_eof);
|
||||
// GET_SHARED_GLOBAL(samFreq, g_samFreq);
|
||||
// tmr :> start_time;
|
||||
start_dsp_processing(samFreq);
|
||||
// tmr :> end_time;
|
||||
}
|
||||
}
|
||||
|
||||
#endif //(AIZIP_DNR == 1)
|
||||
|
||||
@@ -57,5 +57,13 @@ void start_dsp_processing(unsigned samFreq);
|
||||
#define MUTED_MIC 0x5A
|
||||
#define UNMUTED_MIC 0xA5
|
||||
|
||||
// 改动原因:添加HID控制命令宏定义,用于button_task中的按键处理(从dnr_dsp_buf.c移到这里,以便dsp.c可以访问)
|
||||
#define HID_CONTROL_PLAYPAUSE 0x01
|
||||
#define HID_CONTROL_NEXT 0x02
|
||||
#define HID_CONTROL_PREV 0x04
|
||||
#define HID_CONTROL_VOLUP 0x00
|
||||
#define HID_CONTROL_VOLDN 0x01
|
||||
#define HID_CONTROL_MUTE 0x20
|
||||
|
||||
#endif //RINGBUFFER_H
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#define DEBUG_PRINT_ENABLE 1
|
||||
#define DEBUG_PRINT_ENABLE 0
|
||||
|
||||
#include <platform.h>
|
||||
#include <xs1.h>
|
||||
@@ -66,6 +66,8 @@ unsigned g_dnr_on_off_t1 = DNR_OFF; // Default DNR off
|
||||
#define MUTE_ON 1
|
||||
#define MUTE_OFF 0
|
||||
unsigned g_mute_on_off_t1 = MUTE_ON;
|
||||
// 改动原因:添加tile0的静音状态全局变量,用于button_task和dnr_dsp_buffer_task之间的静音状态同步
|
||||
unsigned g_mute_on_off_t0 = MUTE_OFF; // tile0默认非静音
|
||||
|
||||
unsigned g_game_mode = 0;
|
||||
|
||||
@@ -672,19 +674,22 @@ void LevelMeter(AUDIO_T AudioData[NUM_USB_CHAN_OUT][FRAME_SIZE])
|
||||
#endif
|
||||
}
|
||||
|
||||
void hid_update(unsigned char hid_data) {
|
||||
// if (hidIsChangePending(0)) return;
|
||||
extern unsigned g_ButtonVal;
|
||||
|
||||
volatile unsigned * reportData = &lastHidData;
|
||||
*reportData = hid_data;
|
||||
hidSetChangePending(0);
|
||||
return;
|
||||
void update_button(unsigned char b)
|
||||
{
|
||||
#if HID_CONTROLS
|
||||
SET_SHARED_GLOBAL(g_ButtonVal, 1 << b);
|
||||
hidSetChangePending(0x2);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (PHATEN_GSV2)
|
||||
#define KEY_POLLING_INTERVAL 10000000L // 100ms polling interval
|
||||
#define HOLD_THRESHOLD 20 // time = HOLD_THRESHOLD * KEY_POLLING_INTERVAL = 2000ms
|
||||
#define KEY_POLLING_INTERVAL 1000000L // 10ms polling interval (改动原因:提高按键响应速度,从100ms改为10ms)
|
||||
#define HOLD_THRESHOLD 200 // time = HOLD_THRESHOLD * KEY_POLLING_INTERVAL = 2000ms (改动原因:KEY_POLLING_INTERVAL改为10ms后,HOLD_THRESHOLD需要改为200以保持2000ms长按时间)
|
||||
// 改动原因:添加LED闪烁相关宏定义,用于长按时直接循环闪烁3次
|
||||
#define BLINK_COUNT 3 // LED闪烁次数:3次
|
||||
#endif
|
||||
@@ -1024,7 +1029,7 @@ void hid_button_task(chanend_t cc_mic_level, chanend_t c_hidRcvData, chanend_t c
|
||||
port_disable(p_leds);
|
||||
hwtimer_free(timer);
|
||||
}
|
||||
#define KEY_POLLING_INTERVAL 10000000L // 100ms polling interval
|
||||
#define KEY_POLLING_INTERVAL 1000000L // 10ms polling interval (改动原因:提高按键响应速度,从100ms改为10ms)
|
||||
void button_task(chanend_t c_hidSendData, chanend_t cc_mic_level, chanend_t c_uac_vol)
|
||||
{
|
||||
hwtimer_t timer = hwtimer_alloc();
|
||||
@@ -1154,12 +1159,15 @@ void button_task(chanend_t c_hidSendData, chanend_t cc_mic_level, chanend_t c_ua
|
||||
port_enable(p_ctrl_keys);
|
||||
port_ctrl_keys = port_in(p_ctrl_keys);
|
||||
if ((port_ctrl_keys & KEY_MUTE) == 0) {
|
||||
// mute switch on
|
||||
// mute switch off (unmuted)
|
||||
debug_printf("unmuted\n");
|
||||
isMute = 0;
|
||||
SET_SHARED_GLOBAL(g_mute_on_off_t0, MUTE_OFF); // 初始化tile0静音状态
|
||||
} else {
|
||||
// mute switch on (muted)
|
||||
debug_printf("muted\n");
|
||||
isMute = 1;
|
||||
SET_SHARED_GLOBAL(g_mute_on_off_t0, MUTE_ON); // 初始化tile0静音状态
|
||||
}
|
||||
|
||||
last_ctrl_keys = ((port_ctrl_keys) & KEY_BITS);
|
||||
@@ -1237,6 +1245,73 @@ void button_task(chanend_t c_hidSendData, chanend_t cc_mic_level, chanend_t c_ua
|
||||
{
|
||||
hwtimer_set_trigger_time(timer, hwtimer_get_time(timer) + KEY_POLLING_INTERVAL);
|
||||
|
||||
// 改动原因:将按键处理逻辑从dnr_dsp_buffer_task合并到button_task,统一管理所有按键事件
|
||||
// 改动原因:按键检测间隔从100ms改为10ms,提高响应速度,每次轮询都检测按键状态
|
||||
hidData0 = 0;
|
||||
curr_ctrl_keys = (port_in(p_ctrl_keys)) & KEY_BITS;
|
||||
|
||||
// 改动原因:使用防抖机制,连续检测到相同状态变化才响应,避免按键抖动
|
||||
if (curr_ctrl_keys != last_ctrl_keys) {
|
||||
debounce_cnt++; // 状态变化计数器递增
|
||||
if (debounce_cnt >= 2) { // 连续2次检测到相同变化(20ms防抖),确认按键状态变化
|
||||
debounce_cnt = 0;
|
||||
keys_changed = curr_ctrl_keys ^ last_ctrl_keys;
|
||||
tmp = 0;
|
||||
switch (keys_changed) {
|
||||
case KEY_MIC_VOL_DN:
|
||||
case KEY_MIC_VOL_UP:
|
||||
// 改动原因:处理麦克风音量按键(仅在非静音状态下处理)
|
||||
if ((isMute == 0) && ((curr_ctrl_keys & KEY_MIC_VOL_DN) == 0)) {
|
||||
tmp = KEY_MIC_VOL_DN;
|
||||
debug_printf("KEY_MIC_VOL_DN pressed\n");
|
||||
} else {
|
||||
if ((isMute == 0) && ((curr_ctrl_keys & KEY_MIC_VOL_UP) == 0)) {
|
||||
tmp = KEY_MIC_VOL_UP;
|
||||
debug_printf("KEY_MIC_VOL_UP pressed\n");
|
||||
}
|
||||
}
|
||||
if (tmp) {
|
||||
chan_out_byte(cc_mic_level, tmp); // 发送到hid_button_task处理
|
||||
}
|
||||
break;
|
||||
case KEY_MUTE:
|
||||
// 改动原因:处理静音按键,更新静音状态并通知hid_button_task和dnr_dsp_buffer_task
|
||||
if ((curr_ctrl_keys & KEY_MUTE) == 0) {
|
||||
// mute switch off (unmuted)
|
||||
isMute = 0;
|
||||
SET_SHARED_GLOBAL(g_mute_on_off_t0, MUTE_OFF); // 更新tile0静音状态
|
||||
chan_out_byte(cc_mic_level, (uint8_t) UNMUTED_MIC);
|
||||
debug_printf("MUTE: unmuted\n");
|
||||
} else {
|
||||
// mute switch on (muted)
|
||||
isMute = 1;
|
||||
SET_SHARED_GLOBAL(g_mute_on_off_t0, MUTE_ON); // 更新tile0静音状态
|
||||
chan_out_byte(cc_mic_level, (uint8_t) MUTED_MIC);
|
||||
debug_printf("MUTE: muted\n");
|
||||
}
|
||||
break;
|
||||
case KEY_PLAY_VOL_DN:
|
||||
// 改动原因:处理播放音量减按键,发送HID控制命令
|
||||
if ((curr_ctrl_keys & KEY_PLAY_VOL_DN) == 0) {
|
||||
debug_printf("KEY_PLAY_VOL_DN pressed\n");
|
||||
update_button(HID_CONTROL_VOLDN); // 更新HID报告
|
||||
}
|
||||
break;
|
||||
case KEY_PLAY_VOL_UP:
|
||||
// 改动原因:处理播放音量增按键,发送HID控制命令
|
||||
if ((curr_ctrl_keys & KEY_PLAY_VOL_UP) == 0) {
|
||||
update_button(HID_CONTROL_VOLDN); // 更新HID报告
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
last_ctrl_keys = curr_ctrl_keys; // 更新上次按键状态
|
||||
}
|
||||
} else {
|
||||
debounce_cnt = 0; // 状态未变化,重置防抖计数器
|
||||
}
|
||||
|
||||
GET_SHARED_GLOBAL(uac_vol, g_uac_vol);
|
||||
if (uac_vol != last_uac_vol) {
|
||||
unsigned conv_vol = (0xffffffff - uac_vol + 1) >> 8;
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
// Copyright 2022 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#ifndef _hid_report_descriptor_h_
|
||||
#define _hid_report_descriptor_h_
|
||||
// Copyright 2021 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XCORE VocalFusion Licence.
|
||||
|
||||
#ifndef __hid_report_descriptor_h__
|
||||
#define __hid_report_descriptor_h__
|
||||
|
||||
#include "xua_hid_report.h"
|
||||
|
||||
#if 0
|
||||
/* Existing static report descriptor kept for reference */
|
||||
#ifdef HID_CONTROLS
|
||||
unsigned char hidReportDescriptor[] =
|
||||
{
|
||||
0x05, 0x0c, /* Usage Page (Consumer Device) */
|
||||
0x09, 0x01, /* Usage (Consumer Control) */
|
||||
0xa1, 0x01, /* Collection (Application) */
|
||||
#ifdef DFU_CONTROL_USB_HID
|
||||
0x85, 0x01, // HID_BUTTON_REPORT_ID // TODO: report ID uses the global definition
|
||||
#endif
|
||||
0x15, 0x00, /* Logical Minimum (0) */
|
||||
0x25, 0x01, /* Logical Maximum (1) */
|
||||
0x09, 0xb0, /* Usage (Play) */
|
||||
@@ -26,8 +31,119 @@ unsigned char hidReportDescriptor[] =
|
||||
0x95, 0x02, /* Report Count (2) */
|
||||
0x81, 0x01, /* Input (Cnst, Ary, Abs) */
|
||||
0xc0 /* End collection */
|
||||
|
||||
#ifdef DFU_CONTROL_USB_HID
|
||||
,0x06, 0x82, 0xff,
|
||||
0x09, 0x01,
|
||||
0xa1, 0x01,
|
||||
0x09, 0x03,
|
||||
0x85, 0x41, // HID_DFU_REPORT_ID // TODO: report ID uses the global definition
|
||||
0x15, 0x00,
|
||||
0x26, 0xff, 0x00,
|
||||
0x75, 0x08,
|
||||
0x95, 0x3f,
|
||||
0x81, 0x02,
|
||||
0x09, 0x04,
|
||||
0x15, 0x00,
|
||||
0x26, 0xff, 0x00,
|
||||
0x75, 0x08,
|
||||
0x95, 0x3f,
|
||||
0x91, 0x02,
|
||||
0xc0
|
||||
#if 0
|
||||
Usage Page (Vendor-Defined 131) 06 82 FF
|
||||
Usage (Vendor-Defined 1) 09 01
|
||||
Collection (Application) A1 01
|
||||
Usage (Vendor-Defined 3) 09 03
|
||||
Report ID (65) 85 41
|
||||
Logical Minimum (0) 15 00
|
||||
Logical Maximum (255) 26 FF 00
|
||||
Report Size (8) 75 08
|
||||
Report Count (63) 95 3F
|
||||
Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02
|
||||
Usage (Vendor-Defined 4) 09 04
|
||||
Logical Minimum (0) 15 00
|
||||
Logical Maximum (255) 26 FF 00
|
||||
Report Size (8) 75 08
|
||||
Report Count (63) 95 3F
|
||||
Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 91 02
|
||||
End Collection C0
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define non-configurable items in the HID Report descriptor.
|
||||
*/
|
||||
static const USB_HID_Short_Item_t hidCollectionApplication = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_COLLECTION),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidCollectionApplication2 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_COLLECTION),
|
||||
.data = { 0x02, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidCollectionEnd = {
|
||||
.header = HID_REPORT_SET_HEADER(0, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_END_COLLECTION),
|
||||
.data = { 0x00, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidInputConstArray = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidInputDataVar = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT),
|
||||
.data = { 0x02, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidInputFeatureVar = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_FEATURE),
|
||||
.data = { 0x01, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximum0 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||
.data = { 0x00, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximum1 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidLogicalMinimum0 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MINIMUM),
|
||||
.data = { 0x00, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidReportCount2 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||
.data = { 0x00, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportCount8 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||
.data = { 0x08, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportSize1 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_SIZE),
|
||||
.data = { 0x01, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidUsageConsumerControl = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.data = { 0x01, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidUsageConsumerControl2 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.data = { 0x02, 0x00 } };
|
||||
|
||||
|
||||
/*
|
||||
* Define the HID Report Descriptor Item, Usage Page, Report ID and length for each HID Report
|
||||
* For internal purposes, a report element with ID of 0 must be included if report IDs are not being used.
|
||||
*/
|
||||
static const USB_HID_Report_Element_t hidReportPageConsumer = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_USAGE_PAGE),
|
||||
.item.data = { USB_HID_USAGE_PAGE_ID_CONSUMER, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0x1, 2, 0, 0 )
|
||||
};
|
||||
|
||||
static const USB_HID_Report_Element_t hidReportPageVendor = {
|
||||
.item.header = HID_REPORT_SET_HEADER(2, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_USAGE_PAGE),
|
||||
.item.data = {0x83, 0xff },
|
||||
.location = HID_REPORT_SET_LOC(0x2, 2, 0, 0 )
|
||||
};
|
||||
|
||||
|
||||
static const USB_HID_Short_Item_t hidUsagePageConsumer = { .header = 0x05, .data = { 0x0C, 0x00 }};
|
||||
|
||||
@@ -53,143 +169,52 @@ static const USB_HID_Short_Item_t hidPassReportCount3 = { .header = 0
|
||||
static const USB_HID_Short_Item_t hidButtonReportCount = { .header = 0x95, .data = { 0x04, 0x00 }};
|
||||
static const USB_HID_Short_Item_t hidUsageVendor = { .header = 0x09, .data = { 0x04, 0x00 }};
|
||||
static const USB_HID_Short_Item_t hidUsageVendor2 = { .header = 0x09, .data = { 0x05, 0x00 }};
|
||||
|
||||
static const USB_HID_Short_Item_t hidInputFeatureVar = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_FEATURE),
|
||||
.data = { 0x01, 0x00 } };
|
||||
|
||||
#if 0//AIZIP_DNR == 1
|
||||
/*
|
||||
* Define non-configurable items in the HID Report descriptor.
|
||||
*/
|
||||
static const USB_HID_Short_Item_t hidCollectionApplication = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_COLLECTION),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidCollectionEnd = {
|
||||
.header = HID_REPORT_SET_HEADER(0, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_END_COLLECTION),
|
||||
.data = { 0x00, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidInputConstArray = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidInputDataVar = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT),
|
||||
.data = { 0x02, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidOutputDataVar = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_OUTPUT),
|
||||
.data = { 0x02, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidOutputConstArray = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_OUTPUT),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportId0 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_ID),
|
||||
.data = { 0x00, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportId1 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_ID),
|
||||
.data = { 0x01, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximum0 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||
.data = { 0x00, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximum1 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidLogicalMinimum0 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MINIMUM),
|
||||
.data = { 0x00, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximum0F = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||
.data = { 0x0f, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximumFF = {
|
||||
.header = HID_REPORT_SET_HEADER(2, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||
.data = { 0xFF, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidReportCount1 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportCount2 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||
.data = { 0x02, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportCount6 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||
.data = { 0x06, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportCount63 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||
.data = { 0x3F, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportSize1 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_SIZE),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportSize8 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_SIZE),
|
||||
.data = { 0x08, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidUsageConsumerControl = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.data = { 0x01, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidUsageLED = { // BUG: potential bug
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.data = { 0x08, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidUsageSpatialControl = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.data = { 0x00, 0x00 } };
|
||||
|
||||
/*
|
||||
* Define the HID Report Descriptor Item, Usage Page, Report ID and length for each HID Report
|
||||
* For internal purposes, a report element with ID of 0 must be included if report IDs are not being used.
|
||||
*/
|
||||
static const USB_HID_Report_Element_t hidReportPageConsumer = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_USAGE_PAGE),
|
||||
.item.data = { USB_HID_USAGE_PAGE_ID_CONSUMER, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC( 0, 1, 0, 0 )
|
||||
};
|
||||
|
||||
static const USB_HID_Report_Element_t hidReportPageSpatial = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_USAGE_PAGE),
|
||||
.item.data = { USB_HID_USAGE_PAGE_ID_GENERIC_DESKTOP, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC( 0, 1, 0, 0 )
|
||||
};
|
||||
static const USB_HID_Short_Item_t hidOutputDataVar = { .header = 0x91, .data = { 0x02, 0x00 }};
|
||||
|
||||
/*
|
||||
* Define configurable items in the HID Report descriptor.
|
||||
*/
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit5 = {
|
||||
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit7 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xE2, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 5)
|
||||
}; // Mute
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit6 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xB4, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 5)
|
||||
}; // rewind
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit5 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xB3, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 5)
|
||||
}; // forward
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit4 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xEA, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 4)
|
||||
}; // Vol-
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit3 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xE9, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 3)
|
||||
}; // Vol+
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit2 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xB6, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 2)
|
||||
}; // Scan Prev
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit1 = {
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit3 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xB5, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 1)
|
||||
}; // Scan Next
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit0 = {
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit2 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xCD, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 0)
|
||||
}; // Play/Pause
|
||||
|
||||
static USB_HID_Report_Element_t hidUsageUnassigned = {
|
||||
}; // Play
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit1 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0x00, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(1, 64, 0, 0)
|
||||
}; //
|
||||
.item.data = { 0xEA, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 4)
|
||||
}; // Vol-
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit0 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xE9, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 3)
|
||||
}; // Vol+
|
||||
|
||||
/*
|
||||
* List the configurable elements in the HID Report descriptor.
|
||||
@@ -201,14 +226,16 @@ static USB_HID_Report_Element_t* const hidConfigurableElements[] = {
|
||||
&hidUsageByte0Bit3,
|
||||
&hidUsageByte0Bit4,
|
||||
&hidUsageByte0Bit5,
|
||||
&hidUsageUnassigned
|
||||
&hidUsageByte0Bit6,
|
||||
&hidUsageByte0Bit7
|
||||
};
|
||||
|
||||
/*
|
||||
* List HID Reports, one per Report ID.
|
||||
* List HID Reports, one per Report ID. This should be a usage page item with the relevant
|
||||
* If not using report IDs - still have one with report ID 0
|
||||
*/
|
||||
static const USB_HID_Report_Element_t* const hidReports[] = {
|
||||
&hidReportPageVendor,
|
||||
&hidReportPageConsumer
|
||||
};
|
||||
|
||||
@@ -216,12 +243,31 @@ static const USB_HID_Report_Element_t* const hidReports[] = {
|
||||
* List all items in the HID Report descriptor.
|
||||
*/
|
||||
static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = {
|
||||
#if 1
|
||||
&(hidReportPageVendor.item),
|
||||
&hidUsageConsumerControl,
|
||||
&hidCollectionApplication,
|
||||
&hidUsageConsumerVendor,
|
||||
&hidPassReportId,
|
||||
&hidLogicalMinimum0,
|
||||
&hidLogicalMaximum2,
|
||||
&hidReportSize,
|
||||
&hidPassReportCount2,
|
||||
&hidInputDataVar,
|
||||
&hidUsageVendor,
|
||||
&hidLogicalMinimum0,
|
||||
&hidLogicalMaximum2,
|
||||
&hidReportSize,
|
||||
&hidPassReportCount,
|
||||
&hidOutputDataVar,
|
||||
&hidUsageVendor2,
|
||||
&hidReportSize,
|
||||
&hidPassReportCount3,
|
||||
&hidInputFeatureVar,
|
||||
&hidCollectionEnd,
|
||||
&(hidReportPageConsumer.item),
|
||||
&hidUsageConsumerControl,
|
||||
&hidCollectionApplication,
|
||||
|
||||
// &hidReportId1,
|
||||
&hidButtonReportId,
|
||||
&hidLogicalMinimum0,
|
||||
&hidLogicalMaximum1,
|
||||
&(hidUsageByte0Bit0.item),
|
||||
@@ -230,228 +276,21 @@ static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = {
|
||||
&(hidUsageByte0Bit3.item),
|
||||
&(hidUsageByte0Bit4.item),
|
||||
&(hidUsageByte0Bit5.item),
|
||||
&(hidUsageByte0Bit6.item),
|
||||
&(hidUsageByte0Bit7.item),
|
||||
&hidReportSize1,
|
||||
&hidReportCount6,
|
||||
&hidReportCount8,
|
||||
&hidInputDataVar,
|
||||
&hidLogicalMaximum0,
|
||||
&hidReportCount2,
|
||||
&hidInputConstArray,
|
||||
|
||||
// LED Output Report
|
||||
&hidUsageLED, //0x05, 0x08, // Usage Page (LED)
|
||||
&hidLogicalMinimum0, //0x15, 0x00, // Logical Minimum (0)
|
||||
&hidLogicalMaximum0F, //0x25, 0x0F, // Logical Minimum (16) - 8 bits */
|
||||
&hidReportSize8, //0x75, 0x08, // Report Size (8 bits)
|
||||
&hidReportCount1, //0x95, 0x01, // Report Count (1)
|
||||
&hidOutputDataVar, //0x91, 0x02, // Output (Data, Var, Abs) - 1 byte for LED control
|
||||
&hidCollectionEnd,
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
&(hidReportPageConsumer.item),
|
||||
&hidUsageConsumerControl,
|
||||
&hidCollectionApplication,
|
||||
&hidReportId1,
|
||||
&hidLogicalMinimum0,
|
||||
&hidLogicalMaximumFF,
|
||||
&(hidUsageUnassigned.item),
|
||||
&hidReportSize8,
|
||||
&hidReportCount63,
|
||||
&hidOutputDataVar,
|
||||
&(hidUsageUnassigned.item),
|
||||
&hidInputDataVar,
|
||||
&hidCollectionEnd
|
||||
#endif
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Define non-configurable items in the HID Report descriptor.
|
||||
*/
|
||||
static const USB_HID_Short_Item_t hidCollectionApplication = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_COLLECTION),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidCollectionEnd = {
|
||||
.header = HID_REPORT_SET_HEADER(0, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_END_COLLECTION),
|
||||
.data = { 0x00, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidInputConstArray = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidInputDataVar = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT),
|
||||
.data = { 0x02, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidOutputDataVar = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_OUTPUT),
|
||||
.data = { 0x02, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidOutputConstArray = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_OUTPUT),
|
||||
.data = { 0x01, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidReportId1 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_ID),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportId24 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_ID),
|
||||
.data = { 0x18, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportId25 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_ID),
|
||||
.data = { 0x19, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximum0 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||
.data = { 0x00, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximum1 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximum0F = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||
.data = { 0x0f, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximumFF = {
|
||||
.header = HID_REPORT_SET_HEADER(2, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||
.data = { 0xFF, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidLogicalMinimum0 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MINIMUM),
|
||||
.data = { 0x00, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidReportCount1 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportCount2 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||
.data = { 0x02, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportCount6 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||
.data = { 0x06, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportCount63 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||
.data = { 0x3F, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportSize1 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_SIZE),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportSize8 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_SIZE),
|
||||
.data = { 0x08, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidUsageConsumerControl = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.data = { 0x01, 0x00 } };
|
||||
|
||||
/*
|
||||
* Define the HID Report Descriptor Item, Usage Page, Report ID and length for each HID Report
|
||||
* For internal purposes, a report element with ID of 0 must be included if report IDs are not being used.
|
||||
*/
|
||||
static const USB_HID_Report_Element_t hidReportPageConsumer = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_USAGE_PAGE),
|
||||
.item.data = { USB_HID_USAGE_PAGE_ID_CONSUMER, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC( 1, 64, 0, 0 )
|
||||
};
|
||||
|
||||
/*
|
||||
* Define configurable items in the HID Report descriptor.
|
||||
*/
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit5 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xE2, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 5)
|
||||
}; // Mute
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit4 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xEA, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 4)
|
||||
}; // Vol-
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit3 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xE9, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 3)
|
||||
}; // Vol+
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit2 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xB6, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 2)
|
||||
}; // Scan Prev
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit1 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xB5, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 1)
|
||||
}; // Scan Next
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit0 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xCD, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 0)
|
||||
}; // Play/Pause
|
||||
|
||||
static USB_HID_Report_Element_t hidUsageUnassigned = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0x00, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(1, 64, 0, 0)
|
||||
}; //
|
||||
|
||||
/*
|
||||
* List the configurable elements in the HID Report descriptor.
|
||||
*/
|
||||
static USB_HID_Report_Element_t* const hidConfigurableElements[] = {
|
||||
// &hidUsageByte0Bit0,
|
||||
// &hidUsageByte0Bit1,
|
||||
// &hidUsageByte0Bit2,
|
||||
// &hidUsageByte0Bit3,
|
||||
// &hidUsageByte0Bit4,
|
||||
// &hidUsageByte0Bit5
|
||||
&hidUsageUnassigned
|
||||
};
|
||||
|
||||
/*
|
||||
* List HID Reports, one per Report ID.
|
||||
* If not using report IDs - still have one with report ID 0
|
||||
*/
|
||||
static const USB_HID_Report_Element_t* const hidReports[] = {
|
||||
&hidReportPageConsumer
|
||||
};
|
||||
|
||||
/*
|
||||
* List all items in the HID Report descriptor.
|
||||
*/
|
||||
static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = {
|
||||
&(hidReportPageConsumer.item),
|
||||
&hidUsageConsumerControl,
|
||||
&hidCollectionApplication,
|
||||
&hidReportId1,
|
||||
&hidLogicalMinimum0,
|
||||
&hidLogicalMaximumFF,
|
||||
&(hidUsageUnassigned.item),
|
||||
&hidReportSize8,
|
||||
&hidReportCount63,
|
||||
&hidOutputDataVar,
|
||||
&(hidUsageUnassigned.item),
|
||||
&hidInputDataVar,
|
||||
&(hidUsageUnassigned.item),
|
||||
&hidInputFeatureVar,
|
||||
|
||||
|
||||
// &hidLogicalMinimum0,
|
||||
// &hidLogicalMaximum1,
|
||||
// &(hidUsageByte0Bit0.item),
|
||||
// &(hidUsageByte0Bit1.item),
|
||||
// &(hidUsageByte0Bit2.item),
|
||||
// &(hidUsageByte0Bit3.item),
|
||||
// &(hidUsageByte0Bit4.item),
|
||||
// &(hidUsageByte0Bit5.item),
|
||||
// &hidReportSize1,
|
||||
// &hidReportCount6,
|
||||
// &hidInputDataVar,
|
||||
// &hidLogicalMaximum0,
|
||||
// &hidReportCount2,
|
||||
// &hidInputConstArray,
|
||||
&hidCollectionEnd
|
||||
};
|
||||
|
||||
#endif // AIZIP_DNR
|
||||
/*
|
||||
* Define the number of HID Reports
|
||||
* Due to XC not supporting designated initializers, this constant has a hard-coded value.
|
||||
* It must equal ( sizeof hidReports / sizeof ( USB_HID_Report_Element_t* ))
|
||||
*/
|
||||
#define HID_REPORT_COUNT ( 1 )
|
||||
#define HID_REPORT_COUNT ( 2 )
|
||||
|
||||
#endif // _hid_report_descriptor_h_
|
||||
#endif // __hid_report_descriptor_h__
|
||||
|
||||
@@ -1,460 +0,0 @@
|
||||
// Copyright 2022 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#ifndef _hid_report_descriptor_h_
|
||||
#define _hid_report_descriptor_h_
|
||||
|
||||
#include "xua_hid_report.h"
|
||||
|
||||
#if 0
|
||||
/* Existing static report descriptor kept for reference */
|
||||
unsigned char hidReportDescriptor[] =
|
||||
{
|
||||
0x05, 0x0c, /* Usage Page (Consumer Device) */
|
||||
0x09, 0x01, /* Usage (Consumer Control) */
|
||||
0xa1, 0x01, /* Collection (Application) */
|
||||
0x15, 0x00, /* Logical Minimum (0) */
|
||||
0x25, 0x01, /* Logical Maximum (1) */
|
||||
0x09, 0xb0, /* Usage (Play) */
|
||||
0x09, 0xb5, /* Usage (Scan Next Track) */
|
||||
0x09, 0xb6, /* Usage (Scan Previous Track) */
|
||||
0x09, 0xe9, /* Usage (Volume Up) */
|
||||
0x09, 0xea, /* Usage (Volume Down) */
|
||||
0x09, 0xe2, /* Usage (Mute) */
|
||||
0x75, 0x01, /* Report Size (1) */
|
||||
0x95, 0x06, /* Report Count (6) */
|
||||
0x81, 0x02, /* Input (Data, Var, Abs) */
|
||||
0x95, 0x02, /* Report Count (2) */
|
||||
0x81, 0x01, /* Input (Cnst, Ary, Abs) */
|
||||
0xc0 /* End collection */
|
||||
};
|
||||
#endif
|
||||
|
||||
#if 1//AIZIP_DNR == 1
|
||||
/*
|
||||
* Define non-configurable items in the HID Report descriptor.
|
||||
*/
|
||||
static const USB_HID_Short_Item_t hidCollectionApplication = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_COLLECTION),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidCollectionEnd = {
|
||||
.header = HID_REPORT_SET_HEADER(0, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_END_COLLECTION),
|
||||
.data = { 0x00, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidInputConstArray = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidInputDataVar = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT),
|
||||
.data = { 0x02, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidOutputDataVar = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_OUTPUT),
|
||||
.data = { 0x02, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidOutputConstArray = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_OUTPUT),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportId0 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_ID),
|
||||
.data = { 0x00, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportId1 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_ID),
|
||||
.data = { 0x01, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximum0 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||
.data = { 0x00, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximum1 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidLogicalMinimum0 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MINIMUM),
|
||||
.data = { 0x00, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximum0F = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||
.data = { 0x0f, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximumFF = {
|
||||
.header = HID_REPORT_SET_HEADER(2, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||
.data = { 0xFF, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidReportCount1 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportCount2 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||
.data = { 0x02, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportCount6 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||
.data = { 0x06, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportCount63 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||
.data = { 0x3F, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportSize1 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_SIZE),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportSize8 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_SIZE),
|
||||
.data = { 0x08, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidUsageConsumerControl = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.data = { 0x01, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidUsageLED = { // BUG: potential bug
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.data = { 0x08, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidUsageSpatialControl = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.data = { 0x00, 0x00 } };
|
||||
|
||||
/*
|
||||
* Define the HID Report Descriptor Item, Usage Page, Report ID and length for each HID Report
|
||||
* For internal purposes, a report element with ID of 0 must be included if report IDs are not being used.
|
||||
*/
|
||||
static const USB_HID_Report_Element_t hidReportPageConsumer = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_USAGE_PAGE),
|
||||
.item.data = { USB_HID_USAGE_PAGE_ID_CONSUMER, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC( 0, 1, 0, 0 )
|
||||
};
|
||||
|
||||
static const USB_HID_Report_Element_t hidReportPageSpatial = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_USAGE_PAGE),
|
||||
.item.data = { USB_HID_USAGE_PAGE_ID_GENERIC_DESKTOP, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC( 0, 1, 0, 0 )
|
||||
};
|
||||
|
||||
|
||||
static const USB_HID_Short_Item_t hidUsagePageConsumer = { .header = 0x05, .data = { 0x0C, 0x00 }};
|
||||
|
||||
static const USB_HID_Short_Item_t hidUsagePageVendor = { .header = 0x06, .data = { 0x82, 0xff }};
|
||||
|
||||
static const USB_HID_Short_Item_t hidUsageConsumerVendor = { .header = 0x09, .data = { 0x03, 0x00 }};
|
||||
|
||||
static const USB_HID_Short_Item_t hidPassReportId = { .header = 0x85, .data = { 0x1, 0x00 }};
|
||||
static const USB_HID_Short_Item_t hidButtonReportId = { .header = 0x85, .data = { 0x2, 0x00 }};
|
||||
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximum2 = { .header = 0x26, .data = { 0xFF, 0x00 }};
|
||||
|
||||
static const USB_HID_Short_Item_t hidReportSize = { .header = 0x75, .data = { 0x08, 0x00 }};
|
||||
#if DEBUG_MEMORY_LOG_ENABLED
|
||||
static const USB_HID_Short_Item_t hidPassReportCount = { .header = 0x95, .data = { 0x3F, 0x00 }};
|
||||
static const USB_HID_Short_Item_t hidPassReportCount2 = { .header = 0x95, .data = { 0x3F, 0x00 }};
|
||||
static const USB_HID_Short_Item_t hidPassReportCount3 = { .header = 0x95, .data = { 0x3f, 0x00 }};
|
||||
#else
|
||||
static const USB_HID_Short_Item_t hidPassReportCount = { .header = 0x95, .data = { 0x3f, 0x00 }};
|
||||
static const USB_HID_Short_Item_t hidPassReportCount2 = { .header = 0x95, .data = { 0x3f, 0x00 }};
|
||||
static const USB_HID_Short_Item_t hidPassReportCount3 = { .header = 0x95, .data = { 0x3f, 0x00 }};
|
||||
#endif
|
||||
static const USB_HID_Short_Item_t hidButtonReportCount = { .header = 0x95, .data = { 0x04, 0x00 }};
|
||||
static const USB_HID_Short_Item_t hidUsageVendor = { .header = 0x09, .data = { 0x04, 0x00 }};
|
||||
static const USB_HID_Short_Item_t hidUsageVendor2 = { .header = 0x09, .data = { 0x05, 0x00 }};
|
||||
static const USB_HID_Short_Item_t hidOutputDataVar = { .header = 0x91, .data = { 0x02, 0x00 }};
|
||||
|
||||
/*
|
||||
* Define configurable items in the HID Report descriptor.
|
||||
*/
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit5 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xE2, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 5)
|
||||
}; // Mute
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit4 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xEA, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 4)
|
||||
}; // Vol-
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit3 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xE9, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 3)
|
||||
}; // Vol+
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit2 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xB6, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 2)
|
||||
}; // Scan Prev
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit1 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xB5, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 1)
|
||||
}; // Scan Next
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit0 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xCD, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 0)
|
||||
}; // Play/Pause
|
||||
|
||||
static USB_HID_Report_Element_t hidUsageUnassigned = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0x00, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(1, 64, 0, 0)
|
||||
}; //
|
||||
|
||||
/*
|
||||
* List the configurable elements in the HID Report descriptor.
|
||||
*/
|
||||
static USB_HID_Report_Element_t* const hidConfigurableElements[] = {
|
||||
&hidUsageByte0Bit0,
|
||||
&hidUsageByte0Bit1,
|
||||
&hidUsageByte0Bit2,
|
||||
&hidUsageByte0Bit3,
|
||||
&hidUsageByte0Bit4,
|
||||
&hidUsageByte0Bit5,
|
||||
&hidUsageUnassigned
|
||||
};
|
||||
|
||||
/*
|
||||
* List HID Reports, one per Report ID.
|
||||
* If not using report IDs - still have one with report ID 0
|
||||
*/
|
||||
static const USB_HID_Report_Element_t* const hidReports[] = {
|
||||
&hidReportPageConsumer
|
||||
};
|
||||
|
||||
/*
|
||||
* List all items in the HID Report descriptor.
|
||||
*/
|
||||
static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = {
|
||||
#if 1
|
||||
&(hidReportPageConsumer.item),
|
||||
&hidUsageConsumerControl,
|
||||
&hidCollectionApplication,
|
||||
|
||||
// &hidReportId1,
|
||||
&hidLogicalMinimum0,
|
||||
&hidLogicalMaximum1,
|
||||
&(hidUsageByte0Bit0.item),
|
||||
&(hidUsageByte0Bit1.item),
|
||||
&(hidUsageByte0Bit2.item),
|
||||
&(hidUsageByte0Bit3.item),
|
||||
&(hidUsageByte0Bit4.item),
|
||||
&(hidUsageByte0Bit5.item),
|
||||
&hidReportSize1,
|
||||
&hidReportCount6,
|
||||
&hidInputDataVar,
|
||||
&hidLogicalMaximum0,
|
||||
&hidReportCount2,
|
||||
&hidInputConstArray,
|
||||
|
||||
// LED Output Report
|
||||
&hidUsageLED, //0x05, 0x08, // Usage Page (LED)
|
||||
&hidLogicalMinimum0, //0x15, 0x00, // Logical Minimum (0)
|
||||
&hidLogicalMaximum0F, //0x25, 0x0F, // Logical Minimum (16) - 8 bits */
|
||||
&hidReportSize8, //0x75, 0x08, // Report Size (8 bits)
|
||||
&hidReportCount1, //0x95, 0x01, // Report Count (1)
|
||||
&hidOutputDataVar, //0x91, 0x02, // Output (Data, Var, Abs) - 1 byte for LED control
|
||||
&hidCollectionEnd,
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
&(hidReportPageConsumer.item),
|
||||
&hidUsageConsumerControl,
|
||||
&hidCollectionApplication,
|
||||
&hidReportId1,
|
||||
&hidLogicalMinimum0,
|
||||
&hidLogicalMaximumFF,
|
||||
&(hidUsageUnassigned.item),
|
||||
&hidReportSize8,
|
||||
&hidReportCount63,
|
||||
&hidOutputDataVar,
|
||||
&(hidUsageUnassigned.item),
|
||||
&hidInputDataVar,
|
||||
&hidCollectionEnd
|
||||
#endif
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Define non-configurable items in the HID Report descriptor.
|
||||
*/
|
||||
static const USB_HID_Short_Item_t hidCollectionApplication = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_COLLECTION),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidCollectionEnd = {
|
||||
.header = HID_REPORT_SET_HEADER(0, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_END_COLLECTION),
|
||||
.data = { 0x00, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidInputConstArray = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidInputDataVar = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_INPUT),
|
||||
.data = { 0x02, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidOutputDataVar = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_OUTPUT),
|
||||
.data = { 0x02, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidOutputConstArray = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_MAIN, HID_REPORT_ITEM_TAG_OUTPUT),
|
||||
.data = { 0x01, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidReportId1 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_ID),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportId24 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_ID),
|
||||
.data = { 0x18, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportId25 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_ID),
|
||||
.data = { 0x19, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximum0 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||
.data = { 0x00, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximum1 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximum0F = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||
.data = { 0x0f, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidLogicalMaximumFF = {
|
||||
.header = HID_REPORT_SET_HEADER(2, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MAXIMUM),
|
||||
.data = { 0xFF, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidLogicalMinimum0 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_LOGICAL_MINIMUM),
|
||||
.data = { 0x00, 0x00 } };
|
||||
|
||||
static const USB_HID_Short_Item_t hidReportCount1 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportCount2 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||
.data = { 0x02, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportCount6 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||
.data = { 0x06, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportCount63 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT),
|
||||
.data = { 0x3F, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportSize1 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_SIZE),
|
||||
.data = { 0x01, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidReportSize8 = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_SIZE),
|
||||
.data = { 0x08, 0x00 } };
|
||||
static const USB_HID_Short_Item_t hidUsageConsumerControl = {
|
||||
.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.data = { 0x01, 0x00 } };
|
||||
|
||||
/*
|
||||
* Define the HID Report Descriptor Item, Usage Page, Report ID and length for each HID Report
|
||||
* For internal purposes, a report element with ID of 0 must be included if report IDs are not being used.
|
||||
*/
|
||||
static const USB_HID_Report_Element_t hidReportPageConsumer = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_USAGE_PAGE),
|
||||
.item.data = { USB_HID_USAGE_PAGE_ID_CONSUMER, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC( 1, 64, 0, 0 )
|
||||
};
|
||||
|
||||
/*
|
||||
* Define configurable items in the HID Report descriptor.
|
||||
*/
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit5 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xE2, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 5)
|
||||
}; // Mute
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit4 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xEA, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 4)
|
||||
}; // Vol-
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit3 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xE9, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 3)
|
||||
}; // Vol+
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit2 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xB6, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 2)
|
||||
}; // Scan Prev
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit1 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xB5, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 1)
|
||||
}; // Scan Next
|
||||
static USB_HID_Report_Element_t hidUsageByte0Bit0 = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0xCD, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(0, 0, 0, 0)
|
||||
}; // Play/Pause
|
||||
|
||||
static USB_HID_Report_Element_t hidUsageUnassigned = {
|
||||
.item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE),
|
||||
.item.data = { 0x00, 0x00 },
|
||||
.location = HID_REPORT_SET_LOC(1, 64, 0, 0)
|
||||
}; //
|
||||
|
||||
/*
|
||||
* List the configurable elements in the HID Report descriptor.
|
||||
*/
|
||||
static USB_HID_Report_Element_t* const hidConfigurableElements[] = {
|
||||
// &hidUsageByte0Bit0,
|
||||
// &hidUsageByte0Bit1,
|
||||
// &hidUsageByte0Bit2,
|
||||
// &hidUsageByte0Bit3,
|
||||
// &hidUsageByte0Bit4,
|
||||
// &hidUsageByte0Bit5
|
||||
&hidUsageUnassigned
|
||||
};
|
||||
|
||||
/*
|
||||
* List HID Reports, one per Report ID.
|
||||
* If not using report IDs - still have one with report ID 0
|
||||
*/
|
||||
static const USB_HID_Report_Element_t* const hidReports[] = {
|
||||
&hidReportPageConsumer
|
||||
};
|
||||
|
||||
/*
|
||||
* List all items in the HID Report descriptor.
|
||||
*/
|
||||
static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = {
|
||||
&(hidReportPageConsumer.item),
|
||||
&hidUsageConsumerControl,
|
||||
&hidCollectionApplication,
|
||||
&hidReportId1,
|
||||
&hidLogicalMinimum0,
|
||||
&hidLogicalMaximum2,
|
||||
&hidReportSize,
|
||||
&hidPassReportCount2,
|
||||
&hidInputDataVar,
|
||||
&hidUsageVendor,
|
||||
&hidLogicalMinimum0,
|
||||
&hidLogicalMaximum2,
|
||||
&hidReportSize,
|
||||
&hidPassReportCount,
|
||||
&hidOutputDataVar,
|
||||
&hidUsageVendor2,
|
||||
&hidReportSize,
|
||||
&hidPassReportCount3,
|
||||
&hidInputFeatureVar,
|
||||
|
||||
|
||||
// &hidLogicalMinimum0,
|
||||
// &hidLogicalMaximum1,
|
||||
// &(hidUsageByte0Bit0.item),
|
||||
// &(hidUsageByte0Bit1.item),
|
||||
// &(hidUsageByte0Bit2.item),
|
||||
// &(hidUsageByte0Bit3.item),
|
||||
// &(hidUsageByte0Bit4.item),
|
||||
// &(hidUsageByte0Bit5.item),
|
||||
// &hidReportSize1,
|
||||
// &hidReportCount6,
|
||||
// &hidInputDataVar,
|
||||
// &hidLogicalMaximum0,
|
||||
// &hidReportCount2,
|
||||
// &hidInputConstArray,
|
||||
&hidCollectionEnd
|
||||
};
|
||||
|
||||
#endif // AIZIP_DNR
|
||||
/*
|
||||
* Define the number of HID Reports
|
||||
* Due to XC not supporting designated initializers, this constant has a hard-coded value.
|
||||
* It must equal ( sizeof hidReports / sizeof ( USB_HID_Report_Element_t* ))
|
||||
*/
|
||||
#define HID_REPORT_COUNT ( 1 )
|
||||
|
||||
#endif // _hid_report_descriptor_h_
|
||||
Reference in New Issue
Block a user