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.

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?

UserRevisionLine numberNew 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 : usb0_function_controlrw.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 "usb0_function.h"
Kojto 71:53949e6131f6 41
Kojto 71:53949e6131f6 42
Kojto 71:53949e6131f6 43 /*******************************************************************************
Kojto 71:53949e6131f6 44 Typedef definitions
Kojto 71:53949e6131f6 45 *******************************************************************************/
Kojto 71:53949e6131f6 46
Kojto 71:53949e6131f6 47
Kojto 71:53949e6131f6 48 /*******************************************************************************
Kojto 71:53949e6131f6 49 Macro definitions
Kojto 71:53949e6131f6 50 *******************************************************************************/
Kojto 71:53949e6131f6 51
Kojto 71:53949e6131f6 52
Kojto 71:53949e6131f6 53 /*******************************************************************************
Kojto 71:53949e6131f6 54 Imported global variables and functions (from other files)
Kojto 71:53949e6131f6 55 *******************************************************************************/
Kojto 71:53949e6131f6 56
Kojto 71:53949e6131f6 57
Kojto 71:53949e6131f6 58 /*******************************************************************************
Kojto 71:53949e6131f6 59 Exported global variables and functions (to be accessed by other files)
Kojto 71:53949e6131f6 60 *******************************************************************************/
Kojto 71:53949e6131f6 61
Kojto 71:53949e6131f6 62
Kojto 71:53949e6131f6 63 /*******************************************************************************
Kojto 71:53949e6131f6 64 Private global variables and functions
Kojto 71:53949e6131f6 65 *******************************************************************************/
Kojto 71:53949e6131f6 66
Kojto 71:53949e6131f6 67
Kojto 71:53949e6131f6 68 /*******************************************************************************
Kojto 71:53949e6131f6 69 * Function Name: usb0_api_function_CtrlReadStart
Kojto 71:53949e6131f6 70 * Description : Executes the USB control read transfer.
Kojto 71:53949e6131f6 71 * : USB host controller <- USB device
Kojto 71:53949e6131f6 72 * Arguments : uint16_t size ; Data Size
Kojto 71:53949e6131f6 73 * : uint8_t *data ; Data Address
Kojto 71:53949e6131f6 74 * Return Value : DEVDRV_USBF_WRITEEND ; End of data write
Kojto 71:53949e6131f6 75 * : DEVDRV_USBF_WRITESHRT ; End of short data write
Kojto 71:53949e6131f6 76 * : DEVDRV_USBF_WRITING ; Continue of data write
Kojto 71:53949e6131f6 77 * : DEVDRV_USBF_FIFOERROR ; FIFO access error
Kojto 71:53949e6131f6 78 *******************************************************************************/
Kojto 71:53949e6131f6 79 uint16_t usb0_api_function_CtrlReadStart (uint32_t size, uint8_t * data)
Kojto 71:53949e6131f6 80 {
Kojto 71:53949e6131f6 81 uint16_t status;
Kojto 71:53949e6131f6 82 uint16_t mbw;
Kojto 71:53949e6131f6 83
Kojto 71:53949e6131f6 84 usb0_function_set_pid_nak(USB_FUNCTION_PIPE0);
Kojto 71:53949e6131f6 85
Kojto 71:53949e6131f6 86 g_usb0_function_data_count[USB_FUNCTION_PIPE0] = size;
Kojto 71:53949e6131f6 87 g_usb0_function_data_pointer[USB_FUNCTION_PIPE0] = data;
Kojto 71:53949e6131f6 88
Kojto 71:53949e6131f6 89 mbw = usb0_function_get_mbw(g_usb0_function_data_count[USB_FUNCTION_PIPE0],
Kojto 71:53949e6131f6 90 (uint32_t)g_usb0_function_data_pointer[USB_FUNCTION_PIPE0]);
Kojto 71:53949e6131f6 91 usb0_function_set_curpipe(USB_FUNCTION_PIPE0, USB_FUNCTION_CUSE, USB_FUNCTION_CFIFO_WRITE, mbw);
Kojto 71:53949e6131f6 92 USB200.CFIFOCTR = USB_FUNCTION_BITBCLR;
Kojto 71:53949e6131f6 93
Kojto 71:53949e6131f6 94 status = usb0_function_write_buffer_c(USB_FUNCTION_PIPE0);
Kojto 71:53949e6131f6 95
Kojto 71:53949e6131f6 96 /* Peripheral Control sequence */
Kojto 71:53949e6131f6 97 switch (status)
Kojto 71:53949e6131f6 98 {
Kojto 71:53949e6131f6 99 case DEVDRV_USBF_WRITESHRT: /* End of data write */
Kojto 71:53949e6131f6 100 case DEVDRV_USBF_WRITEEND: /* End of data write (not null) */
Kojto 71:53949e6131f6 101 case DEVDRV_USBF_WRITING: /* Continue of data write */
Kojto 71:53949e6131f6 102 usb0_function_enable_bemp_int(USB_FUNCTION_PIPE0); /* Enable Empty Interrupt */
Kojto 71:53949e6131f6 103 usb0_function_set_pid_buf(USB_FUNCTION_PIPE0); /* Set BUF */
Kojto 71:53949e6131f6 104 break;
Kojto 71:53949e6131f6 105
Kojto 71:53949e6131f6 106 case DEVDRV_USBF_FIFOERROR: /* FIFO access error */
Kojto 71:53949e6131f6 107 break;
Kojto 71:53949e6131f6 108
Kojto 71:53949e6131f6 109 default:
Kojto 71:53949e6131f6 110 break;
Kojto 71:53949e6131f6 111 }
Kojto 71:53949e6131f6 112
Kojto 71:53949e6131f6 113 return status; /* End or Err or Continue */
Kojto 71:53949e6131f6 114 }
Kojto 71:53949e6131f6 115
Kojto 71:53949e6131f6 116 /*******************************************************************************
Kojto 71:53949e6131f6 117 * Function Name: usb0_api_function_CtrlWriteStart
Kojto 71:53949e6131f6 118 * Description : Executes the USB control write transfer.
Kojto 71:53949e6131f6 119 * : USB host controller -> USB device
Kojto 71:53949e6131f6 120 * Arguments : uint16_t size ; Data Size
Kojto 71:53949e6131f6 121 * : uint8_t *data ; Data Address
Kojto 71:53949e6131f6 122 * Return Value : none
Kojto 71:53949e6131f6 123 *******************************************************************************/
Kojto 71:53949e6131f6 124 void usb0_api_function_CtrlWriteStart (uint32_t size, uint8_t * data)
Kojto 71:53949e6131f6 125 {
Kojto 71:53949e6131f6 126 uint16_t mbw;
Kojto 71:53949e6131f6 127
Kojto 71:53949e6131f6 128 usb0_function_set_pid_nak(USB_FUNCTION_PIPE0);
Kojto 71:53949e6131f6 129
Kojto 71:53949e6131f6 130 g_usb0_function_data_count[USB_FUNCTION_PIPE0] = size;
Kojto 71:53949e6131f6 131 g_usb0_function_data_pointer[USB_FUNCTION_PIPE0] = data;
Kojto 71:53949e6131f6 132
Kojto 71:53949e6131f6 133 mbw = usb0_function_get_mbw(g_usb0_function_data_count[USB_FUNCTION_PIPE0],
Kojto 71:53949e6131f6 134 (uint32_t)g_usb0_function_data_pointer[USB_FUNCTION_PIPE0]);
Kojto 71:53949e6131f6 135 usb0_function_set_curpipe(USB_FUNCTION_PIPE0, USB_FUNCTION_CUSE, USB_FUNCTION_CFIFO_WRITE, mbw);
Kojto 71:53949e6131f6 136 USB200.CFIFOCTR = USB_FUNCTION_BITBCLR;
Kojto 71:53949e6131f6 137
Kojto 71:53949e6131f6 138 usb0_function_enable_brdy_int(USB_FUNCTION_PIPE0);
Kojto 71:53949e6131f6 139 usb0_function_set_pid_buf(USB_FUNCTION_PIPE0);
Kojto 71:53949e6131f6 140 }
Kojto 71:53949e6131f6 141
Kojto 71:53949e6131f6 142 /* End of File */