USBHost library. NOTE: This library is only officially supported on the LPC1768 platform. For more information, please see the handbook page.

Dependencies:   FATFileSystem mbed-rtos

Dependents:   BTstack WallbotWii SD to Flash Data Transfer USBHost-MSD_HelloWorld ... more

Legacy Warning

This is an mbed 2 library. To learn more about mbed OS 5, visit the docs.

Pull requests against this repository are no longer supported. Please raise against mbed OS 5 as documented above.

Committer:
Kojto
Date:
Thu Jul 27 12:24:30 2017 +0100
Revision:
39:d96aa62afc5b
Update USBHost - add targets directory

This corresponds to mbed-os/master commit 9207365

Who changed what in which revision?

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