📄 d12.h
字号:
#ifndef __D12_H__
#define __D12_H__
#include "alt_types.h"
#include "system.h"
/****************************************/
#define USB_DAT 0
#define USB_CMD 1
#define STATUS_OK 0
#define STATUS_ERR 1
#define EP0_PK_LEN 16
#define TRUE 1
#define FALSE 0
/*******************************************/
#define GET_STATUS 0
#define LEAR_FEATURE 1
#define SET_FEATURE 3
#define SET_ADDRESS 5
#define GET_DESCRIPTOR 6
#define SET_DESCRIPTOR 7
#define GET_CONFIGURATION 8
#define SET_CONFIGURATION 9
#define GET_INTERFACE 10
#define SET_INTERFACE 11
#define SYNCH_FREAME 12
#define DEVICE 1
#define CONFIGURATION 2
#define STRING 3
#define INTERFACE 4
#define ENDPOINT 5
#define DEVICE_REMOTE_WAKUEP 1
#define ENDPOINT_HALT 0
#define D12_STALL 2
#define ENDPOINT0_OUT 0
#define ENDPOINT0_IN 1
#define ENDPOINT1_OUT 2
#define ENDPOINT1_IN 3
#define ENDPOINT2_OUT 4
#define ENDPOINT2_IN 5
#define USB_Device_Setup_Flag 0x40
#define USB_Interface_Setup_Flag 0x41
#define USB_EndPoint_Setup_Flag 0x42
#define USB_SEND_ZERO_Flag 0x43
#define USB_RECIPIENT 0x1F
#define USB_RECIPIENT_DEVICE 0x00
#define USB_RECIPIENT_INTERFACE 0x01
#define USB_RECIPIENT_ENDPOINT 0x02
#define USB_REQUEST_TYPE_MASK 0x60
#define USB_STANDARD_REQUEST 0x00
#define USB_CLASS_REQUEST 0x20
#define USB_VENDOR_REQUEST 0x40
#define USB_REQUEST_MASK 0x0F
#define DEVICE_ADDRESS_MASK 0x7F
#define USB_SETUPPACKET 0x21
/********************************************/
typedef struct mDEVICE_REQUEST
{
alt_u8 bmRequestType;
alt_u8 bRequest;
alt_u16 wValue;
alt_u16 wIndex;
alt_u16 wLength;
} DEVICE_REQUEST,*pDEVICE_REQUEST;
/***********D12初始化********************/
void USB_Port_Init(void); //初始化usb端口
/**********D12操作程序*****************/
alt_u16 D12RdChipId(void); //读取D12 ID
void USB_Connect(alt_u8 mMode,alt_u8 mClk); //USB连接函数
void USB_SetAddr_Enable(alt_u8 mAddr,alt_u8 mEnable); //设置USB地址使能
void USB_SetEndPoint_Enable(alt_u8 mEnable); //设置端点使能
void USB_SetEndPoint_Status(alt_u8 mEndPoint,alt_u8 mStall); //设置端点状态
alt_u8 USB_GetEndPoint_Status(alt_u8 mEndPoint); //获取端点状态
void USB_SetDMA_Mode(alt_u8 mMode); //设置DMA模式
alt_u16 USB_Read_INT_Flag(void); //读中断标志
alt_u8 USB_Read_LastStatus(alt_u8 mEndPoint); //读最后处理状态寄存器
alt_u8 USB_Select_EndPoint(alt_u8 mEndPoint); //选择端点
alt_u8 USB_Read_EndPoint_Buff(alt_u8 mEndPoint,alt_u8 mLen,alt_u8 *mBuff); //读缓冲区
void USB_Write_EndPoint_Buff(alt_u8 mEndPoint,alt_u8 mLen,alt_u8 *mBuff); //写缓冲区
void USB_EndPoint_Setup_Ack(alt_u8 mEndPoint); //SetUp包应答
void USB_Stall(void); //设备停止
/**************端点输入输出操作***************/
void USB_EndPoint0_IN(void);
void USB_EndPoint0_OUT(void);
void USB_EndPoint1_IN(void);
void USB_EndPoint1_OUT(void);
void USB_EndPoint2_IN(void);
void USB_EndPoint2_OUT(void);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -