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