/****************************************Copyright (c)**************************************************
** Guangzou ZLG-MCU Development Co.,LTD.
** graduate school
** http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name: Chap_9.c
** Last modified Date: 2005-8-6
** Last Version: V1.0
** Descriptions: chap_9.c, 实现USB1.1协议
** chap_9.c, realize USB1.1 protocol
**------------------------------------------------------------------------------------------------------
** Created by: 郑明远 MingYuan Zheng
** Created date: 2005-8-6
** Version: V1.0
** Descriptions: 初始版本 The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#include "config.h"
#include "USBConfig.h"
#include "USBCI.h"
#include "USBDriver.h"
#include "Chap_9.h"
#include "Descriptor.h"
/* define control transfer structure variable */
CONTROL_XFER ControlData; /* 定义传输控制结构变量 */
/****************************************************************
** Name: get_report
** Function: get report request
*****************************************************************/
void get_report(void)
{
stall_ep0();
}
/****************************************************************
** Name: get_idle
** Function: get_idle request
*****************************************************************/
void get_idle(void)
{
stall_ep0();
}
/****************************************************************
** Name: get_protocol
** Function: get_protocol request
*****************************************************************/
void get_protocol(void)
{
stall_ep0();
}
/****************************************************************
** Name: set_report
** Function: set_report request
*****************************************************************/
void set_report(void)
{
stall_ep0();
}
/****************************************************************
** Name: set_idle
** Function: set_idle request
*****************************************************************/
void set_idle(void)
{
single_transmit(0, 0); /* send zero length packet to host */
}
/****************************************************************
** Name: set_protocol
** Function: set_protocol request
*****************************************************************/
void set_protocol(void)
{
stall_ep0();
}
/****************************************************************
** Entry address of USB HID request Function
*****************************************************************/
void (*HidClassRequest[])(void) =
{
get_report, //0
get_idle, //1
get_protocol, //2
reserved, //3
reserved, //4
reserved, //5
reserved, //6
reserved, //7
reserved, //8
set_report, //9
set_idle, //0A
set_protocol, //0B
reserved, //0C
reserved, //0D
reserved, //0E
reserved //0F
};
/*************************************************************************
** 函数名称: USB 标准设备请求入口地址指针表
** Function: Entry address of USB standard device request Function
**************************************************************************/
void (*StandardDeviceRequest[])(void) =
{
get_status,
clear_feature,
reserved,
set_feature,
reserved,
set_address,
get_descriptor,
reserved,
get_configuration,
set_configuration,
get_interface,
set_interface,
reserved,
reserved,
reserved,
reserved
};
//*************************************************************************
// USB 协议层函数 USB Protocal Function
//*************************************************************************
/*************************************************************************************************
** 函数名称: stall_ep0() Name: stall_ep0()
** 功能描述: 使控制端点处于停止状态 Function: stall logical endpoint 0
*************************************************************************************************/
void stall_ep0(void)
{
USB_SetEndpointStatus(0, 1);
USB_SetEndpointStatus(1, 1);
}
/*************************************************************************************************
** 函数名称: reserved() Name: reserved()
** 功能描述: 保留子程序 Function: reserved function
*************************************************************************************************/
void reserved(void)
{
stall_ep0();
}
/*************************************************************************************************
** 函数名称: init_unconfig() Name: init_unconfig()
** 功能描述: 进入地址状态,禁止 0 除外的所有端点 Function: disable all endpoints except for control endpoint 0
*************************************************************************************************/
void init_unconfig(void)
{
USB_SetEndpointEnable(0);
}
/*************************************************************************************************
** 函数名称: init_config() Name: init_config()
** 功能描述: 配置处理,允许端点收发 Function: enable all endpoints
*************************************************************************************************/
void init_config(void)
{
USB_SetEndpointEnable(1);
}
/*************************************************************************************************
** 函数名称: single_transmit() Name: single_transmit()
** 功能描述: 通过物理端点 1 发送数据 Function: send data by physical endpoint 1
** 输 入: INT8U * buf: 发送数据指针 Input: INT8U * buf: send buffer
INT8U len: 发送数据长度 INT8U len: send data length
** 输 出: 无 Output: NULL
*************************************************************************************************/
void single_transmit(INT8U * buf, INT8U len)
{
/* the len must below the maxpacket size of physical endpoint 1 */
if( len <= EP0_PACKET_SIZE)
{ /* len 必须小于端点的最大包信息长度 */
USB_WriteEndpoint(1, len, buf);
}
}
/*************************************************************************************************
** 函数名称: code_transmit() Name: code_transmit()
** 功能描述: 通过物理端点 1 发送数据 Function: send data by physical endpoint 1
** 输 入: INT8U *pRomData: 发送数据指针 Inptut: INT8U * buf: send buffer
INT16U len: 发送数据长度 INT8U len: send data length(the value can above
EP0_PACKET_SIZE)
** 输 出: 无 Output: NULL
*************************************************************************************************/
void code_transmit(INT8U * pRomData, INT16U len)
{
ControlData.wCount = 0;
if(ControlData.wLength > len)
ControlData.wLength = len; /* 长度要小于len the wLength can't above len */
ControlData.pData = pRomData;
if( ControlData.wLength >= EP0_PACKET_SIZE)
{ /* wLength above MaxPacketSize of physical endpoint 1 */
USB_WriteEndpoint(1, EP0_PACKET_SIZE, ControlData.pData);
ControlData.wCount += EP0_PACKET_SIZE; /* 计数器累加 count number have been sent */
DISABLE();
bEPPflags.bits.control_state = USB_TRANSMIT; /* 标识发送状态 flag transmit state */
ENABLE();
}
else
{
USB_Wr
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
USBHID.rar (32个子文件)
www.pudn.com.txt 218B
USBHID
USB214x
Descriptor.h 12KB
USBCI.c 18KB
Chap_9.h 3KB
USBdma.h 5KB
USBdma.c 13KB
USBCI.h 7KB
USBDriver.c 16KB
USBDriver.h 3KB
Chap_9.c 25KB
Descriptor.c 5KB
USBHAL.h 1KB
USBHAL.c 5KB
USBHID_Data
DebugInFLASH
ObjectCode
USBHID.i32 17KB
TargetDataWindows.tdt 55KB
USBHID.axf 53KB
CWSettingsWindows.stg 3KB
RelInFLASH
TargetDataWindows.tdt 55KB
DebugInRAM
ObjectCode
TargetDataWindows.tdt 56KB
USBHID.axf 53KB
src
config.h 4KB
main.c 6KB
target.h 4KB
target.c 9KB
IRQ.s 3KB
USBConfig.h 2KB
LPC214x.h 27KB
mem_b.scf 1KB
mem_c.scf 1KB
mem_a.scf 1KB
Startup.s 11KB
USBHID.mcp 205KB
共 32 条
- 1
资源评论
邓凌佳
- 粉丝: 65
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功