Update Firmware Dumper

This commit is contained in:
radiomanV
2017-07-21 18:36:27 +03:00
parent 47bc62fc95
commit 202e8b5325
25 changed files with 9546 additions and 253 deletions

View File

@@ -55,5 +55,4 @@
#define CLOCK_FREQ 48000000
#define GetSystemClock() CLOCK_FREQ
#define GetInstructionClock() CLOCK_FREQ
#endif

View File

@@ -0,0 +1,218 @@
/*********************************************************************
*
* Compiler and hardware specific definitions
*
*********************************************************************
* FileName: Compiler.h
* Dependencies: None
* Processor: PIC10, PIC12, PIC16, PIC18, PIC24, dsPIC, PIC32
* Compiler: Microchip C32 v2.02 or higher
* Microchip C30 v3.31 or higher
* Microchip C18 v3.40 or higher
* HI-TECH PICC-18 PRO 9.66 or higher
* HI-TECH PICC PRO V9.81 or higher
* Company: Microchip Technology, Inc.
*
* Software License Agreement
*
* Copyright (C) 2012 Microchip Technology Inc. All rights
* reserved.
*
* Microchip licenses to you the right to use, modify, copy, and
* distribute:
* (i) the Software when embedded on a Microchip microcontroller or
* digital signal controller product ("Device") which is
* integrated into Licensee's product; or
* (ii) ONLY the Software driver source files ENC28J60.c and
* ENC28J60.h ported to a non-Microchip device used in
* conjunction with a Microchip ethernet controller for the
* sole purpose of interfacing with the ethernet controller.
*
* You should refer to the license agreement accompanying this
* Software for additional information regarding your rights and
* obligations.
*
* THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT
* WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
* LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF
* PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
* BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE
* THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER
* SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT
* (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE.
*
*
* Date Comment
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* 10/03/2006 Original, copied from old Compiler.h
* 11/07/2007 Reorganized and simplified
* 03/31/2010 Removed dependency on WORD and DWORD typedefs
* 04/14/2010 Added defines to uniquely identify each compiler
* 10/13/2010 Added support for PIC10, PIC12, and PIC16 with PICC compiler
* 02/15/2012 Added re-define check for Nop, ClrWdt, Reset, Sleep
********************************************************************/
#ifndef __COMPILER_H
#define __COMPILER_H
// Include proper device header file
#if defined(__18CXX) && !defined(HI_TECH_C)
// PIC18 processor with Microchip C18 compiler
#define COMPILER_MPLAB_C18
#include <p18cxxx.h>
#elif defined(__PICC18__) && defined(HI_TECH_C)
// PIC18 processor with (Microchip) HI-TECH PICC-18 compiler
#if !defined(__18CXX)
#define __18CXX
#endif
#define COMPILER_HITECH_PICC18
#include <htc.h>
#elif (defined(_PIC12) || defined(_PIC14) || defined(_PIC14E)) && defined(HI_TECH_C)
// PIC10/12/16 processor with (Microchip) HI-TECH PICC compiler
#define COMPILER_HITECH_PICC
#include <htc.h>
#elif (defined(__PIC24F__) || defined(__PIC24FK__)) && defined(__C30__) // Microchip C30 compiler
// PIC24F processor
#define COMPILER_MPLAB_C30
#include <p24Fxxxx.h>
#elif defined(__PIC24H__) && defined(__C30__) // Microchip C30 compiler
// PIC24H processor
#define COMPILER_MPLAB_C30
#include <p24Hxxxx.h>
#elif defined(__PIC24E__) && defined(__C30__) // Microchip C30 compiler
// PIC24E processor
#define COMPILER_MPLAB_C30
#include <p24Exxxx.h>
#elif defined(__dsPIC33F__) && defined(__C30__) // Microchip C30 compiler
// dsPIC33F processor
#define COMPILER_MPLAB_C30
#include <p33Fxxxx.h>
#elif defined(__dsPIC33E__) && defined(__C30__) // Microchip C30 compiler
// dsPIC33E processor
#define COMPILER_MPLAB_C30
#include <p33Exxxx.h>
#elif defined(__dsPIC30F__) && defined(__C30__) // Microchip C30 compiler
// dsPIC30F processor
#define COMPILER_MPLAB_C30
#include <p30fxxxx.h>
#elif defined(__C30__) // Microchip C30 compiler, but targeting "generic-16bit" processor.
#define COMPILER_MPLAB_C30
#include <p30sim.h>
// Define some useful inline assembly functions which are normally in the
// processor header files, but absent from the generic p30sim.h file.
#if !defined(Nop)
#define Nop() __builtin_nop()
#define ClrWdt() {__asm__ volatile ("clrwdt");}
#define Sleep() {__asm__ volatile ("pwrsav #0");}
#define Idle() {__asm__ volatile ("pwrsav #1");}
#endif
#elif defined(__PIC32MX__) // Microchip C32 compiler
#if !defined(__C32__)
#define __C32__
#endif
#define COMPILER_MPLAB_C32
#include <p32xxxx.h>
#include <plib.h>
#else
#error Unknown processor or compiler. See Compiler.h
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Base RAM and ROM pointer types for given architecture
#if defined(__PIC32MX__)
#define PTR_BASE unsigned long
#define ROM_PTR_BASE unsigned long
#elif defined(__C30__)
#define PTR_BASE unsigned short
#define ROM_PTR_BASE unsigned short
#elif defined(COMPILER_MPLAB_C18)
#define PTR_BASE unsigned short
#define ROM_PTR_BASE unsigned short long
#elif defined(COMPILER_HITECH_PICC18)
#define PTR_BASE unsigned short
#define ROM_PTR_BASE unsigned long
#endif
// Definitions that apply to all except Microchip MPLAB C Compiler for PIC18 MCUs (C18)
#if !defined(COMPILER_MPLAB_C18)
#define memcmppgm2ram(a,b,c) memcmp(a,b,c)
#define strcmppgm2ram(a,b) strcmp(a,b)
#define memcpypgm2ram(a,b,c) memcpy(a,b,c)
#define strcpypgm2ram(a,b) strcpy(a,b)
#define strncpypgm2ram(a,b,c) strncpy(a,b,c)
#define strstrrampgm(a,b) strstr(a,b)
#define strlenpgm(a) strlen(a)
#define strchrpgm(a,b) strchr(a,b)
#define strcatpgm2ram(a,b) strcat(a,b)
#endif
// Definitions that apply to all 8-bit products
// (PIC10, PIC12, PIC16, PIC18)
#if defined(__18CXX) || defined(COMPILER_HITECH_PICC)
#define __attribute__(a)
#define FAR far
// Microchip C18 specific defines
#if defined(COMPILER_MPLAB_C18)
#define ROM rom
#endif
// HI TECH specific defines
#if defined(COMPILER_HITECH_PICC18) || defined(COMPILER_HITECH_PICC)
#define ROM const
#define rom
#ifndef Nop()
#define Nop() asm("NOP");
#endif
#ifndef ClrWdt()
#define ClrWdt() asm("CLRWDT");
#endif
#ifndef Reset()
#define Reset() asm("RESET");
#endif
#ifndef Sleep()
#define Sleep() asm("SLEEP");
#endif
#endif
// Definitions that apply to all 16-bit and 32-bit products
// (PIC24F, PIC24H, dsPIC30F, dsPIC33F, and PIC32)
#else
#define ROM const
// 16-bit specific defines (PIC24F, PIC24H, dsPIC30F, dsPIC33F)
#if defined(__C30__)
#define Reset() asm("reset")
#define FAR __attribute__((far))
#endif
// 32-bit specific defines (PIC32)
#if defined(__PIC32MX__)
#if (__C32_VERSION__ < 200)
#define persistent
#endif
#define far
#define FAR
#define Reset() SoftReset()
#define ClrWdt() (WDTCONSET = _WDTCON_WDTCLR_MASK)
// MPLAB C Compiler for PIC32 MCUs version 1.04 and below don't have a
// Nop() function. However, version 1.05 has Nop() declared as _nop().
#if !defined(Nop) && (__C32_VERSION__ <= 104)
#define Nop() asm("nop")
#endif
#endif
#endif
#endif

View File

@@ -0,0 +1 @@
Required Microchip USB stack from microchip solutions v2013-06-15

146
FirmwareDumper/USB/usb.h Normal file
View File

@@ -0,0 +1,146 @@
//DOM-IGNORE-BEGIN
/*********************************************************************
* The following lines are used by VDI.
* GUID=E537A0C0-6FEE-4afd-89B9-0C35BF72A80B
* GUIInterfaceVersion=1.00
* LibraryVersion=2.4
*********************************************************************/
//DOM-IGNORE-END
/*******************************************************************************
USB Header File
Summary:
This file aggregates all necessary header files for the Microchip USB Host,
Device, and OTG libraries. It provides a single-file can be included in
application code. The USB libraries simplify the implementation of USB
applications by providing an abstraction of the USB module and its registers
and bits such that the source code for the can be the same across various
hardware platforms.
Description:
This file aggregates all necessary header files for the Microchip USB Host,
Device, and OTG libraries. It provides a single-file can be included in
application code. The USB libraries simplify the implementation of USB
applications by providing an abstraction of the USB module and its registers
and bits such that the source code for the can be the same across various
hardware platforms.
Note that this file does not include the header files for any client or
function drivers.
This file is located in the "\<Install Directory\>\\Microchip\\Include\\USB"
directory.
When including this file in a new project, this file can either be
referenced from the directory in which it was installed or copied
directly into the user application folder. If the first method is
chosen to keep the file located in the folder in which it is installed
then include paths need to be added so that the library and the
application both know where to reference each others files. If the
application folder is located in the same folder as the Microchip
folder (like the current demo folders), then the following include
paths need to be added to the application's project:
.
..\\..\\Microchip\\Include
If a different directory structure is used, modify the paths as
required. An example using absolute paths instead of relative paths
would be the following:
C:\\Microchip Solutions\\Microchip\\Include
C:\\Microchip Solutions\\My Demo Application
******************************************************************************/
/******************************************************************************
FileName: usb.h
Dependencies: See INCLUDES section
Processor: PIC18, PIC24, & PIC32 USB Microcontrollers
Hardware:
Complier: Microchip C18 (for PIC18), C30 (for PIC24), or C32 (for PIC32)
Company: Microchip Technology, Inc.
Software License Agreement:
The software supplied herewith by Microchip Technology Incorporated
(the "Company") for its PICmicro(r) Microcontroller is intended and
supplied to you, the Company's customer, for use solely and
exclusively on Microchip PICmicro Microcontroller products. The
software is owned by the Company and/or its supplier, and is
protected under applicable copyright laws. All rights are reserved.
Any use in violation of the foregoing restrictions may subject the
user to criminal sanctions under applicable laws, as well as to
civil liability for the breach of the terms and conditions of this
license.
THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
********************************************************************/
//DOM-IGNORE-END
//DOM-IGNORE-BEGIN
/********************************************************************
File Description:
Change History:
Rev Description
---------- -----------
2.6 - 2.9 No change except stack revision number
********************************************************************/
//DOM-IGNORE-END
#ifndef _USB_H_
#define _USB_H_
//DOM-IGNORE-END
// *****************************************************************************
// *****************************************************************************
// Section: All necessary USB Library headers
// *****************************************************************************
// *****************************************************************************
#include "GenericTypeDefs.h"
#include "Compiler.h"
#include "usb_config.h" // Must be defined by the application
#include "USB/usb_common.h" // Common USB library definitions
#include "USB/usb_ch9.h" // USB device framework definitions
#if defined( USB_SUPPORT_DEVICE )
#include "USB/usb_device.h" // USB Device abstraction layer interface
#endif
#if defined( USB_SUPPORT_HOST )
#include "USB/usb_host.h" // USB Host abstraction layer interface
#endif
#if defined ( USB_SUPPORT_OTG )
#include "USB/usb_otg.h"
#endif
#include "USB/usb_hal.h" // Hardware Abstraction Layer interface
// *****************************************************************************
// *****************************************************************************
// Section: MCHPFSUSB Firmware Version
// *****************************************************************************
// *****************************************************************************
#define USB_MAJOR_VER 2 // Firmware version, major release number.
#define USB_MINOR_VER 9 // Firmware version, minor release number.
#define USB_DOT_VER 0 // Firmware version, dot release number.
#endif // _USB_H_
/*************************************************************************
* EOF
*/

View File

@@ -0,0 +1,618 @@
/*******************************************************************************
USB Chapter 9 Protocol (Header File)
Summary:
This file defines data structures, constants, and macros that are used to
to support the USB Device Framework protocol described in Chapter 9 of the
USB 2.0 specification.
Description:
This file defines data structures, constants, and macros that are used to
to support the USB Device Framework protocol described in Chapter 9 of the
USB 2.0 specification.
This file is located in the "\<Install Directory\>\\Microchip\\Include\\USB"
directory.
When including this file in a new project, this file can either be
referenced from the directory in which it was installed or copied
directly into the user application folder. If the first method is
chosen to keep the file located in the folder in which it is installed
then include paths need to be added so that the library and the
application both know where to reference each others files. If the
application folder is located in the same folder as the Microchip
folder (like the current demo folders), then the following include
paths need to be added to the application's project:
.
..\\..\\Microchip\\Include
If a different directory structure is used, modify the paths as
required. An example using absolute paths instead of relative paths
would be the following:
C:\\Microchip Solutions\\Microchip\\Include
C:\\Microchip Solutions\\My Demo Application
*******************************************************************************/
//DOM-IGNORE-BEGIN
/*******************************************************************************
* FileName: usb_ch9.h
* Dependencies: None
* Processor: PIC18/PIC24/PIC32MX microcontrollers with USB module
* Compiler: C18 v3.13+/C30 v2.01+/C32 v0.00.18+
* Company: Microchip Technology, Inc.
* File Description:
* This file contains the definitions and prototypes used for
* specification chapter 9 compliance.
Software License Agreement
The software supplied herewith by Microchip Technology Incorporated
(the “Company”) for its PICmicro® Microcontroller is intended and
supplied to you, the Companys customer, for use solely and
exclusively on Microchip PICmicro Microcontroller products. The
software is owned by the Company and/or its supplier, and is
protected under applicable copyright laws. All rights are reserved.
Any use in violation of the foregoing restrictions may subject the
user to criminal sanctions under applicable laws, as well as to
civil liability for the breach of the terms and conditions of this
license.
THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*******************************************************************************/
//DOM-IGNORE-END
//DOM-IGNORE-BEGIN
/********************************************************************
Change History:
Rev Description
---- -----------
2.6 Moved many of the CH9 defintions from the device stack files
into this file.
********************************************************************/
//DOM-IGNORE-END
//DOM-IGNORE-BEGIN
#ifndef _USB_CH9_H_
#define _USB_CH9_H_
//DOM-IGNORE-END
// *****************************************************************************
// *****************************************************************************
// Section: USB Descriptors
// *****************************************************************************
// *****************************************************************************
#define USB_DESCRIPTOR_DEVICE 0x01 // bDescriptorType for a Device Descriptor.
#define USB_DESCRIPTOR_CONFIGURATION 0x02 // bDescriptorType for a Configuration Descriptor.
#define USB_DESCRIPTOR_STRING 0x03 // bDescriptorType for a String Descriptor.
#define USB_DESCRIPTOR_INTERFACE 0x04 // bDescriptorType for an Interface Descriptor.
#define USB_DESCRIPTOR_ENDPOINT 0x05 // bDescriptorType for an Endpoint Descriptor.
#define USB_DESCRIPTOR_DEVICE_QUALIFIER 0x06 // bDescriptorType for a Device Qualifier.
#define USB_DESCRIPTOR_OTHER_SPEED 0x07 // bDescriptorType for a Other Speed Configuration.
#define USB_DESCRIPTOR_INTERFACE_POWER 0x08 // bDescriptorType for Interface Power.
#define USB_DESCRIPTOR_OTG 0x09 // bDescriptorType for an OTG Descriptor.
// *****************************************************************************
/* USB Device Descriptor Structure
This struct defines the structure of a USB Device Descriptor. Note that this
structure may need to be packed, or even accessed as bytes, to properly access
the correct fields when used on some device architectures.
*/
typedef struct __attribute__ ((packed)) _USB_DEVICE_DESCRIPTOR
{
BYTE bLength; // Length of this descriptor.
BYTE bDescriptorType; // DEVICE descriptor type (USB_DESCRIPTOR_DEVICE).
WORD bcdUSB; // USB Spec Release Number (BCD).
BYTE bDeviceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific.
BYTE bDeviceSubClass; // Subclass code (assigned by the USB-IF).
BYTE bDeviceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific.
BYTE bMaxPacketSize0; // Maximum packet size for endpoint 0.
WORD idVendor; // Vendor ID (assigned by the USB-IF).
WORD idProduct; // Product ID (assigned by the manufacturer).
WORD bcdDevice; // Device release number (BCD).
BYTE iManufacturer; // Index of String Descriptor describing the manufacturer.
BYTE iProduct; // Index of String Descriptor describing the product.
BYTE iSerialNumber; // Index of String Descriptor with the device's serial number.
BYTE bNumConfigurations; // Number of possible configurations.
} USB_DEVICE_DESCRIPTOR;
// *****************************************************************************
/* USB Configuration Descriptor Structure
This struct defines the structure of a USB Configuration Descriptor. Note that this
structure may need to be packed, or even accessed as bytes, to properly access
the correct fields when used on some device architectures.
*/
typedef struct __attribute__ ((packed)) _USB_CONFIGURATION_DESCRIPTOR
{
BYTE bLength; // Length of this descriptor.
BYTE bDescriptorType; // CONFIGURATION descriptor type (USB_DESCRIPTOR_CONFIGURATION).
WORD wTotalLength; // Total length of all descriptors for this configuration.
BYTE bNumInterfaces; // Number of interfaces in this configuration.
BYTE bConfigurationValue; // Value of this configuration (1 based).
BYTE iConfiguration; // Index of String Descriptor describing the configuration.
BYTE bmAttributes; // Configuration characteristics.
BYTE bMaxPower; // Maximum power consumed by this configuration.
} USB_CONFIGURATION_DESCRIPTOR;
// Attributes bits
#define USB_CFG_DSC_REQUIRED 0x80 // Required attribute
#define USB_CFG_DSC_SELF_PWR (0x40|USB_CFG_DSC_REQUIRED) // Device is self powered.
#define USB_CFG_DSC_REM_WAKE (0x20|USB_CFG_DSC_REQUIRED) // Device can request remote wakup
// *****************************************************************************
/* USB Interface Descriptor Structure
This struct defines the structure of a USB Interface Descriptor. Note that this
structure may need to be packed, or even accessed as bytes, to properly access
the correct fields when used on some device architectures.
*/
typedef struct __attribute__ ((packed)) _USB_INTERFACE_DESCRIPTOR
{
BYTE bLength; // Length of this descriptor.
BYTE bDescriptorType; // INTERFACE descriptor type (USB_DESCRIPTOR_INTERFACE).
BYTE bInterfaceNumber; // Number of this interface (0 based).
BYTE bAlternateSetting; // Value of this alternate interface setting.
BYTE bNumEndpoints; // Number of endpoints in this interface.
BYTE bInterfaceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific.
BYTE bInterfaceSubClass; // Subclass code (assigned by the USB-IF).
BYTE bInterfaceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific.
BYTE iInterface; // Index of String Descriptor describing the interface.
} USB_INTERFACE_DESCRIPTOR;
// *****************************************************************************
/* USB Endpoint Descriptor Structure
This struct defines the structure of a USB Endpoint Descriptor. Note that this
structure may need to be packed, or even accessed as bytes, to properly access
the correct fields when used on some device architectures.
*/
typedef struct __attribute__ ((packed)) _USB_ENDPOINT_DESCRIPTOR
{
BYTE bLength; // Length of this descriptor.
BYTE bDescriptorType; // ENDPOINT descriptor type (USB_DESCRIPTOR_ENDPOINT).
BYTE bEndpointAddress; // Endpoint address. Bit 7 indicates direction (0=OUT, 1=IN).
BYTE bmAttributes; // Endpoint transfer type.
WORD wMaxPacketSize; // Maximum packet size.
BYTE bInterval; // Polling interval in frames.
} USB_ENDPOINT_DESCRIPTOR;
// Endpoint Direction
#define EP_DIR_IN 0x80 // Data flows from device to host
#define EP_DIR_OUT 0x00 // Data flows from host to device
// ******************************************************************
// USB Endpoint Attributes
// ******************************************************************
// Section: Transfer Types
#define EP_ATTR_CONTROL (0<<0) // Endoint used for control transfers
#define EP_ATTR_ISOCH (1<<0) // Endpoint used for isochronous transfers
#define EP_ATTR_BULK (2<<0) // Endpoint used for bulk transfers
#define EP_ATTR_INTR (3<<0) // Endpoint used for interrupt transfers
// Section: Synchronization Types (for isochronous enpoints)
#define EP_ATTR_NO_SYNC (0<<2) // No Synchronization
#define EP_ATTR_ASYNC (1<<2) // Asynchronous
#define EP_ATTR_ADAPT (2<<2) // Adaptive synchronization
#define EP_ATTR_SYNC (3<<2) // Synchronous
// Section: Usage Types (for isochronous endpoints)
#define EP_ATTR_DATA (0<<4) // Data Endpoint
#define EP_ATTR_FEEDBACK (1<<4) // Feedback endpoint
#define EP_ATTR_IMP_FB (2<<4) // Implicit Feedback data EP
// Section: Max Packet Sizes
#define EP_MAX_PKT_INTR_LS 8 // Max low-speed interrupt packet
#define EP_MAX_PKT_INTR_FS 64 // Max full-speed interrupt packet
#define EP_MAX_PKT_ISOCH_FS 1023 // Max full-speed isochronous packet
#define EP_MAX_PKT_BULK_FS 64 // Max full-speed bulk packet
#define EP_LG_PKT_BULK_FS 32 // Large full-speed bulk packet
#define EP_MED_PKT_BULK_FS 16 // Medium full-speed bulk packet
#define EP_SM_PKT_BULK_FS 8 // Small full-speed bulk packet
/* Descriptor IDs
The descriptor ID type defines the information required by the HOST during a
GET_DESCRIPTOR request
*/
typedef struct
{
BYTE index;
BYTE type;
UINT16 language_id;
} DESCRIPTOR_ID;
// *****************************************************************************
/* USB OTG Descriptor Structure
This struct defines the structure of a USB OTG Descriptor. Note that this
structure may need to be packed, or even accessed as bytes, to properly access
the correct fields when used on some device architectures.
*/
typedef struct __attribute__ ((packed)) _USB_OTG_DESCRIPTOR
{
BYTE bLength; // Length of this descriptor.
BYTE bDescriptorType; // OTG descriptor type (USB_DESCRIPTOR_OTG).
BYTE bmAttributes; // OTG attributes.
} USB_OTG_DESCRIPTOR;
// ******************************************************************
// Section: USB String Descriptor Structure
// ******************************************************************
// This structure describes the USB string descriptor. The string
// descriptor provides user-readable information about various aspects of
// the device. The first string desriptor (string descriptor zero (0)),
// provides a list of the number of languages supported by the set of
// string descriptors for this device instead of an actual string.
//
// Note: The strings are in 2-byte-per-character unicode, not ASCII.
//
// Note: This structure only describes the "header" of the string
// descriptor. The actual data (either the language ID array or the
// array of unicode characters making up the string, must be allocated
// immediately following this header with no padding between them.
typedef struct __attribute__ ((packed)) _USB_STRING_DSC
{
BYTE bLength; // Size of this descriptor
BYTE bDescriptorType; // Type, USB_DSC_STRING
} USB_STRING_DESCRIPTOR;
// ******************************************************************
// Section: USB Device Qualifier Descriptor Structure
// ******************************************************************
// This structure describes the device qualifier descriptor. The device
// qualifier descriptor provides overall device information if the device
// supports "other" speeds.
//
// Note: A high-speed device may support "other" speeds (ie. full or low).
// If so, it may need to implement the the device qualifier and other
// speed descriptors.
typedef struct __attribute__ ((packed)) _USB_DEVICE_QUALIFIER_DESCRIPTOR
{
BYTE bLength; // Size of this descriptor
BYTE bType; // Type, always USB_DESCRIPTOR_DEVICE_QUALIFIER
WORD bcdUSB; // USB spec version, in BCD
BYTE bDeviceClass; // Device class code
BYTE bDeviceSubClass; // Device sub-class code
BYTE bDeviceProtocol; // Device protocol
BYTE bMaxPacketSize0; // EP0, max packet size
BYTE bNumConfigurations; // Number of "other-speed" configurations
BYTE bReserved; // Always zero (0)
} USB_DEVICE_QUALIFIER_DESCRIPTOR;
// ******************************************************************
// Section: USB Setup Packet Structure
// ******************************************************************
// This structure describes the data contained in a USB standard device
// request's setup packet. It is the data packet sent from the host to
// the device to control and configure the device.
//
// Note: Refer to the USB 2.0 specification for additional details on the
// usage of the setup packet and standard device requests.
typedef union __attribute__ ((packed))
{
/** Standard Device Requests ***********************************/
struct __attribute__ ((packed))
{
BYTE bmRequestType; //from table 9-2 of USB2.0 spec
BYTE bRequest; //from table 9-2 of USB2.0 spec
WORD wValue; //from table 9-2 of USB2.0 spec
WORD wIndex; //from table 9-2 of USB2.0 spec
WORD wLength; //from table 9-2 of USB2.0 spec
};
struct __attribute__ ((packed))
{
unsigned :8;
unsigned :8;
WORD_VAL W_Value; //from table 9-2 of USB2.0 spec, allows byte/bitwise access
WORD_VAL W_Index; //from table 9-2 of USB2.0 spec, allows byte/bitwise access
WORD_VAL W_Length; //from table 9-2 of USB2.0 spec, allows byte/bitwise access
};
struct __attribute__ ((packed))
{
unsigned Recipient:5; //Device,Interface,Endpoint,Other
unsigned RequestType:2; //Standard,Class,Vendor,Reserved
unsigned DataDir:1; //Host-to-device,Device-to-host
unsigned :8;
BYTE bFeature; //DEVICE_REMOTE_WAKEUP,ENDPOINT_HALT
unsigned :8;
unsigned :8;
unsigned :8;
unsigned :8;
unsigned :8;
};
struct __attribute__ ((packed))
{
union // offset description
{ // ------ ------------------------
BYTE bmRequestType; // 0 Bit-map of request type
struct
{
BYTE recipient: 5; // Recipient of the request
BYTE type: 2; // Type of request
BYTE direction: 1; // Direction of data X-fer
};
}requestInfo;
};
struct __attribute__ ((packed))
{
unsigned :8;
unsigned :8;
BYTE bDscIndex; //For Configuration and String DSC Only
BYTE bDescriptorType; //Device,Configuration,String
WORD wLangID; //Language ID
unsigned :8;
unsigned :8;
};
struct __attribute__ ((packed))
{
unsigned :8;
unsigned :8;
BYTE_VAL bDevADR; //Device Address 0-127
BYTE bDevADRH; //Must equal zero
unsigned :8;
unsigned :8;
unsigned :8;
unsigned :8;
};
struct __attribute__ ((packed))
{
unsigned :8;
unsigned :8;
BYTE bConfigurationValue; //Configuration Value 0-255
BYTE bCfgRSD; //Must equal zero (Reserved)
unsigned :8;
unsigned :8;
unsigned :8;
unsigned :8;
};
struct __attribute__ ((packed))
{
unsigned :8;
unsigned :8;
BYTE bAltID; //Alternate Setting Value 0-255
BYTE bAltID_H; //Must equal zero
BYTE bIntfID; //Interface Number Value 0-255
BYTE bIntfID_H; //Must equal zero
unsigned :8;
unsigned :8;
};
struct __attribute__ ((packed))
{
unsigned :8;
unsigned :8;
unsigned :8;
unsigned :8;
BYTE bEPID; //Endpoint ID (Number & Direction)
BYTE bEPID_H; //Must equal zero
unsigned :8;
unsigned :8;
};
struct __attribute__ ((packed))
{
unsigned :8;
unsigned :8;
unsigned :8;
unsigned :8;
unsigned EPNum:4; //Endpoint Number 0-15
unsigned :3;
unsigned EPDir:1; //Endpoint Direction: 0-OUT, 1-IN
unsigned :8;
unsigned :8;
unsigned :8;
};
/** End: Standard Device Requests ******************************/
} CTRL_TRF_SETUP, SETUP_PKT, *PSETUP_PKT;
// ******************************************************************
// ******************************************************************
// Section: USB Specification Constants
// ******************************************************************
// ******************************************************************
// Section: Valid PID Values
//DOM-IGNORE-BEGIN
#define PID_OUT 0x1 // PID for an OUT token
#define PID_ACK 0x2 // PID for an ACK handshake
#define PID_DATA0 0x3 // PID for DATA0 data
#define PID_PING 0x4 // Special PID PING
#define PID_SOF 0x5 // PID for a SOF token
#define PID_NYET 0x6 // PID for a NYET handshake
#define PID_DATA2 0x7 // PID for DATA2 data
#define PID_SPLIT 0x8 // Special PID SPLIT
#define PID_IN 0x9 // PID for a IN token
#define PID_NAK 0xA // PID for a NAK handshake
#define PID_DATA1 0xB // PID for DATA1 data
#define PID_PRE 0xC // Special PID PRE (Same as PID_ERR)
#define PID_ERR 0xC // Special PID ERR (Same as PID_PRE)
#define PID_SETUP 0xD // PID for a SETUP token
#define PID_STALL 0xE // PID for a STALL handshake
#define PID_MDATA 0xF // PID for MDATA data
#define PID_MASK_DATA 0x03 // Data PID mask
#define PID_MASK_DATA_SHIFTED (PID_MASK_DATA << 2) // Data PID shift to proper position
//DOM-IGNORE-END
// Section: USB Token Types
//DOM-IGNORE-BEGIN
#define USB_TOKEN_OUT 0x01 // U1TOK - OUT token
#define USB_TOKEN_IN 0x09 // U1TOK - IN token
#define USB_TOKEN_SETUP 0x0D // U1TOK - SETUP token
//DOM-IGNORE-END
// Section: OTG Descriptor Constants
#define OTG_HNP_SUPPORT 0x02 // OTG Descriptor bmAttributes - HNP support flag
#define OTG_SRP_SUPPORT 0x01 // OTG Descriptor bmAttributes - SRP support flag
// Section: Endpoint Directions
#define USB_IN_EP 0x80 // IN endpoint mask
#define USB_OUT_EP 0x00 // OUT endpoint mask
// Section: Standard Device Requests
#define USB_REQUEST_GET_STATUS 0 // Standard Device Request - GET STATUS
#define USB_REQUEST_CLEAR_FEATURE 1 // Standard Device Request - CLEAR FEATURE
#define USB_REQUEST_SET_FEATURE 3 // Standard Device Request - SET FEATURE
#define USB_REQUEST_SET_ADDRESS 5 // Standard Device Request - SET ADDRESS
#define USB_REQUEST_GET_DESCRIPTOR 6 // Standard Device Request - GET DESCRIPTOR
#define USB_REQUEST_SET_DESCRIPTOR 7 // Standard Device Request - SET DESCRIPTOR
#define USB_REQUEST_GET_CONFIGURATION 8 // Standard Device Request - GET CONFIGURATION
#define USB_REQUEST_SET_CONFIGURATION 9 // Standard Device Request - SET CONFIGURATION
#define USB_REQUEST_GET_INTERFACE 10 // Standard Device Request - GET INTERFACE
#define USB_REQUEST_SET_INTERFACE 11 // Standard Device Request - SET INTERFACE
#define USB_REQUEST_SYNCH_FRAME 12 // Standard Device Request - SYNCH FRAME
#define USB_FEATURE_ENDPOINT_HALT 0 // CLEAR/SET FEATURE - Endpoint Halt
#define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // CLEAR/SET FEATURE - Device remote wake-up
#define USB_FEATURE_TEST_MODE 2 // CLEAR/SET FEATURE - Test mode
// Section: Setup Data Constants
#define USB_SETUP_HOST_TO_DEVICE 0x00 // Device Request bmRequestType transfer direction - host to device transfer
#define USB_SETUP_DEVICE_TO_HOST 0x80 // Device Request bmRequestType transfer direction - device to host transfer
#define USB_SETUP_TYPE_STANDARD 0x00 // Device Request bmRequestType type - standard
#define USB_SETUP_TYPE_CLASS 0x20 // Device Request bmRequestType type - class
#define USB_SETUP_TYPE_VENDOR 0x40 // Device Request bmRequestType type - vendor
#define USB_SETUP_RECIPIENT_DEVICE 0x00 // Device Request bmRequestType recipient - device
#define USB_SETUP_RECIPIENT_INTERFACE 0x01 // Device Request bmRequestType recipient - interface
#define USB_SETUP_RECIPIENT_ENDPOINT 0x02 // Device Request bmRequestType recipient - endpoint
#define USB_SETUP_RECIPIENT_OTHER 0x03 // Device Request bmRequestType recipient - other
#define USB_SETUP_HOST_TO_DEVICE_BITFIELD (USB_SETUP_HOST_TO_DEVICE>>7) // Device Request bmRequestType transfer direction - host to device transfer - bit definition
#define USB_SETUP_DEVICE_TO_HOST_BITFIELD (USB_SETUP_DEVICE_TO_HOST>>7) // Device Request bmRequestType transfer direction - device to host transfer - bit definition
#define USB_SETUP_TYPE_STANDARD_BITFIELD (USB_SETUP_TYPE_STANDARD>>5) // Device Request bmRequestType type - standard
#define USB_SETUP_TYPE_CLASS_BITFIELD (USB_SETUP_TYPE_CLASS>>5) // Device Request bmRequestType type - class
#define USB_SETUP_TYPE_VENDOR_BITFIELD (USB_SETUP_TYPE_VENDOR>>5) // Device Request bmRequestType type - vendor
#define USB_SETUP_RECIPIENT_DEVICE_BITFIELD (USB_SETUP_RECIPIENT_DEVICE) // Device Request bmRequestType recipient - device
#define USB_SETUP_RECIPIENT_INTERFACE_BITFIELD (USB_SETUP_RECIPIENT_INTERFACE) // Device Request bmRequestType recipient - interface
#define USB_SETUP_RECIPIENT_ENDPOINT_BITFIELD (USB_SETUP_RECIPIENT_ENDPOINT) // Device Request bmRequestType recipient - endpoint
#define USB_SETUP_RECIPIENT_OTHER_BITFIELD (USB_SETUP_RECIPIENT_OTHER) // Device Request bmRequestType recipient - other
// Section: OTG SET FEATURE Constants
#define OTG_FEATURE_B_HNP_ENABLE 3 // SET FEATURE OTG - Enable B device to perform HNP
#define OTG_FEATURE_A_HNP_SUPPORT 4 // SET FEATURE OTG - A device supports HNP
#define OTG_FEATURE_A_ALT_HNP_SUPPORT 5 // SET FEATURE OTG - Another port on the A device supports HNP
// Section: USB Endpoint Transfer Types
#define USB_TRANSFER_TYPE_CONTROL 0x00 // Endpoint is a control endpoint.
#define USB_TRANSFER_TYPE_ISOCHRONOUS 0x01 // Endpoint is an isochronous endpoint.
#define USB_TRANSFER_TYPE_BULK 0x02 // Endpoint is a bulk endpoint.
#define USB_TRANSFER_TYPE_INTERRUPT 0x03 // Endpoint is an interrupt endpoint.
// Section: Standard Feature Selectors for CLEAR_FEATURE Requests
#define USB_FEATURE_ENDPOINT_STALL 0 // Endpoint recipient
#define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // Device recipient
#define USB_FEATURE_TEST_MODE 2 // Device recipient
// Section: USB Class Code Definitions
#define USB_HUB_CLASSCODE 0x09 // Class code for a hub.
/********************************************************************
USB Endpoint Definitions
USB Standard EP Address Format: DIR:X:X:X:EP3:EP2:EP1:EP0
This is used in the descriptors.
********************************************************************/
#define _EP_IN 0x80
#define _EP_OUT 0x00
#define _EP01_OUT 0x01
#define _EP01_IN 0x81
#define _EP02_OUT 0x02
#define _EP02_IN 0x82
#define _EP03_OUT 0x03
#define _EP03_IN 0x83
#define _EP04_OUT 0x04
#define _EP04_IN 0x84
#define _EP05_OUT 0x05
#define _EP05_IN 0x85
#define _EP06_OUT 0x06
#define _EP06_IN 0x86
#define _EP07_OUT 0x07
#define _EP07_IN 0x87
#define _EP08_OUT 0x08
#define _EP08_IN 0x88
#define _EP09_OUT 0x09
#define _EP09_IN 0x89
#define _EP10_OUT 0x0A
#define _EP10_IN 0x8A
#define _EP11_OUT 0x0B
#define _EP11_IN 0x8B
#define _EP12_OUT 0x0C
#define _EP12_IN 0x8C
#define _EP13_OUT 0x0D
#define _EP13_IN 0x8D
#define _EP14_OUT 0x0E
#define _EP14_IN 0x8E
#define _EP15_OUT 0x0F
#define _EP15_IN 0x8F
/* Configuration Attributes */
#define _DEFAULT (0x01<<7) //Default Value (Bit 7 is set)
#define _SELF (0x01<<6) //Self-powered (Supports if set)
#define _RWU (0x01<<5) //Remote Wakeup (Supports if set)
#define _HNP (0x01 << 1) //HNP (Supports if set)
#define _SRP (0x01) //SRP (Supports if set)
/* Endpoint Transfer Type */
#define _CTRL 0x00 //Control Transfer
#define _ISO 0x01 //Isochronous Transfer
#define _BULK 0x02 //Bulk Transfer
#define _INTERRUPT 0x03 //Interrupt Transfer
#if defined(__18CXX) || defined(__C30__) || defined __XC16__
#define _INT 0x03 //Interrupt Transfer
#endif
/* Isochronous Endpoint Synchronization Type */
#define _NS (0x00<<2) //No Synchronization
#define _AS (0x01<<2) //Asynchronous
#define _AD (0x02<<2) //Adaptive
#define _SY (0x03<<2) //Synchronous
/* Isochronous Endpoint Usage Type */
#define _DE (0x00<<4) //Data endpoint
#define _FE (0x01<<4) //Feedback endpoint
#define _IE (0x02<<4) //Implicit feedback Data endpoint
//These are the directional indicators used for the USBTransferOnePacket()
// function.
#define OUT_FROM_HOST 0
#define IN_TO_HOST 1
#endif // _USB_CH9_H_
/*************************************************************************
* EOF
*/

View File

@@ -0,0 +1,601 @@
/******************************************************************************
Common USB Library Definitions (Header File)
Summary:
This file defines data types, constants, and macros that are common to
multiple layers of the Microchip USB Firmware Stack.
Description:
This file defines data types, constants, and macros that are common to
multiple layers of the Microchip USB Firmware Stack.
This file is located in the "\<Install Directory\>\\Microchip\\Include\\USB"
directory.
When including this file in a new project, this file can either be
referenced from the directory in which it was installed or copied
directly into the user application folder. If the first method is
chosen to keep the file located in the folder in which it is installed
then include paths need to be added so that the library and the
application both know where to reference each others files. If the
application folder is located in the same folder as the Microchip
folder (like the current demo folders), then the following include
paths need to be added to the application's project:
.
..\\..\\MicrochipInclude
If a different directory structure is used, modify the paths as
required. An example using absolute paths instead of relative paths
would be the following:
C:\\Microchip Solutions\\Microchip\\Include
C:\\Microchip Solutions\\My Demo Application
*******************************************************************************/
//DOM-IGNORE-BEGIN
/*******************************************************************************
FileName: usb_common.h
Dependencies: See included files, below.
Processor: PIC18/PIC24/PIC32MX microcontrollers with USB module
Compiler: C18 v3.13+/C30 v2.01+/C32 v0.00.18+
Company: Microchip Technology, Inc.
Software License Agreement
The software supplied herewith by Microchip Technology Incorporated
(the “Company”) for its PICmicro® Microcontroller is intended and
supplied to you, the Companys customer, for use solely and
exclusively on Microchip PICmicro Microcontroller products. The
software is owned by the Company and/or its supplier, and is
protected under applicable copyright laws. All rights are reserved.
Any use in violation of the foregoing restrictions may subject the
user to criminal sanctions under applicable laws, as well as to
civil liability for the breach of the terms and conditions of this
license.
THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*******************************************************************************/
//DOM-IGNORE-END
//DOM-IGNORE-BEGIN
/********************************************************************
Change History:
Rev Description
---- -----------
2.6 Moved many of the USB events
2.6a Changed the limit of USB_EVENT from UINT_MAX to INT_MAX
2.7 No change
********************************************************************/
//DOM-IGNORE-END
//DOM-IGNORE-BEGIN
#ifndef _USB_COMMON_H_
#define _USB_COMMON_H_
//DOM-IGNORE-END
#include <limits.h>
// *****************************************************************************
// *****************************************************************************
// Section: USB Constants
// *****************************************************************************
// *****************************************************************************
// Section: Error Code Values
#define USB_SUCCESS 0x00 // USB operation successful.
#define USB_INVALID_STATE 0x01 // Operation cannot be performed in current state.
#define USB_BUSY 0x02 // A transaction is already in progress.
#define USB_ILLEGAL_REQUEST 0x03 // Cannot perform requested operation.
#define USB_INVALID_CONFIGURATION 0x04 // Configuration descriptor not found.
#define USB_MEMORY_ALLOCATION_ERROR 0x05 // Out of dynamic memory.
#define USB_UNKNOWN_DEVICE 0x06 // Device with specified address is not attached.
#define USB_CANNOT_ENUMERATE 0x07 // Cannot enumerate the attached device.
#define USB_EVENT_QUEUE_FULL 0x08 // Event queue was full when an event occured.
#define USB_ENDPOINT_BUSY 0x10 // Endpoint is currently processing a transaction.
#define USB_ENDPOINT_STALLED 0x11 // Endpoint is currently stalled. User must clear the condition.
#define USB_ENDPOINT_ERROR 0x12 // Will need more than this eventually
#define USB_ENDPOINT_ERROR_ILLEGAL_PID 0x13 // Illegal PID received.
#define USB_ENDPOINT_NOT_FOUND 0x14 // Requested endpoint does not exist on device.
#define USB_ENDPOINT_ILLEGAL_DIRECTION 0x15 // Reads must be performe on IN endpoints, writes on OUT endpoints.
//#define USB_ENDPOINT_TRANSACTION_IN_PROGRESS 0x16
#define USB_ENDPOINT_NAK_TIMEOUT 0x17 // Too many NAK's occurred while waiting for the current transaction.
#define USB_ENDPOINT_ILLEGAL_TYPE 0x18 // Transfer type must match endpoint description.
#define USB_ENDPOINT_UNRESOLVED_STATE 0x19 // Endpoint is in an unknown state after completing a transaction.
#define USB_ENDPOINT_ERROR_BIT_STUFF 0x20 // USB Module - Bit stuff error.
#define USB_ENDPOINT_ERROR_DMA 0x21 // USB Module - DMA error.
#define USB_ENDPOINT_ERROR_TIMEOUT 0x22 // USB Module - Bus timeout.
#define USB_ENDPOINT_ERROR_DATA_FIELD 0x23 // USB Module - Data field size error.
#define USB_ENDPOINT_ERROR_CRC16 0x24 // USB Module - CRC16 failure.
#define USB_ENDPOINT_ERROR_END_OF_FRAME 0x25 // USB Module - End of Frame error.
#define USB_ENDPOINT_ERROR_PID_CHECK 0x26 // USB Module - Illegal PID received.
#define USB_ENDPOINT_ERROR_BMX 0x27 // USB Module - Bus Matrix error.
#define USB_ERROR_INSUFFICIENT_POWER 0x28 // Too much power was requested
// Section: Return values for USBHostDeviceStatus()
#define USB_DEVICE_STATUS 0x30 // Offset for USBHostDeviceStatus() return codes
#define USB_DEVICE_ATTACHED (USB_DEVICE_STATUS | 0x30) // Device is attached and running
#define USB_DEVICE_DETACHED (USB_DEVICE_STATUS | 0x01) // No device is attached
#define USB_DEVICE_ENUMERATING (USB_DEVICE_STATUS | 0x02) // Device is enumerating
#define USB_HOLDING_OUT_OF_MEMORY (USB_DEVICE_STATUS | 0x03) // Not enough heap space available
#define USB_HOLDING_UNSUPPORTED_DEVICE (USB_DEVICE_STATUS | 0x04) // Invalid configuration or unsupported class
#define USB_HOLDING_UNSUPPORTED_HUB (USB_DEVICE_STATUS | 0x05) // Hubs are not supported
#define USB_HOLDING_INVALID_CONFIGURATION (USB_DEVICE_STATUS | 0x06) // Invalid configuration requested
#define USB_HOLDING_PROCESSING_CAPACITY (USB_DEVICE_STATUS | 0x07) // Processing requirement excessive
#define USB_HOLDING_POWER_REQUIREMENT (USB_DEVICE_STATUS | 0x08) // Power requirement excessive
#define USB_HOLDING_CLIENT_INIT_ERROR (USB_DEVICE_STATUS | 0x09) // Client driver failed to initialize
#define USB_DEVICE_SUSPENDED (USB_DEVICE_STATUS | 0x0A) // Device is suspended
#define USB_ERROR_CLASS_DEFINED 0x50 // Offset for application defined errors
#define USB_SINGLE_DEVICE_ADDRESS 0x01 // Default USB device address (single device support)
// *****************************************************************************
// *****************************************************************************
// Section: USB Data Types
// *****************************************************************************
// *****************************************************************************
// *****************************************************************************
/* Data Transfer Flags
The following flags are used in the flags parameter of the "USBDEVTransferData"
and "USBHALTransferData" routines. They can be accessed by the bitfield
definitions or the macros can be OR'd together to identify the endpoint number
and properties of the data transfer.
<code>
7 6 5 4 3 2 1 0 - Field name
| | | | \_____/
| | | | +----- ep_num - Endpoint number
| | | +---------- zero_pkt - End transfer with short or zero-sized packet
| | +------------ dts - 0=DATA0 packet, 1=DATA1 packet
| +-------------- force_dts - Force data toggle sync to match dts field
+---------------- direction - Transfer direction: 0=Receive, 1=Transmit
</code>
*/
typedef union
{
BYTE bitmap;
struct
{
BYTE ep_num: 4;
BYTE zero_pkt: 1;
BYTE dts: 1;
BYTE force_dts: 1;
BYTE direction: 1;
}field;
} TRANSFER_FLAGS;
// *****************************************************************************
/* Data Transfer Flags, Endpoint Number Constants
These macros can be used as values for the "ep_num" field of the TRANSFER_FLAGS
data type.
*/
#define USB_EP0 0 //
#define USB_EP1 1 //
#define USB_EP2 2 //
#define USB_EP3 3 //
#define USB_EP4 4 //
#define USB_EP5 5 //
#define USB_EP6 6 //
#define USB_EP7 7 //
#define USB_EP8 8 //
#define USB_EP9 9 //
#define USB_EP10 10 //
#define USB_EP11 11 //
#define USB_EP12 12 //
#define USB_EP13 13 //
#define USB_EP14 14 //
#define USB_EP15 15 //
// *****************************************************************************
/* Data Transfer Flags, Bitmap Constants
These macros can be used as values for the "bitmap" field of the TRANSFER_FLAGS
data type.
*/
#define USB_TRANSMIT 0x80 // Data will be transmitted to the USB
#define USB_RECEIVE 0x00 // Data will be received from the USB
#define USB_FORCE_DTS 0x40 // Forces data toggle sync as below:
#define USB_DTS_MASK 0x20 // Mask for DTS bit (below)
#define USB_ZERO_PKT 0x10 // End transfer w/a short or zero-length packet
#define USB_DATA0 0x00|USB_FORCE_DTS // Force DATA0
#define USB_DATA1 0x20|USB_FORCE_DTS // Force DATA1
#define USB_SETUP_PKT USB_RECEIVE|USB_DATA0|USB_EP0 // Setup Packet
#define USB_SETUP_DATA USB_DATA1|USB_ZERO_PKT|USB_EP0 // Setup-transfer Data Packet
#define USB_SETUP_STATUS USB_DATA1|USB_EP0 // Setup-transfer Status Packet
#define USB_EP_NUM_MASK 0x0F // Endpoint number (ep_num) mask
// *****************************************************************************
/* Data Transfer Flags, Initialization Macro
This macro can be used with the above bitmap constants to initialize a
TRANSFER_FLAGS value. It provides the correct data type to avoid compiler
warnings.
*/
#define XFLAGS(f) ((TRANSFER_FLAGS)((BYTE)(f))) // Initialization Macro
// *****************************************************************************
/* USB Events
This enumeration identifies USB events that occur. It is used to
inform USB drivers and applications of events on the bus. It is passed
as a parameter to the event-handling routine, which must match the
prototype of the USB_CLIENT_EVENT_HANDLER data type, when an event occurs.
*/
typedef enum
{
// No event occured (NULL event)
EVENT_NONE = 0,
EVENT_DEVICE_STACK_BASE = 1,
EVENT_HOST_STACK_BASE = 100,
// A USB hub has been attached. Hub support is not currently available.
EVENT_HUB_ATTACH,
// A stall has occured. This event is not used by the Host stack.
EVENT_STALL,
// VBus SRP Pulse, (VBus > 2.0v), Data: BYTE Port Number (For future support)
EVENT_VBUS_SES_REQUEST,
// The voltage on Vbus has dropped below 4.4V/4.7V. The application is
// responsible for monitoring Vbus and calling USBHostVbusEvent() with this
// event. This event is not generated by the stack.
EVENT_VBUS_OVERCURRENT,
// An enumerating device is requesting power. The data associated with this
// event is of the data type USB_VBUS_POWER_EVENT_DATA. Note that
// the requested current is specified in 2mA units, identical to the power
// specification in a device's Configuration Descriptor.
EVENT_VBUS_REQUEST_POWER,
// Release power from a detaching device. The data associated with this
// event is of the data type USB_VBUS_POWER_EVENT_DATA. The current value
// specified in the data can be ignored.
EVENT_VBUS_RELEASE_POWER,
// The voltage on Vbus is good, and the USB OTG module can be powered on.
// The application is responsible for monitoring Vbus and calling
// USBHostVbusEvent() with this event. This event is not generated by the
// stack. If the application issues an EVENT_VBUS_OVERCURRENT, then no
// power will be applied to that port, and no device can attach to that
// port, until the application issues the EVENT_VBUS_POWER_AVAILABLE for
// the port.
EVENT_VBUS_POWER_AVAILABLE,
// The attached device is not supported by the application. The attached
// device is not allowed to enumerate.
EVENT_UNSUPPORTED_DEVICE,
// Cannot enumerate the attached device. This is generated if communication
// errors prevent the device from enumerating.
EVENT_CANNOT_ENUMERATE,
// The client driver cannot initialize the the attached device. The
// attached is not allowed to enumerate.
EVENT_CLIENT_INIT_ERROR,
// The Host stack does not have enough heap space to enumerate the device.
// Check the amount of heap space allocated to the application. In MPLAB,
// select Project> Build Options...> Project. Select the appropriate
// linker tab, and inspect the "Heap size" entry.
EVENT_OUT_OF_MEMORY,
// Unspecified host error. (This error should not occur).
EVENT_UNSPECIFIED_ERROR,
// USB cable has been detached. The data associated with this event is the
// address of detached device, a single BYTE.
EVENT_DETACH,
// A USB transfer has completed. The data associated with this event is of
// the data type HOST_TRANSFER_DATA if the event is generated from the host
// stack.
EVENT_TRANSFER,
// A USB Start of Frame token has been received. This event is not
// used by the Host stack.
EVENT_SOF,
// Device-mode resume received. This event is not used by the Host stack.
EVENT_RESUME,
// Device-mode suspend/idle event received. This event is not used by the
// Host stack.
EVENT_SUSPEND,
// Device-mode bus reset received. This event is not used by the Host
// stack.
EVENT_RESET,
// In Host mode, an isochronous data read has completed. This event will only
// be passed to the DataEventHandler, which is only utilized if it is defined.
// Note that the DataEventHandler is called from within the USB interrupt, so
// it is critical that it return in time for the next isochronous data packet.
EVENT_DATA_ISOC_READ,
// In Host mode, an isochronous data write has completed. This event will only
// be passed to the DataEventHandler, which is only utilized if it is defined.
// Note that the DataEventHandler is called from within the USB interrupt, so
// it is critical that it return in time for the next isochronous data packet.
EVENT_DATA_ISOC_WRITE,
// In Host mode, this event gives the application layer the option to reject
// a client driver that was selected by the stack. This is needed when multiple
// devices are supported by class level support, but one configuration and client
// driver is preferred over another. Since configuration number is not guaranteed,
// the stack cannot do this automatically. This event is issued only when
// looking through configuration descriptors; the driver selected at the device
// level cannot be overridden, since there shouldn't be any other options to
// choose from.
EVENT_OVERRIDE_CLIENT_DRIVER_SELECTION,
// In host mode, this event is thrown for every millisecond that passes. Like all
// events, this is thrown from the USBHostTasks() or USBTasks() routine so its
// timeliness will be determined by the rate that these functions are called. If
// they are not called very often, then the 1ms events will build up and be
// dispatched as the USBTasks() or USBHostTasks() functions are called (one event
// per call to these functions.
EVENT_1MS,
// Class-defined event offsets start here:
EVENT_GENERIC_BASE = 400, // Offset for Generic class events
EVENT_MSD_BASE = 500, // Offset for Mass Storage Device class events
EVENT_HID_BASE = 600, // Offset for Human Interface Device class events
EVENT_PRINTER_BASE = 700, // Offset for Printer class events
EVENT_CDC_BASE = 800, // Offset for CDC class events
EVENT_CHARGER_BASE = 900, // Offset for Charger client driver events.
EVENT_AUDIO_BASE = 1000, // Offset for Audio client driver events.
EVENT_USER_BASE = 10000, // Add integral values to this event number
// to create user-defined events.
// There was a transfer error on the USB. The data associated with this
// event is of data type HOST_TRANSFER_DATA.
EVENT_BUS_ERROR = INT_MAX
} USB_EVENT;
// *****************************************************************************
/* EVENT_TRANSFER Data
This data structure is passed to the appropriate layer's
USB_EVENT_HANDLER when an EVT_XFER event has occured, indicating
that a transfer has completed on the USB. It provides the endpoint,
direction, and actual size of the transfer.
*/
typedef struct _transfer_event_data
{
TRANSFER_FLAGS flags; // Transfer flags (see above)
UINT32 size; // Actual number of bytes transferred
BYTE pid; // Packet ID
} USB_TRANSFER_EVENT_DATA;
// *****************************************************************************
/* EVENT_VBUS_REQUEST_POWER and EVENT_VBUS_RELEASE_POWER Data
This data structure is passed to the appropriate layer's
USB_EVENT_HANDLER when an EVENT_VBUS_REQUEST_POWER or EVENT_VBUS_RELEASE_POWER
event has occured, indicating that a change in Vbus power is being requested.
*/
typedef struct _vbus_power_data
{
BYTE port; // Physical port number
BYTE current; // Current in 2mA units
} USB_VBUS_POWER_EVENT_DATA;
// *****************************************************************************
/* USB_OVERRIDE_CLIENT_DRIVER_EVENT_DATA Data
This data structure is passed to the application layer when a client driver is
select, in case multiple client drivers can support a particular device.
*/
typedef struct _override_client_driver_data
{
WORD idVendor;
WORD idProduct;
BYTE bDeviceClass;
BYTE bDeviceSubClass;
BYTE bDeviceProtocol;
} USB_OVERRIDE_CLIENT_DRIVER_EVENT_DATA;
// *****************************************************************************
/* EVT_STALL Data
The EVT_STALL event has a 16-bit data value associated with it where
a bit is set in the position for each endpoint that is currently
stalled (ie. bit 0 = EP0, bit 1 = EP1, etc.)
*/
// *****************************************************************************
// *****************************************************************************
// Section: Event Handling Routines
// *****************************************************************************
// *****************************************************************************
/*******************************************************************************
Function:
BOOL <Event-handling Function Name> ( USB_EVENT event,
void *data, unsigned int size )
Description:
This routine is a "call out" routine that must be implemented by
any layer of the USB SW Stack (except the HAL which is at the
root of the event-call tree that needs to receive events. When
an event occurs, the HAL calls the next higher layer in the
stack to handle the event. Each layer either handles the event
or calls the layer above it to handle the event. Events are
identified by the "event" parameter and may have associated
data. If the higher layer was able to handle the event, it
should return TRUE. If not, it should return FALSE.
Preconditions:
USBInitialize must have been called to initialize the USB SW
Stack.
Paramters:
USB_EVENT event - Identifies the bus event that occured
void *data - Pointer to event-specific data
unsigned int size - Size of the event-specific data
Return Values:
None
Remarks:
The function is name is defined by the layer that implements
it. A pointer to the function will be placed by into a table
that the lower-layer will use to call it. This requires the
function to use a specific call "signature" (return data type
and values and data parameter types and values).
*******************************************************************************/
typedef BOOL (*USB_EVENT_HANDLER) ( USB_EVENT event, void *data, unsigned int size );
// *****************************************************************************
// *****************************************************************************
// Section: USB Application Program Interface (API) Routines
// *****************************************************************************
// *****************************************************************************
/****************************************************************************
Function:
BOOL USBInitialize ( unsigned long flags )
Summary:
This interface initializes the variables of the USB host stack.
Description:
This interface initializes the USB stack.
Precondition:
None
Parameters:
flags - reserved
Return Values:
TRUE - Initialization successful
FALSE - Initialization failure
Remarks:
This interface is implemented as a macro that can be defined by the
application or by default is defined correctly for the stack mode.
***************************************************************************/
#ifndef USBInitialize
#if defined( USB_SUPPORT_DEVICE )
#if defined( USB_SUPPORT_HOST )
#if defined( USB_SUPPORT_OTG )
#error "USB OTG is not yet supported."
#else
#define USBInitialize(f) \
(USBDEVInitialize(f) && USBHostInit(f)) ? \
TRUE : FALSE
#endif
#else
#define USBInitialize(f) USBDeviceInit()
#endif
#else
#if defined( USB_SUPPORT_HOST )
#define USBInitialize(f) USBHostInit(f)
#else
#error "Application must define support mode in usb_config.h"
#endif
#endif
#endif
/****************************************************************************
Function:
void USBTasks( void )
Summary:
This function executes the tasks for USB operation.
Description:
This function executes the tasks for USB host operation. It must be
executed on a regular basis to keep everything functioning.
Precondition:
USBInitialize() has been called.
Parameters:
None
Returns:
None
Remarks:
This interface is implemented as a macro that can be defined by the
application or by default is defined correctly for the stack mode.
***************************************************************************/
#ifndef USBTasks // Implemented as a macro that can be overridden.
#if defined( USB_SUPPORT_DEVICE )
#if defined( USB_SUPPORT_HOST )
#if defined( USB_SUPPORT_OTG )
#error "USB OTG is not yet supported."
#else
#define USBTasks() {USBHostTasks(); USBHALHandleBusEvent();}
#endif
#else
#define USBTasks() USBDeviceTasks()
#endif
#else
#if defined( USB_SUPPORT_HOST )
#define USBTasks() USBHostTasks()
#else
#error "Application must define support mode in usb_config.h"
#endif
#endif
#endif
#define USB_PING_PONG__NO_PING_PONG 0x00 //0b00
#define USB_PING_PONG__EP0_OUT_ONLY 0x01 //0b01
#define USB_PING_PONG__FULL_PING_PONG 0x02 //0b10
#define USB_PING_PONG__ALL_BUT_EP0 0x03 //0b11
#endif // _USB_COMMON_H_
/*************************************************************************
* EOF
*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,490 @@
/********************************************************************
File Information:
FileName: usb_device_local.h
Dependencies: See INCLUDES section
Processor: PIC18,PIC24, PIC32 and dsPIC33E USB Microcontrollers
Hardware: The code is natively intended to be used on the following
hardware platforms: PICDEM<45> FS USB Demo Board,
PIC18F87J50 FS USB Plug-In Module, or
Explorer 16 + compatible USB PIM. The firmware may be
modified for use on other USB platforms by editing the
HardwareProfile.h file.
Complier: Microchip C18 (for PIC18),C30 (for PIC24 and dsPIC33E)
and C32 (for PIC32)
Company: Microchip Technology, Inc.
Software License Agreement:
The software supplied herewith by Microchip Technology Incorporated
(the <20>Company<6E>) for its PIC<49> Microcontroller is intended and
supplied to you, the Company<6E>s customer, for use solely and
exclusively on Microchip PIC Microcontroller products. The
software is owned by the Company and/or its supplier, and is
protected under applicable copyright laws. All rights are reserved.
Any use in violation of the foregoing restrictions may subject the
user to criminal sanctions under applicable laws, as well as to
civil liability for the breach of the terms and conditions of this
license.
THIS SOFTWARE IS PROVIDED IN AN <20>AS IS<49> CONDITION. NO WARRANTIES,
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
Summary:
This file contains functions, macros, definitions, variables,
datatypes, etc. that are required for usage with the MCHPFSUSB device
stack. This file should be included in projects that use the device stack.
This file is located in the "\<Install Directory\>\\Microchip\\USB"
directory.
Description:
USB Device Stack File
This file contains functions, macros, definitions, variables,
datatypes, etc. that are required for usage with the MCHPFSUSB device
stack. This file should be included in projects that use the device stack.
This file is located in the "\<Install Directory\>\\Microchip\\USB"
directory.
When including this file in a new project, this file can either be
referenced from the directory in which it was installed or copied
directly into the user application folder. If the first method is
chosen to keep the file located in the folder in which it is installed
then include paths need to be added so that the library and the
application both know where to reference each others files. If the
application folder is located in the same folder as the Microchip
folder (like the current demo folders), then the following include
paths need to be added to the application's project:
.
..\\..\\MicrochipInclude
If a different directory structure is used, modify the paths as
required. An example using absolute paths instead of relative paths
would be the following:
C:\\Microchip Solutions\\Microchip\\Include
C:\\Microchip Solutions\\My Demo Application
********************************************************************
File Description:
Change History:
Rev Description
---- -----------
2.8 Initial revision. Contents extracted from the previous usb_device.c
file, so as to make the usb_device.c file less cluttered.
Fixed BD() and EP() macro computation error, when running in
USB_PING_PONG__EP0_OUT_ONLY mode.
2.9 No functional change. Fixed spelling typo in the name of
"USB_TRANSFER_COMPLETE_HANDLER()"
********************************************************************/
#include "usb_config.h"
/* Short Packet States - Used by Control Transfer Read - CTRL_TRF_TX */
#define SHORT_PKT_NOT_USED 0
#define SHORT_PKT_PENDING 1
#define SHORT_PKT_SENT 2
/* Control Transfer States */
#define WAIT_SETUP 0
#define CTRL_TRF_TX 1
#define CTRL_TRF_RX 2
typedef union
{
struct
{
unsigned char ping_pong_state :1;
unsigned char transfer_terminated :1;
} bits;
BYTE Val;
} EP_STATUS;
#if (USB_PING_PONG_MODE == USB_PING_PONG__NO_PING_PONG)
#define USB_NEXT_EP0_OUT_PING_PONG 0x0000 // Used in USB Device Mode only
#define USB_NEXT_EP0_IN_PING_PONG 0x0000 // Used in USB Device Mode only
#define USB_NEXT_PING_PONG 0x0000 // Used in USB Device Mode only
#define EP0_OUT_EVEN 0 // Used in USB Device Mode only
#define EP0_OUT_ODD 0 // Used in USB Device Mode only
#define EP0_IN_EVEN 1 // Used in USB Device Mode only
#define EP0_IN_ODD 1 // Used in USB Device Mode only
#define EP1_OUT_EVEN 2 // Used in USB Device Mode only
#define EP1_OUT_ODD 2 // Used in USB Device Mode only
#define EP1_IN_EVEN 3 // Used in USB Device Mode only
#define EP1_IN_ODD 3 // Used in USB Device Mode only
#define EP2_OUT_EVEN 4 // Used in USB Device Mode only
#define EP2_OUT_ODD 4 // Used in USB Device Mode only
#define EP2_IN_EVEN 5 // Used in USB Device Mode only
#define EP2_IN_ODD 5 // Used in USB Device Mode only
#define EP3_OUT_EVEN 6 // Used in USB Device Mode only
#define EP3_OUT_ODD 6 // Used in USB Device Mode only
#define EP3_IN_EVEN 7 // Used in USB Device Mode only
#define EP3_IN_ODD 7 // Used in USB Device Mode only
#define EP4_OUT_EVEN 8 // Used in USB Device Mode only
#define EP4_OUT_ODD 8 // Used in USB Device Mode only
#define EP4_IN_EVEN 9 // Used in USB Device Mode only
#define EP4_IN_ODD 9 // Used in USB Device Mode only
#define EP5_OUT_EVEN 10 // Used in USB Device Mode only
#define EP5_OUT_ODD 10 // Used in USB Device Mode only
#define EP5_IN_EVEN 11 // Used in USB Device Mode only
#define EP5_IN_ODD 11 // Used in USB Device Mode only
#define EP6_OUT_EVEN 12 // Used in USB Device Mode only
#define EP6_OUT_ODD 12 // Used in USB Device Mode only
#define EP6_IN_EVEN 13 // Used in USB Device Mode only
#define EP6_IN_ODD 13 // Used in USB Device Mode only
#define EP7_OUT_EVEN 14 // Used in USB Device Mode only
#define EP7_OUT_ODD 14 // Used in USB Device Mode only
#define EP7_IN_EVEN 15 // Used in USB Device Mode only
#define EP7_IN_ODD 15 // Used in USB Device Mode only
#define EP8_OUT_EVEN 16 // Used in USB Device Mode only
#define EP8_OUT_ODD 16 // Used in USB Device Mode only
#define EP8_IN_EVEN 17 // Used in USB Device Mode only
#define EP8_IN_ODD 17 // Used in USB Device Mode only
#define EP9_OUT_EVEN 18 // Used in USB Device Mode only
#define EP9_OUT_ODD 18 // Used in USB Device Mode only
#define EP9_IN_EVEN 19 // Used in USB Device Mode only
#define EP9_IN_ODD 19 // Used in USB Device Mode only
#define EP10_OUT_EVEN 20 // Used in USB Device Mode only
#define EP10_OUT_ODD 20 // Used in USB Device Mode only
#define EP10_IN_EVEN 21 // Used in USB Device Mode only
#define EP10_IN_ODD 21 // Used in USB Device Mode only
#define EP11_OUT_EVEN 22 // Used in USB Device Mode only
#define EP11_OUT_ODD 22 // Used in USB Device Mode only
#define EP11_IN_EVEN 23 // Used in USB Device Mode only
#define EP11_IN_ODD 23 // Used in USB Device Mode only
#define EP12_OUT_EVEN 24 // Used in USB Device Mode only
#define EP12_OUT_ODD 24 // Used in USB Device Mode only
#define EP12_IN_EVEN 25 // Used in USB Device Mode only
#define EP12_IN_ODD 25 // Used in USB Device Mode only
#define EP13_OUT_EVEN 26 // Used in USB Device Mode only
#define EP13_OUT_ODD 26 // Used in USB Device Mode only
#define EP13_IN_EVEN 27 // Used in USB Device Mode only
#define EP13_IN_ODD 27 // Used in USB Device Mode only
#define EP14_OUT_EVEN 28 // Used in USB Device Mode only
#define EP14_OUT_ODD 28 // Used in USB Device Mode only
#define EP14_IN_EVEN 29 // Used in USB Device Mode only
#define EP14_IN_ODD 29 // Used in USB Device Mode only
#define EP15_OUT_EVEN 30 // Used in USB Device Mode only
#define EP15_OUT_ODD 30 // Used in USB Device Mode only
#define EP15_IN_EVEN 31 // Used in USB Device Mode only
#define EP15_IN_ODD 31 // Used in USB Device Mode only
#define EP(ep,dir,pp) (2*ep+dir) // Used in USB Device Mode only
#define BD(ep,dir,pp) ((8 * ep) + (4 * dir)) // Used in USB Device Mode only
#elif (USB_PING_PONG_MODE == USB_PING_PONG__EP0_OUT_ONLY)
#define USB_NEXT_EP0_OUT_PING_PONG 0x0004
#define USB_NEXT_EP0_IN_PING_PONG 0x0000
#define USB_NEXT_PING_PONG 0x0000
#define EP0_OUT_EVEN 0
#define EP0_OUT_ODD 1
#define EP0_IN_EVEN 2
#define EP0_IN_ODD 2
#define EP1_OUT_EVEN 3
#define EP1_OUT_ODD 3
#define EP1_IN_EVEN 4
#define EP1_IN_ODD 4
#define EP2_OUT_EVEN 5
#define EP2_OUT_ODD 5
#define EP2_IN_EVEN 6
#define EP2_IN_ODD 6
#define EP3_OUT_EVEN 7
#define EP3_OUT_ODD 7
#define EP3_IN_EVEN 8
#define EP3_IN_ODD 8
#define EP4_OUT_EVEN 9
#define EP4_OUT_ODD 9
#define EP4_IN_EVEN 10
#define EP4_IN_ODD 10
#define EP5_OUT_EVEN 11
#define EP5_OUT_ODD 11
#define EP5_IN_EVEN 12
#define EP5_IN_ODD 12
#define EP6_OUT_EVEN 13
#define EP6_OUT_ODD 13
#define EP6_IN_EVEN 14
#define EP6_IN_ODD 14
#define EP7_OUT_EVEN 15
#define EP7_OUT_ODD 15
#define EP7_IN_EVEN 16
#define EP7_IN_ODD 16
#define EP8_OUT_EVEN 17
#define EP8_OUT_ODD 17
#define EP8_IN_EVEN 18
#define EP8_IN_ODD 18
#define EP9_OUT_EVEN 19
#define EP9_OUT_ODD 19
#define EP9_IN_EVEN 20
#define EP9_IN_ODD 20
#define EP10_OUT_EVEN 21
#define EP10_OUT_ODD 21
#define EP10_IN_EVEN 22
#define EP10_IN_ODD 22
#define EP11_OUT_EVEN 23
#define EP11_OUT_ODD 23
#define EP11_IN_EVEN 24
#define EP11_IN_ODD 24
#define EP12_OUT_EVEN 25
#define EP12_OUT_ODD 25
#define EP12_IN_EVEN 26
#define EP12_IN_ODD 26
#define EP13_OUT_EVEN 27
#define EP13_OUT_ODD 27
#define EP13_IN_EVEN 28
#define EP13_IN_ODD 28
#define EP14_OUT_EVEN 29
#define EP14_OUT_ODD 29
#define EP14_IN_EVEN 30
#define EP14_IN_ODD 30
#define EP15_OUT_EVEN 31
#define EP15_OUT_ODD 31
#define EP15_IN_EVEN 32
#define EP15_IN_ODD 32
#define EP(ep,dir,pp) (2u*ep+dir+(((ep==0)&&(dir==0))?pp:1))
#define BD(ep,dir,pp) (4u*((2u*ep)+dir+(((ep==0)&&(dir==0))?pp:1)))
#elif (USB_PING_PONG_MODE == USB_PING_PONG__FULL_PING_PONG)
#if defined (__18CXX) || defined(__C30__) || defined __XC16__ || defined(__XC8)
#if (defined (__dsPIC33E__) || defined (__PIC24E__))
#define USB_NEXT_EP0_OUT_PING_PONG 0x0008
#define USB_NEXT_EP0_IN_PING_PONG 0x0008
#define USB_NEXT_PING_PONG 0x0008
#else
#define USB_NEXT_EP0_OUT_PING_PONG 0x0004
#define USB_NEXT_EP0_IN_PING_PONG 0x0004
#define USB_NEXT_PING_PONG 0x0004
#endif
#elif defined(__C32__)
#define USB_NEXT_EP0_OUT_PING_PONG 0x0008
#define USB_NEXT_EP0_IN_PING_PONG 0x0008
#define USB_NEXT_PING_PONG 0x0008
#else
#error "Not defined for this compiler"
#endif
#define EP0_OUT_EVEN 0
#define EP0_OUT_ODD 1
#define EP0_IN_EVEN 2
#define EP0_IN_ODD 3
#define EP1_OUT_EVEN 4
#define EP1_OUT_ODD 5
#define EP1_IN_EVEN 6
#define EP1_IN_ODD 7
#define EP2_OUT_EVEN 8
#define EP2_OUT_ODD 9
#define EP2_IN_EVEN 10
#define EP2_IN_ODD 11
#define EP3_OUT_EVEN 12
#define EP3_OUT_ODD 13
#define EP3_IN_EVEN 14
#define EP3_IN_ODD 15
#define EP4_OUT_EVEN 16
#define EP4_OUT_ODD 17
#define EP4_IN_EVEN 18
#define EP4_IN_ODD 19
#define EP5_OUT_EVEN 20
#define EP5_OUT_ODD 21
#define EP5_IN_EVEN 22
#define EP5_IN_ODD 23
#define EP6_OUT_EVEN 24
#define EP6_OUT_ODD 25
#define EP6_IN_EVEN 26
#define EP6_IN_ODD 27
#define EP7_OUT_EVEN 28
#define EP7_OUT_ODD 29
#define EP7_IN_EVEN 30
#define EP7_IN_ODD 31
#define EP8_OUT_EVEN 32
#define EP8_OUT_ODD 33
#define EP8_IN_EVEN 34
#define EP8_IN_ODD 35
#define EP9_OUT_EVEN 36
#define EP9_OUT_ODD 37
#define EP9_IN_EVEN 38
#define EP9_IN_ODD 39
#define EP10_OUT_EVEN 40
#define EP10_OUT_ODD 41
#define EP10_IN_EVEN 42
#define EP10_IN_ODD 43
#define EP11_OUT_EVEN 44
#define EP11_OUT_ODD 45
#define EP11_IN_EVEN 46
#define EP11_IN_ODD 47
#define EP12_OUT_EVEN 48
#define EP12_OUT_ODD 49
#define EP12_IN_EVEN 50
#define EP12_IN_ODD 51
#define EP13_OUT_EVEN 52
#define EP13_OUT_ODD 53
#define EP13_IN_EVEN 54
#define EP13_IN_ODD 55
#define EP14_OUT_EVEN 56
#define EP14_OUT_ODD 57
#define EP14_IN_EVEN 58
#define EP14_IN_ODD 59
#define EP15_OUT_EVEN 60
#define EP15_OUT_ODD 61
#define EP15_IN_EVEN 62
#define EP15_IN_ODD 63
#define EP(ep,dir,pp) (4*ep+2*dir+pp)
#if defined (__18CXX) || defined(__C30__) || defined __XC16__ || (__XC8)
#if (defined(__dsPIC33E__) || defined (__PIC24E__))
#define BD(ep,dir,pp) (8*(4*ep+2*dir+pp))
#else
#define BD(ep,dir,pp) (4*(4*ep+2*dir+pp))
#endif
#elif defined(__C32__)
#define BD(ep,dir,pp) (8*(4*ep+2*dir+pp))
#else
#error "Not defined for this compiler"
#endif
#elif (USB_PING_PONG_MODE == USB_PING_PONG__ALL_BUT_EP0)
#define USB_NEXT_EP0_OUT_PING_PONG 0x0000
#define USB_NEXT_EP0_IN_PING_PONG 0x0000
#define USB_NEXT_PING_PONG 0x0004
#define EP0_OUT_EVEN 0
#define EP0_OUT_ODD 0
#define EP0_IN_EVEN 1
#define EP0_IN_ODD 1
#define EP1_OUT_EVEN 2
#define EP1_OUT_ODD 3
#define EP1_IN_EVEN 4
#define EP1_IN_ODD 5
#define EP2_OUT_EVEN 6
#define EP2_OUT_ODD 7
#define EP2_IN_EVEN 8
#define EP2_IN_ODD 9
#define EP3_OUT_EVEN 10
#define EP3_OUT_ODD 11
#define EP3_IN_EVEN 12
#define EP3_IN_ODD 13
#define EP4_OUT_EVEN 14
#define EP4_OUT_ODD 15
#define EP4_IN_EVEN 16
#define EP4_IN_ODD 17
#define EP5_OUT_EVEN 18
#define EP5_OUT_ODD 19
#define EP5_IN_EVEN 20
#define EP5_IN_ODD 21
#define EP6_OUT_EVEN 22
#define EP6_OUT_ODD 23
#define EP6_IN_EVEN 24
#define EP6_IN_ODD 25
#define EP7_OUT_EVEN 26
#define EP7_OUT_ODD 27
#define EP7_IN_EVEN 28
#define EP7_IN_ODD 29
#define EP8_OUT_EVEN 30
#define EP8_OUT_ODD 31
#define EP8_IN_EVEN 32
#define EP8_IN_ODD 33
#define EP9_OUT_EVEN 34
#define EP9_OUT_ODD 35
#define EP9_IN_EVEN 36
#define EP9_IN_ODD 37
#define EP10_OUT_EVEN 38
#define EP10_OUT_ODD 39
#define EP10_IN_EVEN 40
#define EP10_IN_ODD 41
#define EP11_OUT_EVEN 42
#define EP11_OUT_ODD 43
#define EP11_IN_EVEN 44
#define EP11_IN_ODD 45
#define EP12_OUT_EVEN 46
#define EP12_OUT_ODD 47
#define EP12_IN_EVEN 48
#define EP12_IN_ODD 49
#define EP13_OUT_EVEN 50
#define EP13_OUT_ODD 51
#define EP13_IN_EVEN 52
#define EP13_IN_ODD 53
#define EP14_OUT_EVEN 54
#define EP14_OUT_ODD 55
#define EP14_IN_EVEN 56
#define EP14_IN_ODD 57
#define EP15_OUT_EVEN 58
#define EP15_OUT_ODD 59
#define EP15_IN_EVEN 60
#define EP15_IN_ODD 61
#define EP(ep,dir,pp) (4*ep+2*dir+((ep==0)?0:(pp-2)))
#define BD(ep,dir,pp) (4*(4*ep+2*dir+((ep==0)?0:(pp-2))))
#else
#error "No ping pong mode defined."
#endif
/****** Event callback enabling/disabling macros ********************
This section of code is used to disable specific USB events that may not be
desired by the user. This can save code size and increase throughput and
decrease CPU utiliazation.
********************************************************************/
#if defined USB_DISABLE_SUSPEND_HANDLER
#define USB_SUSPEND_HANDLER(event,pointer,size)
#warning "Disabling the suspend handler is not recommended. Proper suspend handling is required to create a compliant USB device."
#else
#define USB_SUSPEND_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size)
#endif
#if defined USB_DISABLE_WAKEUP_FROM_SUSPEND_HANDLER
#define USB_WAKEUP_FROM_SUSPEND_HANDLER(event,pointer,size)
#warning "Disabling the wake from suspend handler is not recommended. Proper suspend handling is required to create a compliant USB device."
#else
#define USB_WAKEUP_FROM_SUSPEND_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size)
#endif
#if defined USB_DISABLE_SOF_HANDLER
#define USB_SOF_HANDLER(event,pointer,size)
#else
#define USB_SOF_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size)
#endif
#if defined USB_DISABLE_TRANSFER_TERMINATED_HANDLER
#define USB_TRANSFER_TERMINATED_HANDLER(event,pointer,size)
#else
#define USB_TRANSFER_TERMINATED_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size)
#endif
#if defined USB_DISABLE_ERROR_HANDLER
#define USB_ERROR_HANDLER(event,pointer,size)
#else
#define USB_ERROR_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size)
#endif
#if defined USB_DISABLE_NONSTANDARD_EP0_REQUEST_HANDLER
#define USB_NONSTANDARD_EP0_REQUEST_HANDLER(event,pointer,size)
#else
#define USB_NONSTANDARD_EP0_REQUEST_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size)
#endif
#if defined USB_DISABLE_SET_DESCRIPTOR_HANDLER
#define USB_SET_DESCRIPTOR_HANDLER(event,pointer,size)
#else
#define USB_SET_DESCRIPTOR_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size)
#endif
#if defined USB_DISABLE_SET_CONFIGURATION_HANDLER
#define USB_SET_CONFIGURATION_HANDLER(event,pointer,size)
#else
#define USB_SET_CONFIGURATION_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size)
#endif
#if defined USB_DISABLE_TRANSFER_COMPLETE_HANDLER
#define USB_TRANSFER_COMPLETE_HANDLER(event,pointer,size)
#else
#define USB_TRANSFER_COMPLETE_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size)
#endif

