firmware/usbmmap.h
changeset 2 2f55e5dd591d
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/firmware/usbmmap.h	Tue Jan 29 22:31:52 2008 +0100
     1.3 @@ -0,0 +1,175 @@
     1.4 +/*********************************************************************
     1.5 + *
     1.6 + *                Microchip USB C18 Firmware Version 1.0
     1.7 + *
     1.8 + *********************************************************************
     1.9 + * FileName:        usbmmap.h
    1.10 + * Dependencies:    See INCLUDES section below
    1.11 + * Processor:       PIC18
    1.12 + * Compiler:        C18 2.30.01+
    1.13 + * Company:         Microchip Technology, Inc.
    1.14 + *
    1.15 + * Software License Agreement
    1.16 + *
    1.17 + * The software supplied herewith by Microchip Technology Incorporated
    1.18 + * (the “Company”) for its PICmicro® Microcontroller is intended and
    1.19 + * supplied to you, the Company’s customer, for use solely and
    1.20 + * exclusively on Microchip PICmicro Microcontroller products. The
    1.21 + * software is owned by the Company and/or its supplier, and is
    1.22 + * protected under applicable copyright laws. All rights are reserved.
    1.23 + * Any use in violation of the foregoing restrictions may subject the
    1.24 + * user to criminal sanctions under applicable laws, as well as to
    1.25 + * civil liability for the breach of the terms and conditions of this
    1.26 + * license.
    1.27 + *
    1.28 + * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
    1.29 + * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
    1.30 + * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
    1.31 + * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
    1.32 + * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
    1.33 + * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
    1.34 + *
    1.35 + * Author               Date        Comment
    1.36 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1.37 + * Rawin Rojvanit       11/19/04    Original.
    1.38 + ********************************************************************/
    1.39 +
    1.40 +#ifndef USBMMAP_H
    1.41 +#define USBMMAP_H
    1.42 +
    1.43 +/** I N C L U D E S **********************************************************/
    1.44 +#include "typedefs.h"
    1.45 +
    1.46 +/** D E F I N I T I O N S ****************************************************/
    1.47 +
    1.48 +/* Buffer Descriptor Status Register Initialization Parameters */
    1.49 +#define _BSTALL     0x04                //Buffer Stall enable
    1.50 +#define _DTSEN      0x08                //Data Toggle Synch enable
    1.51 +#define _INCDIS     0x10                //Address increment disable
    1.52 +#define _KEN        0x20                //SIE keeps buff descriptors enable
    1.53 +#define _DAT0       0x00                //DATA0 packet expected next
    1.54 +#define _DAT1       0x40                //DATA1 packet expected next
    1.55 +#define _DTSMASK    0x40                //DTS Mask
    1.56 +#define _USIE       0x80                //SIE owns buffer
    1.57 +#define _UCPU       0x00                //CPU owns buffer
    1.58 +
    1.59 +/* USB Device States - To be used with [byte usb_device_state] */
    1.60 +#define DETACHED_STATE          0
    1.61 +#define ATTACHED_STATE          1
    1.62 +#define POWERED_STATE           2
    1.63 +#define DEFAULT_STATE           3
    1.64 +#define ADR_PENDING_STATE       4
    1.65 +#define ADDRESS_STATE           5
    1.66 +#define CONFIGURED_STATE        6
    1.67 +
    1.68 +/* Memory Types for Control Transfer - used in USB_DEVICE_STATUS */
    1.69 +#define _RAM 0
    1.70 +#define _ROM 1
    1.71 +
    1.72 +/** T Y P E S ****************************************************************/
    1.73 +typedef union _USB_DEVICE_STATUS
    1.74 +{
    1.75 +    byte _byte;
    1.76 +    struct
    1.77 +    {
    1.78 +        unsigned RemoteWakeup:1;// [0]Disabled [1]Enabled: See usbdrv.c,usb9.c
    1.79 +        unsigned ctrl_trf_mem:1;// [0]RAM      [1]ROM
    1.80 +    };
    1.81 +} USB_DEVICE_STATUS;
    1.82 +
    1.83 +typedef union _BD_STAT
    1.84 +{
    1.85 +    byte _byte;
    1.86 +    struct{
    1.87 +        unsigned BC8:1;
    1.88 +        unsigned BC9:1;
    1.89 +        unsigned BSTALL:1;              //Buffer Stall Enable
    1.90 +        unsigned DTSEN:1;               //Data Toggle Synch Enable
    1.91 +        unsigned INCDIS:1;              //Address Increment Disable
    1.92 +        unsigned KEN:1;                 //BD Keep Enable
    1.93 +        unsigned DTS:1;                 //Data Toggle Synch Value
    1.94 +        unsigned UOWN:1;                //USB Ownership
    1.95 +    };
    1.96 +    struct{
    1.97 +        unsigned BC8:1;
    1.98 +        unsigned BC9:1;
    1.99 +        unsigned PID0:1;
   1.100 +        unsigned PID1:1;
   1.101 +        unsigned PID2:1;
   1.102 +        unsigned PID3:1;
   1.103 +        unsigned :1;
   1.104 +        unsigned UOWN:1;
   1.105 +    };
   1.106 +    struct{
   1.107 +        unsigned :2;
   1.108 +        unsigned PID:4;                 //Packet Identifier
   1.109 +        unsigned :2;
   1.110 +    };
   1.111 +} BD_STAT;                              //Buffer Descriptor Status Register
   1.112 +
   1.113 +typedef union _BDT
   1.114 +{
   1.115 +    struct
   1.116 +    {
   1.117 +        BD_STAT Stat;
   1.118 +        byte Cnt;
   1.119 +        byte ADRL;                      //Buffer Address Low
   1.120 +        byte ADRH;                      //Buffer Address High
   1.121 +    };
   1.122 +    struct
   1.123 +    {
   1.124 +        unsigned :8;
   1.125 +        unsigned :8;
   1.126 +        byte* ADR;                      //Buffer Address
   1.127 +    };
   1.128 +} BDT;                                  //Buffer Descriptor Table
   1.129 +
   1.130 +/** E X T E R N S ************************************************************/
   1.131 +extern byte usb_device_state;
   1.132 +extern USB_DEVICE_STATUS usb_stat;
   1.133 +extern byte usb_active_cfg;
   1.134 +extern byte usb_alt_intf[MAX_NUM_INT];
   1.135 +
   1.136 +extern volatile far BDT ep0Bo;          //Endpoint #0 BD Out
   1.137 +extern volatile far BDT ep0Bi;          //Endpoint #0 BD In
   1.138 +extern volatile far BDT ep1Bo;          //Endpoint #1 BD Out
   1.139 +extern volatile far BDT ep1Bi;          //Endpoint #1 BD In
   1.140 +extern volatile far BDT ep2Bo;          //Endpoint #2 BD Out
   1.141 +extern volatile far BDT ep2Bi;          //Endpoint #2 BD In
   1.142 +extern volatile far BDT ep3Bo;          //Endpoint #3 BD Out
   1.143 +extern volatile far BDT ep3Bi;          //Endpoint #3 BD In
   1.144 +extern volatile far BDT ep4Bo;          //Endpoint #4 BD Out
   1.145 +extern volatile far BDT ep4Bi;          //Endpoint #4 BD In
   1.146 +extern volatile far BDT ep5Bo;          //Endpoint #5 BD Out
   1.147 +extern volatile far BDT ep5Bi;          //Endpoint #5 BD In
   1.148 +extern volatile far BDT ep6Bo;          //Endpoint #6 BD Out
   1.149 +extern volatile far BDT ep6Bi;          //Endpoint #6 BD In
   1.150 +extern volatile far BDT ep7Bo;          //Endpoint #7 BD Out
   1.151 +extern volatile far BDT ep7Bi;          //Endpoint #7 BD In
   1.152 +extern volatile far BDT ep8Bo;          //Endpoint #8 BD Out
   1.153 +extern volatile far BDT ep8Bi;          //Endpoint #8 BD In
   1.154 +extern volatile far BDT ep9Bo;          //Endpoint #9 BD Out
   1.155 +extern volatile far BDT ep9Bi;          //Endpoint #9 BD In
   1.156 +extern volatile far BDT ep10Bo;         //Endpoint #10 BD Out
   1.157 +extern volatile far BDT ep10Bi;         //Endpoint #10 BD In
   1.158 +extern volatile far BDT ep11Bo;         //Endpoint #11 BD Out
   1.159 +extern volatile far BDT ep11Bi;         //Endpoint #11 BD In
   1.160 +extern volatile far BDT ep12Bo;         //Endpoint #12 BD Out
   1.161 +extern volatile far BDT ep12Bi;         //Endpoint #12 BD In
   1.162 +extern volatile far BDT ep13Bo;         //Endpoint #13 BD Out
   1.163 +extern volatile far BDT ep13Bi;         //Endpoint #13 BD In
   1.164 +extern volatile far BDT ep14Bo;         //Endpoint #14 BD Out
   1.165 +extern volatile far BDT ep14Bi;         //Endpoint #14 BD In
   1.166 +extern volatile far BDT ep15Bo;         //Endpoint #15 BD Out
   1.167 +extern volatile far BDT ep15Bi;         //Endpoint #15 BD In
   1.168 +
   1.169 +extern volatile far CTRL_TRF_SETUP SetupPkt;
   1.170 +extern volatile far CTRL_TRF_DATA CtrlTrfData;
   1.171 +
   1.172 +#if defined(USB_USE_CDC)
   1.173 +extern volatile far unsigned char cdc_notice[CDC_INT_EP_SIZE];
   1.174 +extern volatile far unsigned char cdc_data_rx[CDC_BULK_OUT_EP_SIZE];
   1.175 +extern volatile far unsigned char cdc_data_tx[CDC_BULK_IN_EP_SIZE];
   1.176 +#endif
   1.177 +
   1.178 +#endif //USBMMAP_H