USBDevice with MAX32620HSP platform support

Fork of USBDevice by mbed official

Committer:
mbed_official
Date:
Fri Apr 29 01:16:25 2016 +0100
Revision:
62:c1549af978d6
Synchronized with git revision fe9720f24b1adc71ab6962506ec51290f6afd270

Full URL: https://github.com/mbedmicro/mbed/commit/fe9720f24b1adc71ab6962506ec51290f6afd270/

[Renesas RZ/A1H] Enable asynchronous communications

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 62:c1549af978d6 1 /*******************************************************************************
mbed_official 62:c1549af978d6 2 * DISCLAIMER
mbed_official 62:c1549af978d6 3 * This software is supplied by Renesas Electronics Corporation and is only
mbed_official 62:c1549af978d6 4 * intended for use with Renesas products. No other uses are authorized. This
mbed_official 62:c1549af978d6 5 * software is owned by Renesas Electronics Corporation and is protected under
mbed_official 62:c1549af978d6 6 * all applicable laws, including copyright laws.
mbed_official 62:c1549af978d6 7 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
mbed_official 62:c1549af978d6 8 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
mbed_official 62:c1549af978d6 9 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
mbed_official 62:c1549af978d6 10 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
mbed_official 62:c1549af978d6 11 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
mbed_official 62:c1549af978d6 12 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
mbed_official 62:c1549af978d6 13 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
mbed_official 62:c1549af978d6 14 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
mbed_official 62:c1549af978d6 15 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
mbed_official 62:c1549af978d6 16 * Renesas reserves the right, without notice, to make changes to this software
mbed_official 62:c1549af978d6 17 * and to discontinue the availability of this software. By using this software,
mbed_official 62:c1549af978d6 18 * you agree to the additional terms and conditions found by accessing the
mbed_official 62:c1549af978d6 19 * following link:
mbed_official 62:c1549af978d6 20 * http://www.renesas.com/disclaimer
mbed_official 62:c1549af978d6 21 * Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
mbed_official 62:c1549af978d6 22 *******************************************************************************/
mbed_official 62:c1549af978d6 23 /*******************************************************************************
mbed_official 62:c1549af978d6 24 * File Name : usb0_function_controlrw.c
mbed_official 62:c1549af978d6 25 * $Rev: 1116 $
mbed_official 62:c1549af978d6 26 * $Date:: 2014-07-09 16:29:19 +0900#$
mbed_official 62:c1549af978d6 27 * Device(s) : RZ/A1H
mbed_official 62:c1549af978d6 28 * Tool-Chain :
mbed_official 62:c1549af978d6 29 * OS : None
mbed_official 62:c1549af978d6 30 * H/W Platform :
mbed_official 62:c1549af978d6 31 * Description : RZ/A1H R7S72100 USB Sample Program
mbed_official 62:c1549af978d6 32 * Operation :
mbed_official 62:c1549af978d6 33 * Limitations :
mbed_official 62:c1549af978d6 34 *******************************************************************************/
mbed_official 62:c1549af978d6 35
mbed_official 62:c1549af978d6 36
mbed_official 62:c1549af978d6 37 /*******************************************************************************
mbed_official 62:c1549af978d6 38 Includes <System Includes> , "Project Includes"
mbed_official 62:c1549af978d6 39 *******************************************************************************/
mbed_official 62:c1549af978d6 40 #include "usb0_function.h"
mbed_official 62:c1549af978d6 41
mbed_official 62:c1549af978d6 42
mbed_official 62:c1549af978d6 43 /*******************************************************************************
mbed_official 62:c1549af978d6 44 Typedef definitions
mbed_official 62:c1549af978d6 45 *******************************************************************************/
mbed_official 62:c1549af978d6 46
mbed_official 62:c1549af978d6 47
mbed_official 62:c1549af978d6 48 /*******************************************************************************
mbed_official 62:c1549af978d6 49 Macro definitions
mbed_official 62:c1549af978d6 50 *******************************************************************************/
mbed_official 62:c1549af978d6 51
mbed_official 62:c1549af978d6 52
mbed_official 62:c1549af978d6 53 /*******************************************************************************
mbed_official 62:c1549af978d6 54 Imported global variables and functions (from other files)
mbed_official 62:c1549af978d6 55 *******************************************************************************/
mbed_official 62:c1549af978d6 56
mbed_official 62:c1549af978d6 57
mbed_official 62:c1549af978d6 58 /*******************************************************************************
mbed_official 62:c1549af978d6 59 Exported global variables and functions (to be accessed by other files)
mbed_official 62:c1549af978d6 60 *******************************************************************************/
mbed_official 62:c1549af978d6 61
mbed_official 62:c1549af978d6 62
mbed_official 62:c1549af978d6 63 /*******************************************************************************
mbed_official 62:c1549af978d6 64 Private global variables and functions
mbed_official 62:c1549af978d6 65 *******************************************************************************/
mbed_official 62:c1549af978d6 66
mbed_official 62:c1549af978d6 67
mbed_official 62:c1549af978d6 68 /*******************************************************************************
mbed_official 62:c1549af978d6 69 * Function Name: usb0_api_function_CtrlReadStart
mbed_official 62:c1549af978d6 70 * Description : Executes the USB control read transfer.
mbed_official 62:c1549af978d6 71 * : USB host controller <- USB device
mbed_official 62:c1549af978d6 72 * Arguments : uint16_t size ; Data Size
mbed_official 62:c1549af978d6 73 * : uint8_t *data ; Data Address
mbed_official 62:c1549af978d6 74 * Return Value : DEVDRV_USBF_WRITEEND ; End of data write
mbed_official 62:c1549af978d6 75 * : DEVDRV_USBF_WRITESHRT ; End of short data write
mbed_official 62:c1549af978d6 76 * : DEVDRV_USBF_WRITING ; Continue of data write
mbed_official 62:c1549af978d6 77 * : DEVDRV_USBF_FIFOERROR ; FIFO access error
mbed_official 62:c1549af978d6 78 *******************************************************************************/
mbed_official 62:c1549af978d6 79 uint16_t usb0_api_function_CtrlReadStart (uint32_t size, uint8_t * data)
mbed_official 62:c1549af978d6 80 {
mbed_official 62:c1549af978d6 81 uint16_t status;
mbed_official 62:c1549af978d6 82 uint16_t mbw;
mbed_official 62:c1549af978d6 83
mbed_official 62:c1549af978d6 84 usb0_function_set_pid_nak(USB_FUNCTION_PIPE0);
mbed_official 62:c1549af978d6 85
mbed_official 62:c1549af978d6 86 g_usb0_function_data_count[USB_FUNCTION_PIPE0] = size;
mbed_official 62:c1549af978d6 87 g_usb0_function_data_pointer[USB_FUNCTION_PIPE0] = data;
mbed_official 62:c1549af978d6 88
mbed_official 62:c1549af978d6 89 mbw = usb0_function_get_mbw(g_usb0_function_data_count[USB_FUNCTION_PIPE0],
mbed_official 62:c1549af978d6 90 (uint32_t)g_usb0_function_data_pointer[USB_FUNCTION_PIPE0]);
mbed_official 62:c1549af978d6 91 usb0_function_set_curpipe(USB_FUNCTION_PIPE0, USB_FUNCTION_CUSE, USB_FUNCTION_CFIFO_WRITE, mbw);
mbed_official 62:c1549af978d6 92 USB200.CFIFOCTR = USB_FUNCTION_BITBCLR;
mbed_official 62:c1549af978d6 93
mbed_official 62:c1549af978d6 94 status = usb0_function_write_buffer_c(USB_FUNCTION_PIPE0);
mbed_official 62:c1549af978d6 95
mbed_official 62:c1549af978d6 96 /* Peripheral Control sequence */
mbed_official 62:c1549af978d6 97 switch (status)
mbed_official 62:c1549af978d6 98 {
mbed_official 62:c1549af978d6 99 case DEVDRV_USBF_WRITESHRT: /* End of data write */
mbed_official 62:c1549af978d6 100 case DEVDRV_USBF_WRITEEND: /* End of data write (not null) */
mbed_official 62:c1549af978d6 101 case DEVDRV_USBF_WRITING: /* Continue of data write */
mbed_official 62:c1549af978d6 102 usb0_function_enable_bemp_int(USB_FUNCTION_PIPE0); /* Enable Empty Interrupt */
mbed_official 62:c1549af978d6 103 usb0_function_set_pid_buf(USB_FUNCTION_PIPE0); /* Set BUF */
mbed_official 62:c1549af978d6 104 break;
mbed_official 62:c1549af978d6 105
mbed_official 62:c1549af978d6 106 case DEVDRV_USBF_FIFOERROR: /* FIFO access error */
mbed_official 62:c1549af978d6 107 break;
mbed_official 62:c1549af978d6 108
mbed_official 62:c1549af978d6 109 default:
mbed_official 62:c1549af978d6 110 break;
mbed_official 62:c1549af978d6 111 }
mbed_official 62:c1549af978d6 112
mbed_official 62:c1549af978d6 113 return status; /* End or Err or Continue */
mbed_official 62:c1549af978d6 114 }
mbed_official 62:c1549af978d6 115
mbed_official 62:c1549af978d6 116 /*******************************************************************************
mbed_official 62:c1549af978d6 117 * Function Name: usb0_api_function_CtrlWriteStart
mbed_official 62:c1549af978d6 118 * Description : Executes the USB control write transfer.
mbed_official 62:c1549af978d6 119 * : USB host controller -> USB device
mbed_official 62:c1549af978d6 120 * Arguments : uint16_t size ; Data Size
mbed_official 62:c1549af978d6 121 * : uint8_t *data ; Data Address
mbed_official 62:c1549af978d6 122 * Return Value : none
mbed_official 62:c1549af978d6 123 *******************************************************************************/
mbed_official 62:c1549af978d6 124 void usb0_api_function_CtrlWriteStart (uint32_t size, uint8_t * data)
mbed_official 62:c1549af978d6 125 {
mbed_official 62:c1549af978d6 126 uint16_t mbw;
mbed_official 62:c1549af978d6 127
mbed_official 62:c1549af978d6 128 usb0_function_set_pid_nak(USB_FUNCTION_PIPE0);
mbed_official 62:c1549af978d6 129
mbed_official 62:c1549af978d6 130 g_usb0_function_data_count[USB_FUNCTION_PIPE0] = size;
mbed_official 62:c1549af978d6 131 g_usb0_function_data_pointer[USB_FUNCTION_PIPE0] = data;
mbed_official 62:c1549af978d6 132
mbed_official 62:c1549af978d6 133 mbw = usb0_function_get_mbw(g_usb0_function_data_count[USB_FUNCTION_PIPE0],
mbed_official 62:c1549af978d6 134 (uint32_t)g_usb0_function_data_pointer[USB_FUNCTION_PIPE0]);
mbed_official 62:c1549af978d6 135 usb0_function_set_curpipe(USB_FUNCTION_PIPE0, USB_FUNCTION_CUSE, USB_FUNCTION_CFIFO_WRITE, mbw);
mbed_official 62:c1549af978d6 136 USB200.CFIFOCTR = USB_FUNCTION_BITBCLR;
mbed_official 62:c1549af978d6 137
mbed_official 62:c1549af978d6 138 usb0_function_enable_brdy_int(USB_FUNCTION_PIPE0);
mbed_official 62:c1549af978d6 139 usb0_function_set_pid_buf(USB_FUNCTION_PIPE0);
mbed_official 62:c1549af978d6 140 }
mbed_official 62:c1549af978d6 141
mbed_official 62:c1549af978d6 142 /* End of File */