📄 usb_includes.h
字号:
/*********************************************************************
(c) copyright Freescale Semiconductor Hong Kong Ltd 2004
ALL RIGHTS RESERVED
*********************************************************************
USB Driver Module for S12 MCUs
*********************************************************************
File: usb_Includes.h
Description: Define my System Configuration & Compiler Options.
Date: Mar. 2003
Author: Vincent Ko
********************************************************************/
//#ifndef _H_USB_INCLUDES_ // To avoid multiple defining
//#define _H_USB_INCLUDES_ // start of Constants & Macros definition
#include "Hidef.h"
// =====================================================
//
// Module Specific Constant definitions
//
// =====================================================
#define kSetupPacketSize 8 // Setup Packet size
#define kMaxNumberOfUsbHook 4 // Max number of hooks per event
// USB SETUP package data format
#define bmRequestType 0 //0 bmRequestType byte position
#define bRequest 1 //1 bRequest byte position
#define wValue_l 2 //2 wValue Low byte position
#define wValue_h 3 //3 wValue High byte position
#define wIndex_l 4 //4 wIndex Low byte position
#define wIndex_h 5 //5 wIndex High byte position
#define wLength_l 6 //6 wLength Low byte position
#define wLength_h 7 //7 wLength High byte position
// USB Commands
#define GET_STATUS 0
#define CLEAR_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_FRAME 12
#define GETMAXLUN 0xFE // Mass Storage, vendor specific command
#define MS_RESET 0xFF // Bulk only mass storage reset, vendor specific command
#define DEVICE 1
#define CONFIGURATION 2
#define STRING 3
#define INTERFACE 4
#define ENDPOINT 5
#define DEVICE_QUALIFIER 6
#define OTHER_SPEED_CONFIGURATION 7
#define INTERFACE_POWER 8
#define PHY1IN 0
#define PHY1OUT 1
#define PHY2 2
#define PHY3 3
#define PHY4 4
#define PHY5 5
#define PHY6 6
#define EndPt0 0
#define EndPt1 1
#define EndPt2 2
#define EndPt3 3
#define EndPt4 4
#define EndPt5 5
#define EndPt6 6
#define Config0 0
#define Config1 1
#define ON_LED b_BIT0
#define SUSPEND_LED b_BIT1
#define ERROR_LED b_BIT3
// Recipient for bmRequest byte
#define bm_DEVICE 0
#define bm_INTERFACE 1
#define bm_ENDPOINT 2
#define bm_OTHER 3
// Feature Selector Table
#define DEVICE_REMOTE_WAKEUP 1
#define ENDPOINT_HALT 0
#define TEST_MODE 2
// Mass storage class constant
// Generate enumeration
#define SUCCESS 1
#define FAIL 0
// Base address of each peripheral modules.
#define QRAM_CH1_W *(volatile muint16*)(QRAM_BANK+0x0000)
#define QRAM_CH1 *(volatile muint8*)(QRAM_BANK+0x0000)
#define QRAM_CH1_15 *(volatile muint8*)(QRAM_BANK+0x000f)
#define QRAM_CH2 *(volatile muint8*)(QRAM_BANK+0x0040)
// CSW command enumeration
#define kUSBCSWPass 0
#define kUSBCSWFail 1
#define kUSBCSWPhaseError 2
// ======================================================
//
// Global Variables internally used by USB Driver
//
// ======================================================
//
#pragma DATA_SEG DEFAULT
// The Sys Timer Hook Function List
extern pHookFunc gpUsbRequestHookTable[];
extern pHookFunc gpUsbDataHookTable[];
// ===================================================================
//
// Module Specific Macro Functions definitions
//
// ===================================================================
// USB Opcode
// The definition of USB Command Block Data structure
typedef struct {
muint32 Signature; // Signature
muint32 Tag; // Tag
muint32 Length; // Length
muint8 DeviceNo; // Device No.
muint8 Reserved; // Reserved
muint8 CommandLength; // Command Length
muint8 SCSICommand; // SCSI command
muint8 NotUsedByte; // Not used
muint32 LBA; // Logical Block Address
muint32 TLB; // Transfer Length of Block
muint16 NotUsedInt; // Not used int
muint32 NotUsedLong; // Not used long
} msUSBMessage;
//typedef msUSBMessage *pmsUSBMessage;
typedef void (*pUSBFunc)();
#pragma CODE_SEG DEFAULT
// *********************************************************************
//
// FUNCTIONS INTERNALLY USED BY USB Driver
//
// DO NOT CALL TO THESE FUNCTIONS DIRECTLY.
//
// *********************************************************************
// ==================================================================
// USB_InitUsbData() -
//
// To initialize the USB global variables.
// ==================================================================
void USB_ModuleInit(void);
// ===========================================================
// IQUE_Module_Init() -
//
// Enable the IQUE module
//
// ===========================================================
void IQUE_Module_Init(void);
// ===========================================================
// USB_InitCBITransport() -
//
// Configurate 1 x 512 bytes BULK in, 1 x 512 Bytes BULK out
// and 1 x 2 bytes interrupt endpoint.
//
// ===========================================================
//void USB_InitCBITransport(void);
// ===========================================================
// USB_InitBulkOnlyTransport() -
//
// Configurate 1 x 64 bytes BULK in and 1 x 64 Bytes BULK out.
//
// ===========================================================
void USB_InitBulkOnlyTransport(void);
// ===========================================================
// Decode_SETUP() -
//
// Decode the setup packet
//
// ===========================================================
void USB_DecodeSETUP(volatile muint8 *p_Packet);
void USB_SCSINotSupport(void);
// ===========================================================
// USB_StallEP() -
//
// STALL Endpoint #.
//
//
// ===========================================================
void USB_StallEP(muint8 PhyEPNo);
// ===========================================================
// USB_UnStallEP() -
//
// UNSTALL Endpoint #.
//
//
// ===========================================================
void USB_UnStallEP(muint8 PhyEPNo);
// ===========================================================
// USBMS_DecodeCBW() -
//
// Decode the Mass Storage CBW packet
//
// ===========================================================
void USBMS_DecodeCBW(muint8 *p_Packet);
// ===========================================================
// USB_SetControlPtr() -
//
// Enable Control pointer.
//
//
// ===========================================================
volatile muint16 *USB_SetControlPtr(muint8 PhyEPNo);
// ===========================================================
// USB_SetBufferPtr() -
//
// Enable Buffer pointer.
//
//
// ===========================================================
volatile muint8 *USB_SetBufferPtr(muint8 PhyEPNo);
// ===========================================================
// USB_Move2LocalBuffer(FR_ptr, TO_ptr, Len) -
//
// Move data with Length "len" from pointer FR_ptr to
// Local buffer pointer TO_ptr.
//
// ===========================================================
void USB_Move2LocalBuffer(muint8 *FR_ptr, muint8 *TO_ptr, muint16 Len);
// ===========================================================
// USB_Move2QUE3(FR_ptr, Len) -
//
// Move data with Length "len" from pointer FR_ptr to
// QUE1 FIFO.
//
// ===========================================================
void USB_Move2QUE3(muint8 *FR_ptr, muint16 Len);
muint16 USB_GetMin(muint16 Value1, muint16 Value2);
//#endif _H_USB_INCLUDES_ // end of my Constants & Macros definition
//
// The end of file usb_Includes.h
// *********************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -