firmware/usbdefs_ep0_buff.h
changeset 2 2f55e5dd591d
equal deleted inserted replaced
1:f08135942074 2:2f55e5dd591d
       
     1 /*********************************************************************
       
     2  *
       
     3  *                Microchip USB C18 Firmware Version 1.0
       
     4  *
       
     5  *********************************************************************
       
     6  * FileName:        usbdefs_ep0_buff.h
       
     7  * Dependencies:    See INCLUDES section below
       
     8  * Processor:       PIC18
       
     9  * Compiler:        C18 2.30.01+
       
    10  * Company:         Microchip Technology, Inc.
       
    11  *
       
    12  * Software License Agreement
       
    13  *
       
    14  * The software supplied herewith by Microchip Technology Incorporated
       
    15  * (the “Company”) for its PICmicro® Microcontroller is intended and
       
    16  * supplied to you, the Company’s customer, for use solely and
       
    17  * exclusively on Microchip PICmicro Microcontroller products. The
       
    18  * software is owned by the Company and/or its supplier, and is
       
    19  * protected under applicable copyright laws. All rights are reserved.
       
    20  * Any use in violation of the foregoing restrictions may subject the
       
    21  * user to criminal sanctions under applicable laws, as well as to
       
    22  * civil liability for the breach of the terms and conditions of this
       
    23  * license.
       
    24  *
       
    25  * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
       
    26  * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
       
    27  * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
       
    28  * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
       
    29  * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
       
    30  * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
       
    31  *
       
    32  * Author               Date        Comment
       
    33  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    34  * Rawin Rojvanit       11/19/04    Original.
       
    35  ********************************************************************/
       
    36 
       
    37 /******************************************************************************
       
    38  * USB Definitions: Endpoint 0 Buffer
       
    39  *****************************************************************************/
       
    40 #ifndef USBDEFS_EP0_BUFF_H
       
    41 #define USBDEFS_EP0_BUFF_H
       
    42 
       
    43 /** I N C L U D E S **********************************************************/
       
    44 #include "typedefs.h"
       
    45 #include "usbcfg.h"       // usbcfg.h contains required definitions
       
    46 
       
    47 /******************************************************************************
       
    48  * CTRL_TRF_SETUP:
       
    49  *
       
    50  * Every setup packet has 8 bytes.
       
    51  * However, the buffer size has to equal the EP0_BUFF_SIZE value specified
       
    52  * in autofiles\usbcfg.h
       
    53  * The value of EP0_BUFF_SIZE can be 8, 16, 32, or 64.
       
    54  *
       
    55  * First 8 bytes are defined to be directly addressable to improve speed
       
    56  * and reduce code size.
       
    57  * Bytes beyond the 8th byte have to be accessed using indirect addressing.
       
    58  *****************************************************************************/
       
    59 typedef union _CTRL_TRF_SETUP
       
    60 {
       
    61     /** Array for indirect addressing ****************************************/
       
    62     struct
       
    63     {
       
    64         byte _byte[EP0_BUFF_SIZE];
       
    65     };
       
    66     
       
    67     /** Standard Device Requests *********************************************/
       
    68     struct
       
    69     {
       
    70         byte bmRequestType;
       
    71         byte bRequest;    
       
    72         word wValue;
       
    73         word wIndex;
       
    74         word wLength;
       
    75     };
       
    76     struct
       
    77     {
       
    78         unsigned :8;
       
    79         unsigned :8;
       
    80         WORD W_Value;
       
    81         WORD W_Index;
       
    82         WORD W_Length;
       
    83     };
       
    84     struct
       
    85     {
       
    86         unsigned Recipient:5;           //Device,Interface,Endpoint,Other
       
    87         unsigned RequestType:2;         //Standard,Class,Vendor,Reserved
       
    88         unsigned DataDir:1;             //Host-to-device,Device-to-host
       
    89         unsigned :8;
       
    90         byte bFeature;                  //DEVICE_REMOTE_WAKEUP,ENDPOINT_HALT
       
    91         unsigned :8;
       
    92         unsigned :8;
       
    93         unsigned :8;
       
    94         unsigned :8;
       
    95         unsigned :8;
       
    96     };
       
    97     struct
       
    98     {
       
    99         unsigned :8;
       
   100         unsigned :8;
       
   101         byte bDscIndex;                 //For Configuration and String DSC Only
       
   102         byte bDscType;                  //Device,Configuration,String
       
   103         word wLangID;                   //Language ID
       
   104         unsigned :8;
       
   105         unsigned :8;
       
   106     };
       
   107     struct
       
   108     {
       
   109         unsigned :8;
       
   110         unsigned :8;
       
   111         BYTE bDevADR;                   //Device Address 0-127
       
   112         byte bDevADRH;                  //Must equal zero
       
   113         unsigned :8;
       
   114         unsigned :8;
       
   115         unsigned :8;
       
   116         unsigned :8;
       
   117     };
       
   118     struct
       
   119     {
       
   120         unsigned :8;
       
   121         unsigned :8;
       
   122         byte bCfgValue;                 //Configuration Value 0-255
       
   123         byte bCfgRSD;                   //Must equal zero (Reserved)
       
   124         unsigned :8;
       
   125         unsigned :8;
       
   126         unsigned :8;
       
   127         unsigned :8;
       
   128     };
       
   129     struct
       
   130     {
       
   131         unsigned :8;
       
   132         unsigned :8;
       
   133         byte bAltID;                    //Alternate Setting Value 0-255
       
   134         byte bAltID_H;                  //Must equal zero
       
   135         byte bIntfID;                   //Interface Number Value 0-255
       
   136         byte bIntfID_H;                 //Must equal zero
       
   137         unsigned :8;
       
   138         unsigned :8;
       
   139     };
       
   140     struct
       
   141     {
       
   142         unsigned :8;
       
   143         unsigned :8;
       
   144         unsigned :8;
       
   145         unsigned :8;
       
   146         byte bEPID;                     //Endpoint ID (Number & Direction)
       
   147         byte bEPID_H;                   //Must equal zero
       
   148         unsigned :8;
       
   149         unsigned :8;
       
   150     };
       
   151     struct
       
   152     {
       
   153         unsigned :8;
       
   154         unsigned :8;
       
   155         unsigned :8;
       
   156         unsigned :8;
       
   157         unsigned EPNum:4;               //Endpoint Number 0-15
       
   158         unsigned :3;
       
   159         unsigned EPDir:1;               //Endpoint Direction: 0-OUT, 1-IN
       
   160         unsigned :8;
       
   161         unsigned :8;
       
   162         unsigned :8;
       
   163     };
       
   164     /** End: Standard Device Requests ****************************************/
       
   165     
       
   166 } CTRL_TRF_SETUP;
       
   167 
       
   168 /******************************************************************************
       
   169  * CTRL_TRF_DATA:
       
   170  *
       
   171  * Buffer size has to equal the EP0_BUFF_SIZE value specified
       
   172  * in autofiles\usbcfg.h
       
   173  * The value of EP0_BUFF_SIZE can be 8, 16, 32, or 64.
       
   174  *
       
   175  * First 8 bytes are defined to be directly addressable to improve speed
       
   176  * and reduce code size.
       
   177  * Bytes beyond the 8th byte have to be accessed using indirect addressing.
       
   178  *****************************************************************************/
       
   179 typedef union _CTRL_TRF_DATA
       
   180 {
       
   181     /** Array for indirect addressing ****************************************/
       
   182     struct
       
   183     {
       
   184         byte _byte[EP0_BUFF_SIZE];
       
   185     };
       
   186     
       
   187     /** First 8-byte direct addressing ***************************************/
       
   188     struct
       
   189     {
       
   190         byte _byte0;
       
   191         byte _byte1;
       
   192         byte _byte2;
       
   193         byte _byte3;
       
   194         byte _byte4;
       
   195         byte _byte5;
       
   196         byte _byte6;
       
   197         byte _byte7;
       
   198     };
       
   199     struct
       
   200     {
       
   201         word _word0;
       
   202         word _word1;
       
   203         word _word2;
       
   204         word _word3;
       
   205     };
       
   206 
       
   207 } CTRL_TRF_DATA;
       
   208 
       
   209 #endif //USBDEFS_EP0_BUFF_H