TMC32_QJB/HID/HID_request.c
2026-04-30 16:23:12 +08:00

111 lines
2.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/********************************************************************************
* Copyright (c) 2016, Beijing Tongfang Microelectroics Co., Ltd.
* All rights reserved.
* Module: HID class response
* Author: Yang Song
* Version: V1.0
* History:
* 2016-09-22 Original version
********************************************************************************/
#include "global.h"
u8 g_bCapsLock=CAPSLOCKOFF; //0 没开; 1开了
u8 g_bNumLock=NUMLOCKOFF; //0 没开; 1开了
/***************************************************************************
* Function: hidSendReportDscrpt
* Description:HID Data processing
* Input: NULL
* Return: NULL
* Other: NULL
**************************************************************************/
void hidSendReportDscrpt(void)
{
if(g_bUsbDevType == USBDEVTYPE_HIDPOS)
{
Memcpy(USBbuf,(u8 *)usbHidPosReportDescriptor,HID_POS_RPT_LEN);
usbEpnTxAll(0,USBbuf,HID_POS_RPT_LEN);
}
else if(g_bUsbDevType == USBDEVTYPE_HIDKBD)
{
Memcpy(USBbuf,(u8 *)usbHidKbdReportDescriptor,HID_KBD_RPT_LEN);
usbEpnTxAll(0,USBbuf,HID_KBD_RPT_LEN);
}
}
/***************************************************************************
* Function: Hid_SendReportDscrpt
* Description:HID Data processing
* Input: NULL
* Return: NULL
* Other: NULL
**************************************************************************/
void hidReportRequest(u8 req)
{
switch(req)
{
case SET_REPORT : hidSetReportRequest(); break;
case GET_REPORT : hidGetReportRequest(); break;
default : break;
}
}
/***************************************************************************
* Function: Hid_SendReportDscrpt
* Description:HID Data processing
* Input: NULL
* Return: NULL
* Other: NULL
**************************************************************************/
void hidGetReportRequest(void)
{
}
/***************************************************************************
* Function: fSet_Report
* Description:HID Data processing
* Input: NULL
* Return: NULL
* Other: NULL
**************************************************************************/
void hidSetReportRequest(void)
{
if(g_bUsbDevType == USBDEVTYPE_HIDKBD)
{
if((st_usbDeviceRequest.wValue & 0xFFFF) == 0x200)
{
while(!EP0STSCXDPKT);
if(g_abUsbEp0Buf[0] & 0x02) //大写
{
g_bCapsLock = CAPSLOCKON;
}
else //小写
{
g_bCapsLock = CAPSLOCKOFF;
}
if(g_abUsbEp0Buf[0] & 0x01) //numlock
{
g_bNumLock = NUMLOCKON;
}
else
{
g_bNumLock = NUMLOCKOFF;
}
return;
}
}
}
//发送小键盘锁定
void SendNumLock(void)
{
memset(g_abUsbEp2Buf,0,8);
g_abUsbEp2Buf[2] = 0x53;
usbEpnTxAll(2,g_abUsbEp2Buf,8);
g_abUsbEp2Buf[2] = 0x00;
usbEpnTxAll(2,g_abUsbEp2Buf,8);
}