日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁 > 單片機(jī) > 單片機(jī)
[導(dǎo)讀]#ifndef __USBCFG_H__#define __USBCFG_H__//#define USB_IF_NUM 1#define USB_MAX_PACKET0 64#define USB_DMA_EP 0x00000000//盡量不要是能太多時間//這里每一個事件都代表著一個回調(diào)函數(shù),使能了該事件就需要實現(xiàn)相

#ifndef __USBCFG_H__

#define __USBCFG_H__

//#define USB_IF_NUM 1

#define USB_MAX_PACKET0 64

#define USB_DMA_EP 0x00000000

//盡量不要是能太多時間

//這里每一個事件都代表著一個回調(diào)函數(shù),使能了該事件就需要實現(xiàn)相應(yīng)的回調(diào)函數(shù)

#define USB_EP_EVENT 0x0003 //哪些端點需要實現(xiàn)中斷處理函數(shù),一位代表一個端點

#define USB_CONFIGURE_EVENT 1 //usb配置事件

#define USB_HID_IF_NUM 0 //usb hid使用端點 第幾個接口

#define USB_DEBUG 0

#if USB_DEBUG

#define usb_debug_printf(format,args...) printf(format,##args) //變參宏定義

#else

#define usb_debug_printf(x,...) while(0);

#endif

#endif

#ifndef __USBUSER_H__

#define __USBUSER_H__

#include "usbhw.h"

//hid報告長度

#define HID_REPORT_NUM 1

//hid中斷端點地址

#define HID_EP_IN 0x81

#define HID_EP_OUT 0X01

/* USB回調(diào)方法 */

extern void USB_Power_Event(BOOL power);

extern void USB_Reset_Event(void);

extern void USB_Suspend_Event(void);

extern void USB_Resume_Event(void);

extern void USB_WakeUp_Event(void);

extern void USB_SOF_Event(void);

extern void USB_Error_Event(U32 error);

/* usb端點終端回調(diào)函數(shù)類型定義 */

#define USB_EVT_SETUP 1 /* setup包 */

#define USB_EVT_OUT 2 /* OUT 包 */

#define USB_EVT_IN 3 /* IN 包 */

#define USB_EVT_OUT_NAK 4 /* NACK OUT 包 */

#define USB_EVT_IN_NAK 5 /* NACK IN 包 */

#define USB_EVT_OUT_STALL 6 /* 忽略 out包 */

#define USB_EVT_IN_STALL 7 /* 忽略 in包 */

/* USB端點事件回調(diào)期(方法數(shù)組) */

extern void(*const USB_P_EP[16])(U32 event);

/* USB端點回調(diào)方法 */

extern void USB_EndPoint0(U32 event);//最重要的函數(shù),處理USB枚舉相關(guān)事件

extern void USB_EndPoint1(U32 event);

extern void USB_EndPoint2(U32 event);

extern void USB_EndPoint3(U32 event);

extern void USB_EndPoint4(U32 event);

extern void USB_EndPoint5(U32 event);

extern void USB_EndPoint6(U32 event);

extern void USB_EndPoint7(U32 event);

extern void USB_EndPoint8(U32 event);

extern void USB_EndPoint9(U32 event);

extern void USB_EndPoint10(U32 event);

extern void USB_EndPoint11(U32 event);

extern void USB_EndPoint12(U32 event);

extern void USB_EndPoint13(U32 event);

extern void USB_EndPoint14(U32 event);

extern void USB_EndPoint15(U32 event);

/* USB枚舉過程內(nèi)核調(diào)用事件 */

extern void USB_Configure_Event(void);

extern void USB_Interface_Event(void);

extern void USB_Feature_Event(void);

#endif

#include "usbuser.h"

#include "usbep1.h"

/*

* USB Set Configuration Event Callback

* Called automatically on USB Set Configuration Request

*/

#if USB_CONFIGURE_EVENT

void USB_Configure_Event(void)

{

u8 Buf[4]={0,0,0,0};

if(USB_Configuration)

{/* Check if USB is configured */

USB_WriteEP(HID_EP_IN,Buf,sizeof(Buf));

}

}

#endif

//宏展開為USB_EndPointx()類型的函數(shù)

#define P_EP(n) ((USB_EP_EVENT & (1 << (n))) ? USB_EndPoint##n : NULL)

/* USB端點中斷處理的回調(diào)函數(shù) */

void(*const USB_P_EP[16])(U32 event)=

{ P_EP(0),//使用宏

P_EP(1),

P_EP(2),

P_EP(3),

P_EP(4),

P_EP(5),

P_EP(6),

P_EP(7),

P_EP(8),

P_EP(9),

P_EP(10),

P_EP(11),

P_EP(12),

P_EP(13),

P_EP(14),

P_EP(15),

};

//端點1中斷的回調(diào)函數(shù)

void USB_EndPoint1(U32 event)

{

switch(event)

{

caseUSB_EVT_IN:

usb_ep1_in_process();

//GetInReport();

//USB_WriteEP(HID_EP_IN, &InReport, sizeof(InReport));

break;

caseUSB_EVT_OUT:

usb_ep1_out_process();

break;

}

}

void USB_EndPoint2(U32 event)

{

}

void USB_EndPoint3(U32 event)

{

}

void USB_EndPoint4(U32 event)

{

}

void USB_EndPoint5(U32 event)

{

}

void USB_EndPoint6(U32 event)

{

}

void USB_EndPoint7(U32 event)

{

}

void USB_EndPoint8(U32 event)

{

}

void USB_EndPoint9(U32 event)

{

}

void USB_EndPoint10(U32 event)

{

}

void USB_EndPoint11(U32 event)

{

}

void USB_EndPoint12(U32 event)

{

}

void USB_EndPoint13(U32 event)

{

}

void USB_EndPoint14(U32 event)

{

}

void USB_EndPoint15(U32 event)

{

}

#ifndef __USBCFG_H__

#define __USBCFG_H__

//#define USB_IF_NUM 1

#define USB_MAX_PACKET0 64

#define USB_DMA_EP 0x00000000

//盡量不要是能太多時間

//這里每一個事件都代表著一個回調(diào)函數(shù),使能了該事件就需要實現(xiàn)相應(yīng)的回調(diào)函數(shù)

#define USB_EP_EVENT 0x0003 //哪些端點需要實現(xiàn)中斷處理函數(shù),一位代表一個端點

#define USB_CONFIGURE_EVENT 1 //usb配置事件

#define USB_HID_IF_NUM 0 //usb hid使用端點 第幾個接口

#define USB_DEBUG 0

#if USB_DEBUG

#define usb_debug_printf(format,args...) printf(format,##args) //變參宏定義

#else

#define usb_debug_printf(x,...) while(0);

#endif

#endif

#ifndef __USBUSER_H__

#define __USBUSER_H__

#include "usbhw.h"

//hid報告長度

#define HID_REPORT_NUM 1

//hid中斷端點地址

#define HID_EP_IN 0x81

#define HID_EP_OUT 0X01

/* USB回調(diào)方法 */

extern void USB_Power_Event(BOOL power);

extern void USB_Reset_Event(void);

extern void USB_Suspend_Event(void);

extern void USB_Resume_Event(void);

extern void USB_WakeUp_Event(void);

extern void USB_SOF_Event(void);

extern void USB_Error_Event(U32 error);

/* usb端點終端回調(diào)函數(shù)類型定義 */

#define USB_EVT_SETUP 1 /* setup包 */

#define USB_EVT_OUT 2 /* OUT 包 */

#define USB_EVT_IN 3 /* IN 包 */

#define USB_EVT_OUT_NAK 4 /* NACK OUT 包 */

#define USB_EVT_IN_NAK 5 /* NACK IN 包 */

#define USB_EVT_OUT_STALL 6 /* 忽略 out包 */

#define USB_EVT_IN_STALL 7 /* 忽略 in包 */

/* USB端點事件回調(diào)期(方法數(shù)組) */

extern void(*const USB_P_EP[16])(U32 event);

/* USB端點回調(diào)方法 */

extern void USB_EndPoint0(U32 event);//最重要的函數(shù),處理USB枚舉相關(guān)事件

extern void USB_EndPoint1(U32 event);

extern void USB_EndPoint2(U32 event);

extern void USB_EndPoint3(U32 event);

extern void USB_EndPoint4(U32 event);

extern void USB_EndPoint5(U32 event);

extern void USB_EndPoint6(U32 event);

extern void USB_EndPoint7(U32 event);

extern void USB_EndPoint8(U32 event);

extern void USB_EndPoint9(U32 event);

extern void USB_EndPoint10(U32 event);

extern void USB_EndPoint11(U32 event);

extern void USB_EndPoint12(U32 event);

extern void USB_EndPoint13(U32 event);

extern void USB_EndPoint14(U32 event);

extern void USB_EndPoint15(U32 event);

/* USB枚舉過程內(nèi)核調(diào)用事件 */

extern void USB_Configure_Event(void);

extern void USB_Interface_Event(void);

extern void USB_Feature_Event(void);

#endif

#include "usbuser.h"

#include "usbep1.h"

/*

* USB Set Configuration Event Callback

* Called automatically on USB Set Configuration Request

*/

#if USB_CONFIGURE_EVENT

void USB_Configure_Event(void)

{

u8 Buf[4]={0,0,0,0};

if(USB_Configuration)

{/* Check if USB is configured */

USB_WriteEP(HID_EP_IN,Buf,sizeof(Buf));

}

}

#endif

//宏展開為USB_EndPointx()類型的函數(shù)

#define P_EP(n) ((USB_EP_EVENT & (1 << (n))) ? USB_EndPoint##n : NULL)

/* USB端點中斷處理的回調(diào)函數(shù) */

void (* co

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內(nèi)容真實性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關(guān)閉