⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usb.h

📁 这是一个pic 的usb 的驱动程序,具体说明看程序,不会不认识英文吧
💻 H
📖 第 1 页 / 共 2 页
字号:
///////////////////////////////////////////////////////////////////////////
////                              usb.h                                ////
////                                                                   ////
//// Function protypes, defintions and globals used by CCS USB driver  ////
////                                                                   ////
//// This file is part of CCS's PIC USB driver code, which includes:   ////
////   usb_desc.h - an example set of config and device descriptors    ////
////   usb.c - USB token and request handler code                      ////
////   usb.h - definitions, prototypes and global variables            ////
////   And the hardware peripheral level.  At the time of writing,     ////
////    CCS provides two hardware peripheral drivers.  National        ////
////    USBN960x (usbn960x.cc) and PIC16C7x5 (usb_pic.c).              ////
////                                                                   ////
//// Two examples are given using CCS's PIC USB driver.                ////
//// ex_usb_scope.c is a bulk device that sends 512 bytes to the       ////
//// host and uses the USBN960x.  ex_usb_hid.c is a HID device and     ////
//// uses the PIC16C7x5.                                               ////
////                                                                   ////
////                   **** DEFINITIONS *****                          ////
//// The following definitions are declared here, but can be           ////
//// overwritten in your code.  Unless needed otherwise, leave         ////
//// to default value.  If confused about a definition read the        ////
//// comments at each defintion                                        ////
////                                                                   ////
//// USB_SUPPORT_IDLE (FALSE) - Set to TRUE if your device supports    ////
////                            Set_Idle HID class request.  Set to    ////
////                            False if you do not (device will       ////
////                            send a Wrong-state if computer         ////
////                            sends a Set_Idle / Get_Idle command)   ////
////                            NOTE: If you set to TRUE you must      ////
////                            provide your own code.  See            ////
////                            usb_set_idle() and usb_get_idle() in   ////
////                            usb.c                                  ////
////                                                                   ////
//// USB_BOOT_PROTOCOL (FALSE) - Set to TRUE if your device supports   ////
////                            Set_Protocl HID class request. Set to  ////
////                            False if you do not (device will       ////
////                            send a Wrong-state if computer         ////
////                            sends a Set_Protocl / Get_Protocol     ////
////                            command).                              ////
////                            NOTE: If you set to TRUE you must      ////
////                            provide your own code in the           ////
////                            application that properly send boot    ////
////                            or HID packets.                        ////
////                                                                   ////
//// USB_MAX_EP0_PACKET_LENGTH (8) - Max Packet size for Endpoint 0    ////
////                                                                   ////
//// USB_EPx_RX_ENABLE (0) - Where x is the endpoint number. EP0 is    ////
////                         always enabled.  Setting to 0 keeps       ////
////                         endpoint disabled, setting 1 enables      ////
////                         endpoint for bulk/interrupt, and          ////
////                         setting 2 enables endpoint for iso.       ////
////                         Endpoint is enabled when host             ////
////                         sends a configuration.                    ////
////                                                                   ////
//// USB_EPx_RX_SIZE (0) - Size to make RX buffer.                     ////
////                                                                   ////
//// USB_DO_DEBUG (FALSE) - Whether or not to print out debug          ////
////                        information out serial port.  Enabling     ////
////                        may cause problems due to timing.          ////
////                        Uses PIC's Transmit Buffer Empty interrupt ////
////                                                                   ////
//// USB_HID_DEVICE (TRUE) - HID devices require extra code to handle  ////
////                         HID requests.  You can disable to save    ////
////                         ROM space if you are not using a HID      ////
////                         device.  If you are not using a HID       ////
////                         device you must provide your own O/S      ////
////                         (Windows) driver.                         ////
////                                                                   ////
//// The other definitions should not be changed.                      ////
////                                                                   ////
////                 **** SPECIAL VARIABLES ****                       ////
//// The following variables contain either status bits or             ////
//// receive/transmit buffers used by the USB routines.                ////
////                                                                   ////
//// usb_epX_rx_buffer - Array containing data host sent to PIC.       ////
////                     X is endpoint number.                         ////
////                                                                   ////
//// usb_epX_rx_status - Status of RX buffer.  X is endpoint number.   ////
////                                                                   ////
///////////////////////////////////////////////////////////////////////////
////                                                                   ////
//// Version History:                                                  ////
////                                                                   ////
//// October 15th, 2003: Support for boot protocol added.              ////
////         Set USB_BOOT_PROTOCOL to TRUE to support this.            ////
////         The array hid_protocol[] saves which protocol mode each   ////
////         interface is in.  It is your applications job to send     ////
////         data that either fit the boot protocol or HID protocol.   ////
////                                                                   ////
//// May 6th, 2003: Fixed a potential stack overflow using PCM         ////
////                                                                   ////
//// October 29th, 2002: New definition added to USB_STATES            ////
////                                                                   ////
//// August 2nd, 2002: Initial Public Release                          ////
////                                                                   ////
///////////////////////////////////////////////////////////////////////////
////        (C) Copyright 1996,2002 Custom Computer Services           ////
//// This source code may only be used by licensed users of the CCS    ////
//// C compiler.  This source code may only be distributed to other    ////
//// licensed users of the CCS C compiler.  No other use,              ////
//// reproduction or distribution is permitted without written         ////
//// permission.  Derivative programs created using this software      ////
//// in object code form are not restricted in any way.                ////
///////////////////////////////////////////////////////////////////////////


#IFNDEF __USB_PROTOTYPES__
#DEFINE __USB_PROTOTYPES__

#IFNDEF USB_SUPPORT_IDLE
   #DEFINE USB_SUPPORT_IDLE  FALSE
#ENDIF

#IFNDEF USB_BOOT_PROTOCOL
   #DEFINE USB_BOOT_PROTOCOL FALSE
#ENDIF


#ifndef USB_DO_DEBUG
   #DEFINE USB_DO_DEBUG  FALSE
#ENDIF

//should the compiler add the extra HID handler code?  Defaults to yes.
#IFNDEF USB_HID_DEVICE
   #DEFINE USB_HID_DEVICE TRUE
#ENDIF

//CCS code has only been tested with a max packet length of 8, but code
//was written to handle a different size.
//Not recommended to change, however.  Slow speed requires 8.
#IFNDEF USB_MAX_EP0_PACKET_LENGTH
  #DEFINE USB_MAX_EP0_PACKET_LENGTH 8
#ENDIF


#define USB_EP0_RX_SIZE    USB_MAX_EP0_PACKET_LENGTH  //endpoint 0 is setup, and should always be the MAX_PACKET_LENGTH.  Slow speed specifies 8

//*** ENABLE RX ENDPOINTS AND BUFFERS
//ENABLE -> 0 = off, 1 = interrupt or bulk transfers, 2 = iso transfers
#ifndef USB_EP1_RX_ENABLE
   #define USB_EP1_RX_ENABLE  0  //default to off
   #ifndef USB_EP1_RX_SIZE
      #define USB_EP1_RX_SIZE 0  //if buffer length wasn't already defined, set to 8
   #endif
#endif

#ifndef USB_EP2_RX_ENABLE
   #define USB_EP2_RX_ENABLE  0  //default to off
   #ifndef USB_EP2_RX_SIZE
      #define USB_EP2_RX_SIZE 0  //if buffer length wasn't already defined, set to 8
   #endif
#endif

#ifndef USB_EP3_RX_ENABLE
   #define USB_EP3_RX_ENABLE  0  //default to off
   #ifndef USB_EP3_RX_SIZE
      #define USB_EP3_RX_SIZE 0  //if buffer length wasn't already defined, set to 8
   #endif
#endif

#ifndef USB_EP4_RX_ENABLE
   #define USB_EP4_RX_ENABLE  0  //default to off
   #ifndef USB_EP4_RX_SIZE
      #define USB_EP4_RX_SIZE 0  //if buffer length wasn't already defined, set to 8
   #endif
#endif

#ifndef USB_EP5_RX_ENABLE
   #define USB_EP5_RX_ENABLE  0  //default to off
   #ifndef USB_EP5_RX_SIZE
      #define USB_EP5_RX_SIZE 0  //if buffer length wasn't already defined, set to 8
   #endif
