?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 32

Line No. Rev Author Line
1 32 kaklik /******************************************************************************
2  
3 USB PIC18-Specific Header
4  
5 This file defines PIC18-specific items.
6  
7  
8 Software License Agreement
9  
10 The software supplied herewith by Microchip Technology Incorporated
11 (the “Company”) for its PICmicro® Microcontroller is intended and
12 supplied to you, the Company’s customer, for use solely and
13 exclusively on Microchip PICmicro Microcontroller products. The
14 software is owned by the Company and/or its supplier, and is
15 protected under applicable copyright laws. All rights are reserved.
16 Any use in violation of the foregoing restrictions may subject the
17 user to criminal sanctions under applicable laws, as well as to
18 civil liability for the breach of the terms and conditions of this
19 license.
20  
21 THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
22 WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
23 TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24 PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
25 IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
26 CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
27  
28 Change History:
29 Rev Description
30 ---------- ----------------------------------------------------------
31 2.6 - 2.7a No change
32  
33 *******************************************************************************/
34  
35  
36  
37 // To Do: Put all PIC18-specific USB HW definitions here,
38  
39 #define KVA_TO_PA(v) v
40 #define PA_TO_KVA0(pa) pa
41 #define PA_TO_KVA1(pa) pa
42 #define GET_PHYSICAL_ADDRESS(v) (v)
43  
44  
45 /* translate betwwen KSEG0 and KSEG1 virtual addresses */
46 #define KVA0_TO_KVA1(v) ((v) | 0x20000000)
47 #define KVA1_TO_KVA0(v) ((v) & ~0x20000000)
48  
49  
50 /********************************************************************
51 * USB - PIC Endpoint Definitions
52 * PIC Endpoint Address Format: X:EP3:EP2:EP1:EP0:DIR:PPBI:X
53 * This is used when checking the value read from USTAT
54 *
55 * NOTE: These definitions are not used in the descriptors.
56 * EP addresses used in the descriptors have different format.
57 *******************************************************************/
58 #define USTAT_EP0_PP_MASK ~0x02
59 #define USTAT_EP_MASK 0x7E
60 #define USTAT_EP0_OUT 0x00
61 #define USTAT_EP0_OUT_EVEN 0x00
62 #define USTAT_EP0_OUT_ODD 0x02
63  
64 #define USTAT_EP0_IN 0x04
65 #define USTAT_EP0_IN_EVEN 0x04
66 #define USTAT_EP0_IN_ODD 0x06
67  
68  
69 //******************************************************************************
70 // USB Endpoint Control Registers
71 //
72 // In USB Host mode, only EP0 control registers are used. The other registers
73 // should be disabled.
74 //******************************************************************************
75 typedef union
76 {
77 BYTE UEP[16];
78 } _UEP;
79  
80 #define UEP_STALL 0x0002
81  
82  
83 /********************************************************************
84 * Buffer Descriptor Status Register
85 *******************************************************************/
86  
87 /* Buffer Descriptor Status Register Initialization Parameters */
88 #define _BSTALL 0x04 //Buffer Stall enable
89 #define _DTSEN 0x08 //Data Toggle Synch enable
90 #define _INCDIS 0x10 //Address increment disable
91 #define _KEN 0x20 //SIE keeps buff descriptors enable
92 #define _DAT0 0x00 //DATA0 packet expected next
93 #define _DAT1 0x40 //DATA1 packet expected next
94 #define _DTSMASK 0x40 //DTS Mask
95 #define _USIE 0x80 //SIE owns buffer
96 #define _UCPU 0x00 //CPU owns buffer
97  
98 #define _STAT_MASK 0xFF
99  
100 /* BDT entry structure definition */
101 typedef union _BD_STAT
102 {
103 BYTE Val;
104 struct{
105 //If the CPU owns the buffer then these are the values
106 unsigned BC8:1; //bit 8 of the byte count
107 unsigned BC9:1; //bit 9 of the byte count
108 unsigned BSTALL:1; //Buffer Stall Enable
109 unsigned DTSEN:1; //Data Toggle Synch Enable
110 unsigned INCDIS:1; //Address Increment Disable
111 unsigned KEN:1; //BD Keep Enable
112 unsigned DTS:1; //Data Toggle Synch Value
113 unsigned UOWN:1; //USB Ownership
114 };
115 struct{
116 //if the USB module owns the buffer then these are
117 // the values
118 unsigned BC8:1; //bit 8 of the byte count
119 unsigned BC9:1; //bit 9 of the byte count
120 unsigned PID0:1; //Packet Identifier
121 unsigned PID1:1;
122 unsigned PID2:1;
123 unsigned PID3:1;
124 unsigned :1;
125 unsigned UOWN:1; //USB Ownership
126 };
127 struct{
128 unsigned :2;
129 unsigned PID:4; //Packet Identifier
130 unsigned :2;
131 };
132 } BD_STAT; //Buffer Descriptor Status Register
133  
134  
135 /********************************************************************
136 * Buffer Descriptor Table Mapping
137 *******************************************************************/
138  
139 // BDT Entry Layout
140 typedef union __BDT
141 {
142 struct
143 {
144 BD_STAT STAT;
145 BYTE CNT;
146 BYTE ADRL; //Buffer Address Low
147 BYTE ADRH; //Buffer Address High
148 };
149 struct
150 {
151 unsigned :8;
152 unsigned :8;
153 BYTE* ADR; //Buffer Address
154 };
155 DWORD Val;
156 BYTE v[4];
157 } BDT_ENTRY;
158  
159  
160 /****************************************************************
161 Function:
162 void USBPowerModule(void)
163  
164 Description:
165 This macro is used to power up the USB module if required<br>
166 PIC18: defines as nothing<br>
167 PIC24: defines as U1PWRCbits.USBPWR = 1;<br>
168  
169 Precondition:
170 None
171  
172 Parameters:
173 None
174  
175 Return Values:
176 None
177  
178 Remarks:
179 None
180  
181 ****************************************************************/
182 #define USBPowerModule()
183  
184 /****************************************************************
185 Function:
186 USBSetBDTAddress(addr)
187  
188 Description:
189 This macro is used to power up the USB module if required
190  
191 Precondition:
192 None
193  
194 Parameters:
195 None
196  
197 Return Values:
198 None
199  
200 Remarks:
201 None
202  
203 ****************************************************************/
204 #define USBSetBDTAddress(addr)
205 #define USBPingPongBufferReset UCONbits.PPBRST
206  
207 #define USBTransactionCompleteIE UIEbits.TRNIE
208 #define USBTransactionCompleteIF UIRbits.TRNIF
209 #define USBTransactionCompleteIFReg (BYTE*)&UIR
210 #define USBTransactionCompleteIFBitNum 3
211  
212 #define USBResetIE UIEbits.URSTIE
213 #define USBResetIF UIRbits.URSTIF
214 #define USBResetIFReg (BYTE*)&UIR
215 #define USBResetIFBitNum 0
216  
217 #define USBIdleIE UIEbits.IDLEIE
218 #define USBIdleIF UIRbits.IDLEIF
219 #define USBIdleIFReg (BYTE*)&UIR
220 #define USBIdleIFBitNum 4
221  
222 #define USBActivityIE UIEbits.ACTVIE
223 #define USBActivityIF UIRbits.ACTVIF
224 #define USBActivityIFReg (BYTE*)&UIR
225 #define USBActivityIFBitNum 2
226  
227 #define USBSOFIE UIEbits.SOFIE
228 #define USBSOFIF UIRbits.SOFIF
229 #define USBSOFIFReg (BYTE*)&UIR
230 #define USBSOFIFBitNum 6
231  
232 #define USBStallIE UIEbits.STALLIE
233 #define USBStallIF UIRbits.STALLIF
234 #define USBStallIFReg (BYTE*)&UIR
235 #define USBStallIFBitNum 5
236  
237 #define USBErrorIE UIEbits.UERRIE
238 #define USBErrorIF UIRbits.UERRIF
239 #define USBErrorIFReg (BYTE*)&UIR
240 #define USBErrorIFBitNum 1
241  
242 #define USBSE0Event UCONbits.SE0
243 #define USBSuspendControl UCONbits.SUSPND
244 #define USBPacketDisable UCONbits.PKTDIS
245 #define USBResumeControl UCONbits.RESUME
246  
247  
248  
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3