1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
|
/*******************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only
* intended for use with Renesas products. No other uses are authorized. This
* software is owned by Renesas Electronics Corporation and is protected under
* all applicable laws, including copyright laws.
* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* Renesas reserves the right, without notice, to make changes to this software
* and to discontinue the availability of this software. By using this software,
* you agree to the additional terms and conditions found by accessing the
* following link:
* http://www.renesas.com/disclaimer
* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
*******************************************************************************/
/*******************************************************************************
* File Name : usb1_function_userdef.c
* $Rev: 1116 $
* $Date:: 2014-07-09 16:29:19 +0900#$
* Device(s) : RZ/A1H
* Tool-Chain :
* OS : None
* H/W Platform :
* Description : RZ/A1H R7S72100 USB Sample Program
* Operation :
* Limitations :
*******************************************************************************/
/*******************************************************************************
Includes <System Includes> , "Project Includes"
*******************************************************************************/
#include <stdio.h>
#include "r_typedefs.h"
#include "iodefine.h"
#include "devdrv_usb_function_api.h"
#include "usb1_function_dmacdrv.h" /* common DMAC driver for USB */
/*******************************************************************************
Typedef definitions
*******************************************************************************/
/*******************************************************************************
Macro definitions
*******************************************************************************/
#define DUMMY_ACCESS OSTM0CNT
/* #define CACHE_WRITEBACK */
/*******************************************************************************
Imported global variables and functions (from other files)
*******************************************************************************/
extern int32_t io_cwb(unsigned long start, unsigned long end);
/*******************************************************************************
Exported global variables and functions (to be accessed by other files)
*******************************************************************************/
static void usb1_function_enable_dmac0(uint32_t src, uint32_t dst, uint32_t count,
uint32_t size, uint32_t dir, uint32_t fifo, uint16_t dfacc);
static void usb1_function_enable_dmac1(uint32_t src, uint32_t dst, uint32_t count,
uint32_t size, uint32_t dir, uint32_t fifo, uint16_t dfacc);
static void Userdef_USB_usb1_function_delay_10us_2(void);
/*******************************************************************************
Private global variables and functions
*******************************************************************************/
/*******************************************************************************
* Function Name: Userdef_USB_usb1_function_d0fifo_dmaintid
* Description : get D0FIFO DMA Interrupt ID
* Arguments : none
* Return Value : D0FIFO DMA Interrupt ID
*******************************************************************************/
IRQn_Type Userdef_USB_usb1_function_d0fifo_dmaintid (void)
{
#if 0
return DMAINT1_IRQn;
#else
return 0xFFFF;
#endif
}
/*******************************************************************************
* Function Name: Userdef_USB_usb1_function_d1fifo_dmaintid
* Description : get D1FIFO DMA Interrupt ID
* Arguments : none
* Return Value : D1FIFO DMA Interrupt ID
*******************************************************************************/
IRQn_Type Userdef_USB_usb1_function_d1fifo_dmaintid (void)
{
#if 0
return DMAINT1_IRQn;
#else
return 0xFFFF;
#endif
}
/*******************************************************************************
* Function Name: Userdef_USB_usb1_function_attach
* Description : Wait for the software of 1ms.
* : Alter this function according to the user's system.
* Arguments : none
* Return Value : none
*******************************************************************************/
void Userdef_USB_usb1_function_attach (void)
{
printf("\n");
printf("channel 1 attach device\n");
printf("\n");
}
/*******************************************************************************
* Function Name: Userdef_USB_usb1_function_detach
* Description : Wait for the software of 1ms.
* : Alter this function according to the user's system.
* Arguments : none
* Return Value : none
*******************************************************************************/
void Userdef_USB_usb1_function_detach (void)
{
printf("\n");
printf("channel 1 detach device\n");
printf("\n");
}
/*******************************************************************************
* Function Name: Userdef_USB_usb1_function_delay_1ms
* Description : Wait for the software of 1ms.
* : Alter this function according to the user's system.
* Arguments : none
* Return Value : none
*******************************************************************************/
void Userdef_USB_usb1_function_delay_1ms (void)
{
volatile int i;
volatile unsigned long tmp;
/*
* Wait 1ms (Please change for your MCU).
*/
for (i = 0; i < 1440; ++i)
{
tmp = DUMMY_ACCESS;
}
}
/*******************************************************************************
* Function Name: Userdef_USB_usb1_function_delay_xms
* Description : Wait for the software in the period of time specified by the
* : argument.
* : Alter this function according to the user's system.
* Arguments : uint32_t msec ; Wait Time (msec)
* Return Value : none
*******************************************************************************/
void Userdef_USB_usb1_function_delay_xms (uint32_t msec)
{
volatile unsigned short i;
for (i = 0; i < msec; ++i)
{
Userdef_USB_usb1_function_delay_1ms();
}
}
/*******************************************************************************
* Function Name: Userdef_USB_usb1_function_delay_10us
* Description : Waits for software for the period specified by the argument.
* : Alter this function according to the user's system.
* Arguments : uint32_t usec ; Wait Time(x 10usec)
* Return Value : none
*******************************************************************************/
void Userdef_USB_usb1_function_delay_10us (uint32_t usec)
{
volatile int i;
/* Wait 10us (Please change for your MCU) */
for (i = 0; i < usec; ++i)
{
Userdef_USB_usb1_function_delay_10us_2();
}
}
/*******************************************************************************
* Function Name: Userdef_USB_usb1_function_delay_10us_2
* Description : Waits for software for the period specified by the argument.
* : Alter this function according to the user's system.
* Arguments : none
* Return Value : none
*******************************************************************************/
static void Userdef_USB_usb1_function_delay_10us_2 (void)
{
volatile int i;
volatile unsigned long tmp;
/* Wait 1us (Please change for your MCU) */
for (i = 0; i < 14; ++i)
{
tmp = DUMMY_ACCESS;
}
}
/*******************************************************************************
* Function Name: Userdef_USB_usb1_function_delay_500ns
* Description : Wait for software for 500ns.
* : Alter this function according to the user's system.
* Arguments : none
* Return Value : none
*******************************************************************************/
void Userdef_USB_usb1_function_delay_500ns (void)
{
volatile int i;
volatile unsigned long tmp;
/* Wait 500ns (Please change for your MCU) */
/* Wait 500ns I clock 266MHz */
tmp = DUMMY_ACCESS;
}
/*******************************************************************************
* Function Name: Userdef_USB_usb1_function_start_dma
* Description : Enables DMA transfer on the information specified by the argument.
* : Set DMAC register by this function to enable DMA transfer.
* : After executing this function, USB module is set to start DMA
* : transfer. DMA transfer should not wait for DMA transfer complete.
* Arguments : USB_FUNCTION_DMA_t *dma : DMA parameter
* : typedef struct{
* : uint32_t fifo; FIFO for using
* : uint32_t buffer; Start address of transfer source/destination
* : uint32_t bytes; Transfer size(Byte)
* : uint32_t dir; Transfer direction(0:Buffer->FIFO, 1:FIFO->Buffer)
* : uint32_t size; DMA transfer size
* : } USB_FUNCTION_DMA_t;
* : uint16_t dfacc ; 0 : cycle steal mode
* : 1 : 16byte continuous mode
* : 2 : 32byte continuous mode
* Return Value : none
*******************************************************************************/
void Userdef_USB_usb1_function_start_dma (USB_FUNCTION_DMA_t * dma, uint16_t dfacc)
{
uint32_t trncount;
uint32_t src;
uint32_t dst;
uint32_t size;
uint32_t dir;
#ifdef CACHE_WRITEBACK
uint32_t ptr;
#endif
trncount = dma->bytes;
dir = dma->dir;
if (dir == USB_FUNCTION_FIFO2BUF)
{
/* DxFIFO determination */
dst = dma->buffer;
#ifndef __USB_FUNCTION_DF_ACC_ENABLE__
if (dma->fifo == USB_FUNCTION_D0FIFO_DMA)
{
src = (uint32_t)(&USB201.D0FIFO.UINT32);
}
else
{
src = (uint32_t)(&USB201.D1FIFO.UINT32);
}
size = dma->size;
if (size == 0)
{
src += 3; /* byte access */
}
else if (size == 1)
{
src += 2; /* short access */
}
else
{
/* Do Nothing */
}
#else
size = dma->size;
if (size == 2)
{
/* 32bit access */
if (dfacc == 2)
{
/* 32byte access */
if (dma->fifo == USB_FUNCTION_D0FIFO_DMA)
{
src = (uint32_t)(&USB201.D0FIFOB0);
}
else
{
src = (uint32_t)(&USB201.D1FIFOB0);
}
}
else if (dfacc == 1)
{
/* 16byte access */
if (dma->fifo == USB_FUNCTION_D0FIFO_DMA)
{
src = (uint32_t)(&USB201.D0FIFOB0);
}
else
{
src = (uint32_t)(&USB201.D1FIFOB0);
}
}
else
{
/* normal access */
if (dma->fifo == USB_FUNCTION_D0FIFO_DMA)
{
src = (uint32_t)(&USB201.D0FIFO.UINT32);
}
else
{
src = (uint32_t)(&USB201.D1FIFO.UINT32);
}
}
}
else if (size == 1)
{
/* 16bit access */
dfacc = 0; /* force normal access */
if (dma->fifo == USB_FUNCTION_D0FIFO_DMA)
{
src = (uint32_t)(&USB201.D0FIFO.UINT32);
}
else
{
src = (uint32_t)(&USB201.D1FIFO.UINT32);
}
src += 2; /* short access */
}
else
{
/* 8bit access */
dfacc = 0; /* force normal access */
if (dma->fifo == USB_FUNCTION_D0FIFO_DMA)
{
src = (uint32_t)(&USB201.D0FIFO.UINT32);
}
else
{
src = (uint32_t)(&USB201.D1FIFO.UINT32);
}
src += 3; /* byte access */
}
#endif
}
else
{
/* DxFIFO determination */
src = dma->buffer;
#ifndef __USB_FUNCTION_DF_ACC_ENABLE__
if (dma->fifo == USB_FUNCTION_D0FIFO_DMA)
{
dst = (uint32_t)(&USB201.D0FIFO.UINT32);
}
else
{
dst = (uint32_t)(&USB201.D1FIFO.UINT32);
}
size = dma->size;
if (size == 0)
{
dst += 3; /* byte access */
}
else if (size == 1)
{
dst += 2; /* short access */
}
else
{
/* Do Nothing */
}
#else
size = dma->size;
if (size == 2)
{
/* 32bit access */
if (dfacc == 2)
{
/* 32byte access */
if (dma->fifo == USB_FUNCTION_D0FIFO_DMA)
{
dst = (uint32_t)(&USB201.D0FIFOB0);
}
else
{
dst = (uint32_t)(&USB201.D1FIFOB0);
}
}
else if (dfacc == 1)
{
/* 16byte access */
if (dma->fifo == USB_FUNCTION_D0FIFO_DMA)
{
dst = (uint32_t)(&USB201.D0FIFOB0);
}
else
{
dst = (uint32_t)(&USB201.D1FIFOB0);
}
}
else
{
/* normal access */
if (dma->fifo == USB_FUNCTION_D0FIFO_DMA)
{
dst = (uint32_t)(&USB201.D0FIFO.UINT32);
}
else
{
dst = (uint32_t)(&USB201.D1FIFO.UINT32);
}
}
}
else if (size == 1)
{
/* 16bit access */
dfacc = 0; /* force normal access */
if (dma->fifo == USB_FUNCTION_D0FIFO_DMA)
{
dst = (uint32_t)(&USB201.D0FIFO.UINT32);
}
else
{
dst = (uint32_t)(&USB201.D1FIFO.UINT32);
}
dst += 2; /* short access */
}
else
{
/* 8bit access */
dfacc = 0; /* force normal access */
if (dma->fifo == USB_FUNCTION_D0FIFO_DMA)
{
dst = (uint32_t)(&USB201.D0FIFO.UINT32);
}
else
{
dst = (uint32_t)(&USB201.D1FIFO.UINT32);
}
dst += 3; /* byte access */
}
#endif
}
#ifdef CACHE_WRITEBACK
ptr = (uint32_t)dma->buffer;
if ((ptr & 0x20000000ul) == 0)
{
io_cwb((uint32_t)ptr, (uint32_t)(ptr) + trncount);
}
#endif
if (dma->fifo == USB_FUNCTION_D0FIFO_DMA)
{
usb1_function_enable_dmac0(src, dst, trncount, size, dir, dma->fifo, dfacc);
}
else
{
usb1_function_enable_dmac1(src, dst, trncount, size, dir, dma->fifo, dfacc);
}
}
/*******************************************************************************
* Function Name: usb1_function_enable_dmac0
* Description : Enables DMA transfer on the information specified by the argument.
* Arguments : uint32_t src : src address
* : uint32_t dst : dst address
* : uint32_t count : transfer byte
* : uint32_t size : transfer size
* : uint32_t dir : direction
* : uint32_t fifo : FIFO(D0FIFO or D1FIFO)
* : uint16_t dfacc : 0 : normal access
* : : 1 : 16byte access
* : : 2 : 32byte access
* Return Value : none
*******************************************************************************/
static void usb1_function_enable_dmac0 (uint32_t src, uint32_t dst, uint32_t count,
uint32_t size, uint32_t dir, uint32_t fifo, uint16_t dfacc)
{
dmac_transinfo_t trans_info;
uint32_t request_factor = 0;
int32_t ret;
/* ==== Variable setting for DMAC initialization ==== */
trans_info.src_addr = (uint32_t)src; /* Start address of transfer source */
trans_info.dst_addr = (uint32_t)dst; /* Start address of transfer destination */
trans_info.count = (uint32_t)count; /* Total byte count to be transferred */
#ifndef __USB_FUNCTION_DF_ACC_ENABLE__
if (size == 0)
{
trans_info.src_size = DMAC_TRANS_SIZE_8; /* Transfer source transfer size */
trans_info.dst_size = DMAC_TRANS_SIZE_8; /* Transfer destination transfer size */
}
else if (size == 1)
{
trans_info.src_size = DMAC_TRANS_SIZE_16; /* Transfer source transfer size */
trans_info.dst_size = DMAC_TRANS_SIZE_16; /* Transfer destination transfer size */
}
else if (size == 2)
{
trans_info.src_size = DMAC_TRANS_SIZE_32; /* Transfer source transfer size */
trans_info.dst_size = DMAC_TRANS_SIZE_32; /* Transfer destination transfer size */
}
else
{
printf("size error!!\n");
}
#else
if (dfacc == 2)
{
/* 32byte access */
trans_info.src_size = DMAC_TRANS_SIZE_256; /* Transfer source transfer size */
trans_info.dst_size = DMAC_TRANS_SIZE_256; /* Transfer destination transfer size */
}
else if (dfacc == 1)
{
/* 16byte access */
trans_info.src_size = DMAC_TRANS_SIZE_128; /* Transfer source transfer size */
trans_info.dst_size = DMAC_TRANS_SIZE_128; /* Transfer destination transfer size */
}
else
{
/* normal access */
if (size == 0)
{
trans_info.src_size = DMAC_TRANS_SIZE_8; /* Transfer source transfer size */
trans_info.dst_size = DMAC_TRANS_SIZE_8; /* Transfer destination transfer size */
}
else if (size == 1)
{
trans_info.src_size = DMAC_TRANS_SIZE_16; /* Transfer source transfer size */
trans_info.dst_size = DMAC_TRANS_SIZE_16; /* Transfer destination transfer size */
}
else if (size == 2)
{
trans_info.src_size = DMAC_TRANS_SIZE_32; /* Transfer source transfer size */
trans_info.dst_size = DMAC_TRANS_SIZE_32; /* Transfer destination transfer size */
}
else
{
printf("size error!!\n");
}
}
#endif
if (dir == USB_FUNCTION_FIFO2BUF)
{
request_factor =DMAC_REQ_USB1_DMA0_RX; /* USB_0 channel 0 receive FIFO full */
trans_info.saddr_dir = DMAC_TRANS_ADR_NO_INC; /* Count direction of transfer source address */
trans_info.daddr_dir = DMAC_TRANS_ADR_INC; /* Count direction of transfer destination address */
}
else if (dir == USB_FUNCTION_BUF2FIFO)
{
request_factor =DMAC_REQ_USB1_DMA0_TX; /* USB_0 channel 0 receive FIFO empty */
trans_info.saddr_dir = DMAC_TRANS_ADR_INC; /* Count direction of transfer source address */
trans_info.daddr_dir = DMAC_TRANS_ADR_NO_INC; /* Count direction of transfer destination address */
}
else
{
/* Do Nothing */
}
/* ==== DMAC initialization ==== */
usb1_function_DMAC3_PeriReqInit((const dmac_transinfo_t *)&trans_info,
DMAC_MODE_REGISTER,
DMAC_SAMPLE_SINGLE,
request_factor,
0); /* Don't care DMAC_REQ_REQD is setting in
usb1_function_DMAC3_PeriReqInit() */
/* ==== DMAC startup ==== */
ret = usb1_function_DMAC3_Open(DMAC_REQ_MODE_PERI);
if (ret != 0)
{
printf("DMAC3 Open error!!\n");
}
return;
}
/*******************************************************************************
* Function Name: usb1_function_enable_dmac1
* Description : Enables DMA transfer on the information specified by the argument.
* Arguments : uint32_t src : src address
* : uint32_t dst : dst address
* : uint32_t count : transfer byte
* : uint32_t size : transfer size
* : uint32_t dir : direction
* : uint32_t fifo : FIFO(D0FIFO or D1FIFO)
* : uint16_t dfacc : 0 : normal access
* : : 1 : 16byte access
* : : 2 : 32byte access
* Return Value : none
*******************************************************************************/
static void usb1_function_enable_dmac1 (uint32_t src, uint32_t dst, uint32_t count,
uint32_t size, uint32_t dir, uint32_t fifo, uint16_t dfacc)
{
dmac_transinfo_t trans_info;
uint32_t request_factor = 0;
int32_t ret;
/* ==== Variable setting for DMAC initialization ==== */
trans_info.src_addr = (uint32_t)src; /* Start address of transfer source */
trans_info.dst_addr = (uint32_t)dst; /* Start address of transfer destination */
trans_info.count = (uint32_t)count; /* Total byte count to be transferred */
#ifndef __USB_FUNCTION_DF_ACC_ENABLE__
if (size == 0)
{
trans_info.src_size = DMAC_TRANS_SIZE_8; /* Transfer source transfer size */
trans_info.dst_size = DMAC_TRANS_SIZE_8; /* Transfer destination transfer size */
}
else if (size == 1)
{
trans_info.src_size = DMAC_TRANS_SIZE_16; /* Transfer source transfer size */
trans_info.dst_size = DMAC_TRANS_SIZE_16; /* Transfer destination transfer size */
}
else if (size == 2)
{
trans_info.src_size = DMAC_TRANS_SIZE_32; /* Transfer source transfer size */
trans_info.dst_size = DMAC_TRANS_SIZE_32; /* Transfer destination transfer size */
}
else
{
printf("size error!!\n");
}
#else
if (dfacc == 2)
{
/* 32byte access */
trans_info.src_size = DMAC_TRANS_SIZE_256; /* Transfer source transfer size */
trans_info.dst_size = DMAC_TRANS_SIZE_256; /* Transfer destination transfer size */
}
else if (dfacc == 1)
{
/* 16byte access */
trans_info.src_size = DMAC_TRANS_SIZE_128; /* Transfer source transfer size */
trans_info.dst_size = DMAC_TRANS_SIZE_128; /* Transfer destination transfer size */
}
else
{
/* normal access */
if (size == 0)
{
trans_info.src_size = DMAC_TRANS_SIZE_8; /* Transfer source transfer size */
trans_info.dst_size = DMAC_TRANS_SIZE_8; /* Transfer destination transfer size */
}
else if (size == 1)
{
trans_info.src_size = DMAC_TRANS_SIZE_16; /* Transfer source transfer size */
trans_info.dst_size = DMAC_TRANS_SIZE_16; /* Transfer destination transfer size */
}
else if (size == 2)
{
trans_info.src_size = DMAC_TRANS_SIZE_32; /* Transfer source transfer size */
trans_info.dst_size = DMAC_TRANS_SIZE_32; /* Transfer destination transfer size */
}
else
{
printf("size error!!\n");
}
}
#endif
if (dir == USB_FUNCTION_FIFO2BUF)
{
request_factor =DMAC_REQ_USB1_DMA1_RX; /* USB_0 channel 0 receive FIFO full */
trans_info.saddr_dir = DMAC_TRANS_ADR_NO_INC; /* Count direction of transfer source address */
trans_info.daddr_dir = DMAC_TRANS_ADR_INC; /* Count direction of transfer destination address */
}
else if (dir == USB_FUNCTION_BUF2FIFO)
{
request_factor =DMAC_REQ_USB1_DMA1_TX; /* USB_0 channel 0 receive FIFO empty */
trans_info.saddr_dir = DMAC_TRANS_ADR_INC; /* Count direction of transfer source address */
trans_info.daddr_dir = DMAC_TRANS_ADR_NO_INC; /* Count direction of transfer destination address */
}
else
{
/* Do Nothing */
}
/* ==== DMAC initialization ==== */
usb1_function_DMAC4_PeriReqInit((const dmac_transinfo_t *)&trans_info,
DMAC_MODE_REGISTER,
DMAC_SAMPLE_SINGLE,
request_factor,
0); /* Don't care DMAC_REQ_REQD is setting in
usb1_function_DMAC4_PeriReqInit() */
/* ==== DMAC startup ==== */
ret = usb1_function_DMAC4_Open(DMAC_REQ_MODE_PERI);
if (ret != 0)
{
printf("DMAC4 Open error!!\n");
}
return;
}
/*******************************************************************************
* Function Name: Userdef_USB_usb1_function_stop_dma0
* Description : Disables DMA transfer.
* : This function should be executed to DMAC executed at the time
* : of specification of D0_FIF0_DMA in dma->fifo.
* Arguments : none
* Return Value : uint32_t return Transfer Counter register(DMATCRn) value
* : regarding to the bus width.
*******************************************************************************/
uint32_t Userdef_USB_usb1_function_stop_dma0 (void)
{
uint32_t remain;
/* ==== DMAC release ==== */
usb1_function_DMAC3_Close(&remain);
return remain;
}
/*******************************************************************************
* Function Name: Userdef_USB_usb1_function_stop_dma1
* Description : Disables DMA transfer.
* : This function should be executed to DMAC executed at the time
* : of specification of D1_FIF0_DMA in dma->fifo.
* Arguments : none
* Return Value : uint32_t return Transfer Counter register(DMATCRn) value
* : regarding to the bus width.
*******************************************************************************/
uint32_t Userdef_USB_usb1_function_stop_dma1 (void)
{
uint32_t remain;
/* ==== DMAC release ==== */
usb1_function_DMAC4_Close(&remain);
return remain;
}
/* End of File */
|