USB device stack - Added support for the logo/windows key to USB keyboard.

Dependents:   randomSearch

Fork of USBDevice by mbed official

Committer:
mbed_official
Date:
Tue Mar 31 16:15:39 2015 +0100
Revision:
46:378357d7e90d
Synchronized with git revision 251f3f8b55a4dc98b831c80e032464ed45cce309

Full URL: https://github.com/mbedmicro/mbed/commit/251f3f8b55a4dc98b831c80e032464ed45cce309/

[RZ/A1H]Add some function(USB 2port, NVIC wrapper) and modify some settings(OS, Terminal).

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 46:378357d7e90d 1 /*******************************************************************************
mbed_official 46:378357d7e90d 2 * DISCLAIMER
mbed_official 46:378357d7e90d 3 * This software is supplied by Renesas Electronics Corporation and is only
mbed_official 46:378357d7e90d 4 * intended for use with Renesas products. No other uses are authorized. This
mbed_official 46:378357d7e90d 5 * software is owned by Renesas Electronics Corporation and is protected under
mbed_official 46:378357d7e90d 6 * all applicable laws, including copyright laws.
mbed_official 46:378357d7e90d 7 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
mbed_official 46:378357d7e90d 8 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
mbed_official 46:378357d7e90d 9 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
mbed_official 46:378357d7e90d 10 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
mbed_official 46:378357d7e90d 11 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
mbed_official 46:378357d7e90d 12 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
mbed_official 46:378357d7e90d 13 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
mbed_official 46:378357d7e90d 14 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
mbed_official 46:378357d7e90d 15 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
mbed_official 46:378357d7e90d 16 * Renesas reserves the right, without notice, to make changes to this software
mbed_official 46:378357d7e90d 17 * and to discontinue the availability of this software. By using this software,
mbed_official 46:378357d7e90d 18 * you agree to the additional terms and conditions found by accessing the
mbed_official 46:378357d7e90d 19 * following link:
mbed_official 46:378357d7e90d 20 * http://www.renesas.com/disclaimer
mbed_official 46:378357d7e90d 21 * Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
mbed_official 46:378357d7e90d 22 *******************************************************************************/
mbed_official 46:378357d7e90d 23 /*******************************************************************************
mbed_official 46:378357d7e90d 24 * File Name : usb1_function_intrn.c
mbed_official 46:378357d7e90d 25 * $Rev: 1116 $
mbed_official 46:378357d7e90d 26 * $Date:: 2014-07-09 16:29:19 +0900#$
mbed_official 46:378357d7e90d 27 * Device(s) : RZ/A1H
mbed_official 46:378357d7e90d 28 * Tool-Chain :
mbed_official 46:378357d7e90d 29 * OS : None
mbed_official 46:378357d7e90d 30 * H/W Platform :
mbed_official 46:378357d7e90d 31 * Description : RZ/A1H R7S72100 USB Sample Program
mbed_official 46:378357d7e90d 32 * Operation :
mbed_official 46:378357d7e90d 33 * Limitations :
mbed_official 46:378357d7e90d 34 *******************************************************************************/
mbed_official 46:378357d7e90d 35
mbed_official 46:378357d7e90d 36
mbed_official 46:378357d7e90d 37 /*******************************************************************************
mbed_official 46:378357d7e90d 38 Includes <System Includes> , "Project Includes"
mbed_official 46:378357d7e90d 39 *******************************************************************************/
mbed_official 46:378357d7e90d 40 #include "usb1_function.h"
mbed_official 46:378357d7e90d 41
mbed_official 46:378357d7e90d 42
mbed_official 46:378357d7e90d 43 /*******************************************************************************
mbed_official 46:378357d7e90d 44 Typedef definitions
mbed_official 46:378357d7e90d 45 *******************************************************************************/
mbed_official 46:378357d7e90d 46
mbed_official 46:378357d7e90d 47
mbed_official 46:378357d7e90d 48 /*******************************************************************************
mbed_official 46:378357d7e90d 49 Macro definitions
mbed_official 46:378357d7e90d 50 *******************************************************************************/
mbed_official 46:378357d7e90d 51
mbed_official 46:378357d7e90d 52
mbed_official 46:378357d7e90d 53 /*******************************************************************************
mbed_official 46:378357d7e90d 54 Imported global variables and functions (from other files)
mbed_official 46:378357d7e90d 55 *******************************************************************************/
mbed_official 46:378357d7e90d 56
mbed_official 46:378357d7e90d 57
mbed_official 46:378357d7e90d 58 /*******************************************************************************
mbed_official 46:378357d7e90d 59 Exported global variables and functions (to be accessed by other files)
mbed_official 46:378357d7e90d 60 *******************************************************************************/
mbed_official 46:378357d7e90d 61
mbed_official 46:378357d7e90d 62
mbed_official 46:378357d7e90d 63 /*******************************************************************************
mbed_official 46:378357d7e90d 64 Private global variables and functions
mbed_official 46:378357d7e90d 65 *******************************************************************************/
mbed_official 46:378357d7e90d 66
mbed_official 46:378357d7e90d 67
mbed_official 46:378357d7e90d 68 /*******************************************************************************
mbed_official 46:378357d7e90d 69 * Function Name: usb1_function_brdy_int
mbed_official 46:378357d7e90d 70 * Description : Executes BRDY interrupt(USB_FUNCTION_PIPE1-9).
mbed_official 46:378357d7e90d 71 * : According to the pipe that interrupt is generated in,
mbed_official 46:378357d7e90d 72 * : reads/writes buffer allocated in the pipe.
mbed_official 46:378357d7e90d 73 * : This function is executed in the BRDY interrupt handler.
mbed_official 46:378357d7e90d 74 * : This function clears BRDY interrupt status and BEMP interrupt
mbed_official 46:378357d7e90d 75 * : status.
mbed_official 46:378357d7e90d 76 * Arguments : uint16_t Status ; BRDYSTS Register Value
mbed_official 46:378357d7e90d 77 * : uint16_t Int_enbl ; BRDYENB Register Value
mbed_official 46:378357d7e90d 78 * Return Value : none
mbed_official 46:378357d7e90d 79 *******************************************************************************/
mbed_official 46:378357d7e90d 80 #if 0
mbed_official 46:378357d7e90d 81 void usb1_function_brdy_int (uint16_t status, uint16_t int_enb)
mbed_official 46:378357d7e90d 82 {
mbed_official 46:378357d7e90d 83 uint32_t int_sense = 0;
mbed_official 46:378357d7e90d 84 uint16_t pipe;
mbed_official 46:378357d7e90d 85 uint16_t pipebit;
mbed_official 46:378357d7e90d 86
mbed_official 46:378357d7e90d 87 for (pipe = USB_FUNCTION_PIPE1; pipe <= USB_FUNCTION_MAX_PIPE_NO; pipe++)
mbed_official 46:378357d7e90d 88 {
mbed_official 46:378357d7e90d 89 pipebit = g_usb1_function_bit_set[pipe];
mbed_official 46:378357d7e90d 90
mbed_official 46:378357d7e90d 91 if ((status & pipebit) && (int_enb & pipebit))
mbed_official 46:378357d7e90d 92 {
mbed_official 46:378357d7e90d 93 USB201.BRDYSTS = (uint16_t)~pipebit;
mbed_official 46:378357d7e90d 94 USB201.BEMPSTS = (uint16_t)~pipebit;
mbed_official 46:378357d7e90d 95 if ((g_usb1_function_PipeTbl[pipe] & USB_FUNCTION_FIFO_USE) == USB_FUNCTION_D0FIFO_DMA)
mbed_official 46:378357d7e90d 96 {
mbed_official 46:378357d7e90d 97 if (g_usb1_function_DmaStatus[USB_FUNCTION_D0FIFO] != USB_FUNCTION_DMA_READY)
mbed_official 46:378357d7e90d 98 {
mbed_official 46:378357d7e90d 99 usb1_function_dma_interrupt_d0fifo(int_sense);
mbed_official 46:378357d7e90d 100 }
mbed_official 46:378357d7e90d 101
mbed_official 46:378357d7e90d 102 if (RZA_IO_RegRead_16(&g_usb1_function_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 0)
mbed_official 46:378357d7e90d 103 {
mbed_official 46:378357d7e90d 104 usb1_function_read_dma(pipe);
mbed_official 46:378357d7e90d 105 usb1_function_disable_brdy_int(pipe);
mbed_official 46:378357d7e90d 106 }
mbed_official 46:378357d7e90d 107 else
mbed_official 46:378357d7e90d 108 {
mbed_official 46:378357d7e90d 109 USB201.D0FIFOCTR = USB_FUNCTION_BITBCLR;
mbed_official 46:378357d7e90d 110 g_usb1_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_DONE;
mbed_official 46:378357d7e90d 111 }
mbed_official 46:378357d7e90d 112 }
mbed_official 46:378357d7e90d 113 else if ((g_usb1_function_PipeTbl[pipe] & USB_FUNCTION_FIFO_USE) == USB_FUNCTION_D1FIFO_DMA)
mbed_official 46:378357d7e90d 114 {
mbed_official 46:378357d7e90d 115 if (g_usb1_function_DmaStatus[USB_FUNCTION_D1FIFO] != USB_FUNCTION_DMA_READY)
mbed_official 46:378357d7e90d 116 {
mbed_official 46:378357d7e90d 117 usb1_function_dma_interrupt_d1fifo(int_sense);
mbed_official 46:378357d7e90d 118 }
mbed_official 46:378357d7e90d 119
mbed_official 46:378357d7e90d 120 if (RZA_IO_RegRead_16(&g_usb1_function_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 0)
mbed_official 46:378357d7e90d 121 {
mbed_official 46:378357d7e90d 122 usb1_function_read_dma(pipe);
mbed_official 46:378357d7e90d 123 usb1_function_disable_brdy_int(pipe);
mbed_official 46:378357d7e90d 124 }
mbed_official 46:378357d7e90d 125 else
mbed_official 46:378357d7e90d 126 {
mbed_official 46:378357d7e90d 127 USB201.D1FIFOCTR = USB_FUNCTION_BITBCLR;
mbed_official 46:378357d7e90d 128 g_usb1_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_DONE;
mbed_official 46:378357d7e90d 129 }
mbed_official 46:378357d7e90d 130 }
mbed_official 46:378357d7e90d 131 else
mbed_official 46:378357d7e90d 132 {
mbed_official 46:378357d7e90d 133 if (RZA_IO_RegRead_16(&g_usb1_function_pipecfg[pipe], USB_PIPECFG_DIR_SHIFT, USB_PIPECFG_DIR) == 0)
mbed_official 46:378357d7e90d 134 {
mbed_official 46:378357d7e90d 135 usb1_function_read_buffer(pipe);
mbed_official 46:378357d7e90d 136 }
mbed_official 46:378357d7e90d 137 else
mbed_official 46:378357d7e90d 138 {
mbed_official 46:378357d7e90d 139 usb1_function_write_buffer(pipe);
mbed_official 46:378357d7e90d 140 }
mbed_official 46:378357d7e90d 141 }
mbed_official 46:378357d7e90d 142 }
mbed_official 46:378357d7e90d 143 }
mbed_official 46:378357d7e90d 144 }
mbed_official 46:378357d7e90d 145 #endif
mbed_official 46:378357d7e90d 146
mbed_official 46:378357d7e90d 147 /*******************************************************************************
mbed_official 46:378357d7e90d 148 * Function Name: usb1_function_nrdy_int
mbed_official 46:378357d7e90d 149 * Description : Executes NRDY interrupt(USB_FUNCTION_PIPE1-9).
mbed_official 46:378357d7e90d 150 * : Checks NRDY interrupt cause by PID. When the cause if STALL,
mbed_official 46:378357d7e90d 151 * : regards the pipe state as STALL and ends the processing.
mbed_official 46:378357d7e90d 152 * : Then the cause is not STALL, increments the error count to
mbed_official 46:378357d7e90d 153 * : communicate again. When the error count is 3, determines
mbed_official 46:378357d7e90d 154 * : the pipe state as DEVDRV_USBF_PIPE_NORES and ends the processing.
mbed_official 46:378357d7e90d 155 * : This function is executed in the NRDY interrupt handler.
mbed_official 46:378357d7e90d 156 * : This function clears NRDY interrupt status.
mbed_official 46:378357d7e90d 157 * Arguments : uint16_t status ; NRDYSTS Register Value
mbed_official 46:378357d7e90d 158 * : uint16_t int_enb ; NRDYENB Register Value
mbed_official 46:378357d7e90d 159 * Return Value : none
mbed_official 46:378357d7e90d 160 *******************************************************************************/
mbed_official 46:378357d7e90d 161 void usb1_function_nrdy_int (uint16_t status, uint16_t int_enb)
mbed_official 46:378357d7e90d 162 {
mbed_official 46:378357d7e90d 163 uint16_t pid;
mbed_official 46:378357d7e90d 164 uint16_t pipe;
mbed_official 46:378357d7e90d 165 uint16_t bitcheck;
mbed_official 46:378357d7e90d 166
mbed_official 46:378357d7e90d 167 bitcheck = (uint16_t)(status & int_enb);
mbed_official 46:378357d7e90d 168
mbed_official 46:378357d7e90d 169 USB201.NRDYSTS = (uint16_t)~status;
mbed_official 46:378357d7e90d 170
mbed_official 46:378357d7e90d 171 for (pipe = USB_FUNCTION_PIPE1; pipe <= USB_FUNCTION_MAX_PIPE_NO; pipe++)
mbed_official 46:378357d7e90d 172 {
mbed_official 46:378357d7e90d 173 if ((bitcheck&g_usb1_function_bit_set[pipe]) == g_usb1_function_bit_set[pipe])
mbed_official 46:378357d7e90d 174 {
mbed_official 46:378357d7e90d 175 if (RZA_IO_RegRead_16(&USB201.SYSCFG0, USB_SYSCFG_DCFM_SHIFT, USB_SYSCFG_DCFM) == 1)
mbed_official 46:378357d7e90d 176 {
mbed_official 46:378357d7e90d 177 if (g_usb1_function_pipe_status[pipe] == DEVDRV_USBF_PIPE_WAIT)
mbed_official 46:378357d7e90d 178 {
mbed_official 46:378357d7e90d 179 pid = usb1_function_get_pid(pipe);
mbed_official 46:378357d7e90d 180 if ((pid == DEVDRV_USBF_PID_STALL) || (pid == DEVDRV_USBF_PID_STALL2))
mbed_official 46:378357d7e90d 181 {
mbed_official 46:378357d7e90d 182 g_usb1_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_STALL;
mbed_official 46:378357d7e90d 183 }
mbed_official 46:378357d7e90d 184 else
mbed_official 46:378357d7e90d 185 {
mbed_official 46:378357d7e90d 186 g_usb1_function_PipeIgnore[pipe]++;
mbed_official 46:378357d7e90d 187 if (g_usb1_function_PipeIgnore[pipe] == 3)
mbed_official 46:378357d7e90d 188 {
mbed_official 46:378357d7e90d 189 g_usb1_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_NORES;
mbed_official 46:378357d7e90d 190 }
mbed_official 46:378357d7e90d 191 else
mbed_official 46:378357d7e90d 192 {
mbed_official 46:378357d7e90d 193 usb1_function_set_pid_buf(pipe);
mbed_official 46:378357d7e90d 194 }
mbed_official 46:378357d7e90d 195 }
mbed_official 46:378357d7e90d 196 }
mbed_official 46:378357d7e90d 197 }
mbed_official 46:378357d7e90d 198 else
mbed_official 46:378357d7e90d 199 {
mbed_official 46:378357d7e90d 200 /* USB Function */
mbed_official 46:378357d7e90d 201 }
mbed_official 46:378357d7e90d 202 }
mbed_official 46:378357d7e90d 203 }
mbed_official 46:378357d7e90d 204 }
mbed_official 46:378357d7e90d 205
mbed_official 46:378357d7e90d 206 /*******************************************************************************
mbed_official 46:378357d7e90d 207 * Function Name: usb1_function_bemp_int
mbed_official 46:378357d7e90d 208 * Description : Executes BEMP interrupt(USB_FUNCTION_PIPE1-9).
mbed_official 46:378357d7e90d 209 * Arguments : uint16_t status ; BEMPSTS Register Value
mbed_official 46:378357d7e90d 210 * : uint16_t int_enb ; BEMPENB Register Value
mbed_official 46:378357d7e90d 211 * Return Value : none
mbed_official 46:378357d7e90d 212 *******************************************************************************/
mbed_official 46:378357d7e90d 213 void usb1_function_bemp_int (uint16_t status, uint16_t int_enb)
mbed_official 46:378357d7e90d 214 {
mbed_official 46:378357d7e90d 215 uint16_t pid;
mbed_official 46:378357d7e90d 216 uint16_t pipe;
mbed_official 46:378357d7e90d 217 uint16_t bitcheck;
mbed_official 46:378357d7e90d 218 uint16_t inbuf;
mbed_official 46:378357d7e90d 219
mbed_official 46:378357d7e90d 220 bitcheck = (uint16_t)(status & int_enb);
mbed_official 46:378357d7e90d 221
mbed_official 46:378357d7e90d 222 USB201.BEMPSTS = (uint16_t)~status;
mbed_official 46:378357d7e90d 223
mbed_official 46:378357d7e90d 224 for (pipe = USB_FUNCTION_PIPE1; pipe <= USB_FUNCTION_MAX_PIPE_NO; pipe++)
mbed_official 46:378357d7e90d 225 {
mbed_official 46:378357d7e90d 226 if ((bitcheck&g_usb1_function_bit_set[pipe]) == g_usb1_function_bit_set[pipe])
mbed_official 46:378357d7e90d 227 {
mbed_official 46:378357d7e90d 228 pid = usb1_function_get_pid(pipe);
mbed_official 46:378357d7e90d 229
mbed_official 46:378357d7e90d 230 if ((pid == DEVDRV_USBF_PID_STALL) || (pid == DEVDRV_USBF_PID_STALL2))
mbed_official 46:378357d7e90d 231 {
mbed_official 46:378357d7e90d 232 g_usb1_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_STALL;
mbed_official 46:378357d7e90d 233 }
mbed_official 46:378357d7e90d 234 else
mbed_official 46:378357d7e90d 235 {
mbed_official 46:378357d7e90d 236 inbuf = usb1_function_get_inbuf(pipe);
mbed_official 46:378357d7e90d 237
mbed_official 46:378357d7e90d 238 if (inbuf == 0)
mbed_official 46:378357d7e90d 239 {
mbed_official 46:378357d7e90d 240 usb1_function_disable_bemp_int(pipe);
mbed_official 46:378357d7e90d 241 usb1_function_set_pid_nak(pipe);
mbed_official 46:378357d7e90d 242 g_usb1_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_DONE;
mbed_official 46:378357d7e90d 243 }
mbed_official 46:378357d7e90d 244 }
mbed_official 46:378357d7e90d 245 }
mbed_official 46:378357d7e90d 246 }
mbed_official 46:378357d7e90d 247 }
mbed_official 46:378357d7e90d 248
mbed_official 46:378357d7e90d 249 /* End of File */