View File

@@ -0,0 +1,300 @@
/******************************************************************************
File Information:
FileName: usb_function_generic.c
Dependencies: See INCLUDES section below
Processor: Microchip USB Microcontrollers
Hardware: See "<install directory>\Microchip\Help" for details.
Compiler: C18, C30, or C32
Company: Microchip Technology, Inc.
Software License Agreement:
The software supplied herewith by Microchip Technology Incorporated
(the "Company") for its PIC(R) Microcontroller is intended and
supplied to you, the Company's customer, for use solely and
exclusively on Microchip PIC Microcontroller products. The
software is owned by the Company and/or its supplier, and is
protected under applicable copyright laws. All rights are reserved.
Any use in violation of the foregoing restrictions may subject the
user to criminal sanctions under applicable laws, as well as to
civil liability for the breach of the terms and conditions of this
license.
THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
Change History:
Rev Description
Summary:
This file contains all of functions, macros, definitions, variables,
datatypes, etc. that are required for usage with vendor class function
drivers. This file should be included in projects that use vendor class
\function drivers. Vendor class function drivers include MCHPUSB
(Microchip's custom class driver), WinUSB, and LibUSB.
This file is located in the "\<Install Directory\>\\Microchip\\USB\\Generic
Device Driver" directory.
Description:
USB Vender Class Custom Driver Header File
This file contains functions, macros, definitions, variables,
datatypes, etc. that are required for use of vendor class function
drivers. This file should be included in projects that use vendor class
\function drivers.
This file is located in the "\<Install Directory\>\\Microchip\\USB\\Generic
Device Driver" directory.
When including this file in a new project, this file can either be
referenced from the directory in which it was installed or copied
directly into the user application folder. If the first method is
chosen to keep the file located in the folder in which it is installed
then include paths need to be added so that the library and the
application both know where to reference each others files. If the
application folder is located in the same folder as the Microchip
folder (like the current demo folders), then the following include
paths need to be added to the application's project:
..\\..\\Microchip\\Include
.
If a different directory structure is used, modify the paths as
required. An example using absolute paths instead of relative paths
would be the following:
C:\\Microchip Solutions\\Microchip\\Include
C:\\Microchip Solutions\\My Demo Application
******************************************************************************/
//DOM-IGNORE-BEGIN
/********************************************************************
File Description:
Change History:
Rev Description
---- -----------
2.6 Minor changes in include file structure.
2.9h Implemented USBCheckVendorRequest() function, in order to
support MS OS Feature Descriptor handling.
********************************************************************
//DOM-IGNORE-END
******************************************************************************/
/** I N C L U D E S **********************************************************/
#include "USB/usb.h"
#include "./USB/usb_function_generic.h"
#if defined(USB_USE_GEN)
/** V A R I A B L E S ********************************************************/
extern volatile CTRL_TRF_SETUP SetupPkt; //Common buffer that receives the
//8-byte SETUP packet data from the
//host during control transfer
//requests.
/** P R I V A T E P R O T O T Y P E S ***************************************/
/** D E C L A R A T I O N S **************************************************/
/** U S E R A P I ***********************************************************/
/********************************************************************
Function:
USB_HANDLE USBGenWrite(BYTE ep, BYTE* data, WORD len)
Summary:
Sends the specified data out the specified endpoint
Description:
This function sends the specified data out the specified
endpoint and returns a handle to the transfer information.
Typical Usage:
<code>
//make sure that the last transfer isn't busy by checking the handle
if(!USBHandleBusy(USBGenericInHandle))
{
//Send the data contained in the INPacket[] array out on
// endpoint USBGEN_EP_NUM
USBGenericInHandle = USBGenWrite(USBGEN_EP_NUM,(BYTE*)&INPacket[0],sizeof(INPacket));
}
</code>
PreCondition:
None
Parameters:
BYTE ep - the endpoint you want to send the data out of
BYTE* data - pointer to the data that you wish to send
WORD len - the length of the data that you wish to send
Return Values:
USB_HANDLE - a handle for the transfer. This information
should be kept to track the status of the transfer
Remarks:
None
*******************************************************************/
// Implemented as a macro. See usb_function_generic.h
/********************************************************************
Function:
USB_HANDLE USBGenRead(BYTE ep, BYTE* data, WORD len)
Summary:
Receives the specified data out the specified endpoint
Description:
Receives the specified data out the specified endpoint.
Typical Usage:
<code>
//Read 64-bytes from endpoint USBGEN_EP_NUM, into the OUTPacket array.
// Make sure to save the return handle so that we can check it later
// to determine when the transfer is complete.
if(!USBHandleBusy(USBOutHandle))
{
USBOutHandle = USBGenRead(USBGEN_EP_NUM,(BYTE*)&OUTPacket,64);
}
</code>
PreCondition:
None
Parameters:
BYTE ep - the endpoint you want to receive the data into
BYTE* data - pointer to where the data will go when it arrives
WORD len - the length of the data that you wish to receive
Return Values:
USB_HANDLE - a handle for the transfer. This information
should be kept to track the status of the transfer
Remarks:
None
*******************************************************************/
// Implemented as a macro. See usb_function_generic.h
/********************************************************************
Function:
void USBCheckVendorRequest(void)
Summary:
This routine handles vendor class specific requests that happen on EP0.
This function should be called from the USBCBCheckOtherReq() call back
function whenever implementing a custom/vendor class device.
Description:
This routine handles vendor specific requests that may arrive on EP0 as
a control transfer. These can include, but are not necessarily
limited to, requests for Microsft specific OS feature descriptor(s).
This function should be called from the USBCBCheckOtherReq() call back
function whenever using a vendor class device.
Typical Usage:
<code>
void USBCBCheckOtherReq(void)
{
//Since the stack didn't handle the request I need to check
// my class drivers to see if it is for them
USBCheckVendorRequest();
}
</code>
PreCondition:
None
Parameters:
Although this function has a void input, this handler function will
typically need to look at the 8-byte SETUP packet contents that the
host just sent, which may contain the vendor class specific request.
Therefore, the statically allocated SetupPkt structure may be looked
at while in the context of this function, and it will contain the most
recently received 8-byte SETUP packet data.
Return Values:
None
Remarks:
This function normally gets called within the same context as the
USBDeviceTasks() function, just after a new control transfer request
from the host has arrived. If the USB stack is operated in
USB_INTERRUPT mode (a usb_config.h option), then this function
will be executed in the interrupt context. If however the USB stack
is operated in the USB_POLLING mode, then this function executes in the
main loop context.
In order to respond to class specific control transfer request(s) in
this handler function, it is suggested to use one or more of the
USBEP0SendRAMPtr(), USBEP0SendROMPtr(), or USBEP0Receive() API
functions.
*******************************************************************/
void USBCheckVendorRequest(void)
{
#if defined(IMPLEMENT_MICROSOFT_OS_DESCRIPTOR)
WORD Length;
//Check if the most recent SETUP request is class specific
if(SetupPkt.bmRequestType == 0b11000000) //Class specific, device to host, device level target
{
//Check if the host is requesting an MS feature descriptor
if(SetupPkt.bRequest == GET_MS_DESCRIPTOR)
{
//Figure out which descriptor is being requested
if(SetupPkt.wIndex == EXTENDED_COMPAT_ID)
{
//Determine number of bytes to send to host
//Lesser of: requested amount, or total size of the descriptor
Length = CompatIDFeatureDescriptor.dwLength;
if(SetupPkt.wLength < Length)
{
Length = SetupPkt.wLength;
}
//Prepare to send the requested descriptor to the host
USBEP0SendROMPtr((ROM BYTE*)&CompatIDFeatureDescriptor, Length, USB_EP0_ROM | USB_EP0_INCLUDE_ZERO);
}
}
}//if(SetupPkt.bmRequestType == 0b11000000)
else if(SetupPkt.bmRequestType == 0b11000001) //Class specific, device to host, interface target
{
//Check if the host is requesting an MS feature descriptor
if(SetupPkt.bRequest == GET_MS_DESCRIPTOR)
{
//Figure out which descriptor is being requested
if(SetupPkt.wIndex == EXTENDED_PROPERTIES)
{
//Determine number of bytes to send to host
//Lesser of: requested amount, or total size of the descriptor
Length = ExtPropertyFeatureDescriptor.dwLength;
if(SetupPkt.wLength < Length)
{
Length = SetupPkt.wLength;
}
//Prepare to send the requested descriptor to the host
USBEP0SendROMPtr((ROM BYTE*)&ExtPropertyFeatureDescriptor, Length, USB_EP0_ROM | USB_EP0_INCLUDE_ZERO);
}
}
}//else if(SetupPkt.bmRequestType == 0b11000001)
#endif //#if defined(IMPLEMENT_MICROSOFT_OS_DESCRIPTOR)
}//void USBCheckVendorRequest(void)
#endif //def USB_USE_GEN
/** EOF usbgen.c *************************************************************/

