several changes..
1 /*********************************************************************
3 * Microchip USB C18 Firmware Version 1.0
5 *********************************************************************
7 * Dependencies: See INCLUDES section below
9 * Compiler: C18 2.30.01+
10 * Company: Microchip Technology, Inc.
12 * Software License Agreement
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
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.
33 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34 * Rawin Rojvanit 11/19/04 Original.
35 ********************************************************************/
40 /** I N C L U D E S **********************************************************/
43 /** D E F I N I T I O N S ****************************************************/
45 /* Buffer Descriptor Status Register Initialization Parameters */
46 #define _BSTALL 0x04 //Buffer Stall enable
47 #define _DTSEN 0x08 //Data Toggle Synch enable
48 #define _INCDIS 0x10 //Address increment disable
49 #define _KEN 0x20 //SIE keeps buff descriptors enable
50 #define _DAT0 0x00 //DATA0 packet expected next
51 #define _DAT1 0x40 //DATA1 packet expected next
52 #define _DTSMASK 0x40 //DTS Mask
53 #define _USIE 0x80 //SIE owns buffer
54 #define _UCPU 0x00 //CPU owns buffer
56 /* USB Device States - To be used with [byte usb_device_state] */
57 #define DETACHED_STATE 0
58 #define ATTACHED_STATE 1
59 #define POWERED_STATE 2
60 #define DEFAULT_STATE 3
61 #define ADR_PENDING_STATE 4
62 #define ADDRESS_STATE 5
63 #define CONFIGURED_STATE 6
65 /* Memory Types for Control Transfer - used in USB_DEVICE_STATUS */
69 /** T Y P E S ****************************************************************/
70 typedef union _USB_DEVICE_STATUS
75 unsigned RemoteWakeup:1;// [0]Disabled [1]Enabled: See usbdrv.c,usb9.c
76 unsigned ctrl_trf_mem:1;// [0]RAM [1]ROM
80 typedef union _BD_STAT
86 unsigned BSTALL:1; //Buffer Stall Enable
87 unsigned DTSEN:1; //Data Toggle Synch Enable
88 unsigned INCDIS:1; //Address Increment Disable
89 unsigned KEN:1; //BD Keep Enable
90 unsigned DTS:1; //Data Toggle Synch Value
91 unsigned UOWN:1; //USB Ownership
105 unsigned PID:4; //Packet Identifier
108 } BD_STAT; //Buffer Descriptor Status Register
116 byte ADRL; //Buffer Address Low
117 byte ADRH; //Buffer Address High
123 byte* ADR; //Buffer Address
125 } BDT; //Buffer Descriptor Table
127 /** E X T E R N S ************************************************************/
128 extern byte usb_device_state;
129 extern USB_DEVICE_STATUS usb_stat;
130 extern byte usb_active_cfg;
131 extern byte usb_alt_intf[MAX_NUM_INT];
133 extern volatile far BDT ep0Bo; //Endpoint #0 BD Out
134 extern volatile far BDT ep0Bi; //Endpoint #0 BD In
135 extern volatile far BDT ep1Bo; //Endpoint #1 BD Out
136 extern volatile far BDT ep1Bi; //Endpoint #1 BD In
137 extern volatile far BDT ep2Bo; //Endpoint #2 BD Out
138 extern volatile far BDT ep2Bi; //Endpoint #2 BD In
139 extern volatile far BDT ep3Bo; //Endpoint #3 BD Out
140 extern volatile far BDT ep3Bi; //Endpoint #3 BD In
141 extern volatile far BDT ep4Bo; //Endpoint #4 BD Out
142 extern volatile far BDT ep4Bi; //Endpoint #4 BD In
143 extern volatile far BDT ep5Bo; //Endpoint #5 BD Out
144 extern volatile far BDT ep5Bi; //Endpoint #5 BD In
145 extern volatile far BDT ep6Bo; //Endpoint #6 BD Out
146 extern volatile far BDT ep6Bi; //Endpoint #6 BD In
147 extern volatile far BDT ep7Bo; //Endpoint #7 BD Out
148 extern volatile far BDT ep7Bi; //Endpoint #7 BD In
149 extern volatile far BDT ep8Bo; //Endpoint #8 BD Out
150 extern volatile far BDT ep8Bi; //Endpoint #8 BD In
151 extern volatile far BDT ep9Bo; //Endpoint #9 BD Out
152 extern volatile far BDT ep9Bi; //Endpoint #9 BD In
153 extern volatile far BDT ep10Bo; //Endpoint #10 BD Out
154 extern volatile far BDT ep10Bi; //Endpoint #10 BD In
155 extern volatile far BDT ep11Bo; //Endpoint #11 BD Out
156 extern volatile far BDT ep11Bi; //Endpoint #11 BD In
157 extern volatile far BDT ep12Bo; //Endpoint #12 BD Out
158 extern volatile far BDT ep12Bi; //Endpoint #12 BD In
159 extern volatile far BDT ep13Bo; //Endpoint #13 BD Out
160 extern volatile far BDT ep13Bi; //Endpoint #13 BD In
161 extern volatile far BDT ep14Bo; //Endpoint #14 BD Out
162 extern volatile far BDT ep14Bi; //Endpoint #14 BD In
163 extern volatile far BDT ep15Bo; //Endpoint #15 BD Out
164 extern volatile far BDT ep15Bi; //Endpoint #15 BD In
166 extern volatile far CTRL_TRF_SETUP SetupPkt;
167 extern volatile far CTRL_TRF_DATA CtrlTrfData;
169 #if defined(USB_USE_CDC)
170 extern volatile far unsigned char cdc_notice[CDC_INT_EP_SIZE];
171 extern volatile far unsigned char cdc_data_rx[CDC_BULK_OUT_EP_SIZE];
172 extern volatile far unsigned char cdc_data_tx[CDC_BULK_IN_EP_SIZE];