USB device stack
Dependents: mbed-mX-USB-TEST1 USBMSD_SD_HID_HelloWorld HidTest MIDI_usb_bridge ... more
Legacy Warning
This is an mbed 2 library. To learn more about mbed OS 5, visit the docs.
Pull requests against this repository are no longer supported. Please raise against mbed OS 5 as documented above.
targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/usb1/src/function/usb1_function_api.c@71:53949e6131f6, 2017-07-27 (annotated)
- Committer:
- Kojto
- Date:
- Thu Jul 27 12:14:04 2017 +0100
- Revision:
- 71:53949e6131f6
Update libraries
Fixes the previous commmit, as some devices were not copied. USBDevice contains
now targets directory with all targets implementations
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kojto | 71:53949e6131f6 | 1 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 2 | * DISCLAIMER |
Kojto | 71:53949e6131f6 | 3 | * This software is supplied by Renesas Electronics Corporation and is only |
Kojto | 71:53949e6131f6 | 4 | * intended for use with Renesas products. No other uses are authorized. This |
Kojto | 71:53949e6131f6 | 5 | * software is owned by Renesas Electronics Corporation and is protected under |
Kojto | 71:53949e6131f6 | 6 | * all applicable laws, including copyright laws. |
Kojto | 71:53949e6131f6 | 7 | * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING |
Kojto | 71:53949e6131f6 | 8 | * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT |
Kojto | 71:53949e6131f6 | 9 | * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE |
Kojto | 71:53949e6131f6 | 10 | * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. |
Kojto | 71:53949e6131f6 | 11 | * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS |
Kojto | 71:53949e6131f6 | 12 | * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE |
Kojto | 71:53949e6131f6 | 13 | * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR |
Kojto | 71:53949e6131f6 | 14 | * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE |
Kojto | 71:53949e6131f6 | 15 | * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
Kojto | 71:53949e6131f6 | 16 | * Renesas reserves the right, without notice, to make changes to this software |
Kojto | 71:53949e6131f6 | 17 | * and to discontinue the availability of this software. By using this software, |
Kojto | 71:53949e6131f6 | 18 | * you agree to the additional terms and conditions found by accessing the |
Kojto | 71:53949e6131f6 | 19 | * following link: |
Kojto | 71:53949e6131f6 | 20 | * http://www.renesas.com/disclaimer |
Kojto | 71:53949e6131f6 | 21 | * Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved. |
Kojto | 71:53949e6131f6 | 22 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 23 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 24 | * File Name : usb1_function_api.c |
Kojto | 71:53949e6131f6 | 25 | * $Rev: 1116 $ |
Kojto | 71:53949e6131f6 | 26 | * $Date:: 2014-07-09 16:29:19 +0900#$ |
Kojto | 71:53949e6131f6 | 27 | * Device(s) : RZ/A1H |
Kojto | 71:53949e6131f6 | 28 | * Tool-Chain : |
Kojto | 71:53949e6131f6 | 29 | * OS : None |
Kojto | 71:53949e6131f6 | 30 | * H/W Platform : |
Kojto | 71:53949e6131f6 | 31 | * Description : RZ/A1H R7S72100 USB Sample Program |
Kojto | 71:53949e6131f6 | 32 | * Operation : |
Kojto | 71:53949e6131f6 | 33 | * Limitations : |
Kojto | 71:53949e6131f6 | 34 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 35 | |
Kojto | 71:53949e6131f6 | 36 | |
Kojto | 71:53949e6131f6 | 37 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 38 | Includes <System Includes> , "Project Includes" |
Kojto | 71:53949e6131f6 | 39 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 40 | #include "usb1_function.h" |
Kojto | 71:53949e6131f6 | 41 | #include "dev_drv.h" |
Kojto | 71:53949e6131f6 | 42 | |
Kojto | 71:53949e6131f6 | 43 | |
Kojto | 71:53949e6131f6 | 44 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 45 | Typedef definitions |
Kojto | 71:53949e6131f6 | 46 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 47 | |
Kojto | 71:53949e6131f6 | 48 | |
Kojto | 71:53949e6131f6 | 49 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 50 | Macro definitions |
Kojto | 71:53949e6131f6 | 51 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 52 | |
Kojto | 71:53949e6131f6 | 53 | |
Kojto | 71:53949e6131f6 | 54 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 55 | Imported global variables and functions (from other files) |
Kojto | 71:53949e6131f6 | 56 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 57 | |
Kojto | 71:53949e6131f6 | 58 | |
Kojto | 71:53949e6131f6 | 59 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 60 | Exported global variables and functions (to be accessed by other files) |
Kojto | 71:53949e6131f6 | 61 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 62 | |
Kojto | 71:53949e6131f6 | 63 | |
Kojto | 71:53949e6131f6 | 64 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 65 | Private global variables and functions |
Kojto | 71:53949e6131f6 | 66 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 67 | |
Kojto | 71:53949e6131f6 | 68 | |
Kojto | 71:53949e6131f6 | 69 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 70 | * Function Name: usb1_api_function_init |
Kojto | 71:53949e6131f6 | 71 | * Description : Initializes the USB module in the USB function mode. |
Kojto | 71:53949e6131f6 | 72 | * Arguments : uint8_t int_level ; interruput level |
Kojto | 71:53949e6131f6 | 73 | * : uint16_t mode : Speed modes |
Kojto | 71:53949e6131f6 | 74 | * : : USB_FUCNTION_HIGH_SPEED: High-speed device |
Kojto | 71:53949e6131f6 | 75 | * : : USB_FUCNTION_FULL_SPEED: Full-speed device |
Kojto | 71:53949e6131f6 | 76 | * : uint16_t clockmode ; 48MHz ; USBFCLOCK_X1_48MHZ |
Kojto | 71:53949e6131f6 | 77 | * : ; 12MHz ; USBFCLOCK_EXTAL_12MHZ |
Kojto | 71:53949e6131f6 | 78 | * Return Value : none |
Kojto | 71:53949e6131f6 | 79 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 80 | #if 0 |
Kojto | 71:53949e6131f6 | 81 | void usb1_api_function_init (uint8_t int_level, uint16_t mode, uint16_t clockmode) |
Kojto | 71:53949e6131f6 | 82 | { |
Kojto | 71:53949e6131f6 | 83 | volatile uint8_t dummy_buf; |
Kojto | 71:53949e6131f6 | 84 | |
Kojto | 71:53949e6131f6 | 85 | CPG.STBCR7 &= 0xfc; /*The clock of USB0/1 modules is permitted */ |
Kojto | 71:53949e6131f6 | 86 | dummy_buf = CPG.STBCR7; /* (Dummy read) */ |
Kojto | 71:53949e6131f6 | 87 | |
Kojto | 71:53949e6131f6 | 88 | usb1_function_setting_interrupt(int_level); |
Kojto | 71:53949e6131f6 | 89 | |
Kojto | 71:53949e6131f6 | 90 | usb1_function_reset_module(clockmode); /* reset USB module with setting tranciever */ |
Kojto | 71:53949e6131f6 | 91 | /* and HSE=1 */ |
Kojto | 71:53949e6131f6 | 92 | |
Kojto | 71:53949e6131f6 | 93 | usb1_function_init_status(); /* clear variables */ |
Kojto | 71:53949e6131f6 | 94 | |
Kojto | 71:53949e6131f6 | 95 | usb1_function_InitModule(mode); /* select USB Function and Interrupt Enable */ |
Kojto | 71:53949e6131f6 | 96 | /* Detect USB Device to attach or detach */ |
Kojto | 71:53949e6131f6 | 97 | } |
Kojto | 71:53949e6131f6 | 98 | #endif |
Kojto | 71:53949e6131f6 | 99 | |
Kojto | 71:53949e6131f6 | 100 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 101 | * Function Name: usb1_api_function_IsConfigured |
Kojto | 71:53949e6131f6 | 102 | * Description : Checks if the USB device is configured to return the result as |
Kojto | 71:53949e6131f6 | 103 | * : the return value. |
Kojto | 71:53949e6131f6 | 104 | * Arguments : none |
Kojto | 71:53949e6131f6 | 105 | * Return Value : DEVDRV_USBF_YES : Configured & Configured Suspend |
Kojto | 71:53949e6131f6 | 106 | * : DEVDRV_USBF_NO : not Configured |
Kojto | 71:53949e6131f6 | 107 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 108 | uint16_t usb1_api_function_IsConfigured (void) |
Kojto | 71:53949e6131f6 | 109 | { |
Kojto | 71:53949e6131f6 | 110 | uint16_t dvst; |
Kojto | 71:53949e6131f6 | 111 | |
Kojto | 71:53949e6131f6 | 112 | dvst = usb1_function_GetDeviceState(); |
Kojto | 71:53949e6131f6 | 113 | |
Kojto | 71:53949e6131f6 | 114 | if ((dvst == USB_FUNCTION_DVST_CONFIGURED) || |
Kojto | 71:53949e6131f6 | 115 | (dvst == USB_FUNCTION_DVST_CONFIGURED_SUSPEND)) |
Kojto | 71:53949e6131f6 | 116 | { |
Kojto | 71:53949e6131f6 | 117 | return DEVDRV_USBF_YES; |
Kojto | 71:53949e6131f6 | 118 | } |
Kojto | 71:53949e6131f6 | 119 | |
Kojto | 71:53949e6131f6 | 120 | return DEVDRV_USBF_NO; |
Kojto | 71:53949e6131f6 | 121 | } |
Kojto | 71:53949e6131f6 | 122 | |
Kojto | 71:53949e6131f6 | 123 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 124 | * Function Name: usb1_function_GetDeviceState |
Kojto | 71:53949e6131f6 | 125 | * Description : Returns the state of USB device. |
Kojto | 71:53949e6131f6 | 126 | * Arguments : none |
Kojto | 71:53949e6131f6 | 127 | * Return Value : Device States |
Kojto | 71:53949e6131f6 | 128 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 129 | uint16_t usb1_function_GetDeviceState (void) |
Kojto | 71:53949e6131f6 | 130 | { |
Kojto | 71:53949e6131f6 | 131 | uint16_t dvsq; |
Kojto | 71:53949e6131f6 | 132 | uint16_t dvst; |
Kojto | 71:53949e6131f6 | 133 | |
Kojto | 71:53949e6131f6 | 134 | dvsq = USB201.INTSTS0; |
Kojto | 71:53949e6131f6 | 135 | switch (dvsq & USB_FUNCTION_BITDVSQ) |
Kojto | 71:53949e6131f6 | 136 | { |
Kojto | 71:53949e6131f6 | 137 | case USB_FUNCTION_DS_POWR: /* Power state *//* power-on */ |
Kojto | 71:53949e6131f6 | 138 | dvst = USB_FUNCTION_DVST_POWERED; |
Kojto | 71:53949e6131f6 | 139 | break; |
Kojto | 71:53949e6131f6 | 140 | |
Kojto | 71:53949e6131f6 | 141 | case USB_FUNCTION_DS_DFLT: /* Default state *//* bus-reset */ |
Kojto | 71:53949e6131f6 | 142 | dvst = USB_FUNCTION_DVST_DEFAULT; |
Kojto | 71:53949e6131f6 | 143 | break; |
Kojto | 71:53949e6131f6 | 144 | |
Kojto | 71:53949e6131f6 | 145 | case USB_FUNCTION_DS_ADDS: /* Address state */ |
Kojto | 71:53949e6131f6 | 146 | dvst = USB_FUNCTION_DVST_ADDRESS; |
Kojto | 71:53949e6131f6 | 147 | break; |
Kojto | 71:53949e6131f6 | 148 | |
Kojto | 71:53949e6131f6 | 149 | case USB_FUNCTION_DS_CNFG: /* Configured state */ |
Kojto | 71:53949e6131f6 | 150 | dvst = USB_FUNCTION_DVST_CONFIGURED; |
Kojto | 71:53949e6131f6 | 151 | break; |
Kojto | 71:53949e6131f6 | 152 | |
Kojto | 71:53949e6131f6 | 153 | case USB_FUNCTION_DS_SPD_CNFG: /* Configured Suspend state */ |
Kojto | 71:53949e6131f6 | 154 | dvst = USB_FUNCTION_DVST_CONFIGURED_SUSPEND; |
Kojto | 71:53949e6131f6 | 155 | break; |
Kojto | 71:53949e6131f6 | 156 | |
Kojto | 71:53949e6131f6 | 157 | case USB_FUNCTION_DS_SPD_POWR: /* Power Suspend state */ |
Kojto | 71:53949e6131f6 | 158 | case USB_FUNCTION_DS_SPD_DFLT: /* Default Suspend state */ |
Kojto | 71:53949e6131f6 | 159 | case USB_FUNCTION_DS_SPD_ADDR: /* Address Suspend state */ |
Kojto | 71:53949e6131f6 | 160 | dvst = USB_FUNCTION_DVST_SUSPEND; |
Kojto | 71:53949e6131f6 | 161 | break; |
Kojto | 71:53949e6131f6 | 162 | |
Kojto | 71:53949e6131f6 | 163 | default: /* error */ |
Kojto | 71:53949e6131f6 | 164 | dvst = USB_FUNCTION_DVST_SUSPEND; |
Kojto | 71:53949e6131f6 | 165 | break; |
Kojto | 71:53949e6131f6 | 166 | } |
Kojto | 71:53949e6131f6 | 167 | |
Kojto | 71:53949e6131f6 | 168 | return dvst; |
Kojto | 71:53949e6131f6 | 169 | } |
Kojto | 71:53949e6131f6 | 170 | |
Kojto | 71:53949e6131f6 | 171 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 172 | * Function Name: usb1_api_function_start_receive_transfer |
Kojto | 71:53949e6131f6 | 173 | * Description : Starts USB data reception using the pipe specified in the argument. |
Kojto | 71:53949e6131f6 | 174 | * : The FIFO for using is set in the pipe definition table. |
Kojto | 71:53949e6131f6 | 175 | * Arguments : uint16_t pipe ; Pipe Number |
Kojto | 71:53949e6131f6 | 176 | * : uint32_t size ; Data Size |
Kojto | 71:53949e6131f6 | 177 | * : uint8_t *data ; Data data Address |
Kojto | 71:53949e6131f6 | 178 | * Return Value : none |
Kojto | 71:53949e6131f6 | 179 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 180 | void usb1_api_function_start_receive_transfer (uint16_t pipe, uint32_t size, uint8_t * data) |
Kojto | 71:53949e6131f6 | 181 | { |
Kojto | 71:53949e6131f6 | 182 | usb1_function_start_receive_transfer(pipe, size, data); |
Kojto | 71:53949e6131f6 | 183 | } |
Kojto | 71:53949e6131f6 | 184 | |
Kojto | 71:53949e6131f6 | 185 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 186 | * Function Name: usb1_api_function_start_send_transfer |
Kojto | 71:53949e6131f6 | 187 | * Description : Starts the USB data communication using pipe specified by the argument. |
Kojto | 71:53949e6131f6 | 188 | * Arguments : uint16_t pipe ; Pipe Number |
Kojto | 71:53949e6131f6 | 189 | * : uint32_t size ; Data Size |
Kojto | 71:53949e6131f6 | 190 | * : uint8_t *data ; Data data Address |
Kojto | 71:53949e6131f6 | 191 | * Return Value : DEVDRV_USBF_WRITEEND ; Write end |
Kojto | 71:53949e6131f6 | 192 | * : DEVDRV_USBF_WRITESHRT ; short data |
Kojto | 71:53949e6131f6 | 193 | * : DEVDRV_USBF_WRITING ; Continue of data write |
Kojto | 71:53949e6131f6 | 194 | * : DEVDRV_USBF_WRITEDMA ; Write DMA |
Kojto | 71:53949e6131f6 | 195 | * : DEVDRV_USBF_FIFOERROR ; FIFO status |
Kojto | 71:53949e6131f6 | 196 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 197 | uint16_t usb1_api_function_start_send_transfer (uint16_t pipe, uint32_t size, uint8_t * data) |
Kojto | 71:53949e6131f6 | 198 | { |
Kojto | 71:53949e6131f6 | 199 | uint16_t status; |
Kojto | 71:53949e6131f6 | 200 | |
Kojto | 71:53949e6131f6 | 201 | status = usb1_function_start_send_transfer(pipe, size, data); |
Kojto | 71:53949e6131f6 | 202 | |
Kojto | 71:53949e6131f6 | 203 | return status; |
Kojto | 71:53949e6131f6 | 204 | } |
Kojto | 71:53949e6131f6 | 205 | |
Kojto | 71:53949e6131f6 | 206 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 207 | * Function Name: usb1_api_function_check_pipe_status |
Kojto | 71:53949e6131f6 | 208 | * Description : Starts USB data reception using the pipe specified in the argument. |
Kojto | 71:53949e6131f6 | 209 | * : The FIFO for using is set in the pipe definition table. |
Kojto | 71:53949e6131f6 | 210 | * Arguments : uint16_t pipe ; Pipe Number |
Kojto | 71:53949e6131f6 | 211 | * : uint32_t *size ; Data Size |
Kojto | 71:53949e6131f6 | 212 | * Return Value : Pipe Status |
Kojto | 71:53949e6131f6 | 213 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 214 | uint16_t usb1_api_function_check_pipe_status (uint16_t pipe, uint32_t * size) |
Kojto | 71:53949e6131f6 | 215 | { |
Kojto | 71:53949e6131f6 | 216 | if (g_usb1_function_pipe_status[pipe] == DEVDRV_USBF_PIPE_DONE) |
Kojto | 71:53949e6131f6 | 217 | { |
Kojto | 71:53949e6131f6 | 218 | *size = g_usb1_function_PipeDataSize[pipe]; |
Kojto | 71:53949e6131f6 | 219 | g_usb1_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_IDLE; |
Kojto | 71:53949e6131f6 | 220 | |
Kojto | 71:53949e6131f6 | 221 | return DEVDRV_USBF_PIPE_DONE; |
Kojto | 71:53949e6131f6 | 222 | } |
Kojto | 71:53949e6131f6 | 223 | else if (g_usb1_function_pipe_status[pipe] == DEVDRV_USBF_PIPE_NORES) |
Kojto | 71:53949e6131f6 | 224 | { |
Kojto | 71:53949e6131f6 | 225 | *size = 0; |
Kojto | 71:53949e6131f6 | 226 | g_usb1_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_IDLE; |
Kojto | 71:53949e6131f6 | 227 | |
Kojto | 71:53949e6131f6 | 228 | return DEVDRV_USBF_PIPE_NORES; |
Kojto | 71:53949e6131f6 | 229 | } |
Kojto | 71:53949e6131f6 | 230 | else if (g_usb1_function_pipe_status[pipe] == DEVDRV_USBF_PIPE_STALL) |
Kojto | 71:53949e6131f6 | 231 | { |
Kojto | 71:53949e6131f6 | 232 | *size = 0; |
Kojto | 71:53949e6131f6 | 233 | g_usb1_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_IDLE; |
Kojto | 71:53949e6131f6 | 234 | |
Kojto | 71:53949e6131f6 | 235 | return DEVDRV_USBF_PIPE_STALL; |
Kojto | 71:53949e6131f6 | 236 | } |
Kojto | 71:53949e6131f6 | 237 | else if (g_usb1_function_pipe_status[pipe] == DEVDRV_USBF_FIFOERROR) |
Kojto | 71:53949e6131f6 | 238 | { |
Kojto | 71:53949e6131f6 | 239 | *size = 0; |
Kojto | 71:53949e6131f6 | 240 | g_usb1_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_IDLE; |
Kojto | 71:53949e6131f6 | 241 | |
Kojto | 71:53949e6131f6 | 242 | return DEVDRV_USBF_FIFOERROR; |
Kojto | 71:53949e6131f6 | 243 | } |
Kojto | 71:53949e6131f6 | 244 | else |
Kojto | 71:53949e6131f6 | 245 | { |
Kojto | 71:53949e6131f6 | 246 | /* Do Nothing */ |
Kojto | 71:53949e6131f6 | 247 | } |
Kojto | 71:53949e6131f6 | 248 | |
Kojto | 71:53949e6131f6 | 249 | return g_usb1_function_pipe_status[pipe]; |
Kojto | 71:53949e6131f6 | 250 | } |
Kojto | 71:53949e6131f6 | 251 | |
Kojto | 71:53949e6131f6 | 252 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 253 | * Function Name: usb1_api_function_clear_pipe_status |
Kojto | 71:53949e6131f6 | 254 | * Description : Starts USB data reception using the pipe specified in the argument. |
Kojto | 71:53949e6131f6 | 255 | * : The FIFO for using is set in the pipe definition table. |
Kojto | 71:53949e6131f6 | 256 | * Arguments : uint16_t pipe ; Pipe Number |
Kojto | 71:53949e6131f6 | 257 | * Return Value : Pipe Status |
Kojto | 71:53949e6131f6 | 258 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 259 | void usb1_api_function_clear_pipe_status (uint16_t pipe) |
Kojto | 71:53949e6131f6 | 260 | { |
Kojto | 71:53949e6131f6 | 261 | g_usb1_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_IDLE; |
Kojto | 71:53949e6131f6 | 262 | g_usb1_function_PipeDataSize[pipe] = 0; |
Kojto | 71:53949e6131f6 | 263 | } |
Kojto | 71:53949e6131f6 | 264 | |
Kojto | 71:53949e6131f6 | 265 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 266 | * Function Name: usb1_api_function_set_pid_buf |
Kojto | 71:53949e6131f6 | 267 | * Description : Enables communicaqtion in the pipe specified by the argument |
Kojto | 71:53949e6131f6 | 268 | * : (BUF). |
Kojto | 71:53949e6131f6 | 269 | * Arguments : uint16_t pipe ; pipe Number |
Kojto | 71:53949e6131f6 | 270 | * Return Value : none |
Kojto | 71:53949e6131f6 | 271 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 272 | void usb1_api_function_set_pid_buf (uint16_t pipe) |
Kojto | 71:53949e6131f6 | 273 | { |
Kojto | 71:53949e6131f6 | 274 | usb1_function_set_pid_buf(pipe); |
Kojto | 71:53949e6131f6 | 275 | } |
Kojto | 71:53949e6131f6 | 276 | |
Kojto | 71:53949e6131f6 | 277 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 278 | * Function Name: usb1_api_function_set_pid_nak |
Kojto | 71:53949e6131f6 | 279 | * Description : Disables communication (NAK) in the pipe specified by the argument. |
Kojto | 71:53949e6131f6 | 280 | * : When the pipe status was enabling communication (BUF) before |
Kojto | 71:53949e6131f6 | 281 | * : executing before executing this function, waits in the software |
Kojto | 71:53949e6131f6 | 282 | * : until the pipe becomes ready after setting disabled. |
Kojto | 71:53949e6131f6 | 283 | * Arguments : uint16_t pipe ; pipe Number |
Kojto | 71:53949e6131f6 | 284 | * Return Value : none |
Kojto | 71:53949e6131f6 | 285 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 286 | void usb1_api_function_set_pid_nak (uint16_t pipe) |
Kojto | 71:53949e6131f6 | 287 | { |
Kojto | 71:53949e6131f6 | 288 | usb1_function_set_pid_nak(pipe); |
Kojto | 71:53949e6131f6 | 289 | } |
Kojto | 71:53949e6131f6 | 290 | |
Kojto | 71:53949e6131f6 | 291 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 292 | * Function Name: usb1_api_function_set_pid_stall |
Kojto | 71:53949e6131f6 | 293 | * Description : Disables communication (STALL) in the pipe specified by the |
Kojto | 71:53949e6131f6 | 294 | * : argument. |
Kojto | 71:53949e6131f6 | 295 | * Arguments : uint16_t pipe ; pipe Number |
Kojto | 71:53949e6131f6 | 296 | * Return Value : none |
Kojto | 71:53949e6131f6 | 297 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 298 | void usb1_api_function_set_pid_stall (uint16_t pipe) |
Kojto | 71:53949e6131f6 | 299 | { |
Kojto | 71:53949e6131f6 | 300 | usb1_function_set_pid_stall(pipe); |
Kojto | 71:53949e6131f6 | 301 | } |
Kojto | 71:53949e6131f6 | 302 | |
Kojto | 71:53949e6131f6 | 303 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 304 | * Function Name: usb1_api_function_clear_pid_stall |
Kojto | 71:53949e6131f6 | 305 | * Description : Disables communication (NAK) in the pipe specified by the argument. |
Kojto | 71:53949e6131f6 | 306 | * Arguments : uint16_t pipe ; pipe Number |
Kojto | 71:53949e6131f6 | 307 | * Return Value : none |
Kojto | 71:53949e6131f6 | 308 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 309 | void usb1_api_function_clear_pid_stall (uint16_t pipe) |
Kojto | 71:53949e6131f6 | 310 | { |
Kojto | 71:53949e6131f6 | 311 | usb1_function_clear_pid_stall(pipe); |
Kojto | 71:53949e6131f6 | 312 | } |
Kojto | 71:53949e6131f6 | 313 | |
Kojto | 71:53949e6131f6 | 314 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 315 | * Function Name: usb1_api_function_get_pid |
Kojto | 71:53949e6131f6 | 316 | * Description : Returns the pipe state specified by the argument. |
Kojto | 71:53949e6131f6 | 317 | * Arguments : uint16_t pipe ; Pipe Number |
Kojto | 71:53949e6131f6 | 318 | * Return Value : PID |
Kojto | 71:53949e6131f6 | 319 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 320 | uint16_t usb1_api_function_get_pid (uint16_t pipe) |
Kojto | 71:53949e6131f6 | 321 | { |
Kojto | 71:53949e6131f6 | 322 | uint16_t pid; |
Kojto | 71:53949e6131f6 | 323 | |
Kojto | 71:53949e6131f6 | 324 | pid = usb1_function_get_pid(pipe); |
Kojto | 71:53949e6131f6 | 325 | |
Kojto | 71:53949e6131f6 | 326 | return pid; |
Kojto | 71:53949e6131f6 | 327 | } |
Kojto | 71:53949e6131f6 | 328 | |
Kojto | 71:53949e6131f6 | 329 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 330 | * Function Name: usb1_api_function_check_stall |
Kojto | 71:53949e6131f6 | 331 | * Description : |
Kojto | 71:53949e6131f6 | 332 | * Arguments : uint16_t pipe ; Pipe Number |
Kojto | 71:53949e6131f6 | 333 | * Return Value : PID |
Kojto | 71:53949e6131f6 | 334 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 335 | int32_t usb1_api_function_check_stall (uint16_t pipe) |
Kojto | 71:53949e6131f6 | 336 | { |
Kojto | 71:53949e6131f6 | 337 | uint16_t pid; |
Kojto | 71:53949e6131f6 | 338 | |
Kojto | 71:53949e6131f6 | 339 | pid = usb1_function_get_pid(pipe); |
Kojto | 71:53949e6131f6 | 340 | |
Kojto | 71:53949e6131f6 | 341 | if ((pid & DEVDRV_USBF_PID_STALL) == DEVDRV_USBF_PID_STALL) |
Kojto | 71:53949e6131f6 | 342 | { |
Kojto | 71:53949e6131f6 | 343 | return DEVDRV_USBF_STALL; |
Kojto | 71:53949e6131f6 | 344 | } |
Kojto | 71:53949e6131f6 | 345 | |
Kojto | 71:53949e6131f6 | 346 | return DEVDRV_SUCCESS; |
Kojto | 71:53949e6131f6 | 347 | } |
Kojto | 71:53949e6131f6 | 348 | |
Kojto | 71:53949e6131f6 | 349 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 350 | * Function Name: usb1_api_function_set_sqclr |
Kojto | 71:53949e6131f6 | 351 | * Description : Sets the sequence bit of the pipe specified by the argument to |
Kojto | 71:53949e6131f6 | 352 | * : DATA0. |
Kojto | 71:53949e6131f6 | 353 | * Arguments : uint16_t pipe ; Pipe Number |
Kojto | 71:53949e6131f6 | 354 | * Return Value : none |
Kojto | 71:53949e6131f6 | 355 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 356 | void usb1_api_function_set_sqclr (uint16_t pipe) |
Kojto | 71:53949e6131f6 | 357 | { |
Kojto | 71:53949e6131f6 | 358 | usb1_function_set_sqclr(pipe); |
Kojto | 71:53949e6131f6 | 359 | } |
Kojto | 71:53949e6131f6 | 360 | |
Kojto | 71:53949e6131f6 | 361 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 362 | * Function Name: usb1_api_function_set_sqset |
Kojto | 71:53949e6131f6 | 363 | * Description : Sets the sequence bit of the pipe specified by the argument to |
Kojto | 71:53949e6131f6 | 364 | * : DATA1. |
Kojto | 71:53949e6131f6 | 365 | * Arguments : uint16_t pipe ; Pipe number |
Kojto | 71:53949e6131f6 | 366 | * Return Value : none |
Kojto | 71:53949e6131f6 | 367 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 368 | void usb1_api_function_set_sqset (uint16_t pipe) |
Kojto | 71:53949e6131f6 | 369 | { |
Kojto | 71:53949e6131f6 | 370 | usb1_function_set_sqset(pipe); |
Kojto | 71:53949e6131f6 | 371 | } |
Kojto | 71:53949e6131f6 | 372 | |
Kojto | 71:53949e6131f6 | 373 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 374 | * Function Name: usb1_api_function_set_csclr |
Kojto | 71:53949e6131f6 | 375 | * Description : CSPLIT status clear setting of sprit transaction in specified |
Kojto | 71:53949e6131f6 | 376 | * : pipe is performed. |
Kojto | 71:53949e6131f6 | 377 | * : When SQSET bit or SQCLR bit, and SQSET bit or SQCLR bit |
Kojto | 71:53949e6131f6 | 378 | * : in DCPCTR register are continuously changed (when the sequence |
Kojto | 71:53949e6131f6 | 379 | * : toggle bit of data PID is continuously changed over two or more pipes), |
Kojto | 71:53949e6131f6 | 380 | * : the access cycle with 120 ns and more than 5 cycle bus clock is necessary. |
Kojto | 71:53949e6131f6 | 381 | * : Do not set both SQCLR bit and SQSET bit to 1 at the same time. |
Kojto | 71:53949e6131f6 | 382 | * : In addition, both bits should be operated after PID is set to NAK. |
Kojto | 71:53949e6131f6 | 383 | * : However, when it is set to the isochronous transfer as the transfer type |
Kojto | 71:53949e6131f6 | 384 | * : (TYPE=11), writing in SQSET bit is disabled. |
Kojto | 71:53949e6131f6 | 385 | * Arguments : uint16_t pipe ; Pipe number |
Kojto | 71:53949e6131f6 | 386 | * Return Value : none |
Kojto | 71:53949e6131f6 | 387 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 388 | void usb1_api_function_set_csclr (uint16_t pipe) |
Kojto | 71:53949e6131f6 | 389 | { |
Kojto | 71:53949e6131f6 | 390 | usb1_function_set_csclr(pipe); |
Kojto | 71:53949e6131f6 | 391 | } |
Kojto | 71:53949e6131f6 | 392 | |
Kojto | 71:53949e6131f6 | 393 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 394 | * Function Name: usb1_api_function_set_curpipe |
Kojto | 71:53949e6131f6 | 395 | * Description : Allocates FIF0 specifed by the argument in the pipe assigned |
Kojto | 71:53949e6131f6 | 396 | * : by the argument. |
Kojto | 71:53949e6131f6 | 397 | * Arguments : uint16_t pipe ; Pipe Number |
Kojto | 71:53949e6131f6 | 398 | * : uint16_t fifosel ; Select FIFO |
Kojto | 71:53949e6131f6 | 399 | * : uint16_t isel ; FIFO Access Direction |
Kojto | 71:53949e6131f6 | 400 | * : uint16_t mbw ; FIFO Port Access Bit Width |
Kojto | 71:53949e6131f6 | 401 | * Return Value : none |
Kojto | 71:53949e6131f6 | 402 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 403 | void usb1_api_function_set_curpipe (uint16_t pipe, uint16_t fifosel, uint16_t isel, uint16_t mbw) |
Kojto | 71:53949e6131f6 | 404 | { |
Kojto | 71:53949e6131f6 | 405 | usb1_function_set_curpipe(pipe, fifosel, isel, mbw); |
Kojto | 71:53949e6131f6 | 406 | } |
Kojto | 71:53949e6131f6 | 407 | |
Kojto | 71:53949e6131f6 | 408 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 409 | * Function Name: usb1_api_function_clear_brdy_sts |
Kojto | 71:53949e6131f6 | 410 | * Description : Clear BRDY interrupt status in the pipe spceified by the argument. |
Kojto | 71:53949e6131f6 | 411 | * Arguments : uint16_t pipe ; pipe Number |
Kojto | 71:53949e6131f6 | 412 | * Return Value : none |
Kojto | 71:53949e6131f6 | 413 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 414 | void usb1_api_function_clear_brdy_sts (uint16_t pipe) |
Kojto | 71:53949e6131f6 | 415 | { |
Kojto | 71:53949e6131f6 | 416 | usb1_function_clear_brdy_sts(pipe); |
Kojto | 71:53949e6131f6 | 417 | } |
Kojto | 71:53949e6131f6 | 418 | |
Kojto | 71:53949e6131f6 | 419 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 420 | * Function Name: usb1_api_function_clear_bemp_sts |
Kojto | 71:53949e6131f6 | 421 | * Description : Clear BEMP interrupt status in the pipe spceified by the argument. |
Kojto | 71:53949e6131f6 | 422 | * Arguments : uint16_t pipe ; pipe Number |
Kojto | 71:53949e6131f6 | 423 | * Return Value : none |
Kojto | 71:53949e6131f6 | 424 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 425 | void usb1_api_function_clear_bemp_sts (uint16_t pipe) |
Kojto | 71:53949e6131f6 | 426 | { |
Kojto | 71:53949e6131f6 | 427 | usb1_function_clear_bemp_sts(pipe); |
Kojto | 71:53949e6131f6 | 428 | } |
Kojto | 71:53949e6131f6 | 429 | |
Kojto | 71:53949e6131f6 | 430 | /******************************************************************************* |
Kojto | 71:53949e6131f6 | 431 | * Function Name: usb1_api_function_clear_nrdy_sts |
Kojto | 71:53949e6131f6 | 432 | * Description : Clear NRDY interrupt status in the pipe spceified by the argument. |
Kojto | 71:53949e6131f6 | 433 | * Arguments : uint16_t pipe ; pipe Number |
Kojto | 71:53949e6131f6 | 434 | * Return Value : none |
Kojto | 71:53949e6131f6 | 435 | *******************************************************************************/ |
Kojto | 71:53949e6131f6 | 436 | void usb1_api_function_clear_nrdy_sts (uint16_t pipe) |
Kojto | 71:53949e6131f6 | 437 | { |
Kojto | 71:53949e6131f6 | 438 | usb1_function_clear_nrdy_sts(pipe); |
Kojto | 71:53949e6131f6 | 439 | } |
Kojto | 71:53949e6131f6 | 440 | |
Kojto | 71:53949e6131f6 | 441 | /* End of File */ |