キーボードの長押しに対応。
Fork of USBDevice by
USBDevice/TARGET_RENESAS/TARGET_VK_RZ_A1H/usb0/src/common/usb0_function_intrn.c@62:c1549af978d6, 2016-04-29 (annotated)
- 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?
User | Revision | Line number | New 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_intrn.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_function_brdy_int |
mbed_official | 62:c1549af978d6 | 70 | * Description : Executes BRDY interrupt(USB_FUNCTION_PIPE1-9). |
mbed_official | 62:c1549af978d6 | 71 | * : According to the pipe that interrupt is generated in, |
mbed_official | 62:c1549af978d6 | 72 | * : reads/writes buffer allocated in the pipe. |
mbed_official | 62:c1549af978d6 | 73 | * : This function is executed in the BRDY interrupt handler. |
mbed_official | 62:c1549af978d6 | 74 | * : This function clears BRDY interrupt status and BEMP interrupt |
mbed_official | 62:c1549af978d6 | 75 | * : status. |
mbed_official | 62:c1549af978d6 | 76 | * Arguments : uint16_t Status ; BRDYSTS Register Value |
mbed_official | 62:c1549af978d6 | 77 | * : uint16_t Int_enbl ; BRDYENB Register Value |
mbed_official | 62:c1549af978d6 | 78 | * Return Value : none |
mbed_official | 62:c1549af978d6 | 79 | *******************************************************************************/ |
mbed_official | 62:c1549af978d6 | 80 | #if 0 |
mbed_official | 62:c1549af978d6 | 81 | void usb0_function_brdy_int (uint16_t status, uint16_t int_enb) |
mbed_official | 62:c1549af978d6 | 82 | { |
mbed_official | 62:c1549af978d6 | 83 | uint32_t int_sense = 0; |
mbed_official | 62:c1549af978d6 | 84 | uint16_t pipe; |
mbed_official | 62:c1549af978d6 | 85 | uint16_t pipebit; |
mbed_official | 62:c1549af978d6 | 86 | |
mbed_official | 62:c1549af978d6 | 87 | for (pipe = USB_FUNCTION_PIPE1; pipe <= USB_FUNCTION_MAX_PIPE_NO; pipe++) |
mbed_official | 62:c1549af978d6 | 88 | { |
mbed_official | 62:c1549af978d6 | 89 | pipebit = g_usb0_function_bit_set[pipe]; |
mbed_official | 62:c1549af978d6 | 90 | |
mbed_official | 62:c1549af978d6 | 91 | if ((status & pipebit) && (int_enb & pipebit)) |
mbed_official | 62:c1549af978d6 | 92 | { |
mbed_official | 62:c1549af978d6 | 93 | USB200.BRDYSTS = (uint16_t)~pipebit; |
mbed_official | 62:c1549af978d6 | 94 | USB200.BEMPSTS = (uint16_t)~pipebit; |
mbed_official | 62:c1549af978d6 | 95 | if ((g_usb0_function_PipeTbl[pipe] & USB_FUNCTION_FIFO_USE) == USB_FUNCTION_D0FIFO_DMA) |
mbed_official | 62:c1549af978d6 | 96 | { |
mbed_official | 62:c1549af978d6 | 97 | if (g_usb0_function_DmaStatus[USB_FUNCTION_D0FIFO] != USB_FUNCTION_DMA_READY) |
mbed_official | 62:c1549af978d6 | 98 | { |
mbed_official | 62:c1549af978d6 | 99 | usb0_function_dma_interrupt_d0fifo(int_sense); |
mbed_official | 62:c1549af978d6 | 100 | } |
mbed_official | 62:c1549af978d6 | 101 | |
mbed_official | 62:c1549af978d6 | 102 | if (RZA_IO_RegRead_16(&g_usb0_function_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 0) |
mbed_official | 62:c1549af978d6 | 103 | { |
mbed_official | 62:c1549af978d6 | 104 | usb0_function_read_dma(pipe); |
mbed_official | 62:c1549af978d6 | 105 | usb0_function_disable_brdy_int(pipe); |
mbed_official | 62:c1549af978d6 | 106 | } |
mbed_official | 62:c1549af978d6 | 107 | else |
mbed_official | 62:c1549af978d6 | 108 | { |
mbed_official | 62:c1549af978d6 | 109 | USB200.D0FIFOCTR = USB_FUNCTION_BITBCLR; |
mbed_official | 62:c1549af978d6 | 110 | g_usb0_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_DONE; |
mbed_official | 62:c1549af978d6 | 111 | } |
mbed_official | 62:c1549af978d6 | 112 | } |
mbed_official | 62:c1549af978d6 | 113 | else if ((g_usb0_function_PipeTbl[pipe] & USB_FUNCTION_FIFO_USE) == USB_FUNCTION_D1FIFO_DMA) |
mbed_official | 62:c1549af978d6 | 114 | { |
mbed_official | 62:c1549af978d6 | 115 | if (g_usb0_function_DmaStatus[USB_FUNCTION_D1FIFO] != USB_FUNCTION_DMA_READY) |
mbed_official | 62:c1549af978d6 | 116 | { |
mbed_official | 62:c1549af978d6 | 117 | usb0_function_dma_interrupt_d1fifo(int_sense); |
mbed_official | 62:c1549af978d6 | 118 | } |
mbed_official | 62:c1549af978d6 | 119 | |
mbed_official | 62:c1549af978d6 | 120 | if (RZA_IO_RegRead_16(&g_usb0_function_pipecfg[pipe], USB_PIPECFG_BFRE_SHIFT, USB_PIPECFG_BFRE) == 0) |
mbed_official | 62:c1549af978d6 | 121 | { |
mbed_official | 62:c1549af978d6 | 122 | usb0_function_read_dma(pipe); |
mbed_official | 62:c1549af978d6 | 123 | usb0_function_disable_brdy_int(pipe); |
mbed_official | 62:c1549af978d6 | 124 | } |
mbed_official | 62:c1549af978d6 | 125 | else |
mbed_official | 62:c1549af978d6 | 126 | { |
mbed_official | 62:c1549af978d6 | 127 | USB200.D1FIFOCTR = USB_FUNCTION_BITBCLR; |
mbed_official | 62:c1549af978d6 | 128 | g_usb0_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_DONE; |
mbed_official | 62:c1549af978d6 | 129 | } |
mbed_official | 62:c1549af978d6 | 130 | } |
mbed_official | 62:c1549af978d6 | 131 | else |
mbed_official | 62:c1549af978d6 | 132 | { |
mbed_official | 62:c1549af978d6 | 133 | if (RZA_IO_RegRead_16(&g_usb0_function_pipecfg[pipe], USB_PIPECFG_DIR_SHIFT, USB_PIPECFG_DIR) == 0) |
mbed_official | 62:c1549af978d6 | 134 | { |
mbed_official | 62:c1549af978d6 | 135 | usb0_function_read_buffer(pipe); |
mbed_official | 62:c1549af978d6 | 136 | } |
mbed_official | 62:c1549af978d6 | 137 | else |
mbed_official | 62:c1549af978d6 | 138 | { |
mbed_official | 62:c1549af978d6 | 139 | usb0_function_write_buffer(pipe); |
mbed_official | 62:c1549af978d6 | 140 | } |
mbed_official | 62:c1549af978d6 | 141 | } |
mbed_official | 62:c1549af978d6 | 142 | } |
mbed_official | 62:c1549af978d6 | 143 | } |
mbed_official | 62:c1549af978d6 | 144 | } |
mbed_official | 62:c1549af978d6 | 145 | #endif |
mbed_official | 62:c1549af978d6 | 146 | |
mbed_official | 62:c1549af978d6 | 147 | /******************************************************************************* |
mbed_official | 62:c1549af978d6 | 148 | * Function Name: usb0_function_nrdy_int |
mbed_official | 62:c1549af978d6 | 149 | * Description : Executes NRDY interrupt(USB_FUNCTION_PIPE1-9). |
mbed_official | 62:c1549af978d6 | 150 | * : Checks NRDY interrupt cause by PID. When the cause if STALL, |
mbed_official | 62:c1549af978d6 | 151 | * : regards the pipe state as STALL and ends the processing. |
mbed_official | 62:c1549af978d6 | 152 | * : Then the cause is not STALL, increments the error count to |
mbed_official | 62:c1549af978d6 | 153 | * : communicate again. When the error count is 3, determines |
mbed_official | 62:c1549af978d6 | 154 | * : the pipe state as DEVDRV_USBF_PIPE_NORES and ends the processing. |
mbed_official | 62:c1549af978d6 | 155 | * : This function is executed in the NRDY interrupt handler. |
mbed_official | 62:c1549af978d6 | 156 | * : This function clears NRDY interrupt status. |
mbed_official | 62:c1549af978d6 | 157 | * Arguments : uint16_t status ; NRDYSTS Register Value |
mbed_official | 62:c1549af978d6 | 158 | * : uint16_t int_enb ; NRDYENB Register Value |
mbed_official | 62:c1549af978d6 | 159 | * Return Value : none |
mbed_official | 62:c1549af978d6 | 160 | *******************************************************************************/ |
mbed_official | 62:c1549af978d6 | 161 | void usb0_function_nrdy_int (uint16_t status, uint16_t int_enb) |
mbed_official | 62:c1549af978d6 | 162 | { |
mbed_official | 62:c1549af978d6 | 163 | uint16_t pid; |
mbed_official | 62:c1549af978d6 | 164 | uint16_t pipe; |
mbed_official | 62:c1549af978d6 | 165 | uint16_t bitcheck; |
mbed_official | 62:c1549af978d6 | 166 | |
mbed_official | 62:c1549af978d6 | 167 | bitcheck = (uint16_t)(status & int_enb); |
mbed_official | 62:c1549af978d6 | 168 | |
mbed_official | 62:c1549af978d6 | 169 | USB200.NRDYSTS = (uint16_t)~status; |
mbed_official | 62:c1549af978d6 | 170 | |
mbed_official | 62:c1549af978d6 | 171 | for (pipe = USB_FUNCTION_PIPE1; pipe <= USB_FUNCTION_MAX_PIPE_NO; pipe++) |
mbed_official | 62:c1549af978d6 | 172 | { |
mbed_official | 62:c1549af978d6 | 173 | if ((bitcheck&g_usb0_function_bit_set[pipe]) == g_usb0_function_bit_set[pipe]) |
mbed_official | 62:c1549af978d6 | 174 | { |
mbed_official | 62:c1549af978d6 | 175 | if (RZA_IO_RegRead_16(&USB200.SYSCFG0, USB_SYSCFG_DCFM_SHIFT, USB_SYSCFG_DCFM) == 1) |
mbed_official | 62:c1549af978d6 | 176 | { |
mbed_official | 62:c1549af978d6 | 177 | if (g_usb0_function_pipe_status[pipe] == DEVDRV_USBF_PIPE_WAIT) |
mbed_official | 62:c1549af978d6 | 178 | { |
mbed_official | 62:c1549af978d6 | 179 | pid = usb0_function_get_pid(pipe); |
mbed_official | 62:c1549af978d6 | 180 | if ((pid == DEVDRV_USBF_PID_STALL) || (pid == DEVDRV_USBF_PID_STALL2)) |
mbed_official | 62:c1549af978d6 | 181 | { |
mbed_official | 62:c1549af978d6 | 182 | g_usb0_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_STALL; |
mbed_official | 62:c1549af978d6 | 183 | } |
mbed_official | 62:c1549af978d6 | 184 | else |
mbed_official | 62:c1549af978d6 | 185 | { |
mbed_official | 62:c1549af978d6 | 186 | g_usb0_function_PipeIgnore[pipe]++; |
mbed_official | 62:c1549af978d6 | 187 | if (g_usb0_function_PipeIgnore[pipe] == 3) |
mbed_official | 62:c1549af978d6 | 188 | { |
mbed_official | 62:c1549af978d6 | 189 | g_usb0_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_NORES; |
mbed_official | 62:c1549af978d6 | 190 | } |
mbed_official | 62:c1549af978d6 | 191 | else |
mbed_official | 62:c1549af978d6 | 192 | { |
mbed_official | 62:c1549af978d6 | 193 | usb0_function_set_pid_buf(pipe); |
mbed_official | 62:c1549af978d6 | 194 | } |
mbed_official | 62:c1549af978d6 | 195 | } |
mbed_official | 62:c1549af978d6 | 196 | } |
mbed_official | 62:c1549af978d6 | 197 | } |
mbed_official | 62:c1549af978d6 | 198 | else |
mbed_official | 62:c1549af978d6 | 199 | { |
mbed_official | 62:c1549af978d6 | 200 | /* USB Function */ |
mbed_official | 62:c1549af978d6 | 201 | } |
mbed_official | 62:c1549af978d6 | 202 | } |
mbed_official | 62:c1549af978d6 | 203 | } |
mbed_official | 62:c1549af978d6 | 204 | } |
mbed_official | 62:c1549af978d6 | 205 | |
mbed_official | 62:c1549af978d6 | 206 | /******************************************************************************* |
mbed_official | 62:c1549af978d6 | 207 | * Function Name: usb0_function_bemp_int |
mbed_official | 62:c1549af978d6 | 208 | * Description : Executes BEMP interrupt(USB_FUNCTION_PIPE1-9). |
mbed_official | 62:c1549af978d6 | 209 | * Arguments : uint16_t status ; BEMPSTS Register Value |
mbed_official | 62:c1549af978d6 | 210 | * : uint16_t int_enb ; BEMPENB Register Value |
mbed_official | 62:c1549af978d6 | 211 | * Return Value : none |
mbed_official | 62:c1549af978d6 | 212 | *******************************************************************************/ |
mbed_official | 62:c1549af978d6 | 213 | void usb0_function_bemp_int (uint16_t status, uint16_t int_enb) |
mbed_official | 62:c1549af978d6 | 214 | { |
mbed_official | 62:c1549af978d6 | 215 | uint16_t pid; |
mbed_official | 62:c1549af978d6 | 216 | uint16_t pipe; |
mbed_official | 62:c1549af978d6 | 217 | uint16_t bitcheck; |
mbed_official | 62:c1549af978d6 | 218 | uint16_t inbuf; |
mbed_official | 62:c1549af978d6 | 219 | |
mbed_official | 62:c1549af978d6 | 220 | bitcheck = (uint16_t)(status & int_enb); |
mbed_official | 62:c1549af978d6 | 221 | |
mbed_official | 62:c1549af978d6 | 222 | USB200.BEMPSTS = (uint16_t)~status; |
mbed_official | 62:c1549af978d6 | 223 | |
mbed_official | 62:c1549af978d6 | 224 | for (pipe = USB_FUNCTION_PIPE1; pipe <= USB_FUNCTION_MAX_PIPE_NO; pipe++) |
mbed_official | 62:c1549af978d6 | 225 | { |
mbed_official | 62:c1549af978d6 | 226 | if ((bitcheck&g_usb0_function_bit_set[pipe]) == g_usb0_function_bit_set[pipe]) |
mbed_official | 62:c1549af978d6 | 227 | { |
mbed_official | 62:c1549af978d6 | 228 | pid = usb0_function_get_pid(pipe); |
mbed_official | 62:c1549af978d6 | 229 | |
mbed_official | 62:c1549af978d6 | 230 | if ((pid == DEVDRV_USBF_PID_STALL) || (pid == DEVDRV_USBF_PID_STALL2)) |
mbed_official | 62:c1549af978d6 | 231 | { |
mbed_official | 62:c1549af978d6 | 232 | g_usb0_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_STALL; |
mbed_official | 62:c1549af978d6 | 233 | } |
mbed_official | 62:c1549af978d6 | 234 | else |
mbed_official | 62:c1549af978d6 | 235 | { |
mbed_official | 62:c1549af978d6 | 236 | inbuf = usb0_function_get_inbuf(pipe); |
mbed_official | 62:c1549af978d6 | 237 | |
mbed_official | 62:c1549af978d6 | 238 | if (inbuf == 0) |
mbed_official | 62:c1549af978d6 | 239 | { |
mbed_official | 62:c1549af978d6 | 240 | usb0_function_disable_bemp_int(pipe); |
mbed_official | 62:c1549af978d6 | 241 | usb0_function_set_pid_nak(pipe); |
mbed_official | 62:c1549af978d6 | 242 | g_usb0_function_pipe_status[pipe] = DEVDRV_USBF_PIPE_DONE; |
mbed_official | 62:c1549af978d6 | 243 | } |
mbed_official | 62:c1549af978d6 | 244 | } |
mbed_official | 62:c1549af978d6 | 245 | } |
mbed_official | 62:c1549af978d6 | 246 | } |
mbed_official | 62:c1549af978d6 | 247 | } |
mbed_official | 62:c1549af978d6 | 248 | |
mbed_official | 62:c1549af978d6 | 249 | /* End of File */ |