I changed one line of code in the file with path name: USBDeviceHT/targets/TARGET_Maxim

Fork of USBDeviceHT by Helmut Tschemernjak

Committer:
dev_alexander
Date:
Fri Jun 01 21:43:55 2018 +0000
Revision:
6:c1f162fd7777
Parent:
0:a3ea811f80f2
Fixed Error with code not compiling due to an issue with there not being a (uint32_t) cast of a (void) pointer. Maxim was the only mbed vendor to not have this one (uint32_t) cast in the spot it was added to. Look into public repos for similar cases.

Who changed what in which revision?

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