View File

@@ -0,0 +1,253 @@
/******************************************************************************
File Information:
FileName: usb_function_generic.h
Dependencies: See INCLUDES section below
Processor: PIC18 or PIC24 USB Microcontrollers
Hardware: The code is natively intended to be used on the following
hardware platforms: PICDEM(TM) FS USB Demo Board,
PIC18F87J50 FS USB Plug-In Module, or
Explorer 16 + PIC24 USB PIM. The firmware may be
modified for use on other USB platforms by editing the
HardwareProfile.h file.
Compiler: C18, C30, or C32
Company: Microchip Technology, Inc.
Software License Agreement:
The software supplied herewith by Microchip Technology Incorporated
(the "Company") for its PIC(R) Microcontroller is intended and
supplied to you, the Company's customer, for use solely and
exclusively on Microchip PIC Microcontroller products. The
software is owned by the Company and/or its supplier, and is
protected under applicable copyright laws. All rights are reserved.
Any use in violation of the foregoing restrictions may subject the
user to criminal sanctions under applicable laws, as well as to
civil liability for the breach of the terms and conditions of this
license.
THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
Change History:
Rev Description
Summary:
This file contains all of functions, macros, definitions, variables,
datatypes, etc. that are required for usage with vendor class function
drivers. This file should be included in projects that use vendor class
\function drivers. Vendor class function drivers include MCHPUSB
(Microchip's custom class driver), WinUSB, and LibUSB. This file should also be included into the
usb_descriptors.c file and any other user file that requires access to
vendor class interfaces.
This file is located in the "\<Install
Directory\>\\Microchip\\Include\\USB" directory.
Description:
USB Vender Class Custom Driver File
This file contains all of functions, macros, definitions, variables,
datatypes, etc. that are required for usage with vendor class function
drivers. This file should be included in projects that use vendor class
\function drivers. This file should also be included into the
usb_descriptors.c file and any other user file that requires access to
vendor class interfaces.
This file is located in the "\<Install
Directory\>\\Microchip\\Include\\USB" directory.
When including this file in a new project, this file can either be
referenced from the directory in which it was installed or copied
directly into the user application folder. If the first method is
chosen to keep the file located in the folder in which it is installed
then include paths need to be added so that the library and the
application both know where to reference each others files. If the
application folder is located in the same folder as the Microchip
folder (like the current demo folders), then the following include
paths need to be added to the application's project:
.
..\\..\\Microchip\\Include
If a different directory structure is used, modify the paths as
required. An example using absolute paths instead of relative paths
would be the following:
C:\\Microchip Solutions\\Microchip\\Include
C:\\Microchip Solutions\\My Demo Application
******************************************************************************/
//DOM-IGNORE-BEGIN
/********************************************************************
File Description:
Change History:
Rev Description
---- -----------
2.6 No Change
2.9h Added prototype for USBCheckVendorRequest()
********************************************************************/
//DOM-IGNORE-END
#ifndef USBGEN_H
#define USBGEN_H
#include "GenericTypeDefs.h"
#include "usb_config.h"
/** I N C L U D E S **********************************************************/
/** D E F I N I T I O N S ****************************************************/
/** S T R U C T U R E S ******************************************************/
/** E X T E R N S ************************************************************/
/** P U B L I C P R O T O T Y P E S *****************************************/
/********************************************************************
Function:
USB_HANDLE USBGenWrite(BYTE ep, BYTE* data, WORD len)
Summary:
Sends the specified data out the specified endpoint
Description:
This function sends the specified data out the specified
endpoint and returns a handle to the transfer information.
Typical Usage:
<code>
//make sure that the last transfer isn't busy by checking the handle
if(!USBHandleBusy(USBGenericInHandle))
{
//Send the data contained in the INPacket[] array out on
// endpoint USBGEN_EP_NUM
USBGenericInHandle = USBGenWrite(USBGEN_EP_NUM,(BYTE*)&INPacket[0],sizeof(INPacket));
}
</code>
PreCondition:
None
Parameters:
BYTE ep - the endpoint you want to send the data out of
BYTE* data - pointer to the data that you wish to send
WORD len - the length of the data that you wish to send
Return Values:
USB_HANDLE - a handle for the transfer. This information
should be kept to track the status of the transfer
Remarks:
None
*******************************************************************/
#define USBGenWrite(ep,data,len) USBTxOnePacket(ep,data,len)
/********************************************************************
Function:
USB_HANDLE USBGenRead(BYTE ep, BYTE* data, WORD len)
Summary:
Receives the specified data out the specified endpoint
Description:
Receives the specified data out the specified endpoint.
Typical Usage:
<code>
//Read 64-bytes from endpoint USBGEN_EP_NUM, into the OUTPacket array.
// Make sure to save the return handle so that we can check it later
// to determine when the transfer is complete.
if(!USBHandleBusy(USBOutHandle))
{
USBOutHandle = USBGenRead(USBGEN_EP_NUM,(BYTE*)&OUTPacket,64);
}
</code>
PreCondition:
None
Parameters:
BYTE ep - the endpoint you want to receive the data into
BYTE* data - pointer to where the data will go when it arrives
WORD len - the length of the data that you wish to receive
Return Values:
USB_HANDLE - a handle for the transfer. This information
should be kept to track the status of the transfer
Remarks:
None
*******************************************************************/
#define USBGenRead(ep,data,len) USBRxOnePacket(ep,data,len)
/********************************************************************
Function:
void USBCheckVendorRequest(void)
Summary:
This routine handles vendor class specific requests that happen on EP0.
This function should be called from the USBCBCheckOtherReq() call back
function whenever implementing a custom/vendor class device.
Description:
This routine handles vendor specific requests that may arrive on EP0 as
a control transfer. These can include, but are not necessarily
limited to, requests for Microsft specific OS feature descriptor(s).
This function should be called from the USBCBCheckOtherReq() call back
function whenever using a vendor class device.
Typical Usage:
<code>
void USBCBCheckOtherReq(void)
{
//Since the stack didn't handle the request I need to check
// my class drivers to see if it is for them
USBCheckVendorRequest();
}
</code>
PreCondition:
None
Parameters:
Although this function has a void input, this handler function will
typically need to look at the 8-byte SETUP packet contents that the
host just sent, which may contain the vendor class specific request.
Therefore, the statically allocated SetupPkt structure may be looked
at while in the context of this function, and it will contain the most
recently received 8-byte SETUP packet data.
Return Values:
None
Remarks:
This function normally gets called within the same context as the
USBDeviceTasks() function, just after a new control transfer request
from the host has arrived. If the USB stack is operated in
USB_INTERRUPT mode (a usb_config.h option), then this function
will be executed in the interrupt context. If however the USB stack
is operated in the USB_POLLING mode, then this function executes in the
main loop context.
In order to respond to class specific control transfer request(s) in
this handler function, it is suggested to use one or more of the
USBEP0SendRAMPtr(), USBEP0SendROMPtr(), or USBEP0Receive() API
functions.
*******************************************************************/
void USBCheckVendorRequest(void);
#endif //USBGEN_H

View File

@@ -0,0 +1,653 @@
/******************************************************************************
USB Hardware Abstraction Layer (HAL) (Header File)
Summary:
This file abstracts the hardware interface.
Description:
This file abstracts the hardware interface.
This file is located in the "\<Install Directory\>\\Microchip\\Include\\USB"
directory.
When including this file in a new project, this file can either be
referenced from the directory in which it was installed or copied
directly into the user application folder. If the first method is
chosen to keep the file located in the folder in which it is installed
then include paths need to be added so that the library and the
application both know where to reference each others files. If the
application folder is located in the same folder as the Microchip
folder (like the current demo folders), then the following include
paths need to be added to the application's project:
.
..\\..\\MicrochipInclude
If a different directory structure is used, modify the paths as
required. An example using absolute paths instead of relative paths
would be the following:
C:\\Microchip Solutions\\Microchip\\Include
C:\\Microchip Solutions\\My Demo Application
*******************************************************************************/
//DOM-IGNORE-BEGIN
/******************************************************************************
File Description:
This file defines the interface to the USB hardware abstraction layer.
Filename: usb_hal.h
Dependancies: none
Processor: PIC18, PIC24, or PIC32 USB Microcontrollers
Hardware: The code is natively intended to be used on the following
hardware platforms: PICDEM™ FS USB Demo Board,
PIC18F87J50 FS USB Plug-In Module, or
Explorer 16 + PIC24 USB PIM. The firmware may be
modified for use on other USB platforms by editing the
HardwareProfile.h file.
Compiler: Microchip C18 (for PIC18) or C30 (for PIC24)
Company: Microchip Technology, Inc.
Software License Agreement:
The software supplied herewith by Microchip Technology Incorporated
(the “Company”) for its PICmicro® Microcontroller is intended and
supplied to you, the Companys customer, for use solely and
exclusively on Microchip PICmicro Microcontroller products. The
software is owned by the Company and/or its supplier, and is
protected under applicable copyright laws. All rights are reserved.
Any use in violation of the foregoing restrictions may subject the
user to criminal sanctions under applicable laws, as well as to
civil liability for the breach of the terms and conditions of this
license.
THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*************************************************************************/
/********************************************************************
Change History:
Rev Description
---- -----------
2.6- No Change
2.6a
2.7 Minor changes changes to the structure of the conditional
compilation statement ordering.
2.7a No Change
********************************************************************/
#ifndef _USB_HAL_H_
#define _USB_HAL_H_
//DOM-IGNORE-END
#if defined(__18CXX)
#include "USB/usb_hal_pic18.h"
#elif defined(__C30__) || defined __XC16__
#if defined(__dsPIC33E__)
#include "USB/usb_hal_dspic33E.h"
#elif defined(__PIC24E__)
#include "USB/usb_hal_pic24e.h"
#else
#include "USB/usb_hal_pic24.h"
#endif
#elif defined(__PIC32MX__)
#include "USB/usb_hal_pic32.h"
#elif defined(_PIC14E)
#include "USB/usb_hal_pic16f1.h"
#else
#error "Silicon Platform not defined"
#endif
/**********************
Interface Routines
**********************/
/*************************************************************************
Function:
void USBHALSetBusAddress( BYTE addr )
Description:
This routine sets the address of the system on the USB
when acting as a peripheral device.
Preconditions:
1. USBHALInitialize must have been called to
initialize the USB HAL.
2. Endpoint zero (0) must be configured as appropriate
by calls to USBHALSetEpConfiguration.
3. The system must have been enumerated on the USB (as
a device).
Parameters:
addr Desired address of this device on the USB.
Return Values:
None
Side Effect:
The bus address has been set.
Remmarks:
The address is assigned by the host and is received in
a SET_ADDRESS setup request.
*************************************************************************/
/*
This routine is implemented as a macro to a lower-level level routine.
*/
#define USBHALSetBusAddress OTGCORE_SetDeviceAddr
void USBHALSetBusAddress( BYTE addr );
/*************************************************************************
Function:
void USBHALControlUsbResistors( BYTE flags );
Description:
This routine enables or disables the USB pull-up or
pull-down resistors as requested.
Precondition:
USBInitialize must have been called to initialize the
USB SW stack.
Parameters:
flags - This is a bit-mapped flags value indicating
which resistors to enable or disable (see below).
Return Values:
TRUE if successful, FALSE if not.
Side Effects:
The resistors are enabled as requested.
Remarks:
Used for USB peripheral control to connect to or
disconnect from the bus. Otherwise, used for OTG
SRP/HNP and host support.
*************************************************************************/
/*
This routine is implemented as a macro to a lower-level level routine.
*/
#if defined(__18CXX)
void USBHALControlUsbResistors( BYTE flags );
#else
#define USBHALControlUsbResistors OTGCORE_ControlUsbResistors
void USBHALControlUsbResistors( BYTE flags );
#endif
/* USBHALControlUsbResistors flags */
#define USB_HAL_PULL_UP_D_PLUS 0x80 // Pull D+ line high
#define USB_HAL_PULL_UP_D_MINUS 0x40 // Pull D- line high
#define USB_HAL_PULL_DN_D_PLUS 0x20 // Pull D+ line low
#define USB_HAL_PULL_DN_D_MINUS 0x10 // Pull D- line low
/*
The following are defined for convenience:
*/
#define USB_HAL_DEV_CONN_FULL_SPD USB_HAL_PULL_UP_D_PLUS
#define USB_HAL_DEV_CONN_LOW_SPD USB_HAL_PULL_UP_D_MINUS
#define USB_HAL_DEV_DISCONNECT 0
/*
MCHP: Define a method to check for SE0 & a way to send a reset (SE0).
*/
/*************************************************************************
Function:
BOOL USBHALSessionIsValid( void )
Description:
This routine determines if there is currently a valid
USB session or not.
Precondition:
USBInitialize must have been called to initialize the
USB SW stack.
Parameters:
None
Return Values:
TRUE if the session is currently valid, FALSE if not.
Remarks:
Only used for host and OTG support.
*************************************************************************/
BOOL USBHALSessionIsValid( void );
/*************************************************************************
Function:
USBHALControlBusPower
Description:
This routine provides a bitmap of the most recent
error conditions to occur.
Precondition:
USBInitialize must have been called to initialize the
USB SW stack.
Parameters:
cmd - Identifies desired command (see below).
Return Values:
TRUE if successful, FALSE if not.
Remarks:
Only used for host and OTG support.
*************************************************************************/
BOOL USBHALControlBusPower( BYTE cmd );
/* USBHALControlBusPower Commands */
#define USB_VBUS_DISCHARGE 0 // Dicharge Vbus via resistor
#define USB_VBUS_CHARGE 1 // Charge Vbus via resistor
#define USB_VBUS_POWER_ON 3 // Supply power to Vbus
#define USB_VBUS_POWER_OFF 4 // Do not supply power to Vbus
/*
Note: All commands except USB_VBUS_POWER_ON imply that this device
does not actively supply power to Vbus.
*/
/*************************************************************************
Function:
unsigned long USBHALGetLastError( void )
Description:
This routine provides a bitmap of the most recent
error conditions to occur.
Precondition:
USBInitialize must have been called to initialize the
USB SW stack.
Parameters:
None
Return Values:
Bitmap indicating the most recent error condition(s).
Side Effect:
Error record is cleared.
Remarks:
Although record of the error state is cleared, nothing
is done to fix the condition or recover from the
error. The client must take appropriate steps.
*************************************************************************/
unsigned long USBHALGetLastError( void );
/*
USBHALGetLastError Error Bits.
*/
#define USBHAL_PID_ERR 0x00000001 // Packet ID Error
#define USBHAL_CRC5 0x00000002 // (Host) Token CRC5 check failed
#define USBHAL_HOST_EOF 0x00000002 // (Host) EOF not reached before next SOF
#define USBHAL_CRC16 0x00000004 // Data packet CRC error
#define USBHAL_DFN8 0x00000008 // Data field size not n*8 bits
#define USBHAL_BTO_ERR 0x00000010 // Bus turn-around timeout
#define USBHAL_DMA_ERR 0x00000020 // DMA error, unable to read/write memory
#define USBHAL_BTS_ERR 0x00000080 // Bit-stuffing error
#define USBHAL_XFER_ID 0x00000100 // Unable to identify transfer EP
#define USBHAL_NO_EP 0x00000200 // Invalid endpoint number
#define USBHAL_DMA_ERR2 0x00000400 // Error starting DMA transaction
/*************************************************************************
Function:
void USBHALHandleBusEvent ( void )
Description:
This routine checks the USB for any events that may
have occured and handles them appropriately. It may
be called directly to poll the USB and handle events
or it may be called in response to an interrupt.
Precondition:
USBInitialize must have been called to initialize the
USB SW stack.
Parameters:
None
Return Values:
None
Side Effects:
Depend on the event that may have occured.
Remarks:
None
*************************************************************************/
void USBHALHandleBusEvent ( void );
/*************************************************************************
Function:
BOOL USBHALStallPipe( TRANSFER_FLAGS pipe )
Description:
This routine stalls the given endpoint.
Preconditions:
USBHALInitialize must have been called to initialize
the USB HAL.
Parameters:
pipe - Uses the TRANSFER_FLAGS (see USBCommon.h) format to
identify the endpoint and direction making up the
pipe to stall.
Note: Only ep_num and direction fields are required.
Return Values:
TRUE if able to stall endpoint, FALSE if not.
Side Effects:
The endpoint will stall if additional data transfer is
attempted.
Given endpoint has been stalled.
Remarks:
Starting another data transfer automatically
"un-stalls" the endpoint.
*************************************************************************/
/*
Note: This function is implemented as a macro, calling directly into
an internal HAL routine.
*/
#define USBHALStallPipe OTGCORE_StallPipe
BOOL USBHALStallPipe( TRANSFER_FLAGS pipe );
/******************************************************************************
Function:
BOOL USBHALUnstallPipe( TRANSFER_FLAGS pipe )
Description:
This routine clears the stall condition for the given pipe.
PreCondition:
Assumes OTGCORE_DeviceEnable has been called and
OTGCORE_StallPipe has been called on the given pipe.
Parameters:
pipe - Uses the TRANSFER_FLAGS (see USBCommon.h) format to
identify the endpoint and direction making up the
pipe to unstall.
Return Values:
TRUE if able to stall the pipe, FALSE if not.
Side Effects:
The BSTALL and UOWN bits (and all other control bits) in
the BDT for the given pipe will be cleared.
Remarks:
None
*****************************************************************************/
/*
Note: This function is implemented as a macro, calling directly into
an internal HAL routine.
*/
#define USBHALUnstallPipe OTGCORE_UnstallPipe
BOOL USBHALUnstallPipe( TRANSFER_FLAGS pipe );
/**************************************************************************
Function:
USBHALGetStalledEndpoints
Description:
This function returns a 16-bit bitmapped value with a
bit set in the position of any endpoint that is stalled
(i.e. if endpoint 0 is stalled then bit 0 is set, if
endpoint 1 is stalled then bit 1 is set, etc.).
Preconditions:
USBHALInitialize must have been called to initialize
the USB HAL.
Parameters:
None
Return Values:
Bitmap of the currently stalled endpoints (see overview).
Remarks:
None
*************************************************************************/
/*
Note: This function is implemented as a macro, calling directly into
a HAL routine.
*/
#define USBHALGetStalledEndpoints OTGCORE_GetStalledEndpoints
UINT16 USBHALGetStalledEndpoints ( void );
/******************************************************************************
Function:
BOOL USBHALFlushPipe( TRANSFER_FLAGS pipe )
Description:
This routine clears any pending transfers on the given
pipe.
Preconditions:
USBHALInitialize must have been called to initialize the
USB HAL.
The caller must ensure that there is no possible way for
hardware to be currently accessing the pipe (see notes).
Parameters:
pipe - Uses the TRANSFER_FLAGS (see USBCommon.h) format to
identify the endpoint and direction making up the
pipe to flush.
Return Values:
TRUE if successful, FALSE if not.
Side Effects:
Transfer data for this pipe has been zero'd out.
Remarks:
This routine ignores the normal HW protocol for ownership
of the pipe data and flushes the pipe, even if it is in
process. Thus, the caller must ensure that data transfer
cannot be in process. This situation occurs when a
transfer has been terminated early by the host.
*****************************************************************************/
BOOL USBHALFlushPipe( TRANSFER_FLAGS pipe );
/**************************************************************************
Function:
USBHALTransferData
Description:
This routine prepares to transfer data on the USB.
If the system is in device mode, the actual transfer
will not occur until the host peforms an OUT request
to the given endpoint. If the system is in host mode,
the transfer will not start until the token has been
sent on the bus.
Preconditions:
1. USBHALInitialize must have been called to
initialize the USB HAL.
2. The endpoint through which the data will be
transferred must be configured as appropriate by a
call to USBHALSetEpConfiguration.
3. The bus must have been enumerated (either as a host
or device). Except for EP0 transfers.
Parameters:
flags - Flags consists of the endpoint number OR'd
with one or more flags indicating transfer
direction and such (see "Data Transfer
Macros" in USBCommon.h):
7 6 5 4 3 2 1 0 - Description
| | | | \_____/
| | | | +----- Endpoint Number
| | | +---------- Short or zero-size pkt
| | +------------ Data Toggle 0/1
| +-------------- Force Data Toggle
+---------------- 1=Transmit/0=Receive
buffer Address of the buffer to receive data.
size Number of bytes of data to transfer.
Return Values:
TRUE if the HAL was able to successfully start the
data transfer, FALSE if not.
Side Effects:
The HAL has prepared to transfer the data on the USB.
Ramarks:
The HAL will continue the data transfer, keeping track
of the buffer address, data remaining, and ping-pong
buffer details internally when USBHALHandleBusEvent is
called (either polled or in response to an interrupt).
The caller will receive notification that the transfer
has completed when the EVT_XFER event is passed into
the USBHALBusEventCallout call-out function.
*************************************************************************/
BOOL USBHALTransferData ( TRANSFER_FLAGS flags,
void *buffer,
unsigned int size );
/*************************************************************************
Function:
USBHALSetEpConfiguration
Description:
This routine allows the caller to configure various
options (see "Flags for USBHALSetEpConfiguration",
below) and set the behavior for the given endpoint.
Precondition:
USBHALInitialize has been called.
Parameters:
ep_num - Number of endpoint to configur, Must be
(ep_num >=0) && (ep_num <= USB_DEV_HIGHEST_EP_NUMBER)
max_pkt_size Size of largest packet this enpoint can
transfer.
flags - Configuration flags (see below)
Return Values:
TRUE if successful, FALSE if not.
Side Effects:
The endpoint has been configured as desired.
Remarks:
The base address and size of the buffer is not set by
this routine. Those features of an endpoint are
dynamically managed by the USBHALTransferData routine.
An endpoint can be "de-configured" by setting its max
packet size to 0. When doing this, you should also
set all flags to 0.
*************************************************************************/
BOOL USBHALSetEpConfiguration ( BYTE ep_num, UINT16 max_pkt_size, UINT16 flags );
/* Flags for USBHALSetEpConfiguration */
#if defined(__18CXX)
#define USB_HAL_TRANSMIT 0x0400 // Enable EP for transmitting data
#define USB_HAL_RECEIVE 0x0200 // Enable EP for receiving data
#define USB_HAL_HANDSHAKE 0x1000 // Enable EP to give ACK/NACK (non isoch)
#define USB_HAL_NO_INC 0x0010 // Use for DMA to another device FIFO
#define USB_HAL_HW_KEEPS 0x0020 // Cause HW to keep EP
#else
#define USB_HAL_TRANSMIT 0x0400 // Enable EP for transmitting data
#define USB_HAL_RECEIVE 0x0800 // Enable EP for receiving data
#define USB_HAL_HANDSHAKE 0x0100 // Enable EP to give ACK/NACK (non isoch)
/* Does not work, Fix this if needed. 3/1/07 - Bud
#define USB_HAL_NO_INC 0x0010 // Use for DMA to another device FIFO
#define USB_HAL_HW_KEEPS 0x0020 // Cause HW to keep EP
*/
#define USB_HAL_ALLOW_HUB 0x8000 // (host only) Enable low-spd hub support
#define USB_HAL_NO_RETRY 0x4000 // (host only) disable auto-retry on NACK
#endif
/*************************************************************************
Function:
USBHALInitialize
Description:
This call performs the basic initialization of the USB
HAL. This routine must be called before any of the
other HAL interface routines are called.
Precondition:
The system has been initialized.
Paramters:
flags - Initialization flags
Return Values:
TRUE if successful, FALSE if not.
Side Effects:
The USB HAL SW stack was initialized.
Remarks:
This routine can be called to reset the controller.
*************************************************************************/
BOOL USBHALInitialize ( unsigned long flags );
#endif // _USB_HAL_H_
/*************************************************************************
* EOF
*/

