Rev 43 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | ingob | 1 | /******************** (C) COPYRIGHT 2006 STMicroelectronics ******************** |
2 | * File Name : usb_regs.c |
||
3 | * Author : MCD Application Team |
||
4 | * Date First Issued : 10/27/2003 : V1.0 |
||
5 | * Description : Interface functions to USB cell registers |
||
6 | ******************************************************************************** |
||
7 | * History: |
||
8 | * 09/18/2006 : V3.0 |
||
9 | * 09/01/2006 : V2.0 |
||
10 | * 10/27/2003 : V1.0 |
||
11 | ******************************************************************************** |
||
12 | * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
||
13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. |
||
14 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, |
||
15 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE |
||
16 | * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING |
||
17 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
||
18 | *******************************************************************************/ |
||
19 | |||
20 | /* Includes ------------------------------------------------------------------*/ |
||
21 | #include "usb_lib.h" |
||
22 | /* Private typedef -----------------------------------------------------------*/ |
||
23 | /* Private define ------------------------------------------------------------*/ |
||
24 | /* Private macro -------------------------------------------------------------*/ |
||
25 | /* Private variables ---------------------------------------------------------*/ |
||
26 | /* Extern variables ----------------------------------------------------------*/ |
||
27 | /* Private function prototypes -----------------------------------------------*/ |
||
28 | /* Private functions ---------------------------------------------------------*/ |
||
29 | /******************************************************************************* |
||
30 | * Function Name : SetCNTR |
||
31 | * Description : |
||
32 | * Input : wRegValue |
||
33 | * Output : None |
||
34 | * Return : None |
||
35 | *******************************************************************************/ |
||
36 | void SetCNTR(u16 wRegValue) |
||
37 | { |
||
38 | _SetCNTR(wRegValue); |
||
39 | } |
||
40 | /******************************************************************************* |
||
41 | * Function Name : GetCNTR |
||
42 | * Description : |
||
43 | * Input : None |
||
44 | * Output : None |
||
45 | * Return : CNTR register Value |
||
46 | *******************************************************************************/ |
||
47 | u16 GetCNTR(void) |
||
48 | { |
||
49 | return(_GetCNTR()); |
||
50 | } |
||
51 | /******************************************************************************* |
||
52 | * Function Name : SetISTR |
||
53 | * Description : |
||
54 | * Input : wRegValue |
||
55 | * Output : None |
||
56 | * Return : None |
||
57 | *******************************************************************************/ |
||
58 | void SetISTR(u16 wRegValue) |
||
59 | { |
||
60 | _SetISTR(wRegValue); |
||
61 | } |
||
62 | /******************************************************************************* |
||
63 | * Function Name : GetISTR |
||
64 | * Description : |
||
65 | * Input : |
||
66 | * Output : |
||
67 | * Return : ISTR register Value |
||
68 | *******************************************************************************/ |
||
69 | u16 GetISTR(void) |
||
70 | { |
||
71 | return(_GetISTR()); |
||
72 | } |
||
73 | /******************************************************************************* |
||
74 | * Function Name : GetFNR |
||
75 | * Description : |
||
76 | * Input : |
||
77 | * Output : |
||
78 | * Return : FNR register Value |
||
79 | *******************************************************************************/ |
||
80 | u16 GetFNR(void) |
||
81 | { |
||
82 | return(_GetFNR()); |
||
83 | } |
||
84 | /******************************************************************************* |
||
85 | * Function Name : SetDADDR |
||
86 | * Description : |
||
87 | * Input : wRegValue |
||
88 | * Output : |
||
89 | * Return : |
||
90 | *******************************************************************************/ |
||
91 | void SetDADDR(u16 wRegValue) |
||
92 | { |
||
93 | _SetDADDR(wRegValue); |
||
94 | } |
||
95 | /******************************************************************************* |
||
96 | * Function Name : GetDADDR |
||
97 | * Description : |
||
98 | * Input : |
||
99 | * Output : |
||
100 | * Return : DADDR register Value |
||
101 | *******************************************************************************/ |
||
102 | u16 GetDADDR(void) |
||
103 | { |
||
104 | return(_GetDADDR()); |
||
105 | } |
||
106 | /******************************************************************************* |
||
107 | * Function Name : SetBTABLE |
||
108 | * Description : |
||
109 | * Input : wRegValue |
||
110 | * Output : |
||
111 | * Return : |
||
112 | *******************************************************************************/ |
||
113 | void SetBTABLE(u16 wRegValue) |
||
114 | { |
||
115 | _SetBTABLE(wRegValue); |
||
116 | } |
||
117 | |||
118 | /******************************************************************************* |
||
119 | * Function Name : GetBTABLE |
||
120 | * Description : |
||
121 | * Input : |
||
122 | * Output : |
||
123 | * Return : BTABLE address |
||
124 | *******************************************************************************/ |
||
125 | u16 GetBTABLE(void) |
||
126 | { |
||
127 | return(_GetBTABLE()); |
||
128 | } |
||
129 | /******************************************************************************* |
||
130 | * Function Name : SetENDPOINT |
||
131 | * Description : |
||
132 | * Input : bEpNum, wRegValue |
||
133 | * Output : |
||
134 | * Return : |
||
135 | *******************************************************************************/ |
||
136 | void SetENDPOINT(u8 bEpNum, u16 wRegValue) |
||
137 | { |
||
138 | _SetENDPOINT(bEpNum,wRegValue); |
||
139 | } |
||
140 | /******************************************************************************* |
||
141 | * Function Name : GetENDPOINT |
||
142 | * Description : |
||
143 | * Input : bEpNum |
||
144 | * Output : |
||
145 | * Return : |
||
146 | *******************************************************************************/ |
||
147 | u16 GetENDPOINT(u8 bEpNum) |
||
148 | { |
||
149 | return(_GetENDPOINT(bEpNum)); |
||
150 | } |
||
151 | /******************************************************************************* |
||
152 | * Function Name : SetEPType |
||
153 | * Description : |
||
154 | * Input : bEpNum, wType |
||
155 | * Output : |
||
156 | * Return : |
||
157 | *******************************************************************************/ |
||
158 | void SetEPType(u8 bEpNum, u16 wType) |
||
159 | { |
||
160 | _SetEPType(bEpNum, wType); |
||
161 | } |
||
162 | /******************************************************************************* |
||
163 | * Function Name : GetEPType |
||
164 | * Description : |
||
165 | * Input : bEpNum, |
||
166 | * Output : |
||
167 | * Return : Endpoint Type |
||
168 | *******************************************************************************/ |
||
169 | u16 GetEPType(u8 bEpNum) |
||
170 | { |
||
171 | return(_GetEPType(bEpNum)); |
||
172 | } |
||
173 | /******************************************************************************* |
||
174 | * Function Name : SetEPTxStatus |
||
175 | * Description : |
||
176 | * Input : bEpNum, wState |
||
177 | * Output : |
||
178 | * Return : |
||
179 | *******************************************************************************/ |
||
180 | void SetEPTxStatus(u8 bEpNum, u16 wState) |
||
181 | { |
||
182 | _SetEPTxStatus(bEpNum,wState); |
||
183 | } |
||
184 | /******************************************************************************* |
||
185 | * Function Name : SetEPRxStatus |
||
186 | * Description : |
||
187 | * Input : bEpNum, wState |
||
188 | * Output : |
||
189 | * Return : |
||
190 | *******************************************************************************/ |
||
191 | void SetEPRxStatus(u8 bEpNum, u16 wState) |
||
192 | { |
||
193 | _SetEPRxStatus(bEpNum,wState); |
||
194 | } |
||
195 | /******************************************************************************* |
||
196 | * Function Name : SetDouBleBuffEPStall |
||
197 | * Description : sets the status for Double Buffer Endpoint to STALL |
||
198 | * Input : bEpNum = endpoint number |
||
199 | bDir = Endpoint direction |
||
200 | * Output : |
||
201 | * Return : |
||
202 | *******************************************************************************/ |
||
203 | void SetDouBleBuffEPStall(u8 bEpNum,u8 bDir) |
||
204 | { |
||
205 | u16 Endpoint_DTOG_Status; |
||
206 | Endpoint_DTOG_Status = GetENDPOINT(bEpNum); |
||
207 | if(bDir== EP_DBUF_OUT) |
||
208 | { /* OUT double buffered endpoint */ |
||
209 | _SetENDPOINT(bEpNum, Endpoint_DTOG_Status & ~EPRX_DTOG1); |
||
210 | } |
||
211 | else if(bDir == EP_DBUF_IN) |
||
212 | { /* IN double buffered endpoint */ |
||
213 | _SetENDPOINT(bEpNum, Endpoint_DTOG_Status & ~EPTX_DTOG1); |
||
214 | } |
||
215 | } |
||
216 | /******************************************************************************* |
||
217 | * Function Name : GetEPTxStatus |
||
218 | * Description : |
||
219 | * Input : bEpNum |
||
220 | * Output : |
||
221 | * Return : Endpoint TX Status |
||
222 | *******************************************************************************/ |
||
223 | u16 GetEPTxStatus(u8 bEpNum) |
||
224 | { |
||
225 | return(_GetEPTxStatus(bEpNum)); |
||
226 | } |
||
227 | /******************************************************************************* |
||
228 | * Function Name : GetEPRxStatus |
||
229 | * Description : |
||
230 | * Input : bEpNum |
||
231 | * Output : |
||
232 | * Return : Endpoint RX Status |
||
233 | *******************************************************************************/ |
||
234 | u16 GetEPRxStatus(u8 bEpNum) |
||
235 | { |
||
236 | return(_GetEPRxStatus(bEpNum)); |
||
237 | } |
||
238 | /******************************************************************************* |
||
239 | * Function Name : SetEPTxValid |
||
240 | * Description : |
||
241 | * Input : bEpNum |
||
242 | * Output : |
||
243 | * Return : |
||
244 | *******************************************************************************/ |
||
245 | void SetEPTxValid(u8 bEpNum) |
||
246 | { |
||
247 | _SetEPTxStatus(bEpNum, EP_TX_VALID); |
||
248 | } |
||
249 | /******************************************************************************* |
||
250 | * Function Name : SetEPRxValid |
||
251 | * Description : |
||
252 | * Input : bEpNum |
||
253 | * Output : |
||
254 | * Return : |
||
255 | *******************************************************************************/ |
||
256 | void SetEPRxValid(u8 bEpNum) |
||
257 | { |
||
258 | _SetEPRxStatus(bEpNum, EP_RX_VALID); |
||
259 | } |
||
260 | /******************************************************************************* |
||
261 | * Function Name : SetEP_KIND |
||
262 | * Description : |
||
263 | * Input : bEpNum |
||
264 | * Output : |
||
265 | * Return : |
||
266 | *******************************************************************************/ |
||
267 | void SetEP_KIND(u8 bEpNum) |
||
268 | { |
||
269 | _SetEP_KIND(bEpNum); |
||
270 | } |
||
271 | /******************************************************************************* |
||
272 | * Function Name : ClearEP_KIND |
||
273 | * Description : |
||
274 | * Input : bEpNum |
||
275 | * Output : |
||
276 | * Return : |
||
277 | *******************************************************************************/ |
||
278 | void ClearEP_KIND(u8 bEpNum) |
||
279 | { |
||
280 | _ClearEP_KIND(bEpNum); |
||
281 | } |
||
282 | /******************************************************************************* |
||
283 | * Function Name : Clear_Status_Out |
||
284 | * Description : Clear the Status Out of the related Endpoint |
||
285 | * Input : bEpNum |
||
286 | * Output : |
||
287 | * Return : |
||
288 | *******************************************************************************/ |
||
289 | void Clear_Status_Out(u8 bEpNum) |
||
290 | { |
||
291 | _ClearEP_KIND(bEpNum); |
||
292 | } |
||
293 | /******************************************************************************* |
||
294 | * Function Name : Set_Status_Out |
||
295 | * Description : Set the Status Out of the related Endpoint |
||
296 | * Input : bEpNum |
||
297 | * Output : |
||
298 | * Return : |
||
299 | *******************************************************************************/ |
||
300 | void Set_Status_Out(u8 bEpNum) |
||
301 | { |
||
302 | _SetEP_KIND(bEpNum); |
||
303 | } |
||
304 | /******************************************************************************* |
||
305 | * Function Name : SetEPDoubleBuff |
||
306 | * Description : |
||
307 | * Input : bEpNum |
||
308 | * Output : |
||
309 | * Return : |
||
310 | *******************************************************************************/ |
||
311 | void SetEPDoubleBuff(u8 bEpNum) |
||
312 | { |
||
313 | _SetEP_KIND(bEpNum); |
||
314 | } |
||
315 | /******************************************************************************* |
||
316 | * Function Name : ClearEPDoubleBuff |
||
317 | * Description : |
||
318 | * Input : bEpNum |
||
319 | * Output : |
||
320 | * Return : |
||
321 | *******************************************************************************/ |
||
322 | void ClearEPDoubleBuff(u8 bEpNum) |
||
323 | { |
||
324 | _ClearEP_KIND(bEpNum); |
||
325 | } |
||
326 | /******************************************************************************* |
||
327 | * Function Name : GetTxStallStatus |
||
328 | * Description : |
||
329 | * Input : bEpNum |
||
330 | * Output : |
||
331 | * Return : |
||
332 | *******************************************************************************/ |
||
333 | u16 GetTxStallStatus(u8 bEpNum) |
||
334 | { |
||
335 | return(_GetTxStallStatus(bEpNum)); |
||
336 | } |
||
337 | /******************************************************************************* |
||
338 | * Function Name : GetRxStallStatus |
||
339 | * Description : |
||
340 | * Input : bEpNum |
||
341 | * Output : |
||
342 | * Return : |
||
343 | *******************************************************************************/ |
||
344 | u16 GetRxStallStatus(u8 bEpNum) |
||
345 | { |
||
346 | return(_GetRxStallStatus(bEpNum)); |
||
347 | } |
||
348 | /******************************************************************************* |
||
349 | * Function Name : ClearEP_CTR_RX |
||
350 | * Description : |
||
351 | * Input : bEpNum |
||
352 | * Output : |
||
353 | * Return : |
||
354 | *******************************************************************************/ |
||
355 | void ClearEP_CTR_RX(u8 bEpNum) |
||
356 | { |
||
357 | _ClearEP_CTR_RX(bEpNum); |
||
358 | } |
||
359 | /******************************************************************************* |
||
360 | * Function Name : ClearEP_CTR_TX |
||
361 | * Description : |
||
362 | * Input : bEpNum |
||
363 | * Output : |
||
364 | * Return : |
||
365 | *******************************************************************************/ |
||
366 | void ClearEP_CTR_TX(u8 bEpNum) |
||
367 | { |
||
368 | _ClearEP_CTR_TX(bEpNum); |
||
369 | } |
||
370 | /******************************************************************************* |
||
371 | * Function Name : ToggleDTOG_RX |
||
372 | * Description : |
||
373 | * Input : bEpNum |
||
374 | * Output : |
||
375 | * Return : |
||
376 | *******************************************************************************/ |
||
377 | void ToggleDTOG_RX(u8 bEpNum) |
||
378 | { |
||
379 | _ToggleDTOG_RX(bEpNum); |
||
380 | } |
||
381 | /******************************************************************************* |
||
382 | * Function Name : ToggleDTOG_TX |
||
383 | * Description : |
||
384 | * Input : bEpNum |
||
385 | * Output : |
||
386 | * Return : |
||
387 | *******************************************************************************/ |
||
388 | void ToggleDTOG_TX(u8 bEpNum) |
||
389 | { |
||
390 | _ToggleDTOG_TX(bEpNum); |
||
391 | } |
||
392 | /******************************************************************************* |
||
393 | * Function Name : ClearDTOG_RX |
||
394 | * Description : |
||
395 | * Input : bEpNum |
||
396 | * Output : |
||
397 | * Return : |
||
398 | *******************************************************************************/ |
||
399 | void ClearDTOG_RX(u8 bEpNum) |
||
400 | { |
||
401 | _ClearDTOG_RX(bEpNum); |
||
402 | } |
||
403 | /******************************************************************************* |
||
404 | * Function Name : ClearDTOG_TX |
||
405 | * Description : |
||
406 | * Input : bEpNum |
||
407 | * Output : |
||
408 | * Return : |
||
409 | *******************************************************************************/ |
||
410 | void ClearDTOG_TX(u8 bEpNum) |
||
411 | { |
||
412 | _ClearDTOG_TX(bEpNum); |
||
413 | } |
||
414 | /******************************************************************************* |
||
415 | * Function Name : SetEPAddress |
||
416 | * Description : |
||
417 | * Input : bEpNum, bAddr |
||
418 | * Output : |
||
419 | * Return : |
||
420 | *******************************************************************************/ |
||
421 | void SetEPAddress(u8 bEpNum,u8 bAddr) |
||
422 | { |
||
423 | _SetEPAddress(bEpNum,bAddr); |
||
424 | } |
||
425 | /******************************************************************************* |
||
426 | * Function Name : GetEPAddress |
||
427 | * Description : |
||
428 | * Input : bEpNum |
||
429 | * Output : |
||
430 | * Return : |
||
431 | *******************************************************************************/ |
||
432 | u8 GetEPAddress(u8 bEpNum) |
||
433 | { |
||
434 | return(_GetEPAddress(bEpNum)); |
||
435 | } |
||
436 | /******************************************************************************* |
||
437 | * Function Name : SetEPTxAddr |
||
438 | * Description : |
||
439 | * Input : bEpNum, wAddr |
||
440 | * Output : |
||
441 | * Return : |
||
442 | *******************************************************************************/ |
||
443 | void SetEPTxAddr(u8 bEpNum, u16 wAddr) |
||
444 | { |
||
445 | _SetEPTxAddr(bEpNum,wAddr); |
||
446 | } |
||
447 | /******************************************************************************* |
||
448 | * Function Name : SetEPRxAddr |
||
449 | * Description : |
||
450 | * Input : bEpNum, wAddr |
||
451 | * Output : |
||
452 | * Return : |
||
453 | *******************************************************************************/ |
||
454 | void SetEPRxAddr(u8 bEpNum, u16 wAddr) |
||
455 | { |
||
456 | _SetEPRxAddr(bEpNum,wAddr); |
||
457 | } |
||
458 | /******************************************************************************* |
||
459 | * Function Name : GetEPTxAddr |
||
460 | * Description : |
||
461 | * Input : bEpNum |
||
462 | * Output : |
||
463 | * Return : |
||
464 | *******************************************************************************/ |
||
465 | u16 GetEPTxAddr(u8 bEpNum) |
||
466 | { |
||
467 | return(_GetEPTxAddr(bEpNum)); |
||
468 | } |
||
469 | /******************************************************************************* |
||
470 | * Function Name : GetEPRxAddr |
||
471 | * Description : |
||
472 | * Input : bEpNum |
||
473 | * Output : |
||
474 | * Return : |
||
475 | *******************************************************************************/ |
||
476 | u16 GetEPRxAddr(u8 bEpNum) |
||
477 | { |
||
478 | return(_GetEPRxAddr(bEpNum)); |
||
479 | } |
||
480 | /******************************************************************************* |
||
481 | * Function Name : SetEPTxCount |
||
482 | * Description : |
||
483 | * Input : bEpNum, wCount |
||
484 | * Output : |
||
485 | * Return : |
||
486 | *******************************************************************************/ |
||
487 | void SetEPTxCount(u8 bEpNum, u16 wCount) |
||
488 | { |
||
489 | _SetEPTxCount(bEpNum,wCount); |
||
490 | } |
||
491 | /******************************************************************************* |
||
492 | * Function Name : SetEPCountRxReg |
||
493 | * Description : |
||
494 | * Input : *pdwReg, wCount |
||
495 | * Output : |
||
496 | * Return : |
||
497 | *******************************************************************************/ |
||
498 | #ifdef STR7xx |
||
499 | void SetEPCountRxReg(u32 *pdwReg, u16 wCount) |
||
500 | { |
||
501 | _SetEPCountRxReg(dwReg, wCount); |
||
502 | } |
||
503 | #endif |
||
504 | /******************************************************************************* |
||
505 | * Function Name : SetEPRxCount |
||
506 | * Description : |
||
507 | * Input : bEpNum, wCount |
||
508 | * Output : |
||
509 | * Return : |
||
510 | *******************************************************************************/ |
||
511 | void SetEPRxCount(u8 bEpNum, u16 wCount) |
||
512 | { |
||
513 | _SetEPRxCount(bEpNum,wCount); |
||
514 | } |
||
515 | /******************************************************************************* |
||
516 | * Function Name : GetEPTxCount |
||
517 | * Description : |
||
518 | * Input : bEpNum |
||
519 | * Output : |
||
520 | * Return : |
||
521 | *******************************************************************************/ |
||
522 | u16 GetEPTxCount(u8 bEpNum) |
||
523 | { |
||
524 | return(_GetEPTxCount(bEpNum)); |
||
525 | } |
||
526 | /******************************************************************************* |
||
527 | * Function Name : GetEPRxCount |
||
528 | * Description : |
||
529 | * Input : bEpNum |
||
530 | * Output : |
||
531 | * Return : |
||
532 | *******************************************************************************/ |
||
533 | u16 GetEPRxCount(u8 bEpNum) |
||
534 | { |
||
535 | return(_GetEPRxCount(bEpNum)); |
||
536 | } |
||
537 | /******************************************************************************* |
||
538 | * Function Name : SetEPDblBuffAddr |
||
539 | * Description : |
||
540 | * Input : bEpNum, wBuf0Addr, wBuf1Addr |
||
541 | * Output : |
||
542 | * Return : |
||
543 | *******************************************************************************/ |
||
544 | void SetEPDblBuffAddr(u8 bEpNum, u16 wBuf0Addr, u16 wBuf1Addr) |
||
545 | { |
||
546 | _SetEPDblBuffAddr(bEpNum, wBuf0Addr, wBuf1Addr); |
||
547 | } |
||
548 | /******************************************************************************* |
||
549 | * Function Name : SetEPDblBuf0Addr |
||
550 | * Description : |
||
551 | * Input : bEpNum, wBuf0Addr |
||
552 | * Output : |
||
553 | * Return : |
||
554 | *******************************************************************************/ |
||
555 | void SetEPDblBuf0Addr(u8 bEpNum,u16 wBuf0Addr) |
||
556 | { |
||
557 | _SetEPDblBuf0Addr(bEpNum, wBuf0Addr); |
||
558 | } |
||
559 | /******************************************************************************* |
||
560 | * Function Name : SetEPDblBuf1Addr |
||
561 | * Description : |
||
562 | * Input : bEpNum, wBuf1Addr |
||
563 | * Output : |
||
564 | * Return : |
||
565 | *******************************************************************************/ |
||
566 | void SetEPDblBuf1Addr(u8 bEpNum,u16 wBuf1Addr) |
||
567 | { |
||
568 | _SetEPDblBuf1Addr(bEpNum, wBuf1Addr); |
||
569 | } |
||
570 | /******************************************************************************* |
||
571 | * Function Name : GetEPDblBuf0Addr |
||
572 | * Description : |
||
573 | * Input : bEpNum |
||
574 | * Output : |
||
575 | * Return : |
||
576 | *******************************************************************************/ |
||
577 | u16 GetEPDblBuf0Addr(u8 bEpNum) |
||
578 | { |
||
579 | return(_GetEPDblBuf0Addr(bEpNum)); |
||
580 | } |
||
581 | /******************************************************************************* |
||
582 | * Function Name : GetEPDblBuf1Addr |
||
583 | * Description : |
||
584 | * Input : bEpNum |
||
585 | * Output : |
||
586 | * Return : |
||
587 | *******************************************************************************/ |
||
588 | u16 GetEPDblBuf1Addr(u8 bEpNum) |
||
589 | { |
||
590 | return(_GetEPDblBuf1Addr(bEpNum)); |
||
591 | } |
||
592 | /******************************************************************************* |
||
593 | * Function Name : SetEPDblBuffCount |
||
594 | * Description : |
||
595 | * Input : bEpNum,bDir, wCount |
||
596 | * Output : |
||
597 | * Return : |
||
598 | *******************************************************************************/ |
||
599 | void SetEPDblBuffCount(u8 bEpNum, u8 bDir, u16 wCount) |
||
600 | { |
||
601 | #ifdef STR7xx /*STR7xx family */ |
||
602 | _SetEPDblBuffCount(bEpNum, bDir, wCount); |
||
603 | #endif |
||
604 | |||
605 | #ifdef STR91x /*STR91x family*/ |
||
606 | SetEPDblBuf0Count(bEpNum, bDir,wCount); |
||
607 | SetEPDblBuf1Count(bEpNum, bDir,wCount); |
||
608 | #endif |
||
609 | } |
||
610 | /******************************************************************************* |
||
611 | * Function Name : SetEPDblBuf0Count |
||
612 | * Description : |
||
613 | * Input : bEpNum, bDir, wCount |
||
614 | * Output : |
||
615 | * Return : |
||
616 | *******************************************************************************/ |
||
617 | void SetEPDblBuf0Count(u8 bEpNum, u8 bDir,u16 wCount) |
||
618 | { |
||
619 | #ifdef STR7xx /*STR7xx family */ |
||
620 | _SetEPDblBuf0Count(bEpNum,bDir,wCount); |
||
621 | #endif |
||
622 | |||
623 | #ifdef STR91x /*STR91x family*/ |
||
624 | u32 BLsize=0; |
||
625 | u32 Blocks; |
||
626 | if(bDir == EP_DBUF_IN) |
||
627 | /* IN double bufferd endpoint */ |
||
628 | SetEPTxCount(bEpNum,wCount); |
||
629 | else if(bDir == EP_DBUF_OUT) |
||
630 | { |
||
631 | /* OUT double bufferd endpoint */ |
||
632 | |||
633 | if (wCount < 64) Blocks = wCount>>1; |
||
634 | else |
||
635 | { |
||
636 | BLsize = 0x8000; |
||
637 | Blocks = wCount>>6; |
||
638 | } |
||
639 | *_pEPBufCount(bEpNum) &=~0x8000; |
||
640 | *_pEPBufCount(bEpNum) |=BLsize; |
||
641 | *_pEPBufCount(bEpNum) &=~0x7C00; |
||
642 | *_pEPBufCount(bEpNum) |=Blocks<<10; |
||
643 | *_pEPBufCount(bEpNum) &=0xFFFFFC00; |
||
644 | } |
||
645 | #endif |
||
646 | } |
||
647 | /******************************************************************************* |
||
648 | * Function Name : SetEPDblBuf1Count |
||
649 | * Description : |
||
650 | * Input : bEpNum, bDir, wCount |
||
651 | * Output : |
||
652 | * Return : |
||
653 | *******************************************************************************/ |
||
654 | void SetEPDblBuf1Count(u8 bEpNum, u8 bDir,u16 wCount) |
||
655 | { |
||
656 | #ifdef STR7xx /*STR7xx family */ |
||
657 | _SetEPDblBuf1Count(bEpNum,bDir,wCount); |
||
658 | #endif |
||
659 | |||
660 | #ifdef STR91x /*STR91x family*/ |
||
661 | if(bDir == EP_DBUF_IN) |
||
662 | /* IN double buffered endpoint */ |
||
663 | { |
||
664 | *_pEPBufCount(bEpNum)&= 0x000FFFF; |
||
665 | *_pEPBufCount(bEpNum)|=(wCount<<16); |
||
666 | } |
||
667 | else if(bDir == EP_DBUF_OUT) |
||
668 | /* OUT double buffered endpoint */ |
||
669 | _SetEPRxCount(bEpNum, wCount); |
||
670 | #endif |
||
671 | } |
||
672 | /******************************************************************************* |
||
673 | * Function Name : GetEPDblBuf0Count |
||
674 | * Description : |
||
675 | * Input : bEpNum |
||
676 | * Output : |
||
677 | * Return : |
||
678 | *******************************************************************************/ |
||
679 | u16 GetEPDblBuf0Count(u8 bEpNum) |
||
680 | { |
||
681 | return(_GetEPDblBuf0Count(bEpNum)); |
||
682 | } |
||
683 | /******************************************************************************* |
||
684 | * Function Name : GetEPDblBuf1Count |
||
685 | * Description : |
||
686 | * Input : bEpNum |
||
687 | * Output : |
||
688 | * Return : |
||
689 | *******************************************************************************/ |
||
690 | u16 GetEPDblBuf1Count(u8 bEpNum) |
||
691 | { |
||
692 | return(_GetEPDblBuf1Count(bEpNum)); |
||
693 | } |
||
694 | #ifdef STR7xx /*STR7xx family */ |
||
695 | /******************************************************************************* |
||
696 | * Function Name : GetEPDblBufDir |
||
697 | * Description : gets direction of the double buffered endpoint |
||
698 | * Input : bEpNum |
||
699 | * Output : EP_DBUF_OUT, EP_DBUF_IN, |
||
700 | EP_DBUF_ERR if the endpoint counter not yet programmed |
||
701 | * Return : |
||
702 | *******************************************************************************/ |
||
703 | EP_DBUF_DIR GetEPDblBufDir(u8 bEpNum) { |
||
704 | if((u16)(*_pEPRxCount(bEpNum) & 0xFC00) != 0) |
||
705 | return(EP_DBUF_OUT); |
||
706 | else if(((u16)(*_pEPTxCount(bEpNum)) & 0x03FF) != 0) |
||
707 | return(EP_DBUF_IN); |
||
708 | else |
||
709 | return(EP_DBUF_ERR); |
||
710 | } |
||
711 | #endif |
||
712 | /******************************************************************************* |
||
713 | * Function Name : FreeUserBuffer |
||
714 | * Description : free buffer used from the application realising it to the line |
||
715 | toggles bit SW_BUF in the double buffered endpoint register |
||
716 | * Input : bEpNum, bDir |
||
717 | * Output : |
||
718 | * Return : |
||
719 | *******************************************************************************/ |
||
720 | void FreeUserBuffer(u8 bEpNum, u8 bDir) |
||
721 | { |
||
722 | if(bDir== EP_DBUF_OUT) |
||
723 | { /* OUT double buffered endpoint */ |
||
724 | _ToggleDTOG_TX(bEpNum); |
||
725 | } |
||
726 | else if(bDir == EP_DBUF_IN) |
||
727 | { /* IN double buffered endpoint */ |
||
728 | _ToggleDTOG_RX(bEpNum); |
||
729 | } |
||
730 | } |
||
731 | |||
732 | /******************************************************************************* |
||
733 | * Function Name : ToWord |
||
734 | * Description : |
||
735 | * Input : bh, bl |
||
736 | * Output : |
||
737 | * Return : |
||
738 | *******************************************************************************/ |
||
739 | u16 ToWord(u8 bh, u8 bl) |
||
740 | { |
||
741 | u16 wRet; |
||
742 | wRet = (u16)bl | ((u16)bh << 8); |
||
743 | return(wRet); |
||
744 | } |
||
745 | /******************************************************************************* |
||
746 | * Function Name : ByteSwap |
||
747 | * Description : |
||
748 | * Input : wSwW |
||
749 | * Output : |
||
750 | * Return : |
||
751 | *******************************************************************************/ |
||
752 | u16 ByteSwap(u16 wSwW) |
||
753 | { |
||
754 | u8 bTemp; |
||
755 | u16 wRet; |
||
756 | bTemp = (u8)(wSwW & 0xff); |
||
757 | wRet = (wSwW >> 8) | ((u16)bTemp << 8); |
||
758 | return(wRet); |
||
759 | } |
||
760 | |||
761 | /* DMA Functions only for STR91x */ |
||
762 | #ifdef STR91x /*str91x family*/ |
||
763 | /******************************************************************************* |
||
764 | * Function Name : SetDMAburstTxSize |
||
765 | * Description : Configure the Burst Size for a Tx Endpoint |
||
766 | * Input : DestBsize: Destination Burst Size |
||
767 | * Output : None |
||
768 | * Return : None |
||
769 | *******************************************************************************/ |
||
770 | void SetDMABurstTxSize(u8 DestBsize) |
||
771 | { |
||
772 | *DMABSIZE &=~0xEF; |
||
773 | *DMABSIZE = (DestBsize<<4); |
||
774 | } |
||
775 | |||
776 | /******************************************************************************* |
||
777 | * Function Name : SetDMABurstRxSize |
||
778 | * Description : Configure the Burst Size for a Rx Endpoint |
||
779 | * Input : SrcBsize: Source Burst |
||
780 | * Output : None |
||
781 | * Return : None |
||
782 | *******************************************************************************/ |
||
783 | void SetDMABurstRxSize(u8 SrcBsize) |
||
784 | { |
||
785 | *DMABSIZE &=~0x7; |
||
786 | *DMABSIZE = SrcBsize; |
||
787 | } |
||
788 | |||
789 | /******************************************************************************* |
||
790 | * Function Name : DMAUnlinkedModeTxConfig |
||
791 | * Description : Configure a Tx Endpoint to trigger TX Unlinked DMA request |
||
792 | * Note : Up to three endpoints could be configured to trigger DMA |
||
793 | request, an index[0:2] must be associated to an endpoint |
||
794 | * Input : -bEpNum: endpoint number[0:9] |
||
795 | * -index: 0,1 or 2 |
||
796 | * Output : None |
||
797 | * Return : None |
||
798 | *******************************************************************************/ |
||
799 | void DMAUnlinkedModeTxConfig(u8 bEpNum ,u8 index) |
||
800 | { |
||
801 | *DMACR2 &=~(0x0F<<(4*index)); |
||
802 | *DMACR2 |=bEpNum<<(4*index); |
||
803 | } |
||
804 | |||
805 | /******************************************************************************* |
||
806 | * Function Name : DMAUnlinkedModeTxEnable |
||
807 | * Description : Enable a Tx endpoint to trigger Tx DMA request |
||
808 | * Input : -index :0,1 or 2 = index associated to endpoint in function |
||
809 | * "DMAUnlinkedModeTxConfig" |
||
810 | * Output : None |
||
811 | * Return : None |
||
812 | *******************************************************************************/ |
||
813 | void DMAUnlinkedModeTxEnable(u8 index) |
||
814 | { |
||
815 | *DMACR3 &=~0x01; /*DMA Tx linked mode disabled*/ |
||
816 | *DMACR2 &=~0x3000; |
||
817 | *DMACR2 |=(index+1)<<12; |
||
818 | } |
||
819 | |||
820 | /******************************************************************************* |
||
821 | * Function Name : DMAUnlinkedModeTxDisable |
||
822 | * Description : Enable a Tx endpoint to trigger Tx DMA request |
||
823 | * Input : index :0,1 or 2 = index associated to endpoint in function |
||
824 | * "DMAUnlinkedModeTxConfig" |
||
825 | * Output : None |
||
826 | * Return : None |
||
827 | *******************************************************************************/ |
||
828 | void DMAUnlinkedModeTxDisable(u8 index) |
||
829 | { |
||
830 | *DMACR2 &=~0x3000; |
||
831 | } |
||
832 | |||
833 | /******************************************************************************* |
||
834 | * Function Name : DMAUnlinkedModeRxEnable |
||
835 | * Description : Enable a Rx Endpoint to trigger Rx DMA |
||
836 | * Input : bEpNum: endpoint number[0:9] |
||
837 | * Output : None |
||
838 | * Return : None |
||
839 | *******************************************************************************/ |
||
840 | void DMAUnlinkedModeRxEnable(u8 bEpNum) |
||
841 | { |
||
842 | *DMACR3 &=~0x80; /*DMA Rx linked mode disabled*/ |
||
843 | *DMACR1 |=(0x1<<bEpNum); |
||
844 | } |
||
845 | |||
846 | /******************************************************************************* |
||
847 | * Function Name : DMAUnlinkedModeRxDisable |
||
848 | * Description : Disable a Rx Endpoint to trigger Rx DMA |
||
849 | * Input : bEpNum: endpoint number[0:9] |
||
850 | * Output : None |
||
851 | * Return : None |
||
852 | *******************************************************************************/ |
||
853 | void DMAUnlinkedModeRxDisable(u8 bEpNum) |
||
854 | { |
||
855 | *DMACR1 &=~(0x1<<bEpNum); |
||
856 | } |
||
857 | |||
858 | /******************************************************************************* |
||
859 | * Function Name : DMALinkedModeRxConfig |
||
860 | * Description : Configure a Rx endpoint to trigger DMA linked request |
||
861 | * Input : bEpNum: endpoint number[0:9] |
||
862 | * Output : None |
||
863 | * Return : None |
||
864 | *******************************************************************************/ |
||
865 | void DMALinkedModeRxConfig(u8 bEpNum) |
||
866 | { |
||
867 | *DMACR3 &=~0x1E00; |
||
868 | *DMACR3 |=bEpNum<<9; |
||
869 | } |
||
870 | |||
871 | /******************************************************************************* |
||
872 | * Function Name : DMALinkedModeTxConfig |
||
873 | * Description : Configure a Tx endpoint to trigger DMA linked request |
||
874 | * Input : bEpNum: endpoint number[0:9] |
||
875 | * Output : None |
||
876 | * Return : None |
||
877 | *******************************************************************************/ |
||
878 | void DMALinkedModeTxConfig(u8 bEpNum) |
||
879 | { |
||
880 | *DMACR3 &=~0x1E; |
||
881 | *DMACR3 |=bEpNum<<1; |
||
882 | } |
||
883 | |||
884 | /******************************************************************************* |
||
885 | * Function Name : DMALinkedModeRxEnable |
||
886 | * Description : Enable the DMA Linked Rx mode |
||
887 | * Input : None |
||
888 | * Output : None |
||
889 | * Return : None |
||
890 | *******************************************************************************/ |
||
891 | void DMALinkedModeRxEnable(void) |
||
892 | { |
||
893 | *DMACR3 |=0x100; |
||
894 | *DMACR3 |=0x2000; |
||
895 | } |
||
896 | |||
897 | /******************************************************************************* |
||
898 | * Function Name : DMALinkedModeTxEnable |
||
899 | * Description : Enable the DMA Linked Tx mode |
||
900 | * Input : None |
||
901 | * Output : None |
||
902 | * Return : None |
||
903 | *******************************************************************************/ |
||
904 | void DMALinkedModeTxEnable(void) |
||
905 | { |
||
906 | *DMACR3 |=0x1; |
||
907 | *DMACR3 |=0x20; |
||
908 | } |
||
909 | /******************************************************************************* |
||
910 | * Function Name : DMALinkedModeRxDisable |
||
911 | * Description : Disable the DMA Linked Rx mode |
||
912 | * Input : None |
||
913 | * Output : None |
||
914 | * Return : None |
||
915 | *******************************************************************************/ |
||
916 | void DMALinkedModeRxDisable(void) |
||
917 | { |
||
918 | *DMACR3 &=~0x100; |
||
919 | *DMACR3 &=~0x2000; |
||
920 | } |
||
921 | |||
922 | /******************************************************************************* |
||
923 | * Function Name : DMALinkedModeTxDisable |
||
924 | * Description : Disable the DMA Linked Tx mode |
||
925 | * Input : None |
||
926 | * Output : None |
||
927 | * Return : None |
||
928 | *******************************************************************************/ |
||
929 | void DMALinkedModeTxDisable(void) |
||
930 | { |
||
931 | *DMACR3 &=~0x1; |
||
932 | *DMACR3 &=~0x20; |
||
933 | } |
||
934 | /******************************************************************************* |
||
935 | * Function Name : USB_DMASynchEnable |
||
936 | * Description : Enable the Synchronization Logic |
||
937 | * Input : TRUE or FALSE |
||
938 | * Output : None |
||
939 | * Return : None |
||
940 | *******************************************************************************/ |
||
941 | void DMASynchEnable(void) |
||
942 | { |
||
943 | *DMACR3 |=0x40; |
||
944 | } |
||
945 | |||
946 | /******************************************************************************* |
||
947 | * Function Name : USB_DMASynchDisable |
||
948 | * Description : Disable the Synchronization Logic |
||
949 | * Input : TRUE or FALSE |
||
950 | * Output : None |
||
951 | * Return : None |
||
952 | *******************************************************************************/ |
||
953 | void DMASynchDisable(void) |
||
954 | { |
||
955 | *DMACR3 &=~0x40; |
||
956 | } |
||
957 | |||
958 | /******************************************************************************* |
||
959 | * Function Name : SetDMALLITxLength |
||
960 | * Description : Set the DMA LLI Tx length |
||
961 | * Input : length |
||
962 | * Output : None |
||
963 | * Return : None |
||
964 | *******************************************************************************/ |
||
965 | void SetDMALLITxLength(u8 length) |
||
966 | { |
||
967 | *DMALLI &=~0xFF; |
||
968 | *DMALLI |= length; |
||
969 | } |
||
970 | |||
971 | /******************************************************************************* |
||
972 | * Function Name : SetDMALLIRxLength |
||
973 | * Description : Set the DMA LLI Rx length |
||
974 | * Input : length |
||
975 | * Output : None |
||
976 | * Return : None |
||
977 | *******************************************************************************/ |
||
978 | void SetDMALLIRxLength(u8 length ) |
||
979 | { |
||
980 | *DMALLI &=~0xFF00; |
||
981 | *DMALLI |= length<<8; |
||
982 | } |
||
983 | |||
984 | /******************************************************************************* |
||
985 | * Function Name : SetDMALLIRxPacketNum |
||
986 | * Description : Set the LLI_RX_NPACKETS field in register USB_DMABSIZE register |
||
987 | * Input : None |
||
988 | * Output : None |
||
989 | * Return : None |
||
990 | *******************************************************************************/ |
||
991 | void SetDMALLIRxPacketNum(u8 PacketNum) |
||
992 | { |
||
993 | *DMABSIZE &=0xFF; |
||
994 | *DMABSIZE |=(PacketNum<<8); |
||
995 | } |
||
996 | |||
997 | /******************************************************************************* |
||
998 | * Function Name : GetDMALLIPacketNum |
||
999 | * Description : gets the LLI_RX_NPACKETS field value |
||
1000 | * Input : None |
||
1001 | * Output : None |
||
1002 | * Return : LLI_RX_NPACKETS field value |
||
1003 | *******************************************************************************/ |
||
1004 | u8 GetDMALLIRxPacketNum(void) |
||
1005 | { |
||
1006 | return((u8)(*DMABSIZE & 0xFF00)>>8); |
||
1007 | } |
||
1008 | #endif |
||
1009 | /******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/ |
||
1010 |