SDG+USBHost(Mouse) Sample

Dependencies:   Sound_Generator USBHost_custom

Fork of SDG_Mouse_Sample by GR-PEACH_producer_meeting

Information

Japanese version is available in lower part of this page.
このページの後半に日本語版が用意されています.

What is this?

This program is a demonstration that sounds the sound by mouse operation by using USBHost(Mouse) and Sound Generator.

Settings

Close JP3 of GR-PEACH.
/media/uploads/RyoheiHagimoto/sdg-mouse.jpg

Operation

operationeffect
Right clickSounds
Left clickReset to base tone (C)
Moves the mouse to the rightLower the sound
Moves the mouse to the leftHigher the sound
Center cursorAdjust the sensitivity.
Reset the reference value in the click.

Others

The default setting of serial communication (baud rate etc.) in mbed is shown the following link.
Please refer to the link and change the settings of your PC terminal software.
The default value of baud rate in mbed is 9600, and this application uses baud rate 9600.
https://developer.mbed.org/teams/Renesas/wiki/GR-PEACH-Getting-Started#install-the-usb-serial-communication


概要

このプログラムは、USBHost(Mouse) + Sound Generatorで、マウス操作による擬似笛デモです。

設定

GR-PEACHのJP3をショートする必要があります。
/media/uploads/RyoheiHagimoto/sdg-mouse.jpg

操作方法

操作内容
右クリック音出力開始
左クリック基準音(ド)にリセット
マウス右移動高音になります
マウス左移動低音になります
センターカーソル音高低の変化量調整(クリックで基準値にリセット)

Others

mbedのシリアル通信(ボーレート等)のデフォルト設定は以下のリンクに示しています。
リンクを参考に、お使いのPCターミナルソフトの設定を変更して下さい。
mbedでのボーレートのデフォルト値は9600で、このサンプルではボーレート9600を使います。
https://developer.mbed.org/teams/Renesas/wiki/GR-PEACH-Getting-Started#install-the-usb-serial-communication

Committer:
mbed_official
Date:
Mon Jan 19 14:30:37 2015 +0000
Revision:
27:4206883f4cb7
Child:
28:8e62b6403505
Synchronized with git revision 0ab8d2e6b3d884137dcb5c62d29a07abe132bac7

Full URL: https://github.com/mbedmicro/mbed/commit/0ab8d2e6b3d884137dcb5c62d29a07abe132bac7/

RZ_A1H - Implement some USB functions and fix some bugs about USBHost common codes.

Who changed what in which revision?

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