#endif

#ifndef USB_EP6_RX_ENABLE
   #define USB_EP6_RX_ENABLE  0  //default to off
   #ifndef USB_EP6_RX_SIZE
      #define USB_EP6_RX_SIZE 0  //if buffer length wasn't already defined, set to 8
   #endif
#endif

#ifndef USB_EP7_RX_ENABLE
   #define USB_EP7_RX_ENABLE  0  //default to off
   #ifndef USB_EP7_RX_SIZE
      #define USB_EP7_RX_SIZE 0  //if buffer length wasn't already defined, set to 8
   #endif
#endif

#ifndef USB_EP8_RX_ENABLE
   #define USB_EP8_RX_ENABLE  0  //default to off
   #ifndef USB_EP8_RX_SIZE
      #define USB_EP8_RX_SIZE 0  //if buffer length wasn't already defined, set to 8
   #endif
#endif

#ifndef USB_EP9_RX_ENABLE
   #define USB_EP9_RX_ENABLE  0  //default to off
   #ifndef USB_EP9_RX_SIZE
      #define USB_EP9_RX_SIZE 0  //if buffer length wasn't already defined, set to 8
   #endif
#endif

#ifndef USB_EP10_RX_ENABLE
   #define USB_EP10_RX_ENABLE  0  //default to off
   #ifndef USB_EP10_RX_SIZE
      #define USB_EP10_RX_SIZE 0  //if buffer length wasn't already defined, set to 8
   #endif
#endif

#ifndef USB_EP11_RX_ENABLE
   #define USB_EP11_RX_ENABLE  0  //default to off
   #ifndef USB_EP11_RX_SIZE
      #define USB_EP11_RX_SIZE 0  //if buffer length wasn't already defined, set to 8
   #endif
#endif

#ifndef USB_EP12_RX_ENABLE
   #define USB_EP12_RX_ENABLE  0  //default to off
   #ifndef USB_EP12_RX_SIZE
      #define USB_EP12_RX_SIZE 0  //if buffer length wasn't already defined, set to 8
   #endif
#endif

#ifndef USB_EP13_RX_ENABLE
   #define USB_EP13_RX_ENABLE  0  //default to off
   #ifndef USB_EP13_RX_SIZE
      #define USB_EP13_RX_SIZE 0  //if buffer length wasn't already defined, set to 8
   #endif
#endif

#ifndef USB_EP14_RX_ENABLE
   #define USB_EP14_RX_ENABLE  0  //default to off
   #ifndef USB_EP14_RX_SIZE
      #define USB_EP14_RX_SIZE 0  //if buffer length wasn't already defined, set to 8
   #endif
#endif

#ifndef USB_EP15_RX_ENABLE
   #define USB_EP15_RX_ENABLE  0  //default to off
   #ifndef USB_EP15_RX_SIZE
      #define USB_EP15_RX_SIZE 0  //if buffer length wasn't already defined, set to 8
   #endif
#endif

//*** ENABLE TX ENDPOINTS AND BUFFERS
//ENABLE -> 0 = off, 1 = interrupt or bulk transfers, 2 = iso transfers
#ifndef USB_EP1_TX_ENABLE
   #define USB_EP1_TX_ENABLE  0  //default to off
#endif
#ifndef USB_EP2_TX_ENABLE
   #define USB_EP2_TX_ENABLE  0  //default to off
#endif
#ifndef USB_EP3_TX_ENABLE
   #define USB_EP3_TX_ENABLE  0  //default to off
#endif
#ifndef USB_EP4_TX_ENABLE
   #define USB_EP4_TX_ENABLE  0  //default to off
#endif
#ifndef USB_EP5_TX_ENABLE
   #define USB_EP5_TX_ENABLE  0  //default to off
#endif
#ifndef USB_EP6_TX_ENABLE
   #define USB_EP6_TX_ENABLE  0  //default to off
#endif
#ifndef USB_EP7_TX_ENABLE
   #define USB_EP7_TX_ENABLE  0  //default to off

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -