1 /*******************************************************************************
3 * This software is supplied by Renesas Electronics Corporation and is only
4 * intended for use with Renesas products. No other uses are authorized. This
5 * software is owned by Renesas Electronics Corporation and is protected under
6 * all applicable laws, including copyright laws.
7 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
8 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
9 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
10 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
11 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
12 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
13 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
14 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
15 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
16 * Renesas reserves the right, without notice, to make changes to this software
17 * and to discontinue the availability of this software. By using this software,
18 * you agree to the additional terms and conditions found by accessing the
20 * http://www.renesas.com/disclaimer
21 * Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
22 *******************************************************************************/
23 /*******************************************************************************
24 * File Name : usb1_host_lib.c
26 * $Date:: 2014-07-09 16:29:19 +0900#$
31 * Description : RZ/A1H R7S72100 USB Sample Program
34 *******************************************************************************/
37 /*******************************************************************************
38 Includes <System Includes> , "Project Includes"
39 *******************************************************************************/
40 #include "usb1_host.h"
41 #if(1) /* ohci_wrapp */
42 #include "MBRZA1H.h" /* INTC Driver Header */
44 #include "devdrv_intc.h" /* INTC Driver Header */
48 /*******************************************************************************
50 *******************************************************************************/
53 /*******************************************************************************
55 *******************************************************************************/
58 /*******************************************************************************
59 Imported global variables and functions (from other files)
60 *******************************************************************************/
63 /*******************************************************************************
64 Exported global variables and functions (to be accessed by other files)
65 *******************************************************************************/
68 /*******************************************************************************
69 Private global variables and functions
70 *******************************************************************************/
73 /*******************************************************************************
74 * Function Name: usb1_host_enable_brdy_int
75 * Description : Enables BRDY interrupt in the pipe spceified by the argument.
76 * : Disables BEMP/NRDY/BRDY interrupts in all pipes before enabling
77 * : BRDY. Enables BRDY interrupt in the pipe specified by the argument
78 * : in the disabled status. After enabling BRDY, recover all
79 * : BEMP/NRDY/BRDY disabled/enabled status.
80 * Arguments : uint16_t pipe ; pipe Number
82 *******************************************************************************/
83 void usb1_host_enable_brdy_int (uint16_t pipe
)
85 /* enable brdy interrupt */
86 USB201
.BRDYENB
|= (uint16_t)g_usb1_host_bit_set
[pipe
];
89 /*******************************************************************************
90 * Function Name: usb1_host_disable_brdy_int
91 * Description : Disables BRDY interrupt in the pipe spceified by the argument.
92 * : Disables BEMP/NRDY/BRDY interrupts in all pipes before disabling
93 * : BRDY. Enables BRDY interrupt in the pipe specified by the argument
94 * : in the disabled status. After disabling BRDY, recover all
95 * : BEMP/NRDY/BRDY disabled/enabled status.
96 * Arguments : uint16_t pipe ; pipe Number
98 *******************************************************************************/
99 void usb1_host_disable_brdy_int (uint16_t pipe
)
101 /* disable brdy interrupt */
102 USB201
.BRDYENB
&= (uint16_t)~(g_usb1_host_bit_set
[pipe
]);
105 /*******************************************************************************
106 * Function Name: usb1_host_clear_brdy_sts
107 * Description : Clear BRDY interrupt status in the pipe spceified by the argument.
108 * Arguments : uint16_t pipe ; pipe Number
109 * Return Value : none
110 *******************************************************************************/
111 void usb1_host_clear_brdy_sts (uint16_t pipe
)
113 /* clear brdy status */
114 USB201
.BRDYSTS
= (uint16_t)~(g_usb1_host_bit_set
[pipe
]);
117 /*******************************************************************************
118 * Function Name: usb1_host_enable_bemp_int
119 * Description : Enables BEMP interrupt in the pipe spceified by the argument.
120 * : Disables BEMP/NRDY/BRDY interrupts in all pipes before enabling
121 * : BEMP. Enables BEMP interrupt in the pipe specified by the argument
122 * : in the disabled status. After enabling BEMP, recover all
123 * : BEMP/NRDY/BRDY disabled/enabled status.
124 * Arguments : uint16_t pipe ; pipe Number
125 * Return Value : none
126 *******************************************************************************/
127 void usb1_host_enable_bemp_int (uint16_t pipe
)
129 /* enable bemp interrupt */
130 USB201
.BEMPENB
|= (uint16_t)g_usb1_host_bit_set
[pipe
];
133 /*******************************************************************************
134 * Function Name: usb1_host_disable_bemp_int
135 * Description : Disables BEMP interrupt in the pipe spceified by the argument.
136 * : Disables BEMP/NRDY/BRDY interrupts in all pipes before disabling
137 * : BEMP. Enables BEMP interrupt in the pipe specified by the argument
138 * : in the disabled status. After enabling BEMP, recover all
139 * : BEMP/NRDY/BRDY disabled/enabled status.
140 * Arguments : uint16_t pipe ; pipe Number
141 * Return Value : none
142 *******************************************************************************/
143 void usb1_host_disable_bemp_int (uint16_t pipe
)
145 /* disable bemp interrupt */
146 USB201
.BEMPENB
&= (uint16_t)~(g_usb1_host_bit_set
[pipe
]);
149 /*******************************************************************************
150 * Function Name: usb1_host_clear_bemp_sts
151 * Description : Clear BEMP interrupt status in the pipe spceified by the argument.
152 * Arguments : uint16_t pipe ; pipe Number
153 * Return Value : none
154 *******************************************************************************/
155 void usb1_host_clear_bemp_sts (uint16_t pipe
)
157 /* clear bemp status */
158 USB201
.BEMPSTS
= (uint16_t)~(g_usb1_host_bit_set
[pipe
]);
161 /*******************************************************************************
162 * Function Name: usb1_host_enable_nrdy_int
163 * Description : Enables NRDY interrupt in the pipe spceified by the argument.
164 * : Disables BEMP/NRDY/BRDY interrupts in all pipes before enabling
165 * : NRDY. Enables NRDY interrupt in the pipe specified by the argument
166 * : in the disabled status. After enabling NRDY, recover all
167 * : BEMP/NRDY/BRDY disabled/enabled status.
168 * Arguments : uint16_t pipe ; pipe Number
169 * Return Value : none
170 *******************************************************************************/
171 void usb1_host_enable_nrdy_int (uint16_t pipe
)
173 /* enable nrdy interrupt */
174 USB201
.NRDYENB
|= (uint16_t)g_usb1_host_bit_set
[pipe
];
177 /*******************************************************************************
178 * Function Name: usb1_host_disable_nrdy_int
179 * Description : Disables NRDY interrupt in the pipe spceified by the argument.
180 * : Disables BEMP/NRDY/BRDY interrupts in all pipes before disabling
181 * : NRDY. Disables NRDY interrupt in the pipe specified by the argument
182 * : in the disabled status. After disabling NRDY, recover all
183 * : BEMP/NRDY/BRDY disabled/enabled status.
184 * Arguments : uint16_t pipe ; pipe Number
185 * Return Value : none
186 *******************************************************************************/
187 void usb1_host_disable_nrdy_int (uint16_t pipe
)
189 /* disable nrdy interrupt */
190 USB201
.NRDYENB
&= (uint16_t)~(g_usb1_host_bit_set
[pipe
]);
193 /*******************************************************************************
194 * Function Name: usb1_host_clear_nrdy_sts
195 * Description : Clear NRDY interrupt status in the pipe spceified by the argument.
196 * Arguments : uint16_t pipe ; pipe Number
197 * Return Value : none
198 *******************************************************************************/
199 void usb1_host_clear_nrdy_sts (uint16_t pipe
)
201 /* clear nrdy status */
202 USB201
.NRDYSTS
= (uint16_t)~(g_usb1_host_bit_set
[pipe
]);
205 /*******************************************************************************
206 * Function Name: usb1_host_is_hispeed
207 * Description : Returns the result of USB reset hand shake (RHST) as
210 * Return Value : USB_HOST_HIGH_SPEED ; Hi-Speed
211 * : USB_HOST_FULL_SPEED ; Full-Speed
212 * : USB_HOST_LOW_SPEED ; Low-Speed
213 * : USB_HOST_NON_SPEED ; error
214 *******************************************************************************/
215 uint16_t usb1_host_is_hispeed (void)
220 rhst
= RZA_IO_RegRead_16(&USB201
.DVSTCTR0
,
221 USB_DVSTCTR0_RHST_SHIFT
,
223 if (rhst
== USB_HOST_HSMODE
)
225 speed
= USB_HOST_HIGH_SPEED
;
227 else if (rhst
== USB_HOST_FSMODE
)
229 speed
= USB_HOST_FULL_SPEED
;
231 else if (rhst
== USB_HOST_LSMODE
)
233 speed
= USB_HOST_LOW_SPEED
;
237 speed
= USB_HOST_NON_SPEED
;
243 /*******************************************************************************
244 * Function Name: usb1_host_is_hispeed_enable
245 * Description : Returns the USB High-Speed connection enabled status as
248 * Return Value : USB_HOST_YES : Hi-Speed Enable
249 * : USB_HOST_NO : Hi-Speed Disable
250 *******************************************************************************/
251 uint16_t usb1_host_is_hispeed_enable (void)
257 if (RZA_IO_RegRead_16(&USB201
.SYSCFG0
,
258 USB_SYSCFG_HSE_SHIFT
,
259 USB_SYSCFG_HSE
) == 1)
267 /*******************************************************************************
268 * Function Name: usb1_host_set_pid_buf
269 * Description : Enables communicaqtion in the pipe specified by the argument
271 * Arguments : uint16_t pipe ; pipe Number
272 * Return Value : none
273 *******************************************************************************/
274 void usb1_host_set_pid_buf (uint16_t pipe
)
278 pid
= usb1_host_get_pid(pipe
);
280 if (pid
== USB_HOST_PID_STALL2
)
282 usb1_host_set_pid_nak(pipe
);
288 RZA_IO_RegWrite_16(&USB201
.DCPCTR
,
290 USB_DCPCTR_PID_SHIFT
,
295 RZA_IO_RegWrite_16(&USB201
.PIPE1CTR
,
297 USB_PIPEnCTR_1_5_PID_SHIFT
,
298 USB_PIPEnCTR_1_5_PID
);
302 RZA_IO_RegWrite_16(&USB201
.PIPE2CTR
,
304 USB_PIPEnCTR_1_5_PID_SHIFT
,
305 USB_PIPEnCTR_1_5_PID
);
309 RZA_IO_RegWrite_16(&USB201
.PIPE3CTR
,
311 USB_PIPEnCTR_1_5_PID_SHIFT
,
312 USB_PIPEnCTR_1_5_PID
);
316 RZA_IO_RegWrite_16(&USB201
.PIPE4CTR
,
318 USB_PIPEnCTR_1_5_PID_SHIFT
,
319 USB_PIPEnCTR_1_5_PID
);
323 RZA_IO_RegWrite_16(&USB201
.PIPE5CTR
,
325 USB_PIPEnCTR_1_5_PID_SHIFT
,
326 USB_PIPEnCTR_1_5_PID
);
330 RZA_IO_RegWrite_16(&USB201
.PIPE6CTR
,
332 USB_PIPEnCTR_6_8_PID_SHIFT
,
333 USB_PIPEnCTR_6_8_PID
);
337 RZA_IO_RegWrite_16(&USB201
.PIPE7CTR
,
339 USB_PIPEnCTR_6_8_PID_SHIFT
,
340 USB_PIPEnCTR_6_8_PID
);
344 RZA_IO_RegWrite_16(&USB201
.PIPE8CTR
,
346 USB_PIPEnCTR_6_8_PID_SHIFT
,
347 USB_PIPEnCTR_6_8_PID
);
351 RZA_IO_RegWrite_16(&USB201
.PIPE9CTR
,
353 USB_PIPEnCTR_9_PID_SHIFT
,
362 /*******************************************************************************
363 * Function Name: usb1_host_set_pid_nak
364 * Description : Disables communication (NAK) in the pipe specified by the argument.
365 * : When the pipe status was enabling communication (BUF) before
366 * : executing before executing this function, waits in the software
367 * : until the pipe becomes ready after setting disabled.
368 * Arguments : uint16_t pipe ; pipe Number
369 * Return Value : none
370 *******************************************************************************/
371 void usb1_host_set_pid_nak (uint16_t pipe
)
377 pid
= usb1_host_get_pid(pipe
);
379 if (pid
== USB_HOST_PID_STALL2
)
381 usb1_host_set_pid_stall(pipe
);
387 RZA_IO_RegWrite_16(&USB201
.DCPCTR
,
389 USB_DCPCTR_PID_SHIFT
,
394 RZA_IO_RegWrite_16(&USB201
.PIPE1CTR
,
396 USB_PIPEnCTR_1_5_PID_SHIFT
,
397 USB_PIPEnCTR_1_5_PID
);
401 RZA_IO_RegWrite_16(&USB201
.PIPE2CTR
,
403 USB_PIPEnCTR_1_5_PID_SHIFT
,
404 USB_PIPEnCTR_1_5_PID
);
408 RZA_IO_RegWrite_16(&USB201
.PIPE3CTR
,
410 USB_PIPEnCTR_1_5_PID_SHIFT
,
411 USB_PIPEnCTR_1_5_PID
);
415 RZA_IO_RegWrite_16(&USB201
.PIPE4CTR
,
417 USB_PIPEnCTR_1_5_PID_SHIFT
,
418 USB_PIPEnCTR_1_5_PID
);
422 RZA_IO_RegWrite_16(&USB201
.PIPE5CTR
,
424 USB_PIPEnCTR_1_5_PID_SHIFT
,
425 USB_PIPEnCTR_1_5_PID
);
429 RZA_IO_RegWrite_16(&USB201
.PIPE6CTR
,
431 USB_PIPEnCTR_6_8_PID_SHIFT
,
432 USB_PIPEnCTR_6_8_PID
);
436 RZA_IO_RegWrite_16(&USB201
.PIPE7CTR
,
438 USB_PIPEnCTR_6_8_PID_SHIFT
,
439 USB_PIPEnCTR_6_8_PID
);
443 RZA_IO_RegWrite_16(&USB201
.PIPE8CTR
,
445 USB_PIPEnCTR_6_8_PID_SHIFT
,
446 USB_PIPEnCTR_6_8_PID
);
450 RZA_IO_RegWrite_16(&USB201
.PIPE9CTR
,
452 USB_PIPEnCTR_9_PID_SHIFT
,
460 if (pid
== USB_HOST_PID_BUF
)
462 for (loop
= 0; loop
< 200; loop
++)
467 pbusy
= RZA_IO_RegRead_16(&USB201
.DCPCTR
,
468 USB_DCPCTR_PBUSY_SHIFT
,
473 pbusy
= RZA_IO_RegRead_16(&USB201
.PIPE1CTR
,
474 USB_PIPEnCTR_1_5_PBUSY_SHIFT
,
475 USB_PIPEnCTR_1_5_PBUSY
);
479 pbusy
= RZA_IO_RegRead_16(&USB201
.PIPE2CTR
,
480 USB_PIPEnCTR_1_5_PBUSY_SHIFT
,
481 USB_PIPEnCTR_1_5_PBUSY
);
485 pbusy
= RZA_IO_RegRead_16(&USB201
.PIPE3CTR
,
486 USB_PIPEnCTR_1_5_PBUSY_SHIFT
,
487 USB_PIPEnCTR_1_5_PBUSY
);
491 pbusy
= RZA_IO_RegRead_16(&USB201
.PIPE4CTR
,
492 USB_PIPEnCTR_1_5_PBUSY_SHIFT
,
493 USB_PIPEnCTR_1_5_PBUSY
);
497 pbusy
= RZA_IO_RegRead_16(&USB201
.PIPE5CTR
,
498 USB_PIPEnCTR_1_5_PBUSY_SHIFT
,
499 USB_PIPEnCTR_1_5_PBUSY
);
503 pbusy
= RZA_IO_RegRead_16(&USB201
.PIPE6CTR
,
504 USB_PIPEnCTR_6_8_PBUSY_SHIFT
,
505 USB_PIPEnCTR_6_8_PBUSY
);
509 pbusy
= RZA_IO_RegRead_16(&USB201
.PIPE7CTR
,
510 USB_PIPEnCTR_6_8_PBUSY_SHIFT
,
511 USB_PIPEnCTR_6_8_PBUSY
);
515 pbusy
= RZA_IO_RegRead_16(&USB201
.PIPE8CTR
,
516 USB_PIPEnCTR_6_8_PBUSY_SHIFT
,
517 USB_PIPEnCTR_6_8_PBUSY
);
521 pbusy
= RZA_IO_RegRead_16(&USB201
.PIPE9CTR
,
522 USB_PIPEnCTR_9_PBUSY_SHIFT
,
523 USB_PIPEnCTR_9_PBUSY
);
536 Userdef_USB_usb1_host_delay_500ns();
541 /*******************************************************************************
542 * Function Name: usb1_host_set_pid_stall
543 * Description : Disables communication (STALL) in the pipe specified by the
545 * Arguments : uint16_t pipe ; pipe Number
546 * Return Value : none
547 *******************************************************************************/
548 void usb1_host_set_pid_stall (uint16_t pipe
)
552 pid
= usb1_host_get_pid(pipe
);
554 if (pid
== USB_HOST_PID_BUF
)
559 RZA_IO_RegWrite_16(&USB201
.DCPCTR
,
561 USB_DCPCTR_PID_SHIFT
,
566 RZA_IO_RegWrite_16(&USB201
.PIPE1CTR
,
568 USB_PIPEnCTR_1_5_PID_SHIFT
,
569 USB_PIPEnCTR_1_5_PID
);
573 RZA_IO_RegWrite_16(&USB201
.PIPE2CTR
,
575 USB_PIPEnCTR_1_5_PID_SHIFT
,
576 USB_PIPEnCTR_1_5_PID
);
580 RZA_IO_RegWrite_16(&USB201
.PIPE3CTR
,
582 USB_PIPEnCTR_1_5_PID_SHIFT
,
583 USB_PIPEnCTR_1_5_PID
);
587 RZA_IO_RegWrite_16(&USB201
.PIPE4CTR
,
589 USB_PIPEnCTR_1_5_PID_SHIFT
,
590 USB_PIPEnCTR_1_5_PID
);
594 RZA_IO_RegWrite_16(&USB201
.PIPE5CTR
,
596 USB_PIPEnCTR_1_5_PID_SHIFT
,
597 USB_PIPEnCTR_1_5_PID
);
601 RZA_IO_RegWrite_16(&USB201
.PIPE6CTR
,
603 USB_PIPEnCTR_6_8_PID_SHIFT
,
604 USB_PIPEnCTR_6_8_PID
);
608 RZA_IO_RegWrite_16(&USB201
.PIPE7CTR
,
610 USB_PIPEnCTR_6_8_PID_SHIFT
,
611 USB_PIPEnCTR_6_8_PID
);
615 RZA_IO_RegWrite_16(&USB201
.PIPE8CTR
,
617 USB_PIPEnCTR_6_8_PID_SHIFT
,
618 USB_PIPEnCTR_6_8_PID
);
622 RZA_IO_RegWrite_16(&USB201
.PIPE9CTR
,
624 USB_PIPEnCTR_9_PID_SHIFT
,
637 RZA_IO_RegWrite_16(&USB201
.DCPCTR
,
639 USB_DCPCTR_PID_SHIFT
,
644 RZA_IO_RegWrite_16(&USB201
.PIPE1CTR
,
646 USB_PIPEnCTR_1_5_PID_SHIFT
,
647 USB_PIPEnCTR_1_5_PID
);
651 RZA_IO_RegWrite_16(&USB201
.PIPE2CTR
,
653 USB_PIPEnCTR_1_5_PID_SHIFT
,
654 USB_PIPEnCTR_1_5_PID
);
658 RZA_IO_RegWrite_16(&USB201
.PIPE3CTR
,
660 USB_PIPEnCTR_1_5_PID_SHIFT
,
661 USB_PIPEnCTR_1_5_PID
);
665 RZA_IO_RegWrite_16(&USB201
.PIPE4CTR
,
667 USB_PIPEnCTR_1_5_PID_SHIFT
,
668 USB_PIPEnCTR_1_5_PID
);
672 RZA_IO_RegWrite_16(&USB201
.PIPE5CTR
,
674 USB_PIPEnCTR_1_5_PID_SHIFT
,
675 USB_PIPEnCTR_1_5_PID
);
679 RZA_IO_RegWrite_16(&USB201
.PIPE6CTR
,
681 USB_PIPEnCTR_6_8_PID_SHIFT
,
682 USB_PIPEnCTR_6_8_PID
);
686 RZA_IO_RegWrite_16(&USB201
.PIPE7CTR
,
688 USB_PIPEnCTR_6_8_PID_SHIFT
,
689 USB_PIPEnCTR_6_8_PID
);
693 RZA_IO_RegWrite_16(&USB201
.PIPE8CTR
,
695 USB_PIPEnCTR_6_8_PID_SHIFT
,
696 USB_PIPEnCTR_6_8_PID
);
700 RZA_IO_RegWrite_16(&USB201
.PIPE9CTR
,
702 USB_PIPEnCTR_9_PID_SHIFT
,
712 /*******************************************************************************
713 * Function Name: usb1_host_clear_pid_stall
714 * Description : Disables communication (NAK) in the pipe specified by the argument.
715 * Arguments : uint16_t pipe ; pipe Number
716 * Return Value : none
717 *******************************************************************************/
718 void usb1_host_clear_pid_stall (uint16_t pipe
)
720 usb1_host_set_pid_nak(pipe
);
723 /*******************************************************************************
724 * Function Name: usb1_host_get_pid
725 * Description : Returns the pipe state specified by the argument.
726 * Arguments : uint16_t pipe ; Pipe Number
728 *******************************************************************************/
729 uint16_t usb1_host_get_pid (uint16_t pipe
)
736 pid
= RZA_IO_RegRead_16(&USB201
.DCPCTR
,
737 USB_DCPCTR_PID_SHIFT
,
742 pid
= RZA_IO_RegRead_16(&USB201
.PIPE1CTR
,
743 USB_PIPEnCTR_1_5_PID_SHIFT
,
744 USB_PIPEnCTR_1_5_PID
);
748 pid
= RZA_IO_RegRead_16(&USB201
.PIPE2CTR
,
749 USB_PIPEnCTR_1_5_PID_SHIFT
,
750 USB_PIPEnCTR_1_5_PID
);
754 pid
= RZA_IO_RegRead_16(&USB201
.PIPE3CTR
,
755 USB_PIPEnCTR_1_5_PID_SHIFT
,
756 USB_PIPEnCTR_1_5_PID
);
760 pid
= RZA_IO_RegRead_16(&USB201
.PIPE4CTR
,
761 USB_PIPEnCTR_1_5_PID_SHIFT
,
762 USB_PIPEnCTR_1_5_PID
);
766 pid
= RZA_IO_RegRead_16(&USB201
.PIPE5CTR
,
767 USB_PIPEnCTR_1_5_PID_SHIFT
,
768 USB_PIPEnCTR_1_5_PID
);
772 pid
= RZA_IO_RegRead_16(&USB201
.PIPE6CTR
,
773 USB_PIPEnCTR_6_8_PID_SHIFT
,
774 USB_PIPEnCTR_6_8_PID
);
778 pid
= RZA_IO_RegRead_16(&USB201
.PIPE7CTR
,
779 USB_PIPEnCTR_6_8_PID_SHIFT
,
780 USB_PIPEnCTR_6_8_PID
);
784 pid
= RZA_IO_RegRead_16(&USB201
.PIPE8CTR
,
785 USB_PIPEnCTR_6_8_PID_SHIFT
,
786 USB_PIPEnCTR_6_8_PID
);
790 pid
= RZA_IO_RegRead_16(&USB201
.PIPE9CTR
,
791 USB_PIPEnCTR_9_PID_SHIFT
,
803 /*******************************************************************************
804 * Function Name: usb1_host_set_csclr
805 * Description : CSPLIT status clear setting of sprit transaction in specified
806 * : pipe is performed.
807 * : When SQSET bit or SQCLR bit, and SQSET bit or SQCLR bit
808 * : in DCPCTR register are continuously changed (when the sequence
809 * : toggle bit of data PID is continuously changed over two or more pipes),
810 * : the access cycle with 120 ns and more than 5 cycle bus clock is necessary.
811 * : Do not set both SQCLR bit and SQSET bit to 1 at the same time.
812 * : In addition, both bits should be operated after PID is set to NAK.
813 * : However, when it is set to the isochronous transfer as the transfer type
814 * : (TYPE=11), writing in SQSET bit is disabled.
815 * Arguments : uint16_t pipe ; Pipe number
816 * Return Value : none
817 *******************************************************************************/
818 void usb1_host_set_csclr (uint16_t pipe
)
823 RZA_IO_RegWrite_16(&USB201
.DCPCTR
,
825 USB_DCPCTR_CSCLR_SHIFT
,
830 RZA_IO_RegWrite_16(&USB201
.PIPE1CTR
,
832 USB_PIPEnCTR_1_5_CSCLR_SHIFT
,
833 USB_PIPEnCTR_1_5_CSCLR
);
837 RZA_IO_RegWrite_16(&USB201
.PIPE2CTR
,
839 USB_PIPEnCTR_1_5_CSCLR_SHIFT
,
840 USB_PIPEnCTR_1_5_CSCLR
);
844 RZA_IO_RegWrite_16(&USB201
.PIPE3CTR
,
846 USB_PIPEnCTR_1_5_CSCLR_SHIFT
,
847 USB_PIPEnCTR_1_5_CSCLR
);
851 RZA_IO_RegWrite_16(&USB201
.PIPE4CTR
,
853 USB_PIPEnCTR_1_5_CSCLR_SHIFT
,
854 USB_PIPEnCTR_1_5_CSCLR
);
858 RZA_IO_RegWrite_16(&USB201
.PIPE5CTR
,
860 USB_PIPEnCTR_1_5_CSCLR_SHIFT
,
861 USB_PIPEnCTR_1_5_CSCLR
);
865 RZA_IO_RegWrite_16(&USB201
.PIPE6CTR
,
867 USB_PIPEnCTR_6_8_CSCLR_SHIFT
,
868 USB_PIPEnCTR_6_8_CSCLR
);
872 RZA_IO_RegWrite_16(&USB201
.PIPE7CTR
,
874 USB_PIPEnCTR_6_8_CSCLR_SHIFT
,
875 USB_PIPEnCTR_6_8_CSCLR
);
879 RZA_IO_RegWrite_16(&USB201
.PIPE8CTR
,
881 USB_PIPEnCTR_6_8_CSCLR_SHIFT
,
882 USB_PIPEnCTR_6_8_CSCLR
);
886 RZA_IO_RegWrite_16(&USB201
.PIPE9CTR
,
888 USB_PIPEnCTR_9_CSCLR_SHIFT
,
889 USB_PIPEnCTR_9_CSCLR
);
897 /*******************************************************************************
898 * Function Name: usb1_host_set_sqclr
899 * Description : Sets the sequence bit of the pipe specified by the argument to
901 * Arguments : uint16_t pipe ; Pipe Number
902 * Return Value : none
903 *******************************************************************************/
904 void usb1_host_set_sqclr (uint16_t pipe
)
909 RZA_IO_RegWrite_16(&USB201
.DCPCTR
,
911 USB_DCPCTR_SQCLR_SHIFT
,
916 RZA_IO_RegWrite_16(&USB201
.PIPE1CTR
,
918 USB_PIPEnCTR_1_5_SQCLR_SHIFT
,
919 USB_PIPEnCTR_1_5_SQCLR
);
923 RZA_IO_RegWrite_16(&USB201
.PIPE2CTR
,
925 USB_PIPEnCTR_1_5_SQCLR_SHIFT
,
926 USB_PIPEnCTR_1_5_SQCLR
);
930 RZA_IO_RegWrite_16(&USB201
.PIPE3CTR
,
932 USB_PIPEnCTR_1_5_SQCLR_SHIFT
,
933 USB_PIPEnCTR_1_5_SQCLR
);
937 RZA_IO_RegWrite_16(&USB201
.PIPE4CTR
,
939 USB_PIPEnCTR_1_5_SQCLR_SHIFT
,
940 USB_PIPEnCTR_1_5_SQCLR
);
944 RZA_IO_RegWrite_16(&USB201
.PIPE5CTR
,
946 USB_PIPEnCTR_1_5_SQCLR_SHIFT
,
947 USB_PIPEnCTR_1_5_SQCLR
);
951 RZA_IO_RegWrite_16(&USB201
.PIPE6CTR
,
953 USB_PIPEnCTR_6_8_SQCLR_SHIFT
,
954 USB_PIPEnCTR_6_8_SQCLR
);
958 RZA_IO_RegWrite_16(&USB201
.PIPE7CTR
,
960 USB_PIPEnCTR_6_8_SQCLR_SHIFT
,
961 USB_PIPEnCTR_6_8_SQCLR
);
965 RZA_IO_RegWrite_16(&USB201
.PIPE8CTR
,
967 USB_PIPEnCTR_6_8_SQCLR_SHIFT
,
968 USB_PIPEnCTR_6_8_SQCLR
);
972 RZA_IO_RegWrite_16(&USB201
.PIPE9CTR
,
974 USB_PIPEnCTR_9_SQCLR_SHIFT
,
975 USB_PIPEnCTR_9_SQCLR
);
983 /*******************************************************************************
984 * Function Name: usb1_host_set_sqset
985 * Description : Sets the sequence bit of the pipe specified by the argument to
987 * Arguments : uint16_t pipe ; Pipe number
988 * Return Value : none
989 *******************************************************************************/
990 void usb1_host_set_sqset (uint16_t pipe
)
995 RZA_IO_RegWrite_16(&USB201
.DCPCTR
,
997 USB_DCPCTR_SQSET_SHIFT
,
1001 case USB_HOST_PIPE1
:
1002 RZA_IO_RegWrite_16(&USB201
.PIPE1CTR
,
1004 USB_PIPEnCTR_1_5_SQSET_SHIFT
,
1005 USB_PIPEnCTR_1_5_SQSET
);
1008 case USB_HOST_PIPE2
:
1009 RZA_IO_RegWrite_16(&USB201
.PIPE2CTR
,
1011 USB_PIPEnCTR_1_5_SQSET_SHIFT
,
1012 USB_PIPEnCTR_1_5_SQSET
);
1015 case USB_HOST_PIPE3
:
1016 RZA_IO_RegWrite_16(&USB201
.PIPE3CTR
,
1018 USB_PIPEnCTR_1_5_SQSET_SHIFT
,
1019 USB_PIPEnCTR_1_5_SQSET
);
1022 case USB_HOST_PIPE4
:
1023 RZA_IO_RegWrite_16(&USB201
.PIPE4CTR
,
1025 USB_PIPEnCTR_1_5_SQSET_SHIFT
,
1026 USB_PIPEnCTR_1_5_SQSET
);
1029 case USB_HOST_PIPE5
:
1030 RZA_IO_RegWrite_16(&USB201
.PIPE5CTR
,
1032 USB_PIPEnCTR_1_5_SQSET_SHIFT
,
1033 USB_PIPEnCTR_1_5_SQSET
);
1036 case USB_HOST_PIPE6
:
1037 RZA_IO_RegWrite_16(&USB201
.PIPE6CTR
,
1039 USB_PIPEnCTR_6_8_SQSET_SHIFT
,
1040 USB_PIPEnCTR_6_8_SQSET
);
1043 case USB_HOST_PIPE7
:
1044 RZA_IO_RegWrite_16(&USB201
.PIPE7CTR
,
1046 USB_PIPEnCTR_6_8_SQSET_SHIFT
,
1047 USB_PIPEnCTR_6_8_SQSET
);
1050 case USB_HOST_PIPE8
:
1051 RZA_IO_RegWrite_16(&USB201
.PIPE8CTR
,
1053 USB_PIPEnCTR_6_8_SQSET_SHIFT
,
1054 USB_PIPEnCTR_6_8_SQSET
);
1057 case USB_HOST_PIPE9
:
1058 RZA_IO_RegWrite_16(&USB201
.PIPE9CTR
,
1060 USB_PIPEnCTR_9_SQSET_SHIFT
,
1061 USB_PIPEnCTR_9_SQSET
);
1069 /*******************************************************************************
1070 * Function Name: usb1_host_get_sqmon
1071 * Description : Toggle bit of specified pipe is obtained
1072 * Arguments : uint16_t pipe ; Pipe number
1073 * Return Value : sqmon
1074 *******************************************************************************/
1075 uint16_t usb1_host_get_sqmon (uint16_t pipe
)
1081 case USB_HOST_PIPE0
:
1082 sqmon
= RZA_IO_RegRead_16(&USB201
.DCPCTR
,
1083 USB_DCPCTR_SQMON_SHIFT
,
1087 case USB_HOST_PIPE1
:
1088 sqmon
= RZA_IO_RegRead_16(&USB201
.PIPE1CTR
,
1089 USB_PIPEnCTR_1_5_SQMON_SHIFT
,
1090 USB_PIPEnCTR_1_5_SQMON
);
1093 case USB_HOST_PIPE2
:
1094 sqmon
= RZA_IO_RegRead_16(&USB201
.PIPE2CTR
,
1095 USB_PIPEnCTR_1_5_SQMON_SHIFT
,
1096 USB_PIPEnCTR_1_5_SQMON
);
1099 case USB_HOST_PIPE3
:
1100 sqmon
= RZA_IO_RegRead_16(&USB201
.PIPE3CTR
,
1101 USB_PIPEnCTR_1_5_SQMON_SHIFT
,
1102 USB_PIPEnCTR_1_5_SQMON
);
1105 case USB_HOST_PIPE4
:
1106 sqmon
= RZA_IO_RegRead_16(&USB201
.PIPE4CTR
,
1107 USB_PIPEnCTR_1_5_SQMON_SHIFT
,
1108 USB_PIPEnCTR_1_5_SQMON
);
1111 case USB_HOST_PIPE5
:
1112 sqmon
= RZA_IO_RegRead_16(&USB201
.PIPE5CTR
,
1113 USB_PIPEnCTR_1_5_SQMON_SHIFT
,
1114 USB_PIPEnCTR_1_5_SQMON
);
1117 case USB_HOST_PIPE6
:
1118 sqmon
= RZA_IO_RegRead_16(&USB201
.PIPE6CTR
,
1119 USB_PIPEnCTR_6_8_SQMON_SHIFT
,
1120 USB_PIPEnCTR_6_8_SQMON
);
1123 case USB_HOST_PIPE7
:
1124 sqmon
= RZA_IO_RegRead_16(&USB201
.PIPE7CTR
,
1125 USB_PIPEnCTR_6_8_SQMON_SHIFT
,
1126 USB_PIPEnCTR_6_8_SQMON
);
1129 case USB_HOST_PIPE8
:
1130 sqmon
= RZA_IO_RegRead_16(&USB201
.PIPE8CTR
,
1131 USB_PIPEnCTR_6_8_SQMON_SHIFT
,
1132 USB_PIPEnCTR_6_8_SQMON
);
1135 case USB_HOST_PIPE9
:
1136 sqmon
= RZA_IO_RegRead_16(&USB201
.PIPE9CTR
,
1137 USB_PIPEnCTR_9_SQMON_SHIFT
,
1138 USB_PIPEnCTR_9_SQMON
);
1149 /*******************************************************************************
1150 * Function Name: usb1_host_aclrm
1151 * Description : The buffer of specified pipe is initialized
1152 * Arguments : uint16_t pipe : Pipe
1153 * Return Value : none
1154 *******************************************************************************/
1155 void usb1_host_aclrm (uint16_t pipe
)
1157 usb1_host_set_aclrm(pipe
);
1158 usb1_host_clr_aclrm(pipe
);
1161 /*******************************************************************************
1162 * Function Name: usb1_host_set_aclrm
1163 * Description : The auto buffer clear mode of specified pipe is enabled
1164 * Arguments : uint16_t pipe : Pipe
1165 * Return Value : none
1166 *******************************************************************************/
1167 void usb1_host_set_aclrm (uint16_t pipe
)
1171 case USB_HOST_PIPE0
:
1174 case USB_HOST_PIPE1
:
1175 RZA_IO_RegWrite_16(&USB201
.PIPE1CTR
,
1177 USB_PIPEnCTR_1_5_ACLRM_SHIFT
,
1178 USB_PIPEnCTR_1_5_ACLRM
);
1181 case USB_HOST_PIPE2
:
1182 RZA_IO_RegWrite_16(&USB201
.PIPE2CTR
,
1184 USB_PIPEnCTR_1_5_ACLRM_SHIFT
,
1185 USB_PIPEnCTR_1_5_ACLRM
);
1188 case USB_HOST_PIPE3
:
1189 RZA_IO_RegWrite_16(&USB201
.PIPE3CTR
,
1191 USB_PIPEnCTR_1_5_ACLRM_SHIFT
,
1192 USB_PIPEnCTR_1_5_ACLRM
);
1195 case USB_HOST_PIPE4
:
1196 RZA_IO_RegWrite_16(&USB201
.PIPE4CTR
,
1198 USB_PIPEnCTR_1_5_ACLRM_SHIFT
,
1199 USB_PIPEnCTR_1_5_ACLRM
);
1202 case USB_HOST_PIPE5
:
1203 RZA_IO_RegWrite_16(&USB201
.PIPE5CTR
,
1205 USB_PIPEnCTR_1_5_ACLRM_SHIFT
,
1206 USB_PIPEnCTR_1_5_ACLRM
);
1209 case USB_HOST_PIPE6
:
1210 RZA_IO_RegWrite_16(&USB201
.PIPE6CTR
,
1212 USB_PIPEnCTR_6_8_ACLRM_SHIFT
,
1213 USB_PIPEnCTR_6_8_ACLRM
);
1216 case USB_HOST_PIPE7
:
1217 RZA_IO_RegWrite_16(&USB201
.PIPE7CTR
,
1219 USB_PIPEnCTR_6_8_ACLRM_SHIFT
,
1220 USB_PIPEnCTR_6_8_ACLRM
);
1223 case USB_HOST_PIPE8
:
1224 RZA_IO_RegWrite_16(&USB201
.PIPE8CTR
,
1226 USB_PIPEnCTR_6_8_ACLRM_SHIFT
,
1227 USB_PIPEnCTR_6_8_ACLRM
);
1230 case USB_HOST_PIPE9
:
1231 RZA_IO_RegWrite_16(&USB201
.PIPE9CTR
,
1233 USB_PIPEnCTR_9_ACLRM_SHIFT
,
1234 USB_PIPEnCTR_9_ACLRM
);
1242 /*******************************************************************************
1243 * Function Name: usb1_host_clr_aclrm
1244 * Description : The auto buffer clear mode of specified pipe is enabled
1245 * Arguments : uint16_t pipe : Pipe
1246 * Return Value : none
1247 *******************************************************************************/
1248 void usb1_host_clr_aclrm (uint16_t pipe
)
1252 case USB_HOST_PIPE0
:
1255 case USB_HOST_PIPE1
:
1256 RZA_IO_RegWrite_16(&USB201
.PIPE1CTR
,
1258 USB_PIPEnCTR_1_5_ACLRM_SHIFT
,
1259 USB_PIPEnCTR_1_5_ACLRM
);
1262 case USB_HOST_PIPE2
:
1263 RZA_IO_RegWrite_16(&USB201
.PIPE2CTR
,
1265 USB_PIPEnCTR_1_5_ACLRM_SHIFT
,
1266 USB_PIPEnCTR_1_5_ACLRM
);
1269 case USB_HOST_PIPE3
:
1270 RZA_IO_RegWrite_16(&USB201
.PIPE3CTR
,
1272 USB_PIPEnCTR_1_5_ACLRM_SHIFT
,
1273 USB_PIPEnCTR_1_5_ACLRM
);
1276 case USB_HOST_PIPE4
:
1277 RZA_IO_RegWrite_16(&USB201
.PIPE4CTR
,
1279 USB_PIPEnCTR_1_5_ACLRM_SHIFT
,
1280 USB_PIPEnCTR_1_5_ACLRM
);
1283 case USB_HOST_PIPE5
:
1284 RZA_IO_RegWrite_16(&USB201
.PIPE5CTR
,
1286 USB_PIPEnCTR_1_5_ACLRM_SHIFT
,
1287 USB_PIPEnCTR_1_5_ACLRM
);
1290 case USB_HOST_PIPE6
:
1291 RZA_IO_RegWrite_16(&USB201
.PIPE6CTR
,
1293 USB_PIPEnCTR_6_8_ACLRM_SHIFT
,
1294 USB_PIPEnCTR_6_8_ACLRM
);
1297 case USB_HOST_PIPE7
:
1298 RZA_IO_RegWrite_16(&USB201
.PIPE7CTR
,
1300 USB_PIPEnCTR_6_8_ACLRM_SHIFT
,
1301 USB_PIPEnCTR_6_8_ACLRM
);
1304 case USB_HOST_PIPE8
:
1305 RZA_IO_RegWrite_16(&USB201
.PIPE8CTR
,
1307 USB_PIPEnCTR_6_8_ACLRM_SHIFT
,
1308 USB_PIPEnCTR_6_8_ACLRM
);
1311 case USB_HOST_PIPE9
:
1312 RZA_IO_RegWrite_16(&USB201
.PIPE9CTR
,
1314 USB_PIPEnCTR_9_ACLRM_SHIFT
,
1315 USB_PIPEnCTR_9_ACLRM
);
1323 /*******************************************************************************
1324 * Function Name: usb1_host_get_inbuf
1325 * Description : Returns INBUFM of the pipe specified by the argument.
1326 * Arguments : uint16_t pipe ; Pipe Number
1327 * Return Value : inbuf
1328 *******************************************************************************/
1329 uint16_t usb1_host_get_inbuf (uint16_t pipe
)
1335 case USB_HOST_PIPE0
:
1339 case USB_HOST_PIPE1
:
1340 inbuf
= RZA_IO_RegRead_16(&USB201
.PIPE1CTR
,
1341 USB_PIPEnCTR_1_5_INBUFM_SHIFT
,
1342 USB_PIPEnCTR_1_5_INBUFM
);
1345 case USB_HOST_PIPE2
:
1346 inbuf
= RZA_IO_RegRead_16(&USB201
.PIPE2CTR
,
1347 USB_PIPEnCTR_1_5_INBUFM_SHIFT
,
1348 USB_PIPEnCTR_1_5_INBUFM
);
1351 case USB_HOST_PIPE3
:
1352 inbuf
= RZA_IO_RegRead_16(&USB201
.PIPE3CTR
,
1353 USB_PIPEnCTR_1_5_INBUFM_SHIFT
,
1354 USB_PIPEnCTR_1_5_INBUFM
);
1357 case USB_HOST_PIPE4
:
1358 inbuf
= RZA_IO_RegRead_16(&USB201
.PIPE4CTR
,
1359 USB_PIPEnCTR_1_5_INBUFM_SHIFT
,
1360 USB_PIPEnCTR_1_5_INBUFM
);
1363 case USB_HOST_PIPE5
:
1364 inbuf
= RZA_IO_RegRead_16(&USB201
.PIPE5CTR
,
1365 USB_PIPEnCTR_1_5_INBUFM_SHIFT
,
1366 USB_PIPEnCTR_1_5_INBUFM
);
1369 case USB_HOST_PIPE6
:
1373 case USB_HOST_PIPE7
:
1377 case USB_HOST_PIPE8
:
1381 case USB_HOST_PIPE9
:
1382 inbuf
= RZA_IO_RegRead_16(&USB201
.PIPE9CTR
,
1383 USB_PIPEnCTR_9_INBUFM_SHIFT
,
1384 USB_PIPEnCTR_9_INBUFM
);
1395 /*******************************************************************************
1396 * Function Name: usb1_host_setting_interrupt
1397 * Description : Sets the USB module interrupt level.
1398 * Arguments : uint8_t level ; interrupt level
1399 * Return Value : none
1400 *******************************************************************************/
1401 void usb1_host_setting_interrupt (uint8_t level
)
1403 #if(1) /* ohci_wrapp */
1404 IRQn_Type d0fifo_dmaintid
;
1405 IRQn_Type d1fifo_dmaintid
;
1407 InterruptHandlerRegister(USBI1_IRQn
, usb1_host_interrupt
);
1408 GIC_SetPriority(USBI1_IRQn
, level
);
1409 GIC_EnableIRQ(USBI1_IRQn
);
1411 d0fifo_dmaintid
= (IRQn_Type
)Userdef_USB_usb1_host_d0fifo_dmaintid();
1413 if (d0fifo_dmaintid
!= 0xFFFF)
1415 InterruptHandlerRegister(d0fifo_dmaintid
, usb1_host_dma_interrupt_d0fifo
);
1416 GIC_SetPriority(d0fifo_dmaintid
, level
);
1417 GIC_EnableIRQ(d0fifo_dmaintid
);
1420 d1fifo_dmaintid
= (IRQn_Type
)Userdef_USB_usb1_host_d1fifo_dmaintid();
1422 if (d1fifo_dmaintid
!= 0xFFFF)
1424 InterruptHandlerRegister(d1fifo_dmaintid
, usb1_host_dma_interrupt_d1fifo
);
1425 GIC_SetPriority(d1fifo_dmaintid
, level
);
1426 GIC_EnableIRQ(d1fifo_dmaintid
);
1429 uint16_t d0fifo_dmaintid
;
1430 uint16_t d1fifo_dmaintid
;
1432 R_INTC_RegistIntFunc(INTC_ID_USBI1
, usb1_host_interrupt
);
1433 R_INTC_SetPriority(INTC_ID_USBI1
, level
);
1434 R_INTC_Enable(INTC_ID_USBI1
);
1436 d0fifo_dmaintid
= Userdef_USB_usb1_host_d0fifo_dmaintid();
1438 if (d0fifo_dmaintid
!= 0xFFFF)
1440 R_INTC_RegistIntFunc(d0fifo_dmaintid
, usb1_host_dma_interrupt_d0fifo
);
1441 R_INTC_SetPriority(d0fifo_dmaintid
, level
);
1442 R_INTC_Enable(d0fifo_dmaintid
);
1445 d1fifo_dmaintid
= Userdef_USB_usb1_host_d1fifo_dmaintid();
1447 if (d1fifo_dmaintid
!= 0xFFFF)
1449 R_INTC_RegistIntFunc(d1fifo_dmaintid
, usb1_host_dma_interrupt_d1fifo
);
1450 R_INTC_SetPriority(d1fifo_dmaintid
, level
);
1451 R_INTC_Enable(d1fifo_dmaintid
);
1456 /*******************************************************************************
1457 * Function Name: usb1_host_reset_module
1458 * Description : Initializes the USB module.
1459 * : Enables providing clock to the USB module.
1460 * : Sets USB bus wait register.
1461 * Arguments : uint16_t clockmode ; 48MHz ; USBHCLOCK_X1_48MHZ
1462 * : ; 12MHz ; USBHCLOCK_EXTAL_12MHZ
1463 * Return Value : none
1464 *******************************************************************************/
1465 void usb1_host_reset_module (uint16_t clockmode
)
1467 if (RZA_IO_RegRead_16(&USB200
.SYSCFG0
,
1468 USB_SYSCFG_UPLLE_SHIFT
,
1469 USB_SYSCFG_UPLLE
) == 1)
1471 if ((USB200
.SYSCFG0
& USB_HOST_BITUCKSEL
) != clockmode
)
1473 RZA_IO_RegWrite_16(&USB201
.SUSPMODE
,
1475 USB_SUSPMODE_SUSPM_SHIFT
,
1476 USB_SUSPMODE_SUSPM
);
1477 RZA_IO_RegWrite_16(&USB200
.SUSPMODE
,
1479 USB_SUSPMODE_SUSPM_SHIFT
,
1480 USB_SUSPMODE_SUSPM
);
1483 USB200
.SYSCFG0
= (USB_HOST_BITUPLLE
| clockmode
);
1484 Userdef_USB_usb1_host_delay_xms(1);
1485 RZA_IO_RegWrite_16(&USB200
.SUSPMODE
,
1487 USB_SUSPMODE_SUSPM_SHIFT
,
1488 USB_SUSPMODE_SUSPM
);
1489 RZA_IO_RegWrite_16(&USB201
.SUSPMODE
,
1491 USB_SUSPMODE_SUSPM_SHIFT
,
1492 USB_SUSPMODE_SUSPM
);
1496 RZA_IO_RegWrite_16(&USB201
.SUSPMODE
,
1498 USB_SUSPMODE_SUSPM_SHIFT
,
1499 USB_SUSPMODE_SUSPM
);
1500 Userdef_USB_usb1_host_delay_xms(1);
1501 RZA_IO_RegWrite_16(&USB201
.SUSPMODE
,
1503 USB_SUSPMODE_SUSPM_SHIFT
,
1504 USB_SUSPMODE_SUSPM
);
1509 RZA_IO_RegWrite_16(&USB201
.SUSPMODE
,
1511 USB_SUSPMODE_SUSPM_SHIFT
,
1512 USB_SUSPMODE_SUSPM
);
1513 RZA_IO_RegWrite_16(&USB200
.SUSPMODE
,
1515 USB_SUSPMODE_SUSPM_SHIFT
,
1516 USB_SUSPMODE_SUSPM
);
1519 USB200
.SYSCFG0
= (USB_HOST_BITUPLLE
| clockmode
);
1520 Userdef_USB_usb1_host_delay_xms(1);
1521 RZA_IO_RegWrite_16(&USB200
.SUSPMODE
,
1523 USB_SUSPMODE_SUSPM_SHIFT
,
1524 USB_SUSPMODE_SUSPM
);
1525 RZA_IO_RegWrite_16(&USB201
.SUSPMODE
,
1527 USB_SUSPMODE_SUSPM_SHIFT
,
1528 USB_SUSPMODE_SUSPM
);
1531 USB201
.BUSWAIT
= (uint16_t)(USB_HOST_BUSWAIT_05
& USB_HOST_BITBWAIT
);
1534 /*******************************************************************************
1535 * Function Name: usb1_host_get_buf_size
1536 * Description : Obtains pipe buffer size specified by the argument and
1537 * : maximum packet size of the USB device in use.
1538 * : When USB_HOST_PIPE0 is specified by the argument, obtains the maximum
1539 * : packet size of the USB device using the corresponding pipe.
1540 * : For the case that USB_HOST_PIPE0 is not assigned by the argument, when the
1541 * : corresponding pipe is in continuous transfer mode,
1542 * : obtains the buffer size allocated in the corresponcing pipe,
1543 * : when incontinuous transfer, obtains maximum packet size.
1544 * Arguments : uint16_t ; pipe Number
1545 * Return Value : Maximum packet size or buffer size
1546 *******************************************************************************/
1547 uint16_t usb1_host_get_buf_size (uint16_t pipe
)
1552 if (pipe
== USB_HOST_PIPE0
)
1554 size
= RZA_IO_RegRead_16(&USB201
.DCPMAXP
,
1555 USB_DCPMAXP_MXPS_SHIFT
,
1560 if (RZA_IO_RegRead_16(&g_usb1_host_pipecfg
[pipe
], USB_PIPECFG_CNTMD_SHIFT
, USB_PIPECFG_CNTMD
) == 1)
1562 bufsize
= RZA_IO_RegRead_16(&g_usb1_host_pipebuf
[pipe
], USB_PIPEBUF_BUFSIZE_SHIFT
, USB_PIPEBUF_BUFSIZE
);
1563 size
= (uint16_t)((bufsize
+ 1) * USB_HOST_PIPExBUF
);
1567 size
= RZA_IO_RegRead_16(&g_usb1_host_pipemaxp
[pipe
], USB_PIPEMAXP_MXPS_SHIFT
, USB_PIPEMAXP_MXPS
);
1573 /*******************************************************************************
1574 * Function Name: usb1_host_get_mxps
1575 * Description : Obtains maximum packet size of the USB device using the pipe
1576 * : specified by the argument.
1577 * Arguments : uint16_t ; Pipe Number
1578 * Return Value : Max Packet Size
1579 *******************************************************************************/
1580 uint16_t usb1_host_get_mxps (uint16_t pipe
)
1584 if (pipe
== USB_HOST_PIPE0
)
1586 size
= RZA_IO_RegRead_16(&USB201
.DCPMAXP
,
1587 USB_DCPMAXP_MXPS_SHIFT
,
1592 size
= RZA_IO_RegRead_16(&g_usb1_host_pipemaxp
[pipe
], USB_PIPEMAXP_MXPS_SHIFT
, USB_PIPEMAXP_MXPS
);