View File

@@ -0,0 +1,600 @@
/******************************************************************************
USB Hardware Abstraction Layer (HAL) (Header File)
Summary:
This file abstracts the hardware interface. The USB stack firmware can be
compiled to work on different USB microcontrollers, such as PIC18 and PIC24.
The USB related special function registers and bit names are generally very
similar between the device families, but small differences in naming exist.
Description:
This file abstracts the hardware interface. The USB stack firmware can be
compiled to work on different USB microcontrollers, such as PIC18 and PIC24.
The USB related special function registers and bit names are generally very
similar between the device families, but small differences in naming exist.
In order to make the same set of firmware work accross the device families,
when modifying SFR contents, a slightly abstracted name is used, which is
then "mapped" to the appropriate real name in the usb_hal_picxx.h header.
Make sure to include the correct version of the usb_hal_picxx.h file for
the microcontroller family which will be used.
This file is located in the "\<Install Directory\>\\Microchip\\Include\\USB"
directory.
When including this file in a new project, this file can either be
referenced from the directory in which it was installed or copied
directly into the user application folder. If the first method is
chosen to keep the file located in the folder in which it is installed
then include paths need to be added so that the library and the
application both know where to reference each others files. If the
application folder is located in the same folder as the Microchip
folder (like the current demo folders), then the following include
paths need to be added to the application's project:
.
..\\..\\MicrochipInclude
If a different directory structure is used, modify the paths as
required. An example using absolute paths instead of relative paths
would be the following:
C:\\Microchip Solutions\\Microchip\\Include
C:\\Microchip Solutions\\My Demo Application
*******************************************************************************/
//DOM-IGNORE-BEGIN
/******************************************************************************
File Description:
This file defines the interface to the USB hardware abstraction layer.
* Filename: usb_hal_pic18.h
Dependencies: See INCLUDES section
Processor: Use this header file when using this firmware with PIC18 USB
microcontrollers
Hardware:
Complier: Microchip C18 (for PIC18)
Company: Microchip Technology, Inc.
Software License Agreement:
The software supplied herewith by Microchip Technology Incorporated
(the “Company”) for its PIC® Microcontroller is intended and
supplied to you, the Companys customer, for use solely and
exclusively on Microchip PIC Microcontroller products. The
software is owned by the Company and/or its supplier, and is
protected under applicable copyright laws. All rights are reserved.
Any use in violation of the foregoing restrictions may subject the
user to criminal sanctions under applicable laws, as well as to
civil liability for the breach of the terms and conditions of this
license.
THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*************************************************************************/
//DOM-IGNORE-BEGIN
/********************************************************************
Change History:
Rev Description
---- -----------
2.6 Changed the inplementation of the interrupt clearing macro
to be more efficient.
2.6a Added DisableNonZeroEndpoints() function
2.7 Added ConvertToPhysicalAddress() and ConvertToVirtualAddress()
macros. Needed for compatiblity with PIC32.
Added USBDisableInterrupts() macro. Fixes issue in dual role
example where a device in polling mode can still have interrupts
enabled from the host mode causing an incorrect vectoring to the
host interrupt controller while in device mode.
2.7a No change
2.8 Added USTAT_FIELDS typedef and associated macros.
********************************************************************/
//DOM-IGNORE-END
#ifndef USB_HAL_PIC18_H
#define USB_HAL_PIC18_H
/*****************************************************************************/
/****** include files ********************************************************/
/*****************************************************************************/
#include "Compiler.h"
#include "usb_config.h"
/*****************************************************************************/
/****** Constant definitions *************************************************/
/*****************************************************************************/
//----- USBEnableEndpoint() input defintions ----------------------------------
#define USB_HANDSHAKE_ENABLED 0x10
#define USB_HANDSHAKE_DISABLED 0x00
#define USB_OUT_ENABLED 0x04
#define USB_OUT_DISABLED 0x00
#define USB_IN_ENABLED 0x02
#define USB_IN_DISABLED 0x00
#define USB_ALLOW_SETUP 0x00
#define USB_DISALLOW_SETUP 0x08
#define USB_STALL_ENDPOINT 0x01
//----- usb_config.h input defintions -----------------------------------------
#define USB_PULLUP_ENABLE 0x10
#define USB_PULLUP_DISABLED 0x00
#define USB_INTERNAL_TRANSCEIVER 0x00
#define USB_EXTERNAL_TRANSCEIVER 0x08
#define USB_FULL_SPEED 0x04
#define USB_LOW_SPEED 0x00
//----- Interrupt Flag definitions --------------------------------------------
#define USBTransactionCompleteIE UIEbits.TRNIE
#define USBTransactionCompleteIF UIRbits.TRNIF
#define USBTransactionCompleteIFReg UIR
#define USBTransactionCompleteIFBitNum 0xF7 //AND mask for clearing TRNIF bit position 4
#define USBResetIE UIEbits.URSTIE
#define USBResetIF UIRbits.URSTIF
#define USBResetIFReg UIR
#define USBResetIFBitNum 0xFE //AND mask for clearing URSTIF bit position 0
#define USBIdleIE UIEbits.IDLEIE
#define USBIdleIF UIRbits.IDLEIF
#define USBIdleIFReg UIR
#define USBIdleIFBitNum 0xEF //AND mask for clearing IDLEIF bit position 5
#define USBActivityIE UIEbits.ACTVIE
#define USBActivityIF UIRbits.ACTVIF
#define USBActivityIFReg UIR
#define USBActivityIFBitNum 0xFB //AND mask for clearing ACTVIF bit position 2
#define USBSOFIE UIEbits.SOFIE
#define USBSOFIF UIRbits.SOFIF
#define USBSOFIFReg UIR
#define USBSOFIFBitNum 0xBF //AND mask for clearing SOFIF bit position 6
#define USBStallIE UIEbits.STALLIE
#define USBStallIF UIRbits.STALLIF
#define USBStallIFReg UIR
#define USBStallIFBitNum 0xDF //AND mask for clearing STALLIF bit position 5
#define USBErrorIE UIEbits.UERRIE
#define USBErrorIF UIRbits.UERRIF
#define USBErrorIFReg UIR
#define USBErrorIFBitNum 0xFD //UERRIF bit position 1. Note: This bit is read only and is cleared by clearing the enabled UEIR flags
//----- Event call back defintions --------------------------------------------
#if defined(USB_DISABLE_SOF_HANDLER)
#define USB_SOF_INTERRUPT 0x00
#else
#define USB_SOF_INTERRUPT 0x40
#endif
#if defined(USB_DISABLE_ERROR_HANDLER)
#define USB_ERROR_INTERRUPT 0x02
#else
#define USB_ERROR_INTERRUPT 0x02
#endif
//----- USB module control bits -----------------------------------------------
#define USBPingPongBufferReset UCONbits.PPBRST
#define USBSE0Event UCONbits.SE0
#define USBSuspendControl UCONbits.SUSPND
#define USBPacketDisable UCONbits.PKTDIS
#define USBResumeControl UCONbits.RESUME
//----- BDnSTAT bit definitions -----------------------------------------------
#define _BSTALL 0x04 //Buffer Stall enable
#define _DTSEN 0x08 //Data Toggle Synch enable
#define _INCDIS 0x10 //Address increment disable
#define _KEN 0x20 //SIE keeps buff descriptors enable
#define _DAT0 0x00 //DATA0 packet expected next
#define _DAT1 0x40 //DATA1 packet expected next
#define _DTSMASK 0x40 //DTS Mask
#define _USIE 0x80 //SIE owns buffer
#define _UCPU 0x00 //CPU owns buffer
#define _STAT_MASK 0xFF
#define USTAT_EP0_PP_MASK ~0x02
#define USTAT_EP_MASK 0x7E
#define USTAT_EP0_OUT 0x00
#define USTAT_EP0_OUT_EVEN 0x00
#define USTAT_EP0_OUT_ODD 0x02
#define USTAT_EP0_IN 0x04
#define USTAT_EP0_IN_EVEN 0x04
#define USTAT_EP0_IN_ODD 0x06
#define ENDPOINT_MASK 0b01111000
//----- U1EP bit definitions --------------------------------------------------
#define UEP_STALL 0x0001
// Cfg Control pipe for this ep
/* Endpoint configuration options for USBEnableEndpoint() function */
#define EP_CTRL 0x06 // Cfg Control pipe for this ep
#define EP_OUT 0x0C // Cfg OUT only pipe for this ep
#define EP_IN 0x0A // Cfg IN only pipe for this ep
#define EP_OUT_IN 0x0E // Cfg both OUT & IN pipes for this ep
//----- Remap the PIC18 register name space------------------------------------
#define U1ADDR UADDR
#define U1IE UIE
#define U1IR UIR
#define U1EIR UEIR
#define U1EIE UEIE
#define U1CON UCON
#define U1EP0 UEP0
#define U1CONbits UCONbits
#define U1EP1 UEP1
#define U1CNFG1 UCFG
#define U1STAT USTAT
#define U1EP0bits UEP0bits
//----- Defintions for BDT address --------------------------------------------
#if defined(__18CXX)
#if defined(__18F14K50) || defined(__18F13K50) || defined(__18LF14K50) || defined(__18LF13K50)
#define USB_BDT_ADDRESS 0x200 //See Linker Script, BDT in bank 2 on these devices - usb2:0x200-0x2FF(256-byte)
#elif defined(__18F47J53) || defined(__18F46J53) || defined(__18F27J53) || defined(__18F26J53) || defined(__18LF47J53) || defined(__18LF46J53) || defined(__18LF27J53) || defined(__18LF26J53)
#define USB_BDT_ADDRESS 0xD00 //BDT in Bank 13 on these devices
#elif defined(__18F97J94) || defined(__18F87J94) || defined(__18F67J94) || defined(__18F96J94) || defined(__18F86J94) || defined(__18F66J94) || defined(__18F96J99) || defined(__18F95J94) || defined(__18F86J99) || defined(__18F85J94) || defined(__18F66J99) || defined(__18F65J94)
#define USB_BDT_ADDRESS 0x100 //BDT in Bank 1 on these devices
#else
#define USB_BDT_ADDRESS 0x400 //All other PIC18 devices place the BDT in usb4:0x400-0x4FF(256-byte)
#endif
#endif
#define BDT_BASE_ADDR_TAG __attribute__ ((aligned (512)))
#define CTRL_TRF_SETUP_ADDR_TAG
#define CTRL_TRF_DATA_ADDR_TAG
//----- Depricated defintions - will be removed at some point of time----------
//--------- Depricated in v2.2
#define _LS 0x00 // Use Low-Speed USB Mode
#define _FS 0x04 // Use Full-Speed USB Mode
#define _TRINT 0x00 // Use internal transceiver
#define _TREXT 0x08 // Use external transceiver
#define _PUEN 0x10 // Use internal pull-up resistor
#define _OEMON 0x40 // Use SIE output indicator
/*****************************************************************************/
/****** Type definitions *****************************************************/
/*****************************************************************************/
// Buffer Descriptor Status Register layout.
typedef union _BD_STAT
{
BYTE Val;
struct{
//If the CPU owns the buffer then these are the values
unsigned BC8:1; //bit 8 of the byte count
unsigned BC9:1; //bit 9 of the byte count
unsigned BSTALL:1; //Buffer Stall Enable
unsigned DTSEN:1; //Data Toggle Synch Enable
unsigned INCDIS:1; //Address Increment Disable
unsigned KEN:1; //BD Keep Enable
unsigned DTS:1; //Data Toggle Synch Value
unsigned UOWN:1; //USB Ownership
};
struct{
//if the USB module owns the buffer then these are
// the values
unsigned :2;
unsigned PID0:1; //Packet Identifier
unsigned PID1:1;
unsigned PID2:1;
unsigned PID3:1;
unsigned :1;
};
struct{
unsigned :2;
unsigned PID:4; //Packet Identifier
unsigned :2;
};
} BD_STAT; //Buffer Descriptor Status Register
// BDT Entry Layout
typedef union __BDT
{
struct
{
BD_STAT STAT;
BYTE CNT;
BYTE ADRL; //Buffer Address Low
BYTE ADRH; //Buffer Address High
};
struct
{
unsigned :8;
unsigned :8;
WORD ADR; //Buffer Address
};
DWORD Val;
BYTE v[4];
} BDT_ENTRY;
// USTAT Register Layout
typedef union __USTAT
{
struct
{
unsigned char filler1:1;
unsigned char ping_pong:1;
unsigned char direction:1;
unsigned char endpoint_number:4;
};
BYTE Val;
} USTAT_FIELDS;
//Macros for fetching parameters from a USTAT_FIELDS variable.
#define USBHALGetLastEndpoint(stat) stat.endpoint_number
#define USBHALGetLastDirection(stat) stat.direction
#define USBHALGetLastPingPong(stat) stat.ping_pong
typedef union _POINTER
{
struct
{
BYTE bLow;
BYTE bHigh;
//byte bUpper;
};
WORD _word; // bLow & bHigh
//pFunc _pFunc; // Usage: ptr.pFunc(); Init: ptr.pFunc = &<Function>;
BYTE* bRam; // Ram byte pointer: 2 bytes pointer pointing
// to 1 byte of data
WORD* wRam; // Ram word poitner: 2 bytes poitner pointing
// to 2 bytes of data
ROM BYTE* bRom; // Size depends on compiler setting
ROM WORD* wRom;
//rom near byte* nbRom; // Near = 2 bytes pointer
//rom near word* nwRom;
//rom far byte* fbRom; // Far = 3 bytes pointer
//rom far word* fwRom;
} POINTER;
/*****************************************************************************/
/****** Function prototypes and macro functions ******************************/
/*****************************************************************************/
#define ConvertToPhysicalAddress(a) ((WORD)(a))
#define ConvertToVirtualAddress(a) ((void *)(a))
//------------------------------------------------------------------------------
//This section is for the PIC18F45K50 Family microcontrollers
//------------------------------------------------------------------------------
#if defined(__18F45K50) || defined(__18F25K50) || defined(__18F24K50) || defined(__18LF45K50) || defined(__18LF25K50) || defined(__18LF24K50)
#define USBClearUSBInterrupt() PIR3bits.USBIF = 0;
#if defined(USB_INTERRUPT)
#define USBMaskInterrupts() {PIE3bits.USBIE = 0;}
#define USBUnmaskInterrupts() {PIE3bits.USBIE = 1;}
#else
#define USBMaskInterrupts()
#define USBUnmaskInterrupts()
#endif
#define USBInterruptFlag PIR3bits.USBIF
//STALLIE, IDLEIE, TRNIE, and URSTIE are all enabled by default and are required
#if defined(USB_INTERRUPT)
#define USBEnableInterrupts() {RCONbits.IPEN = 1;IPR3bits.USBIP = 1;PIE3bits.USBIE = 1;INTCONbits.GIEH = 1;}
#else
#define USBEnableInterrupts()
#endif
#define USBDisableInterrupts() {PIE3bits.USBIE = 0;}
#define SetConfigurationOptions() {\
U1CNFG1 = USB_PULLUP_OPTION | USB_TRANSCEIVER_OPTION | USB_SPEED_OPTION | USB_PING_PONG_MODE;\
U1EIE = 0x9F;\
UIE = 0x39 | USB_SOF_INTERRUPT | USB_ERROR_INTERRUPT;\
}
#else
//------------------------------------------------------------------------------
//This section is for all other PIC18 USB microcontrollers
//------------------------------------------------------------------------------
#define USBClearUSBInterrupt() PIR2bits.USBIF = 0;
#if defined(USB_INTERRUPT)
#define USBMaskInterrupts() {PIE2bits.USBIE = 0;}
#define USBUnmaskInterrupts() {PIE2bits.USBIE = 1;}
#else
#define USBMaskInterrupts()
#define USBUnmaskInterrupts()
#endif
#define USBInterruptFlag PIR2bits.USBIF
//STALLIE, IDLEIE, TRNIE, and URSTIE are all enabled by default and are required
#if defined(USB_INTERRUPT)
#define USBEnableInterrupts() {RCONbits.IPEN = 1;IPR2bits.USBIP = 1;PIE2bits.USBIE = 1;INTCONbits.GIEH = 1;}
#else
#define USBEnableInterrupts()
#endif
#define USBDisableInterrupts() {PIE2bits.USBIE = 0;}
#define SetConfigurationOptions() {\
U1CNFG1 = USB_PULLUP_OPTION | USB_TRANSCEIVER_OPTION | USB_SPEED_OPTION | USB_PING_PONG_MODE;\
U1EIE = 0x9F;\
UIE = 0x39 | USB_SOF_INTERRUPT | USB_ERROR_INTERRUPT;\
}
#endif //end of #if defined(__18F45K50) || defined(__18F25K50)...
//------------------------------------------------------------------------------
/****************************************************************
Function:
void USBPowerModule(void)
Description:
This macro is used to power up the USB module if required<br>
PIC18: defines as nothing<br>
PIC24: defines as U1PWRCbits.USBPWR = 1;<br>
Parameters:
None
Return Values:
None
Remarks:
None
****************************************************************/
#define USBPowerModule()
/****************************************************************
Function:
void USBModuleDisable(void)
Description:
This macro is used to disable the USB module
Parameters:
None
Return Values:
None
Remarks:
None
****************************************************************/
#define USBModuleDisable() {\
UCON = 0;\
UIE = 0;\
USBDeviceState = DETACHED_STATE;\
}
/****************************************************************
Function:
USBSetBDTAddress(addr)
Description:
This macro is used to power up the USB module if required
Parameters:
None
Return Values:
None
Remarks:
None
****************************************************************/
#define USBSetBDTAddress(addr)
/********************************************************************
* Function (macro): void USBClearInterruptFlag(register, BYTE if_and_flag_mask)
*
* PreCondition: None
*
* Input:
* register - the register mnemonic for the register holding the interrupt
flag to be cleared
* BYTE if_and_flag_mask - an AND mask for the interrupt flag that will be
cleared
*
* Output: None
*
* Side Effects: None
*
* Overview: Clears the specified USB interrupt flag.
*
* Note:
*******************************************************************/
#define USBClearInterruptFlag(reg_name, if_and_flag_mask) (reg_name &= if_and_flag_mask)
/********************************************************************
Function:
void USBClearInterruptRegister(WORD reg)
Summary:
Clears the specified interrupt register
PreCondition:
None
Parameters:
WORD reg - the register name that needs to be cleared
Return Values:
None
Remarks:
None
*******************************************************************/
#define USBClearInterruptRegister(reg) reg = 0;
/********************************************************************
Function:
void DisableNonZeroEndpoints(UINT8 last_ep_num)
Summary:
Clears the control registers for the specified non-zero endpoints
PreCondition:
None
Parameters:
UINT8 last_ep_num - the last endpoint number to clear. This
number should include all endpoints used in any configuration.
Return Values:
None
Remarks:
None
*******************************************************************/
#define DisableNonZeroEndpoints(last_ep_num) memset((void*)&U1EP1,0x00,(last_ep_num));
/*****************************************************************************/
/****** Compiler checks ******************************************************/
/*****************************************************************************/
//Definitions for the BDT
#ifndef USB_PING_PONG_MODE
#error "No ping pong mode defined."
#endif
/*****************************************************************************/
/****** Extern variable definitions ******************************************/
/*****************************************************************************/
#if !defined(USBDEVICE_C)
//extern USB_VOLATILE USB_DEVICE_STATE USBDeviceState;
extern USB_VOLATILE BYTE USBActiveConfiguration;
extern USB_VOLATILE IN_PIPE inPipes[1];
extern USB_VOLATILE OUT_PIPE outPipes[1];
#endif
extern volatile BDT_ENTRY* pBDTEntryOut[USB_MAX_EP_NUMBER+1];
extern volatile BDT_ENTRY* pBDTEntryIn[USB_MAX_EP_NUMBER+1];
#endif //#ifndef USB_HAL_PIC18_H

View File

@@ -2,7 +2,7 @@
* File: main.c
* Author: Radioman
*
*
* Created on 09 aprilie 2013, 07:20
*/
@@ -10,7 +10,6 @@
#include <USB/usb_function_generic.h>
#include "HardwareProfile.h"
#include "main.h"
#include "config_bits.h"
#include <delays.h>
#include <string.h>
@@ -21,6 +20,89 @@
#define REMAPPED_HIGH_INTERRUPT_VECTOR_ADDRESS 0x1808
#define REMAPPED_LOW_INTERRUPT_VECTOR_ADDRESS 0x1818
//TL866 Ports settings
#define INIT_LATA (0b00010000)
#define INIT_LATB (0b00000010)
#define INIT_LATC (0b00000000)
#define INIT_LATD (0b00000000)
#define INIT_LATE (0b00000000)
#define INIT_LATF (0b00000000)
#define INIT_LATG (0b00010000)
#define INIT_LATH (0b00000000)
#define INIT_LATJ (0b00000000)
#define INIT_TRISA (0b00000000)
#define INIT_TRISB (0b00000001)
#define INIT_TRISC (0b00000000)
#define INIT_TRISD (0b00000000)
#define INIT_TRISE (0b00000000)
#define INIT_TRISF (0b00000000)
#define INIT_TRISG (0b00000000)
#define INIT_TRISH (0b00000000)
#define INIT_TRISJ (0b00000000)
#define LE0 (LATHbits.LATH0)//vpp0
#define LE1 (LATHbits.LATH1)//vpp1
#define LE2 (LATAbits.LATA2)//vcc0
#define LE3 (LATAbits.LATA0)//vcc1
#define LE4 (LATAbits.LATA5)//vcc2
#define LE5 (LATAbits.LATA3)//gnd0
#define LE6 (LATHbits.LATH4)//gnd2
#define LE7 (LATAbits.LATA1)//gnd3
#define OE_VPP (LATGbits.LATG4)//OE_VPP
#define OE_VCC (LATAbits.LATA4)//OE_VCC
#define SR_DAT (LATHbits.LATH2)//shift register data line
#define SR_CLK (LATHbits.LATH3)//shift register clock line (register shift on 1)
#define LED_PIN (LATCbits.LATC0)
#define LED_ON 1
#define LED_OFF 0
#define INPUT_PIN 1
#define OUTPUT_PIN 0
#define FLAG_FALSE 0
#define FLAG_TRUE 1
#define VERSION_A 1
#define VERSION_CS 2
#define OVER_HEAD 5 //Overhead: <CMD_CODE><LEN><ADDR:3>
#define DATA_SIZE (USBGEN_EP_SIZE - OVER_HEAD)
#define READ_VERSION 0x00
#define READ_FLASH 0x01
#define WRITE_BOOTLOADER 0x02
#define WRITE_CONFIG 0x03
#define WRITE_INFO 0x04
#define GET_INFO 0x05
#define GET_PORT_INP 0x80
#define GET_PORT_LAT 0x81
#define GET_PORT_TRIS 0x82
#define SET_PORT_TRIS 0x83
#define SET_PORT_LAT 0x84
#define SET_SHIFTREG 0x85
#define RESET 0xFF
typedef union {
unsigned char _byte[USBGEN_EP_SIZE]; //For Byte Access
struct {
unsigned char CMD;
unsigned char len;
union {
rom far char *pAdr; //Address Pointer
struct {
unsigned char low; //Little-endian order
unsigned char high;
unsigned char upper;
};
} ADR;
unsigned char data[DATA_SIZE];
};
} DATA_PACKET;
extern void _startup(void);
void high_ISR(void);
void low_ISR(void);

View File

@@ -0,0 +1,9 @@
#
#Fri Jul 21 18:24:37 EEST 2017
default.com-microchip-mplab-nbide-toolchainC18-C18LanguageToolchain.md5=9dcf4e78c5f3f3a1c5abbecc04eb7cbf
default.languagetoolchain.dir=F\:\\SDK\\Microchip\\C18\\bin
configurations-xml=eabbc0b82768a7d80950657b544b883c
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=671be5dae89725b69579225ccba7468e
default.languagetoolchain.version=3.45
host.platform=windows
conf.ids=default

View File

@@ -0,0 +1,449 @@
<?xml version="1.0" encoding="UTF-8"?>
<configurationDescriptor version="62">
<logicalFolder name="root" displayName="root" projectFiles="true">
<logicalFolder name="HeaderFiles"
displayName="Header Files"
projectFiles="true">
<itemPath>config_bits.h</itemPath>
<itemPath>usb_config.h</itemPath>
<itemPath>HardwareProfile.h</itemPath>
</logicalFolder>
<logicalFolder name="LinkerScript"
displayName="Linker Files"
projectFiles="true">
<itemPath>18f87j50.lkr</itemPath>
</logicalFolder>
<logicalFolder name="SourceFiles"
displayName="Source Files"
projectFiles="true">
<itemPath>main.c</itemPath>
<itemPath>usb_descriptors.c</itemPath>
<itemPath>USB/usb_device.c</itemPath>
<itemPath>USB/usb_function_generic.c</itemPath>
</logicalFolder>
<logicalFolder name="ExternalFiles"
displayName="Important Files"
projectFiles="false">
<itemPath>Makefile</itemPath>
</logicalFolder>
</logicalFolder>
<sourceRootList>
<Elem>USB</Elem>
</sourceRootList>
<projectmakefile>Makefile</projectmakefile>
<confs>
<conf name="default" type="2">
<toolsSet>
<developmentServer>localhost</developmentServer>
<targetDevice>PIC18F87J50</targetDevice>
<targetHeader></targetHeader>
<targetPluginBoard></targetPluginBoard>
<platformTool>Simulator</platformTool>
<languageToolchain>C18</languageToolchain>
<languageToolchainVersion>3.45</languageToolchainVersion>
<platform>3</platform>
</toolsSet>
<compileType>
<linkerTool>
<linkerLibItems>
</linkerLibItems>
</linkerTool>
<archiverTool>
</archiverTool>
<loading>
<useAlternateLoadableFile>false</useAlternateLoadableFile>
<parseOnProdLoad>false</parseOnProdLoad>
<alternateLoadableFile></alternateLoadableFile>
</loading>
<subordinates>
</subordinates>
</compileType>
<makeCustomizationType>
<makeCustomizationPreStepEnabled>false</makeCustomizationPreStepEnabled>
<makeCustomizationPreStep></makeCustomizationPreStep>
<makeCustomizationPostStepEnabled>false</makeCustomizationPostStepEnabled>
<makeCustomizationPostStep></makeCustomizationPostStep>
<makeCustomizationPutChecksumInUserID>false</makeCustomizationPutChecksumInUserID>
<makeCustomizationEnableLongLines>false</makeCustomizationEnableLongLines>
<makeCustomizationNormalizeHexFile>false</makeCustomizationNormalizeHexFile>
</makeCustomizationType>
<C18>
<property key="code-model" value="ms"/>
<property key="data-model" value="oa-"/>
<property key="default-char-unsigned" value="false"/>
<property key="enable-all-optimizations" value="true"/>
<property key="enable-int-promotion" value="false"/>
<property key="enable-multi-bank-stack-model" value="false"/>
<property key="enable-ob" value="true"/>
<property key="enable-od" value="true"/>
<property key="enable-om" value="true"/>
<property key="enable-on" value="true"/>
<property key="enable-op" value="true"/>
<property key="enable-opa" value="true"/>
<property key="enable-or" value="true"/>
<property key="enable-os" value="true"/>
<property key="enable-ot" value="true"/>
<property key="enable-ou" value="true"/>
<property key="enable-ow" value="true"/>
<property key="extra-include-directories" value="USB;./"/>
<property key="optimization-master" value="Enable all"/>
<property key="preprocessor-macros" value=""/>
<property key="procedural-abstraction-passes" value="0"/>
<property key="storage-class" value="sca"/>
<property key="verbose" value="false"/>
<property key="warning-level" value="2"/>
</C18>
<C18-AS>
<property key="cross.reference.file" value=""/>
<property key="default.radix" value="HEX"/>
<property key="enable.case.sensitivity" value="true"/>
<property key="hex.output.format" value="INHX32"/>
<property key="preprocessor.macros" value=""/>
<property key="warning.level" value="0"/>
</C18-AS>
<C18-LD>
<property key="cod-file" value="false"/>
<property key="extra-lib-directories" value=""/>
<property key="hex-output-format" value="INHX32"/>
<property key="map-file" value=""/>
</C18-LD>
<C18LanguageToolchain>
<property key="extended-mode" value="false"/>
<property key="extended-mode-mcc18" value="false"/>
<property key="extended-mode-mpasm" value="false"/>
<property key="extended-mode-mplink" value="false"/>
<property key="stack-analysis" value="false"/>
<property key="stack-analysis-mcc18" value="false"/>
<property key="stack-analysis-mplink" value="false"/>
</C18LanguageToolchain>
<Simulator>
<property key="codecoverage.enabled" value="Disable"/>
<property key="codecoverage.enableoutputtofile" value="false"/>
<property key="codecoverage.outputfile" value=""/>
<property key="oscillator.auxfrequency" value="120"/>
<property key="oscillator.auxfrequencyunit" value="Mega"/>
<property key="oscillator.frequency" value="1"/>
<property key="oscillator.frequencyunit" value="Mega"/>
<property key="oscillator.rcfrequency" value="250"/>
<property key="oscillator.rcfrequencyunit" value="Kilo"/>
<property key="periphADC1.altscl" value="false"/>
<property key="periphADC1.minTacq" value=""/>
<property key="periphADC1.tacqunits" value="microseconds"/>
<property key="periphADC2.altscl" value="false"/>
<property key="periphADC2.minTacq" value=""/>
<property key="periphADC2.tacqunits" value="microseconds"/>
<property key="periphComp1.gte" value="gt"/>
<property key="periphComp2.gte" value="gt"/>
<property key="periphComp3.gte" value="gt"/>
<property key="periphComp4.gte" value="gt"/>
<property key="periphComp5.gte" value="gt"/>
<property key="periphComp6.gte" value="gt"/>
<property key="reset.scl" value="false"/>
<property key="reset.type" value="MCLR"/>
<property key="tracecontrol.include.timestamp" value="summarydataenabled"/>
<property key="tracecontrol.select" value="0"/>
<property key="tracecontrol.stallontracebufferfull" value="false"/>
<property key="tracecontrol.timestamp" value="2"/>
<property key="tracecontrol.tracebufmax" value="54600"/>
<property key="tracecontrol.tracefile" value="C:\Users\radioman\mpdeftrace.log"/>
<property key="tracecontrol.traceresetonrun" value="false"/>
<property key="uart10io.output" value="window"/>
<property key="uart10io.outputfile" value=""/>
<property key="uart10io.uartioenabled" value="false"/>
<property key="uart1io.output" value="window"/>
<property key="uart1io.outputfile" value=""/>
<property key="uart1io.uartioenabled" value="false"/>
<property key="uart2io.output" value="window"/>
<property key="uart2io.outputfile" value=""/>
<property key="uart2io.uartioenabled" value="false"/>
<property key="uart3io.output" value="window"/>
<property key="uart3io.outputfile" value=""/>
<property key="uart3io.uartioenabled" value="false"/>
<property key="uart4io.output" value="window"/>
<property key="uart4io.outputfile" value=""/>
<property key="uart4io.uartioenabled" value="false"/>
<property key="uart5io.output" value="window"/>
<property key="uart5io.outputfile" value=""/>
<property key="uart5io.uartioenabled" value="false"/>
<property key="uart6io.output" value="window"/>
<property key="uart6io.outputfile" value=""/>
<property key="uart6io.uartioenabled" value="false"/>
<property key="uart7io.output" value="window"/>
<property key="uart7io.outputfile" value=""/>
<property key="uart7io.uartioenabled" value="false"/>
<property key="uart8io.output" value="window"/>
<property key="uart8io.outputfile" value=""/>
<property key="uart8io.uartioenabled" value="false"/>
<property key="uart9io.output" value="window"/>
<property key="uart9io.outputfile" value=""/>
<property key="uart9io.uartioenabled" value="false"/>
<property key="warningmessagebreakoptions.W0001_CORE_BITREV_MODULO_EN"
value="report"/>
<property key="warningmessagebreakoptions.W0002_CORE_SECURE_MEMORYACCESS"
value="report"/>
<property key="warningmessagebreakoptions.W0003_CORE_SW_RESET" value="report"/>
<property key="warningmessagebreakoptions.W0004_CORE_WDT_RESET" value="report"/>
<property key="warningmessagebreakoptions.W0005_CORE_IOPUW_RESET"
value="report"/>
<property key="warningmessagebreakoptions.W0006_CORE_CODE_GUARD_PFC_RESET"
value="report"/>
<property key="warningmessagebreakoptions.W0007_CORE_DO_LOOP_STACK_UNDERFLOW"
value="report"/>
<property key="warningmessagebreakoptions.W0008_CORE_DO_LOOP_STACK_OVERFLOW"
value="report"/>
<property key="warningmessagebreakoptions.W0009_CORE_NESTED_DO_LOOP_RANGE"
value="report"/>
<property key="warningmessagebreakoptions.W0010_CORE_SIM32_ODD_WORDACCESS"
value="report"/>
<property key="warningmessagebreakoptions.W0011_CORE_SIM32_UNIMPLEMENTED_RAMACCESS"
value="report"/>
<property key="warningmessagebreakoptions.W0012_CORE_STACK_OVERFLOW_RESET"
value="report"/>
<property key="warningmessagebreakoptions.W0013_CORE_STACK_UNDERFLOW_RESET"
value="report"/>
<property key="warningmessagebreakoptions.W0014_CORE_INVALID_OPCODE"
value="report"/>
<property key="warningmessagebreakoptions.W0015_CORE_INVALID_ALT_WREG_SET"
value="report"/>
<property key="warningmessagebreakoptions.W0016_CORE_STACK_ERROR"
value="report"/>
<property key="warningmessagebreakoptions.W0017_CORE_ODD_RAMWORDACCESS"
value="report"/>
<property key="warningmessagebreakoptions.W0018_CORE_UNIMPLEMENTED_RAMACCESS"
value="report"/>
<property key="warningmessagebreakoptions.W0019_CORE_UNIMPLEMENTED_PROMACCESS"
value="report"/>
<property key="warningmessagebreakoptions.W0020_CORE_ACCESS_NOTIN_X_SPACE"
value="report"/>
<property key="warningmessagebreakoptions.W0021_CORE_ACCESS_NOTIN_Y_SPACE"
value="report"/>
<property key="warningmessagebreakoptions.W0022_CORE_XMODEND_LESS_XMODSRT"
value="report"/>
<property key="warningmessagebreakoptions.W0023_CORE_YMODEND_LESS_YMODSRT"
value="report"/>
<property key="warningmessagebreakoptions.W0024_CORE_BITREV_MOD_IS_ZERO"
value="report"/>
<property key="warningmessagebreakoptions.W0025_CORE_HARD_TRAP" value="report"/>
<property key="warningmessagebreakoptions.W0026_CORE_UNIMPLEMENTED_MEMORYACCESS"
value="report"/>
<property key="warningmessagebreakoptions.W0027_CORE_UNIMPLEMENTED_EDSACCESS"
value="report"/>
<property key="warningmessagebreakoptions.W0028_TBLRD_WORM_CONFIG_MEMORY"
value="report"/>
<property key="warningmessagebreakoptions.W0029_TBLRD_DEVICE_ID" value="report"/>
<property key="warningmessagebreakoptions.W0031_BSLIM_INSUFFICIENT_BOOT_SEGMENT"
value="report"/>
<property key="warningmessagebreakoptions.W0032_BSLIM_LIMITS_EXCEEDS_PROG_MEMORY"
value="report"/>
<property key="warningmessagebreakoptions.W0051_INSTRUCTION_DIV_NOT_ENOUGH_REPEAT"
value="report"/>
<property key="warningmessagebreakoptions.W0052_INSTRUCTION_DIV_TOO_MANY_REPEAT"
value="report"/>
<property key="warningmessagebreakoptions.W0101_SIM_UPDATE_FAILED"
value="report"/>
<property key="warningmessagebreakoptions.W0102_SIM_PERIPH_MISSING"
value="report"/>
<property key="warningmessagebreakoptions.W0103_SIM_PERIPH_FAILED"
value="report"/>
<property key="warningmessagebreakoptions.W0104_SIM_FAILED_TO_INIT_TOOL"
value="report"/>
<property key="warningmessagebreakoptions.W0105_SIM_INVALID_FIELD"
value="report"/>
<property key="warningmessagebreakoptions.W0106_SIM_PERIPH_PARTIAL_SUPPORT"
value="report"/>
<property key="warningmessagebreakoptions.W0107_SIM_NOT_SUPPORTED"
value="report"/>
<property key="warningmessagebreakoptions.W0108_SIM_RESERVED_SETTING"
value="report"/>
<property key="warningmessagebreakoptions.W0109_SIM_PERIPHERAL_IN_DEVELOPMENT"
value="report"/>
<property key="warningmessagebreakoptions.W0110_SIM_UNEXPECTED_EVENT"
value="report"/>
<property key="warningmessagebreakoptions.W0201_ADC_NO_STIMULUS_FILE"
value="report"/>
<property key="warningmessagebreakoptions.W0202_ADC_GO_DONE_BIT" value="report"/>
<property key="warningmessagebreakoptions.W0203_ADC_MINIMUM_2_TAD"
value="report"/>
<property key="warningmessagebreakoptions.W0204_ADC_TAD_TOO_SMALL"
value="report"/>
<property key="warningmessagebreakoptions.W0205_ADC_UNEXPECTED_TRANSITION"
value="report"/>
<property key="warningmessagebreakoptions.W0206_ADC_SAMP_TIME_TOO_SHORT"
value="report"/>
<property key="warningmessagebreakoptions.W0207_ADC_NO_PINS_SCANNED"
value="report"/>
<property key="warningmessagebreakoptions.W0208_ADC_UNSUPPORTED_CLOCK_SOURCE"
value="report"/>
<property key="warningmessagebreakoptions.W0209_ADC_ANALOG_CHANNEL_DIGITAL"
value="report"/>
<property key="warningmessagebreakoptions.W0210_ADC_ANALOG_CHANNEL_OUTPUT"
value="report"/>
<property key="warningmessagebreakoptions.W0211_ADC_PIN_INVALID_CHANNEL"
value="report"/>
<property key="warningmessagebreakoptions.W0212_ADC_BAND_GAP_NOT_SUPPORTED"
value="report"/>
<property key="warningmessagebreakoptions.W0213_ADC_RESERVED_SSRC"
value="report"/>
<property key="warningmessagebreakoptions.W0214_ADC_POSITIVE_INPUT_DIGITAL"
value="report"/>
<property key="warningmessagebreakoptions.W0215_ADC_POSITIVE_INPUT_OUTPUT"
value="report"/>
<property key="warningmessagebreakoptions.W0216_ADC_NEGATIVE_INPUT_DIGITAL"
value="report"/>
<property key="warningmessagebreakoptions.W0217_ADC_NEGATIVE_INPUT_OUTPUT"
value="report"/>
<property key="warningmessagebreakoptions.W0218_ADC_REFERENCE_HIGH_DIGITAL"
value="report"/>
<property key="warningmessagebreakoptions.W0219_ADC_REFERENCE_HIGH_OUTPUT"
value="report"/>
<property key="warningmessagebreakoptions.W0220_ADC_REFERENCE_LOW_DIGITAL"
value="report"/>
<property key="warningmessagebreakoptions.W0221_ADC_REFERENCE_LOW_OUTPUT"
value="report"/>
<property key="warningmessagebreakoptions.W0222_ADC_OVERFLOW" value="report"/>
<property key="warningmessagebreakoptions.W0223_ADC_UNDERFLOW" value="report"/>
<property key="warningmessagebreakoptions.W0224_ADC_CTMU_NOT_SUPPORTED"
value="report"/>
<property key="warningmessagebreakoptions.W0225_ADC_INVALID_CH0S"
value="report"/>
<property key="warningmessagebreakoptions.W0226_ADC_VBAT_NOT_SUPPORTED"
value="report"/>
<property key="warningmessagebreakoptions.W0227_ADC_INVALID_ADCS"
value="report"/>
<property key="warningmessagebreakoptions.W0228_ADC_INVALID_ADCS"
value="report"/>
<property key="warningmessagebreakoptions.W0229_ADC_INVALID_ADCS"
value="report"/>
<property key="warningmessagebreakoptions.W0230_ADC_TRIGSEL_NOT_SUPPORTED"
value="report"/>
<property key="warningmessagebreakoptions.W0231_ADC_NOT_WARMED" value="report"/>
<property key="warningmessagebreakoptions.W0232_ADC_CALIBRATION_ABORTED"
value="report"/>
<property key="warningmessagebreakoptions.W0233_ADC_CORE_POWERED_EARLY"
value="report"/>
<property key="warningmessagebreakoptions.W0234_ADC_ALREADY_CALIBRATING"
value="report"/>
<property key="warningmessagebreakoptions.W0235_ADC_CAL_TYPE_CHANGED"
value="report"/>
<property key="warningmessagebreakoptions.W0236_ADC_CAL_INVALIDATED"
value="report"/>
<property key="warningmessagebreakoptions.W0237_ADC_UNKNOWN_DATASHEET"
value="report"/>
<property key="warningmessagebreakoptions.W0238_ADC_INVALID_SFR_FIELD_VALUE"
value="report"/>
<property key="warningmessagebreakoptions.W0239_ADC_UNSUPPORTED_INPUT"
value="report"/>
<property key="warningmessagebreakoptions.W0240_ADC_NOT_CALIBRATED"
value="report"/>
<property key="warningmessagebreakoptions.W0241_ADC_FRACTIONAL_NOT_ALLOWED"
value="report"/>
<property key="warningmessagebreakoptions.W0242_ADC_BG_INT_BEFORE_PWR"
value="report"/>
<property key="warningmessagebreakoptions.W0243_ADC_INVALID_TAD" value="report"/>
<property key="warningmessagebreakoptions.W0244_ADC_CONVERSION_ABORTED"
value="report"/>
<property key="warningmessagebreakoptions.W0400_PWM_PWM_FASTER_THAN_FOSC"
value="report"/>
<property key="warningmessagebreakoptions.W0700_CLC_GENERAL_WARNING"
value="report"/>
<property key="warningmessagebreakoptions.W0701_CLC_CLCOUT_AS_INPUT"
value="report"/>
<property key="warningmessagebreakoptions.W0702_CLC_CIRCULAR_LOOP"
value="report"/>
<property key="warningmessagebreakoptions.W1201_DATAFLASH_MEM_OUTSIDE_RANGE"
value="report"/>
<property key="warningmessagebreakoptions.W1202_DATAFLASH_ERASE_WHILE_LOCKED"
value="report"/>
<property key="warningmessagebreakoptions.W1203_DATAFLASH_WRITE_WHILE_LOCKED"
value="report"/>
<property key="warningmessagebreakoptions.W1401_DMA_PERIPH_NOT_AVAIL"
value="report"/>
<property key="warningmessagebreakoptions.W1402_DMA_INVALID_IRQ" value="report"/>
<property key="warningmessagebreakoptions.W1403_DMA_INVALID_SFR" value="report"/>
<property key="warningmessagebreakoptions.W1404_DMA_INVALID_DMA_ADDR"
value="report"/>
<property key="warningmessagebreakoptions.W1405_DMA_IRQ_DIR_MISMATCH"
value="report"/>
<property key="warningmessagebreakoptions.W1600_PPS_INVALID_MAP" value="report"/>
<property key="warningmessagebreakoptions.W1601_PPS_INVALID_PIN_DESCRIPTION"
value="report"/>
<property key="warningmessagebreakoptions.W1800_PWM_TIMER_SELECTION_NOT_AVIALABLE"
value="report"/>
<property key="warningmessagebreakoptions.W1801_PWM_TIMER_SELECTION_BAD_CLOCK_INPUT"
value="report"/>
<property key="warningmessagebreakoptions.W1802_PWM_TIMER_MISSING_PERSCALER_INFO"
value="report"/>
<property key="warningmessagebreakoptions.W2001_INPUTCAPTURE_TMR3_UNAVAILABLE"
value="report"/>
<property key="warningmessagebreakoptions.W2002_INPUTCAPTURE_CAPTURE_EMPTY"
value="report"/>
<property key="warningmessagebreakoptions.W2003_INPUTCAPTURE_SYNCSEL_NOT_AVIALABLE"
value="report"/>
<property key="warningmessagebreakoptions.W2004_INPUTCAPTURE_BAD_SYNC_SOURCE"
value="report"/>
<property key="warningmessagebreakoptions.W2501_OUTPUTCOMPARE_SYNCSEL_NOT_AVIALABLE"
value="report"/>
<property key="warningmessagebreakoptions.W2502_OUTPUTCOMPARE_BAD_SYNC_SOURCE"
value="report"/>
<property key="warningmessagebreakoptions.W2503_OUTPUTCOMPARE_BAD_TRIGGER_SOURCE"
value="report"/>
<property key="warningmessagebreakoptions.W7001_SMT_CLK_SELECTION_NOT_SUPPORT"
value="report"/>
<property key="warningmessagebreakoptions.W7002_SMT_SIG_SELECTION_NOT_SUPPORT"
value="report"/>
<property key="warningmessagebreakoptions.W7003_SMT_WIN_SELECTION_NOT_SUPPORT"
value="report"/>
<property key="warningmessagebreakoptions.W8001_OSC_INVALID_CLOCK_SOURCE"
value="report"/>
<property key="warningmessagebreakoptions.W9001_TMR_GATE_AND_EXTCLOCK_ENABLED"
value="report"/>
<property key="warningmessagebreakoptions.W9002_TMR_NO_PIN_AVAILABLE"
value="report"/>
<property key="warningmessagebreakoptions.W9003_TMR_INVALID_CLOCK_SOURCE"
value="report"/>
<property key="warningmessagebreakoptions.W9201_UART_TX_OVERFLOW"
value="report"/>
<property key="warningmessagebreakoptions.W9202_UART_TX_CAPTUREFILE"
value="report"/>
<property key="warningmessagebreakoptions.W9203_UART_TX_INVALIDINTERRUPTMODE"
value="report"/>
<property key="warningmessagebreakoptions.W9204_UART_RX_EMPTY_QUEUE"
value="report"/>
<property key="warningmessagebreakoptions.W9205_UART_TX_BADFILE" value="report"/>
<property key="warningmessagebreakoptions.W9401_CVREF_INVALIDSOURCESELECTION"
value="report"/>
<property key="warningmessagebreakoptions.W9402_CVREF_INPUT_OUTPUTPINCONFLICT"
value="report"/>
<property key="warningmessagebreakoptions.W9601_COMP_FVR_SOURCE_UNAVAILABLE"
value="report"/>
<property key="warningmessagebreakoptions.W9602_COMP_DAC_SOURCE_UNAVAILABLE"
value="report"/>
<property key="warningmessagebreakoptions.W9603_COMP_CVREF_SOURCE_UNAVAILABLE"
value="report"/>
<property key="warningmessagebreakoptions.W9604_COMP_SLOPE_SOURCE_UNAVAILABLE"
value="report"/>
<property key="warningmessagebreakoptions.W9605_COMP_PRG_SOURCE_UNAVAILABLE"
value="report"/>
<property key="warningmessagebreakoptions.W9607_COMP_DGTL_FLTR_OPTION_UNAVAILABLE"
value="report"/>
<property key="warningmessagebreakoptions.W9609_COMP_DGTL_FLTR_CLK_UNAVAILABLE"
value="report"/>
<property key="warningmessagebreakoptions.W9801_FVR_INVALID_MODE_SELECTION"
value="report"/>
<property key="warningmessagebreakoptions.W9801_SCL_BAD_SUBTYPE_INDICATION"
value="report"/>
<property key="warningmessagebreakoptions.W9802_SCL_FILE_NOT_FOUND"
value="report"/>
<property key="warningmessagebreakoptions.W9803_SCL_FAILED_TO_READ_FILE"
value="report"/>
<property key="warningmessagebreakoptions.W9804_SCL_UNRECOGNIZED_LABEL"
value="report"/>
<property key="warningmessagebreakoptions.W9805_SCL_UNRECOGNIZED_VAR"
value="report"/>
<property key="warningmessagebreakoptions.displaywarningmessagesoption"
value=""/>
<property key="warningmessagebreakoptions.warningmessages" value="holdstate"/>
</Simulator>
</conf>
</confs>
</configurationDescriptor>

View File

@@ -3,13 +3,14 @@
<type>com.microchip.mplab.nbide.embedded.makeproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/make-project/1">
<name>TL866_Updater</name>
<name>FirmwareDumper</name>
<creation-uuid>c6c863ce-cc00-448b-983f-c3179648c58d</creation-uuid>
<make-project-type>0</make-project-type>
<c-extensions>c</c-extensions>
<cpp-extensions/>
<header-extensions>h</header-extensions>
<sourceEncoding>ISO-8859-1</sourceEncoding>
<asminc-extensions/>
<make-dep-projects/>
</data>
</configuration>

View File

@@ -1,101 +0,0 @@
/*
* File: main.h
* Author: Radioman
*
*
*/
#ifndef MAIN_H
#define MAIN_H
#define _XTAL_FREQ 48000000
//TL866 Ports settings
#define INIT_LATA (0b00010000)
#define INIT_LATB (0b00000010)
#define INIT_LATC (0b00000000)
#define INIT_LATD (0b00000000)
#define INIT_LATE (0b00000000)
#define INIT_LATF (0b00000000)
#define INIT_LATG (0b00010000)
#define INIT_LATH (0b00000000)
#define INIT_LATJ (0b00000000)
#define INIT_TRISA (0b00000000)
#define INIT_TRISB (0b00000001)
#define INIT_TRISC (0b00000000)
#define INIT_TRISD (0b00000000)
#define INIT_TRISE (0b00000000)
#define INIT_TRISF (0b00000000)
#define INIT_TRISG (0b00000000)
#define INIT_TRISH (0b00000000)
#define INIT_TRISJ (0b00000000)
#define LE0 (LATHbits.LATH0)//vpp0
#define LE1 (LATHbits.LATH1)//vpp1
#define LE2 (LATAbits.LATA2)//vcc0
#define LE3 (LATAbits.LATA0)//vcc1
#define LE4 (LATAbits.LATA5)//vcc2
#define LE5 (LATAbits.LATA3)//gnd0
#define LE6 (LATHbits.LATH4)//gnd2
#define LE7 (LATAbits.LATA1)//gnd3
#define OE_VPP (LATGbits.LATG4)//OE_VPP
#define OE_VCC (LATAbits.LATA4)//OE_VCC
#define SR_DAT (LATHbits.LATH2)// shift register data line
#define SR_CLK (LATHbits.LATH3)// shift register clock line (register shift on 1)
#define LED_PIN (LATCbits.LATC0)
#define LED_ON 1
#define LED_OFF 0
#define INPUT_PIN 1
#define OUTPUT_PIN 0
#define FLAG_FALSE 0
#define FLAG_TRUE 1
#define VERSION_A 1
#define VERSION_CS 2
#define OVER_HEAD 5 //Overhead: <CMD_CODE><LEN><ADDR:3>
#define DATA_SIZE (USBGEN_EP_SIZE - OVER_HEAD)
#define READ_VERSION 0x00
#define READ_FLASH 0x01
#define WRITE_BOOTLOADER 0x02
#define WRITE_CONFIG 0x03
#define WRITE_INFO 0x04
#define GET_INFO 0x05
//#define DEBUG_PACKET 0x7F
#define GET_PORT_INP 0x80
#define GET_PORT_LAT 0x81
#define GET_PORT_TRIS 0x82
#define SET_PORT_TRIS 0x83
#define SET_PORT_LAT 0x84
#define SET_SHIFTREG 0x85
#define RESET 0xFF
typedef union {
unsigned char _byte[USBGEN_EP_SIZE]; //For Byte Access
struct {
unsigned char CMD;
unsigned char len;
union {
rom far char *pAdr; //Address Pointer
struct {
unsigned char low; //Little-endian order
unsigned char high;
unsigned char upper;
};
} ADR;
unsigned char data[DATA_SIZE];
};
} DATA_PACKET;
#endif /* MAIN_H */

View File

@@ -1,148 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configurationDescriptor version="62">
<logicalFolder name="root" displayName="root" projectFiles="true">
<logicalFolder name="HeaderFiles"
displayName="Header Files"
projectFiles="true">
<itemPath>config_bits.h</itemPath>
<itemPath>main.h</itemPath>
<itemPath>usb_config.h</itemPath>
<itemPath>HardwareProfile.h</itemPath>
</logicalFolder>
<logicalFolder name="LinkerScript"
displayName="Linker Files"
projectFiles="true">
<itemPath>18f87j50.lkr</itemPath>
</logicalFolder>
<logicalFolder name="SourceFiles"
displayName="Source Files"
projectFiles="true">
<itemPath>main.c</itemPath>
<itemPath>usb_descriptors.c</itemPath>
<itemPath>F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/USB/Generic Device Driver/usb_function_generic.c</itemPath>
<itemPath>F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/USB/usb_device.c</itemPath>
</logicalFolder>
<logicalFolder name="ExternalFiles"
displayName="Important Files"
projectFiles="false">
<itemPath>Makefile</itemPath>
</logicalFolder>
</logicalFolder>
<projectmakefile>Makefile</projectmakefile>
<confs>
<conf name="default" type="2">
<toolsSet>
<developmentServer>localhost</developmentServer>
<targetDevice>PIC18F87J50</targetDevice>
<targetHeader></targetHeader>
<targetPluginBoard></targetPluginBoard>
<platformTool>Simulator</platformTool>
<languageToolchain>C18</languageToolchain>
<languageToolchainVersion>3.45</languageToolchainVersion>
<platform>3</platform>
</toolsSet>
<compileType>
<linkerTool>
<linkerLibItems>
</linkerLibItems>
</linkerTool>
<loading>
<useAlternateLoadableFile>false</useAlternateLoadableFile>
<alternateLoadableFile></alternateLoadableFile>
</loading>
</compileType>
<makeCustomizationType>
<makeCustomizationPreStepEnabled>false</makeCustomizationPreStepEnabled>
<makeCustomizationPreStep></makeCustomizationPreStep>
<makeCustomizationPostStepEnabled>false</makeCustomizationPostStepEnabled>
<makeCustomizationPostStep></makeCustomizationPostStep>
<makeCustomizationPutChecksumInUserID>false</makeCustomizationPutChecksumInUserID>
<makeCustomizationEnableLongLines>false</makeCustomizationEnableLongLines>
<makeCustomizationNormalizeHexFile>false</makeCustomizationNormalizeHexFile>
</makeCustomizationType>
<C18>
<property key="code-model" value="ms"/>
<property key="data-model" value="oa-"/>
<property key="default-char-unsigned" value="false"/>
<property key="enable-all-optimizations" value="true"/>
<property key="enable-int-promotion" value="false"/>
<property key="enable-multi-bank-stack-model" value="false"/>
<property key="enable-ob" value="true"/>
<property key="enable-od" value="true"/>
<property key="enable-om" value="true"/>
<property key="enable-on" value="true"/>
<property key="enable-op" value="true"/>
<property key="enable-opa" value="true"/>
<property key="enable-or" value="true"/>
<property key="enable-os" value="true"/>
<property key="enable-ot" value="true"/>
<property key="enable-ou" value="true"/>
<property key="enable-ow" value="true"/>
<property key="extra-include-directories"
value="F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/Include;./"/>
<property key="optimization-master" value="Enable all"/>
<property key="preprocessor-macros" value=""/>
<property key="procedural-abstraction-passes" value="0"/>
<property key="storage-class" value="sca"/>
<property key="verbose" value="false"/>
<property key="warning-level" value="2"/>
</C18>
<C18-AS>
<property key="cross.reference.file" value=""/>
<property key="default.radix" value="HEX"/>
<property key="enable.case.sensitivity" value="true"/>
<property key="hex.output.format" value="INHX32"/>
<property key="preprocessor.macros" value=""/>
<property key="warning.level" value="0"/>
</C18-AS>
<C18-LD>
<property key="cod-file" value="false"/>
<property key="extra-lib-directories" value=""/>
<property key="hex-output-format" value="INHX32"/>
<property key="map-file" value=""/>
</C18-LD>
<C18LanguageToolchain>
<property key="extended-mode" value="false"/>
<property key="extended-mode-mcc18" value="false"/>
<property key="extended-mode-mpasm" value="false"/>
<property key="extended-mode-mplink" value="false"/>
<property key="stack-analysis" value="false"/>
<property key="stack-analysis-mcc18" value="false"/>
<property key="stack-analysis-mplink" value="false"/>
</C18LanguageToolchain>
<Simulator>
<property key="animationupdates.realtimewatchupdates" value="false"/>
<property key="animationupdates.steptime" value=""/>
<property key="animationupdates.updatetime" value=""/>
<property key="breakoptions.coreerrors" value="Ignore"/>
<property key="breakoptions.corewarnings" value="Ignore"/>
<property key="breakoptions.peripheralerrors" value="Ignore"/>
<property key="breakoptions.peripheralwarnings" value="Ignore"/>
<property key="breakoptions.stimulusmessages.notes" value="Ignore"/>
<property key="breakoptions.stimulusmessags.errors" value="Ignore"/>
<property key="breakoptions.stimulusmessags.warnings" value="Ignore"/>
<property key="breakoptions.wdtwarnings" value="Ignore"/>
<property key="codecoverage.enabled" value="Disable"/>
<property key="codecoverage.enableoutputtofile" value="false"/>
<property key="codecoverage.outputfile" value=""/>
<property key="oscillator.auxfrequency" value="120"/>
<property key="oscillator.auxfrequencyunit" value="Mega"/>
<property key="oscillator.frequency" value="1"/>
<property key="oscillator.frequencyunit" value="Mega"/>
<property key="oscillator.rcfrequency" value="250"/>
<property key="oscillator.rcfrequencyunit" value="Kilo"/>
<property key="performancedata.show" value="false"/>
<property key="periphADC1.altscl" value="false"/>
<property key="periphADC2.altscl" value="false"/>
<property key="tracecontrol.select" value="0"/>
<property key="tracecontrol.timestamp" value="2"/>
<property key="tracecontrol.tracebufmax" value="54600"/>
<property key="tracecontrol.tracefile" value="C:\Users\radioman\mpdeftrace.log"/>
<property key="tracecontrol.traceresetonrun" value="false"/>
<property key="uart1io.output" value="window"/>
<property key="uart1io.outputfile" value=""/>
<property key="uart1io.uartioenabled" value="false"/>
</Simulator>
</conf>
</confs>
</configurationDescriptor>