├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── Win10-Drivers.zip ├── cyprflash ├── CyBootProgrammer.img ├── Makefile ├── compile.bat ├── cyprflash.c ├── cyprflash.exe └── streaming_image.img ├── fx3view ├── Makefile ├── compile.bat └── fx3view.c ├── isotest ├── Makefile ├── charles-streamer │ └── reference │ │ ├── CyUSB30_def.h │ │ ├── UsbdStatus.h │ │ ├── VersionNo.h │ │ ├── ccyusb_c_bindings.h │ │ ├── cyioctl.h │ │ ├── usb100.h │ │ └── usb200.h ├── compile.bat ├── os_generic.c ├── os_generic.h ├── recstream.c ├── recstream.exe ├── teststream.c └── teststream.exe ├── latencytest ├── Makefile ├── compile.bat ├── latencytest.c └── os_generic.h ├── libcyprio ├── cyprio_aux.h ├── cyprio_usb100.h ├── libcyprio.c ├── libcyprio.h └── libcyprio_util.c └── testproject ├── .gitignore ├── .metadata └── .plugins │ └── org.eclipse.core.runtime │ └── .settings │ ├── org.eclipse.cdt.debug.core.prefs │ ├── org.eclipse.debug.core.prefs │ └── org.eclipse.debug.ui.prefs └── USBIsoSource ├── .cproject ├── .gitignore ├── .project ├── .settings └── language.settings.xml ├── Makefile ├── Release └── USBIsoSource.img ├── complex_gpif2.cydsn ├── complex_gpif2.cyfx ├── cyfxgpif2config_complex.h └── projectfiles │ ├── gpif2model.xml │ ├── gpif2timingsimulation.xml │ └── gpif2view.xml ├── complex_gpif_load.c ├── cyfx_gcc_startup.S ├── cyfxisodscr.c ├── cyfxisosrc.c ├── cyfxisosrc.h ├── cyfxtx.c ├── fast_gpif2.cydsn ├── cyfxgpif2config.h ├── fast_gpif2.cyfx └── projectfiles │ ├── gpif2model.xml │ ├── gpif2timingsimulation.xml │ └── gpif2view.xml └── readme.txt /.gitignore: -------------------------------------------------------------------------------- 1 | isotest/CyAPI.cpp 2 | isotest/data.dat -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "fx3view/rawdraw"] 2 | path = fx3view/rawdraw 3 | url = https://github.com/cnlohr/rawdraw 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2017, CNLohr 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # fx3fun 2 | Treat your Cypress FX3 a little like a logic analyzer or realtime software defined bus. Specifically I'm interested in the CYUSB3011-BZXC/CYUSB3012. 3 | 4 | I'm trying to turn it into a logic analyzer. I've been playing with a kit, specifically the $45 http://www.cypress.com/documentation/development-kitsboards/cyusb3kit-003-ez-usb-fx3-superspeed-explorer-kit - and I've found it to be incredibly powerful. This project is split up into a few components. 5 | 6 | (1) The Firmware: It is firmware that turns the GPIF-II bus into a 16-bit, 100 MHz sampling device. Synchronously receiving data and storing it in a buffer to stream back to a computer. My firmware sets up the isochronous pipes in such a way to transfer data back at about 250 MB/s. Also, control messages are really easy to send, so this could also be a really useful tool for programming chips, too! Currently, I'm still using the Windows tools to compile, but shouldn't be hard to use GCC ARM to compile in Linux, especially with the Official Cypress SDK. 7 | 8 | (2) CyprIO (pronounced saɪˈpirˈēˈō): My C-library for use in Windows (with CyUSB32.sys) or Linux (with libusb) that lets you talk to my firmware on the cpress chip. Originally Cypress offered a CyAPI that let you use C++ to talk to their parts, but in digging into it, I found that it was extremely overbearing, and just not a good fit for many of the projects I wanted. Speicifically, more library-style operations, i.e. introducing into sigrok, etc. So, I re-wrote it, in C. Also, a side benefit of this is you can compile it and use it in Windows with only TCC (a 6MB package). All header files needed to compile are included. No Visual Studio needed or anything. 9 | 10 | The PC-side software works in Windows (TCC) or Linux (GCC). Test in both as of Dec 31, 2017. Who knows if it'll keep working. 11 | 12 | (3) isotest - make control transfer to start sampling GPIF bus and receives data coming back. (Uses CyprIO) 13 | 14 | (4) cyprflash - tool that uses CyprIO to boot images on the FX3, and potentially flash a tool that allows writing to an I2C EEPROM on-board, using the official cypress flasher firmware. NOTE: Shouldn't be hard to support an SPI EEPROM, but I don't have a board with SPI EEPROM to test against. 15 | 16 | [![Cypress FX3 as a Possible Logic Analyzer](https://img.youtube.com/vi/_LnZrXrdC00/0.jpg)](https://www.youtube.com/watch?v=_LnZrXrdC00) 17 | 18 | 19 | # Brief installation notes. 20 | 21 | * git clone this repo somewhere. 22 | * Download they Cypress EZ-USB FX3 SDK for Linux from here: https://www.cypress.com/documentation/software-and-drivers/ez-usb-fx3-software-development-kit 23 | * You will find "fx3_firmware_linux.tar.gz" and you can take that and drop "cyfx3sdk" in the same folder that "fx3fun" is located in, so they are parallel. 24 | * Make a folder in your home folder called `Cypress` 25 | * Unzip, from the SDK the following folders into `Cypress` 26 | * `arm-2013.11` 27 | * `cyusb_linux_1.0.5` 28 | * `eclipse` * I don't think this is required. 29 | 30 | Add the following to your .bashrc 31 | 32 | ``` 33 | export PATH=$PATH:$HOME/Cypress/arm-2013.11/bin 34 | export FX3_INSTALL_PATH=$HOME/Cypress/cyfx3sdk 35 | export ARMGCC_INSTALL_PATH=$HOME/Cypress/arm-2013.11 36 | export ARMGCC_VERSION=4.8.1 37 | export CYUSB_ROOT=$HOME/Cypress/cyusb_linux_1.0.4 38 | ``` 39 | * `. ~/.bashrc` 40 | * Optional if you want to build the firmware: 41 | * `cd fx3fun/testproject/USBIsoSource` 42 | * `make` 43 | * cp ?????? TODO: How to do firmware? BIG TODO: No, really how do you actually make the firmware? 44 | * On Windows it looks like it uses `elf2img.exe` 45 | * `cd ../../` 46 | * `cd cyprflash` 47 | * `make` 48 | * Hold the PMODE jumper shorted. 49 | * `sudo ./cyprflash -i -f streaming_image.img` 50 | * `cd ..` 51 | * Reboot board, make sure it's up: 52 | * `lsusb -vv -d 04b4:00f1` 53 | * ISO Test 54 | * `cd isotest` 55 | * 56 | 57 | 58 | # Licensing 59 | 60 | Though everything I am writing may be licensed under the MIT/x11 license OR the NewBSD license (Both of which are compaible with the GPL/LGPL/AFL), there remain some questions about compiling against the Cypress API. I am still looking into this but hope to clear up questions regarding this soon. 61 | 62 | ## Project Log 63 | 64 | Dec 25, 2017: 65 | 66 | I got a Windows 10 PC for once in my life, and decided to dust off the Cypress FX3 Devkit I got two years ago. 67 | 68 | Reading Appnote about getting started: http://www.cypress.com/documentation/application-notes/an75705-getting-started-ez-usb-fx3 - specifically the PDF http://www.cypress.com/file/139296/download 69 | 70 | Install the: http://www.cypress.com/documentation/software-and-drivers/ez-usb-fx3-software-development-kit 71 | 72 | Oh wait... it supports Linux (Rebooting to Linux) 73 | 74 | Ok, installing "Download EZ-USB FX3 SDK v1.3.3 for Linux" ... WOW 413 MB is kinda big for something as tiny as I'd expect this to be. 75 | 76 | ```sudo apt-get install lib32z1 qt4-qmake qt4-dev-tools qt4-linguist-tools qt-sdk libusb-1.0-0-dev eclipse-platform``` 77 | 78 | Follow installion procedure in http://www.cypress.com/system/files/document/files/FX3_SDK_Linux_Support_0.pdf 79 | 80 | Untar contents of all .tar.gz's embedded in the main .tar.gz downloaded to ~/Cypress 81 | 82 | Add to .bashrc, the following: 83 | 84 | ``` 85 | export PATH=$PATH:$HOME/Cypress/arm-2013.11/bin 86 | export FX3_INSTALL_PATH=$HOME/Cypress/cyfx3sdk 87 | export ARMGCC_INSTALL_PATH=$HOME/Cypress/arm-2013.11 88 | export ARMGCC_VERSION=4.8.1 89 | export CYUSB_ROOT=$HOME/Cypress/cyusb_linux_1.0.4 90 | ``` 91 | 92 | Open new terminal. 93 | ``` 94 | cd $FX3_INSTALL_PATH/util/elf2img 95 | gcc elf2img.c -o elf2img -Wall 96 | ``` 97 | 98 | Then 99 | ``` 100 | cd ~/Cypress/cyusb_linux_1.0.4 101 | make 102 | sudo ./install.sh 103 | ``` 104 | 105 | 106 | Now, I'm reading ```~/Cypress/cyfx3sdk/doc/firmware/GettingStartedWithFX3SDK.pdf``` 107 | 108 | Err... then I noticed https://community.cypress.com/thread/18526 ... say no Linux support for the GPIF-II designer (Which is a critical component) why on earth would they bother releasing a Linux ... 109 | 110 | They recommend mono? 111 | 112 | 113 | 114 | BACK ON TRACK 115 | 116 | Go get this thing... (I may not use it?) 117 | 118 | VVV Note added later... I don't think the thing here is useful at all. 119 | ``` 120 | cd ~/Cypress 121 | git clone https://github.com/nickdademo/cyfwstorprog_linux 122 | make 123 | ``` 124 | 125 | ``` 126 | cd ~/Cypress/cyusb_linux_1.0.4/bin 127 | sudo ./cyusb_linux 128 | ``` 129 | 130 | (Make sure it works) 131 | 132 | Open the SDK. 133 | 134 | ``` 135 | cd ~/Cypress/eclipse 136 | ./ezUsbSuite 137 | ``` 138 | 139 | New workspace in: /home/cnlohr/Cypress/test_workspace 140 | 141 | Ok, the GPIF button is greyed out. This is lame. Switch back to Windows. 142 | 143 | In Windows, get and install... http://www.cypress.com/file/139276 ... COMPLETE Installation. 144 | 145 | Run C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\Eclipse 146 | 147 | Make project at C:\projects\fx3fun\testproject 148 | 149 | Ok. Seriously. Why is the GPIF Designer button still grey. I gotta figure out how to build a simple project. I've been at this for almost an hour. 150 | 151 | Back to the getting started tab. http://www.cypress.com/file/139296/download 152 | 153 | Create a new project with the eclipse thing at C:\projects\fx3fun\testproject ... 154 | 155 | File -> Import... "General" "Existing Projects" C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\gpif_examples\cyfxsrammaster + MAKE SURE TO click "copy project into workspace" 156 | 157 | Build release version. 158 | 159 | C:\projects\fx3fun\testproject\SRAMMaster\Release\SRAMMaster.img now exists. 160 | 161 | Run C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\bin\CyControl.exe 162 | 163 | Make sure J4 and J3 are on. Burn to ram the image file. 164 | 165 | Maybe that worked? 166 | 167 | Looks like it _probably_ did, however, I think I want a debugger so I can get printf messages. 168 | 169 | How do I do this debug thing. Connecting to COM5 with 115,200 doesn't show anything, even on the debug firmware, though it seems to with the defualt firmware. 170 | 171 | I added a CyU3PDebugPrint command. Works like a charm.. 172 | 173 | ``` 174 | static void 175 | SRAMAppThread_Entry ( 176 | uint32_t input) 177 | { 178 | /* Initialize the debug module */ 179 | CyFxSRAMApplnDebugInit (); 180 | CyU3PDebugPrint (CY_FX_DEBUG_PRIORITY, "Debug Test\n" ); 181 | ``` 182 | 183 | I SEE IT!!! 184 | 185 | Ok. We're cruising now. 186 | 187 | Got it. The cyfxsrammaster project was cool... But, let's first see if we can actually talk to an app via USB 3.0. Maybe some sort of speed test to make sure we can sustain the needed speeds? 188 | 189 | Delete that project. 190 | 191 | Try File->Import... General/Existing "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\basic_examples\cyfxisosrc" I want an isochronous source! (Don't forget to check the copy workspace box.) 192 | 193 | Build and flash (in debug) 194 | 195 | Fire up "streamer.exe" from C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\bin 196 | 197 | Osnap. It works. Fast. My computer seems to handle 256MB/s pretty well. Our target is 200MB/s, so I'd say we're doing pretty good. 198 | 199 | Their app is all C++'d up... So, I am looking through the code for it as well as this... https://github.com/Cornell-RPAL/occam/blob/master/indigosdk-2.0.15/third/cyusb/CyAPI.cpp 200 | 201 | Their code is called with ```USBDevice = new CCyUSBDevice((HANDLE)this->Handle,CYUSBDRV_GUID,true);``` 202 | 203 | Yep... totally ripping it off... slowly. Spent 2 hours so far... Now, I can at least get a handle to the device. Still need to start sending it control messages to set up the isochronous endpoint. 204 | 205 | Maybe tomorrow? 206 | 207 | Then, who knows! 208 | 209 | 12/26/2017: 210 | 211 | Spent another hour working away with my teststream.c thing... Then started to wonder if libUSB could be leveraged... Tempting... 212 | 213 | I'll keep chugging away for a bit, I guess. 214 | 215 | Still going after about 6 hours. Time to take a break. Was mostly just converting over code to CyprIO. 216 | 217 | NEAT! The very first time after it compiled, it ran! Committing. 218 | 219 | Only getting 12 MB/sec, though. I think it's cause I'm creating and deleting all my transfers. 220 | 221 | TODO: Where are we doing the equivelent of if (USBDevice->SetAltIntfc(i) == true )? 222 | 223 | AH! Looking at Streamer.h they do their own custom function to get data that queues up a bunch of buffers. 224 | 225 | We shall do the same. 226 | 227 | Man, I'm glad I didn't give up and go another route right now. 228 | 229 | Well, computer just did the Win10 equivelent of bluescreening and I lost one of my source files. Thankfully it only took ~15 mins to edit from the last git commit. 230 | 231 | Gotta start git committing more frequently. 232 | 233 | AWW MAN YEAAAAAAAA. Turns out was an uninitialized value. P.S. Neat article. Need to be careful about the overlapped structures. https://blogs.msdn.microsoft.com/oldnewthing/20110202-00/?p=11613 Thanks https://twitter.com/cnlohr/status/945907823560613888 @Mr_Red_Beard 234 | 235 | So, now, if you open the Cypress app and select the second option for the data flow, you get 256,000 kB/s via both apps. 236 | 237 | Seriously... how does SetAltIntfc work? It does seem to set some configuration the device... Found it. return CyprIOControl(ths, IOCTL_ADAPT_SELECT_INTERFACE, &alt, 1L); 238 | 239 | Works like a charm. 240 | 241 | Now to figure out why the data's all wrong. I was just being dumb. Data went where I wanted it. 242 | 243 | Ok, got rid of a ton of stuff from Cypress. Still more to get rid of. But man this is curising along well. About 1% or less CPU utilization at 256 MB/sec. 244 | 245 | MOVING OVER TO THE USB SIDE 246 | 247 | The GPIF designer is pretty easy to use. Took a bit to get the hang of it, but I think I can make something with a data buffer, and one state that just does a ton of data in. 248 | 249 | 12/27/2017: 250 | 251 | Spend 20 minutes dinking more... I think it's time to ask for help and go do regular work. 252 | 253 | https://community.cypress.com/message/148992#148992 254 | 255 | Well, got that working. Was a simple buffer problem. 256 | 257 | I'm gonna need a way of selecting between different run modes, maybe slower modes, too. Better get control messages going. libusb did it right. We should mimic them. 258 | 259 | This is totally kicking my butt. My function somehow differs from theirs. 260 | 261 | Some sort of strange stack corruption. Reading/writing values on the stack seems hosed. Need to understand more. 262 | 263 | INCREDIBLE!!! So, if you start sending data to an iso port and then disconnect, if the data is still sending from the GPIF bus, and you don't send to it. 264 | 265 | Video time! 266 | 267 | Ok, video didn't go well. 268 | 269 | 2 AM 12/29/2017: Trying out different sizes of DMA, etc. Looks like it works in chunks of 2048 just fine but still overflows incessently. 270 | 271 | Post reply to https://community.cypress.com/thread/32169 272 | 273 | Dinked around for about an hour, got nowhere with the bandwidth, though I did notice I can overclock my bus to 8/7ths of 100 MHz :-D 274 | 275 | Gave up around 8 AM... 276 | 277 | 12/29 2:00 PM Started again. Had to use a watermark or fifo-space-left operation with extra states, but it worked! (2 hours more) 278 | 279 | Started again at 10:45 PM. How hard is it to flash custom firmware? Or maybe I should cleanup Cyprio? 280 | 281 | They provide "c_sharp/controlcenter/Form1.cs" which is 3,000 lines long. :(. 282 | 283 | (only spent 15 minutes this time) 284 | 285 | 12/30 Midnight: Starting again. 286 | 287 | Just found out all of the cypress stuff goes through CyUSB3.sys. http://www.cypress.com/file/145261/download 288 | Looks like it all gets piped through a kernel mode driver I got, so it turns out it does take a driver :( -- but apparently it's an easy-for-windows-to-deal-with driver!!! 289 | 290 | Spent about 2 hours looking at the hex of the cypress images and a USBPcap dump of a successful flash of the device using the Cypress tool. That should have taken way less time. 291 | 292 | Now, to figure out why my messages I think are CONTROL OUT messages are turning into CONTROL IN messages >.< 293 | 294 | Got it to boot!!! (RAM only, no writing to flash!) 295 | 296 | NEXT: How do we flash to the I2C EEPROM? (3:00 AM) 297 | 298 | Apparently, that's easy. First, RAM it to the Flasher firmware. Then call flash commands. (0x40/0xBA/(Windex/Wvalue) of the raw binary image. No interpretation needed. 299 | 300 | AND NOW IT WORKS WITH I2C EEPROM (3:50 AM) 301 | 302 | Dec 30, starting around 8 PM... Porting to Linux. 303 | 304 | Just mostly #define out the stuff that is flagrantly Windows. 305 | 306 | Booted back into Windows to make sure it was still working. It wasn't. Also, while in Windows, ditched any of the CyUSB3 stuff in critical path. It could be replaced by generic calls to the control transfer stuff. 307 | 308 | WOOHH SUCCESSFULLY FLASHING IN LINUX!!! (11:08 PM!) 309 | 310 | Woah this isochronous thing was kicking my butt. 12:54 AM, Dec 31, 2017. Iso in linux looks weird, but seems to be working. I'm worried it may be dropping packets. 311 | 312 | Back and forth to Windows once more and everything works in both. 313 | 314 | Dec 31, 1:09 AM. Remerging back into master. 315 | -------------------------------------------------------------------------------- /Win10-Drivers.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/fx3fun/b36d2d7eadebfef53769dc09c573807a1a2a71f4/Win10-Drivers.zip -------------------------------------------------------------------------------- /cyprflash/CyBootProgrammer.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/fx3fun/b36d2d7eadebfef53769dc09c573807a1a2a71f4/cyprflash/CyBootProgrammer.img -------------------------------------------------------------------------------- /cyprflash/Makefile: -------------------------------------------------------------------------------- 1 | all : cyprflash 2 | 3 | LCYPRIO:=../libcyprio 4 | CFLAGS:=-I$(LCYPRIO) -Os 5 | LDFLAGS:=-lusb-1.0 6 | 7 | CYPRIO:=$(LCYPRIO)/libcyprio.c $(LCYPRIO)/libcyprio_util.c 8 | 9 | cyprflash : cyprflash.c $(CYPRIO) 10 | gcc -o $@ $^ $(CFLAGS) $(LDFLAGS) 11 | 12 | clean : 13 | rm -rf *.o *~ cyprflash 14 | 15 | -------------------------------------------------------------------------------- /cyprflash/compile.bat: -------------------------------------------------------------------------------- 1 | set TCC=C:\tcc\tcc.exe 2 | set CFLAGS=-DTCC -DWINDOWS -DHIDAPI -DWIN32 -Os -I. -I../libcyprio -Werror 3 | set LDFLAGS=-s -lkernel32 -lgdi32 -luser32 -lsetupapi -ldbghelp 4 | 5 | del cyprflash.exe 6 | %TCC% -o cyprflash.exe cyprflash.c ../libcyprio/libcyprio.c ../libcyprio/libcyprio_util.c %CFLAGS% %LDFLAGS% 7 | 8 | rem cyprflash.exe -i -f streaming_test.img 9 | cyprflash.exe -ic -p 241 -f USBIsoSource.img 10 | -------------------------------------------------------------------------------- /cyprflash/cyprflash.c: -------------------------------------------------------------------------------- 1 | /* 2 | Tool to boot Cypress FX3 to image file, or flash image file to external i2c EEPROM. 3 | (C) 2017 C. Lohr, under the MIT-x11 or NewBSD License. You decide. 4 | Tested on Windows, working full functionality 12/30/2017 5 | Tested on Linux, working full functionality 12/31/2017 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | //For 'sleep' / 'usleep' 14 | #if defined( WIN32 ) || defined( WINDOWS ) 15 | #include 16 | #else 17 | #include 18 | #endif 19 | 20 | #include 21 | 22 | 23 | int main( int argc, char ** argv ) 24 | { 25 | int do_flash_i2c = 0; 26 | int desired_pid = 0x4720; 27 | int dont_use_bootloader = 0; 28 | const char * file = 0; 29 | int i; 30 | int showhelp = 0; 31 | int do_reboot = 1; 32 | 33 | for( i = 1; i < argc; i++ ) 34 | { 35 | const char * proc = argv[i]; 36 | if( *proc == '-' ) 37 | { 38 | do 39 | { 40 | proc++; 41 | if( !*proc ) continue; 42 | if( *proc == 'i' ) 43 | { 44 | do_flash_i2c = 1; 45 | } 46 | else if( *proc == 'c' ) 47 | { 48 | dont_use_bootloader = 1; 49 | } 50 | else if( *proc == 'f' ) 51 | { 52 | file = argv[i+1]; 53 | i++; 54 | } 55 | else if( *proc == 'n' ) 56 | { 57 | do_reboot = 0; 58 | } 59 | else if( *proc == 'p' ) 60 | { 61 | desired_pid = atoi( argv[i+1] ); 62 | i++; 63 | } 64 | else 65 | { 66 | showhelp = 1; 67 | break; 68 | } 69 | } while( *proc ); 70 | } 71 | else 72 | { 73 | showhelp = 1; 74 | } 75 | if( showhelp ) break; 76 | } 77 | 78 | if( showhelp || file == 0 || file[0] == 0 ) 79 | { 80 | fprintf(stderr, "Usage: %s [-chi] [-p pid] [-f file...]\n", argv[0]); 81 | fprintf(stderr, " -c: Don't use bootload (your app must be able to write flash!)\n"); 82 | fprintf(stderr, " -h: Show help\n"); 83 | fprintf(stderr, " -p: use specific PID\n"); 84 | fprintf(stderr, " -i: Use i2c flash\n"); 85 | fprintf(stderr, " -n: do not reboot\n"); 86 | exit(-1); 87 | } 88 | 89 | if( do_flash_i2c ) 90 | { 91 | FILE * firmware = fopen( file, "rb" ); 92 | if( !firmware || ferror(firmware) ) 93 | { 94 | fprintf( stderr, "Error: can't open file \"%s\" for permanant write.\n", file ); 95 | return -5; 96 | } 97 | 98 | if( !dont_use_bootloader ) 99 | { 100 | int r = CyprIOBootloaderImage( "CyBootProgrammer.img" ); 101 | if( r ) 102 | { 103 | printf("Failed to flash bootloader.\n"); 104 | } 105 | } 106 | 107 | //Bootloader OK. Need to flash binary. 108 | 109 | #if defined( WIN32 ) || defined( WINDOWS ) 110 | Sleep(1000); 111 | #else 112 | sleep(1); 113 | #endif 114 | 115 | struct CyprIO eps; 116 | 117 | int connected = 0; 118 | if( CyprIOConnect( &eps, 0, 0x04b4, desired_pid ) ) 119 | { 120 | fprintf( stderr,"Could not connect to flasher.\n" ); 121 | exit( -5 ); 122 | } 123 | 124 | printf( "Re-enumeration complete.\n" ); 125 | int flashspot = 0; 126 | char buff[2048]; 127 | while( !feof(firmware) && !ferror( firmware ) ) 128 | { 129 | int r = fread( buff, 1, 2048, firmware ); 130 | if( r < 0 ) 131 | { 132 | fprintf( stderr, "Unexpected end of firmware read\n" ); 133 | break; 134 | } 135 | int tries; 136 | for( tries = 0; tries < 10; tries++ ) 137 | { 138 | int e = CyprIOControlTransfer( &eps, 0x40, 0xbc, flashspot>>16, flashspot, buff, r, 5000 ); 139 | if( e == r ) 140 | { 141 | char verify[2048]; 142 | e = CyprIOControlTransfer( &eps, 0xc0, 0xbc, flashspot>>16, flashspot, verify, r, 5000 ); 143 | int i; 144 | #if 0 145 | for( i =0 ;i < r; i++ ) 146 | { 147 | if( !(i&15) ) printf( "\n%04x ", i ); 148 | printf( "%02x %02x // ", (uint8_t)verify[i], (uint8_t)buff[i] ); 149 | } 150 | printf( "\n" ); 151 | printf( "%02x == %02x %02x == %02x\n", buff[0], verify[0], buff[256], verify[256] ); 152 | #endif 153 | if( e == r ) 154 | { 155 | if( memcmp( verify, buff, r ) == 0 ) 156 | break; 157 | else 158 | { 159 | fprintf( stderr, "WARNING: Verify match failed.\n" ); 160 | continue; 161 | } 162 | } 163 | } 164 | fprintf( stderr, "WARNING: Had to re-attempt write at address %08x\n", flashspot ); 165 | } 166 | if( tries == 10 ) 167 | { 168 | fprintf( stderr, "ERROR: Too many retries. Aborting.\n" ); 169 | CyprIODestroy( &eps ); 170 | 171 | } 172 | printf( "." ); 173 | fflush ( stdout ); 174 | flashspot += r; 175 | } 176 | 177 | if( do_reboot ) 178 | { 179 | int e = CyprIOControlTransfer( &eps, 0x40, 0xbc, 0, 0, buff, 0, 5000 ); 180 | if( e ) 181 | { 182 | fprintf( stderr, "WARNING: Could not issue finalization\n" ); 183 | } 184 | } 185 | printf( "Flash complete.\n" ); 186 | CyprIODestroy( &eps ); 187 | } 188 | else 189 | { 190 | int r = CyprIOBootloaderImage( file ); 191 | if( !r ) 192 | { 193 | printf( "Flash succeeded.\n" ); 194 | return 0; 195 | } 196 | else 197 | { 198 | printf( "Flash failed.\n" ); 199 | return -5; 200 | } 201 | } 202 | } 203 | 204 | -------------------------------------------------------------------------------- /cyprflash/cyprflash.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/fx3fun/b36d2d7eadebfef53769dc09c573807a1a2a71f4/cyprflash/cyprflash.exe -------------------------------------------------------------------------------- /cyprflash/streaming_image.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/fx3fun/b36d2d7eadebfef53769dc09c573807a1a2a71f4/cyprflash/streaming_image.img -------------------------------------------------------------------------------- /fx3view/Makefile: -------------------------------------------------------------------------------- 1 | all : fx3view 2 | 3 | CYPERIO:=../libcyprio 4 | CYPERIO_C:=$(CYPERIO)/libcyprio.c $(CYPERIO)/libcyprio_util.c 5 | 6 | CFLAGS := -I$(CYPERIO) -Irawdraw -Os 7 | LDFLAGS:= -lm -lX11 -lXext -lusb-1.0 -lpthread 8 | 9 | rawdraw/CNFGFunctions.c : 10 | echo "Did you forget to checkout submodules?" 11 | echo "I'll try doing it for you." 12 | git submodule update --init --recursive 13 | 14 | fx3view : fx3view.c rawdraw/CNFGFunctions.c rawdraw/CNFGXDriver.c $(CYPERIO_C) 15 | gcc -o $@ $^ $(CFLAGS) $(LDFLAGS) 16 | 17 | clean : 18 | rm -rf *.o *~ fx3view 19 | 20 | -------------------------------------------------------------------------------- /fx3view/compile.bat: -------------------------------------------------------------------------------- 1 | C:\tcc\tcc fx3view.c ../libcyprio/libcyprio.c -lsetupapi -lopengl32 -lgdi32 -luser32 -I../libcyprio -Irawdraw -DTCC -DWINDOWS -DCNFGOGL -DNOSQRT -------------------------------------------------------------------------------- /fx3view/fx3view.c: -------------------------------------------------------------------------------- 1 | /* 2 | Tool to test Cypress FX3 isochronous transfers using the stream test firmware 3 | (C) 2017 C. Lohr, under the MIT-x11 or NewBSD License. You decide. 4 | Tested on Windows, working full functionality 12/30/2017 5 | Tested on Linux, working full functionality 7/22/2018 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include "os_generic.h" 12 | #include 13 | 14 | #if defined(WINDOWS) || defined( WIN32 ) 15 | #include 16 | #else 17 | #include 18 | #include 19 | #endif 20 | 21 | #define CNFG_IMPLEMENTATION 22 | #include 23 | 24 | void * TickThread( void * v ); 25 | 26 | double samples_per_second; 27 | 28 | struct CyprIO eps; 29 | 30 | #define BUFFERSIZE_SAMPLES (1024*1024) 31 | #define MAX_BUFFERS 2 32 | 33 | int TriggerDirection; 34 | int Triggering; 35 | int DisableMask; 36 | int WatchMask = 2; 37 | 38 | struct SetBuffer 39 | { 40 | uint16_t Data[BUFFERSIZE_SAMPLES]; 41 | uint32_t head; 42 | int32_t trigger_point; 43 | }; 44 | 45 | int RunningBuffer; 46 | int DisplayBuffer; 47 | struct SetBuffer Buffers[MAX_BUFFERS]; 48 | uint16_t LastSample; 49 | 50 | 51 | 52 | int Record16; 53 | FILE * RecordFile; 54 | int RecordSize; 55 | int Recording; 56 | char RecordFileName[128]; 57 | 58 | 59 | int callback( void * id, struct CyprIOEndpoint * ep, uint8_t * data, uint32_t length ) 60 | { 61 | uint16_t * datas = (uint16_t*)data; 62 | static double Last; 63 | static int bytes; 64 | int i; 65 | length /= 2; 66 | bytes += length; 67 | double Now = OGGetAbsoluteTime(); 68 | 69 | int TriggerMask = DisableMask?0:WatchMask; //Actually used 70 | 71 | if( Recording ) 72 | { 73 | if( Record16 ) 74 | { 75 | fwrite( data, length*2, 1, RecordFile ); 76 | RecordSize += length * 2; 77 | } 78 | else 79 | { 80 | uint8_t latch[length]; 81 | for( i = 0; i < length;i ++ ) 82 | { 83 | latch[i] = datas[i]; 84 | } 85 | fwrite( latch, length, 1, RecordFile ); 86 | RecordSize += length; 87 | } 88 | } 89 | 90 | #if 1 91 | struct SetBuffer * sb = &Buffers[RunningBuffer]; 92 | for( i = 0; i < length; i++ ) 93 | { 94 | uint16_t sample = datas[i]; 95 | sb->Data[sb->head] = sample; 96 | sb->head = (sb->head+1)&(BUFFERSIZE_SAMPLES-1); 97 | if( sb->trigger_point > -1 ) 98 | { 99 | if( ((sb->trigger_point + (BUFFERSIZE_SAMPLES/2)) % BUFFERSIZE_SAMPLES) == sb->head ) 100 | { 101 | //Switch buffers. 102 | DisplayBuffer = RunningBuffer; 103 | RunningBuffer = ( RunningBuffer + 1 ) % MAX_BUFFERS; 104 | sb = &Buffers[RunningBuffer]; 105 | sb->trigger_point = -1; 106 | Triggering = 0; 107 | } 108 | } 109 | else 110 | { 111 | //Check to see if we need to trigger. 112 | if( TriggerMask && !Triggering ) 113 | { 114 | if( TriggerDirection ) sample = ~sample; 115 | if( !(sample & TriggerMask) ) 116 | { 117 | Triggering = 1; 118 | sb->trigger_point = sb->head; 119 | } 120 | } 121 | } 122 | } 123 | #endif 124 | 125 | if( Last + .2 < Now ) 126 | { 127 | if( Last == 0 ) Last = Now; 128 | //printf( "Got %.3f kB/s [%02x %02x] [%d pack]\n", bytes/1000, data[0], data[1], length ); 129 | samples_per_second = bytes * 5; 130 | Last+=0.2; 131 | bytes = 0; 132 | } 133 | 134 | LastSample = datas[length-1]; 135 | 136 | return 0; 137 | } 138 | 139 | void * CircularRxThread( void * v ) 140 | { 141 | #if defined( WINDOWS ) || defined( WIN32) 142 | CyprIODoCircularDataXferTx( &eps.CypIOEndpoints[0], 65536*16, 8, callback, 0 ); 143 | #else 144 | CyprIODoCircularDataXferTx( &eps.CypIOEndpoints[0], 32768, 8, callback, 0 ); 145 | #endif 146 | } 147 | 148 | void ExitApp() 149 | { 150 | eps.shutdown = 1; 151 | OGUSleep(100000); 152 | CyprIODestroy( &eps ); 153 | } 154 | 155 | void CNFGDrawBox( short x1, short y1, short x2, short y2 ) 156 | { 157 | uint32_t Col = CNFGLastColor; 158 | CNFGColor( CNFGBGColor ); 159 | CNFGTackRectangle( x1, y1, x2, y2 ); 160 | CNFGColor( Col ); 161 | CNFGTackSegment( x1, y1, x2, y1 ); 162 | CNFGTackSegment( x2, y1, x2, y2 ); 163 | CNFGTackSegment( x2, y2, x1, y2 ); 164 | CNFGTackSegment( x1, y2, x1, y1 ); 165 | } 166 | 167 | void DrawFrame() 168 | { 169 | double Now = OGGetAbsoluteTime(); 170 | short w, h; 171 | CNFGGetDimensions( &w, &h ); 172 | char stt[1024]; 173 | 174 | struct SetBuffer * sb = &Buffers[DisplayBuffer]; 175 | 176 | 177 | CNFGBGColor = 0x000040; 178 | CNFGHandleInput(); 179 | CNFGClearFrame(); 180 | CNFGColor( 0xffffff ); 181 | 182 | CNFGPenX = 10; 183 | CNFGPenY = 10; 184 | sprintf( stt, "%5.0f msps %04x [%d]", samples_per_second/1000000, LastSample, DisplayBuffer ); 185 | CNFGSetLineWidth( 2 ); 186 | CNFGDrawText( stt, 3 ); 187 | 188 | 189 | if( Recording ) 190 | { 191 | CNFGPenX = 10; 192 | CNFGPenY = 30; 193 | sprintf( stt, "%5.0f MBytes %s", RecordSize/(1024*1024.0), RecordFileName ); 194 | CNFGSetLineWidth( 2 ); 195 | CNFGDrawText( stt, 3 ); 196 | } 197 | 198 | 199 | CNFGSetLineWidth( 1 ); 200 | 201 | int i; 202 | for( i = 0; i < 16; i++ ) 203 | { 204 | int mask = 1<trigger_point>=0)?(sb->trigger_point-lw/2+BUFFERSIZE_SAMPLES):(sb->head+BUFFERSIZE_SAMPLES); 224 | fmark = fmark & (BUFFERSIZE_SAMPLES-1); 225 | 226 | i = 50; 227 | 228 | int my = (sb->Data[fmark]&mask)?1:0; 229 | int mx = i; 230 | int chans = 100; 231 | int chanh = ( h - 100 ) / channels; 232 | int chanhl = chanh - 20; 233 | int tmy; 234 | 235 | for( ; i < w-50; i++ ) 236 | { 237 | tmy = (sb->Data[fmark]&mask)?1:0; 238 | 239 | if( tmy != my ) 240 | { 241 | CNFGTackSegment( mx, my * chanhl + channel * chanh + chans, i, my * chanhl + channel * chanh + chans ); 242 | CNFGTackSegment( i, my * chanhl + channel * chanh + chans, i, tmy * chanhl + channel * chanh + chans ); 243 | mx = i; 244 | my = tmy; 245 | } 246 | 247 | fmark++; 248 | fmark = fmark & (BUFFERSIZE_SAMPLES-1); 249 | } 250 | CNFGTackSegment( mx, my * chanhl + channel * chanh + chans, i, tmy * chanhl + channel * chanh + chans ); 251 | } 252 | 253 | void DrawButtons(); 254 | DrawButtons(); 255 | 256 | CNFGSwapBuffers(); 257 | 258 | 259 | //Only allow operation at ~60 Hz. 260 | static double LastTime; 261 | double NewNow = OGGetAbsoluteTime(); 262 | double dlay = LastTime + 0.017 - NewNow; 263 | if( dlay > 0 ) 264 | { 265 | OGUSleep( dlay*1000000 ); 266 | } 267 | if( dlay < 0 ) 268 | { 269 | LastTime = Now; 270 | } 271 | else 272 | { 273 | LastTime += 0.017; 274 | } 275 | 276 | } 277 | 278 | int main() 279 | { 280 | #if defined(WIN32) || defined( WINDOWS ) 281 | atexit( ExitApp ); 282 | #else 283 | signal(SIGINT, ExitApp); 284 | #endif 285 | int r = CyprIOConnect( &eps, 0, 0x04b4, 0x00f1 ); 286 | if( r ) 287 | { 288 | fprintf( stderr, "Error: Could not connect to USB device\n" ); 289 | return -1; 290 | } 291 | r = CyprIOGetDevDescriptorInformation( &eps ); 292 | if( r ) 293 | { 294 | fprintf( stderr, "Error: Couldn't get all info needed from device\n" ); 295 | return -1; 296 | } 297 | r = CyprIOSetup( &eps, 0, 2 ); 298 | if( r ) 299 | { 300 | fprintf( stderr, "Error: Could not setup USB device\n" ); 301 | return -1; 302 | } 303 | 304 | //Set up scope stuff... 305 | Buffers[0].trigger_point = -1; 306 | 307 | 308 | 309 | CNFGSetup( "fx3view", 800, 600 ); //return 0 if ok. 310 | 311 | 312 | printf( "Connected successfully\n" ); 313 | 314 | 315 | OGCreateThread( TickThread, 0 ); 316 | OGCreateThread( CircularRxThread, 0 ); 317 | 318 | printf( "...\n" ); 319 | 320 | 321 | while( !eps.shutdown ) 322 | { 323 | DrawFrame(); 324 | } 325 | 326 | 327 | return 0; 328 | } 329 | 330 | 331 | 332 | struct Button; 333 | struct Button 334 | { 335 | int x, y, w, h, id; 336 | int (*BtnClick)( struct Button * ); 337 | const char * text; 338 | uint32_t bgcolor; 339 | float focus; 340 | }; 341 | 342 | 343 | 344 | 345 | int Pause( struct Button * btn ) 346 | { 347 | btn->bgcolor = 0xff0000; 348 | btn->id = !btn->id; 349 | DisableMask = btn->id; 350 | return 0; 351 | } 352 | 353 | 354 | 355 | int RecordFileButton( struct Button * btn ) 356 | { 357 | if( Recording ) 358 | { 359 | Recording = 0; 360 | fclose( RecordFile ); 361 | printf( "Done writing file.\n" ); 362 | if( btn->id ) btn->text = "RECORD 16"; else btn->text = "RECORD 8"; 363 | } 364 | else 365 | { 366 | Record16 = btn->id; 367 | time_t rawtime; 368 | struct tm *info; 369 | time( &rawtime ); 370 | info = localtime( &rawtime ); 371 | if( Record16 ) 372 | strftime(RecordFileName,80,"Data_%Y%m%d%H%M%S.16.dat", info); 373 | else 374 | strftime(RecordFileName,80,"Data_%Y%m%d%H%M%S.8.dat", info); 375 | printf( "Writing to %s\n", RecordFileName ); 376 | RecordFile = fopen( RecordFileName, "wb" ); 377 | RecordSize = 0; 378 | Recording = 1; 379 | btn->text = "RECORDING"; 380 | } 381 | return 0; 382 | } 383 | 384 | 385 | 386 | struct Button gbtns[] = { 387 | { .x = 20, .y = 50, .w = 60, .h = 20, .id = 0, .BtnClick = &Pause, .text = "PAUSE", .bgcolor = 0x202020 }, 388 | { .x = 100, .y = 50, .w = 180, .h = 20, .id = 0, .BtnClick = &RecordFileButton, .text = "RECORD 8", .bgcolor = 0x202020 }, 389 | { .x = 300, .y = 50, .w = 180, .h = 20, .id = 1, .BtnClick = &RecordFileButton, .text = "RECORD 16", .bgcolor = 0x202020 }, 390 | }; 391 | 392 | int cursorx, cursory; 393 | int downmask; 394 | int downbutton = -1; 395 | 396 | void DrawButtons() 397 | { 398 | int buttons = sizeof( gbtns ) / sizeof( gbtns[0] ); 399 | int i; 400 | 401 | int x = cursorx; 402 | int y = cursory; 403 | for( i = 0; i < buttons; i++ ) 404 | { 405 | struct Button * b = &gbtns[i]; 406 | if( x >= b->x && y >= b->y && x <= b->x + b->w && y <= b->y + b->h ) 407 | { 408 | b->focus += (1.0 - b->focus) * .1; 409 | } 410 | } 411 | 412 | 413 | 414 | CNFGColor( 0xffffff ); 415 | for( i = 0; i < buttons; i++ ) 416 | { 417 | struct Button * b = &gbtns[i]; 418 | uint32_t rb = b->bgcolor; 419 | uint32_t re = rb & 0xff; 420 | uint32_t ge = (rb >> 8) & 0xff; 421 | uint32_t be = (rb >> 16) & 0xff; 422 | re = b->focus * 200; 423 | ge = b->focus * 200; 424 | be = b->focus * 200; 425 | if( re > 255 ) re = 255; 426 | if( ge > 255 ) ge = 255; 427 | if( be > 255 ) be = 255; 428 | CNFGBGColor = re | (ge<<8) | (be<<16); 429 | b->focus -= 0.04; 430 | if( b->focus < 0 ) b->focus = 0; 431 | 432 | CNFGDrawBox( b->x, b->y, b->x+b->w, b->y+b->h ); 433 | CNFGPenX = b->x + 4; 434 | CNFGPenY = b->y + 4; 435 | CNFGDrawText( b->text, 3 ); 436 | } 437 | } 438 | 439 | void HandleKey( int keycode, int bDown ) 440 | { 441 | } 442 | 443 | void HandleButton( int x, int y, int button, int bDown ) 444 | { 445 | int buttons = sizeof( gbtns ) / sizeof( gbtns[0] ); 446 | int i; 447 | cursorx = x; 448 | cursory = y; 449 | if( bDown ) 450 | downmask |= 1<= b->x && y >= b->y && x <= b->x + b->w && y <= b->y + b->h ) 458 | { 459 | int down = !(downmask & 1); 460 | if( down ) 461 | { 462 | downbutton = i; 463 | } 464 | else 465 | { 466 | if( downbutton == i ) 467 | { 468 | b->BtnClick( b ); 469 | b->focus = 2; 470 | } 471 | } 472 | } 473 | } 474 | } 475 | 476 | void HandleMotion( int x, int y, int mask ) 477 | { 478 | cursorx = x; 479 | cursory = y; 480 | downmask = mask; 481 | } 482 | 483 | void HandleDestroy() 484 | { 485 | } 486 | 487 | 488 | 489 | 490 | void TickCypr() 491 | { 492 | char buf[64]; 493 | int e = CyprIOControlTransfer( &eps, 0xc0, 0xaa, 0x0102, 0x0304, buf, 50, 10 ); 494 | } 495 | 496 | void * TickThread( void * v ) 497 | { 498 | while(1) 499 | { 500 | TickCypr(); 501 | OGSleep(1); 502 | } 503 | } 504 | -------------------------------------------------------------------------------- /isotest/Makefile: -------------------------------------------------------------------------------- 1 | all : isotest recstream 2 | 3 | LCYPRIO:=../libcyprio 4 | CFLAGS:=-I$(LCYPRIO) -O1 -g 5 | LDFLAGS:=-lusb-1.0 -lpthread 6 | 7 | CYPRIO:=$(LCYPRIO)/libcyprio.c $(LCYPRIO)/libcyprio_util.c 8 | 9 | isotest : teststream.c os_generic.c $(CYPRIO) 10 | gcc -o $@ $^ $(CFLAGS) $(LDFLAGS) 11 | 12 | recstream : recstream.c os_generic.c $(CYPRIO) 13 | gcc -o $@ $^ $(CFLAGS) $(LDFLAGS) 14 | 15 | clean : 16 | rm -rf *.o *~ isotest recstream 17 | 18 | -------------------------------------------------------------------------------- /isotest/charles-streamer/reference/CyUSB30_def.h: -------------------------------------------------------------------------------- 1 | /* 2 | ## Cypress CyAPI C++ library USB3.0 defination header file (CyUSB30_def.h) 3 | ## ======================================================= 4 | ## 5 | ## Copyright Cypress Semiconductor Corporation, 2009-2012, 6 | ## All Rights Reserved 7 | ## UNPUBLISHED, LICENSED SOFTWARE. 8 | ## 9 | ## CONFIDENTIAL AND PROPRIETARY INFORMATION 10 | ## WHICH IS THE PROPERTY OF CYPRESS. 11 | ## 12 | ## Use of this file is governed 13 | ## by the license agreement included in the file 14 | ## 15 | ## /license/license.rtf 16 | ## 17 | ## where is the Cypress software 18 | ## install root directory path. 19 | ## 20 | ## ======================================================= 21 | */ 22 | #ifndef _CYUSB30_H 23 | #define _CYUSB30_H 24 | 25 | //#pragma pack(1) 26 | #pragma pack(push, 1) 27 | // USB3.0 specific constant defination 28 | #define BCDUSBJJMASK 0xFF00 //(0xJJMN JJ - Major version,M Minor version, N sub-minor vesion) 29 | #define USB30MAJORVER 0x0300 30 | #define USB20MAJORVER 0x0200 31 | 32 | #define USB_BOS_DESCRIPTOR_TYPE 0x0F 33 | #define USB_DEVICE_CAPABILITY 0x10 34 | #define USB_SUPERSPEED_ENDPOINT_COMPANION 0x30 35 | #define USB_BOS_CAPABILITY_TYPE_Wireless_USB 0x01 36 | #define USB_BOS_CAPABILITY_TYPE_USB20_EXT 0x02 37 | #define USB_BOS_CAPABILITY_TYPE_SUPERSPEED_USB 0x03 38 | #define USB_BOS_CAPABILITY_TYPE_CONTAINER_ID 0x04 39 | #define USB_BOS_CAPABILITY_TYPE_CONTAINER_ID_SIZE 0x10 40 | 41 | #define USB_BOS_DEVICE_CAPABILITY_TYPE_INDEX 0x2 42 | //constant defination 43 | typedef struct _USB_BOS_DESCRIPTOR 44 | { 45 | UCHAR bLength;/* Descriptor length*/ 46 | UCHAR bDescriptorType;/* Descriptor Type */ 47 | USHORT wTotalLength;/* Total length of descriptor ( icluding device capability*/ 48 | UCHAR bNumDeviceCaps;/* Number of device capability descriptors in BOS */ 49 | }USB_BOS_DESCRIPTOR,*PUSB_BOS_DESCRIPTOR; 50 | 51 | typedef struct _USB_BOS_USB20_DEVICE_EXTENSION 52 | { 53 | UCHAR bLength;/* Descriptor length*/ 54 | UCHAR bDescriptorType;/* Descriptor Type */ 55 | UCHAR bDevCapabilityType;/* Device capability type*/ 56 | UINT bmAttribute;// Bitmap encoding for supprted feature and Link power managment supprted if set 57 | }USB_BOS_USB20_DEVICE_EXTENSION,*PUSB_BOS_USB20_DEVICE_EXTENSION; 58 | 59 | typedef struct _USB_BOS_SS_DEVICE_CAPABILITY 60 | { 61 | UCHAR bLength;/* Descriptor length*/ 62 | UCHAR bDescriptorType;/* Descriptor Type */ 63 | UCHAR bDevCapabilityType;/* Device capability type*/ 64 | UCHAR bmAttribute;// Bitmap encoding for supprted feature and Link power managment supprted if set 65 | USHORT wSpeedsSuported;//low speed supported if set,full speed supported if set,high speed supported if set,super speed supported if set,15:4 nt used 66 | UCHAR bFunctionalitySupporte; 67 | UCHAR bU1DevExitLat;//U1 device exit latency 68 | USHORT bU2DevExitLat;//U2 device exit latency 69 | }USB_BOS_SS_DEVICE_CAPABILITY,*PUSB_BOS_SS_DEVICE_CAPABILITY; 70 | 71 | typedef struct _USB_BOS_CONTAINER_ID 72 | { 73 | UCHAR bLength;/* Descriptor length*/ 74 | UCHAR bDescriptorType;/* Descriptor Type */ 75 | UCHAR bDevCapabilityType;/* Device capability type*/ 76 | UCHAR bReserved; // no use 77 | UCHAR ContainerID[USB_BOS_CAPABILITY_TYPE_CONTAINER_ID_SIZE];/* UUID */ 78 | }USB_BOS_CONTAINER_ID,*PUSB_BOS_CONTAINER_ID; 79 | 80 | typedef struct _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR 81 | { 82 | UCHAR bLength; 83 | UCHAR bDescriptorType; 84 | UCHAR bMaxBurst; 85 | UCHAR bmAttributes; 86 | USHORT bBytesPerInterval; 87 | }USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR,*PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR; 88 | #pragma pack(pop) 89 | #endif /*_CYUSB30_H*/ 90 | 91 | -------------------------------------------------------------------------------- /isotest/charles-streamer/reference/UsbdStatus.h: -------------------------------------------------------------------------------- 1 | 2 | // Note: see usbdi.h in the DDK for the USBD_STATUS source definitions 3 | typedef LONG USBD_STATUS; 4 | #define USBD_STATUS(Status) ((ULONG)(Status) & 0x0FFFFFFFL) 5 | #define USBD_STATE(Status) ((ULONG)(Status) & 0xF0000000L) 6 | 7 | // HC status codes (Note: both error and stall bit are set) 8 | #define USBD_STATUS_SUCCESS ((USBD_STATUS)0x00000000L) 9 | #define USBD_STATUS_PENDING ((USBD_STATUS)0x40000000L) 10 | #define USBD_STATUS_HALTED ((USBD_STATUS)0xC0000000L) 11 | #define USBD_STATUS_ERROR ((USBD_STATUS)0x80000000L) 12 | 13 | #define USBD_STATUS_CRC ((USBD_STATUS)0xC0000001L) 14 | #define USBD_STATUS_BTSTUFF ((USBD_STATUS)0xC0000002L) 15 | #define USBD_STATUS_DATA_TOGGLE_MISMATCH ((USBD_STATUS)0xC0000003L) 16 | #define USBD_STATUS_STALL_PID ((USBD_STATUS)0xC0000004L) 17 | #define USBD_STATUS_DEV_NOT_RESPONDING ((USBD_STATUS)0xC0000005L) 18 | #define USBD_STATUS_PID_CHECK_FAILURE ((USBD_STATUS)0xC0000006L) 19 | #define USBD_STATUS_UNEXPECTED_PID ((USBD_STATUS)0xC0000007L) 20 | #define USBD_STATUS_DATA_OVERRUN ((USBD_STATUS)0xC0000008L) 21 | #define USBD_STATUS_DATA_UNDERRUN ((USBD_STATUS)0xC0000009L) 22 | #define USBD_STATUS_RESERVED1 ((USBD_STATUS)0xC000000AL) 23 | #define USBD_STATUS_RESERVED2 ((USBD_STATUS)0xC000000BL) 24 | #define USBD_STATUS_BUFFER_OVERRUN ((USBD_STATUS)0xC000000CL) 25 | #define USBD_STATUS_BUFFER_UNDERRUN ((USBD_STATUS)0xC000000DL) 26 | #define USBD_STATUS_NOT_ACCESSED ((USBD_STATUS)0xC000000FL) 27 | #define USBD_STATUS_FIFO ((USBD_STATUS)0xC0000010L) 28 | 29 | #define USBD_STATUS_ENDPOINT_HALTED ((USBD_STATUS)0xC0000030L) 30 | #define USBD_STATUS_NO_MEMORY ((USBD_STATUS)0x80000100L) 31 | #define USBD_STATUS_INVALID_URB_FUNCTION ((USBD_STATUS)0x80000200L) 32 | #define USBD_STATUS_INVALID_PARAMETER ((USBD_STATUS)0x80000300L) 33 | #define USBD_STATUS_ERROR_BUSY ((USBD_STATUS)0x80000400L) 34 | #define USBD_STATUS_REQUEST_FAILED ((USBD_STATUS)0x80000500L) 35 | #define USBD_STATUS_INVALID_PIPE_HANDLE ((USBD_STATUS)0x80000600L) 36 | #define USBD_STATUS_NO_BANDWIDTH ((USBD_STATUS)0x80000700L) 37 | #define USBD_STATUS_INTERNAL_HC_ERROR ((USBD_STATUS)0x80000800L) 38 | #define USBD_STATUS_ERROR_SHORT_TRANSFER ((USBD_STATUS)0x80000900L) 39 | #define USBD_STATUS_BAD_START_FRAME ((USBD_STATUS)0xC0000A00L) 40 | #define USBD_STATUS_ISOCH_REQUEST_FAILED ((USBD_STATUS)0xC0000B00L) 41 | #define USBD_STATUS_FRAME_CONTROL_OWNED ((USBD_STATUS)0xC0000C00L) 42 | #define USBD_STATUS_FRAME_CONTROL_NOT_OWNED ((USBD_STATUS)0xC0000D00L) 43 | #define USBD_STATUS_CANCELED ((USBD_STATUS)0x00010000L) 44 | #define USBD_STATUS_CANCELING ((USBD_STATUS)0x00020000L) 45 | 46 | 47 | -------------------------------------------------------------------------------- /isotest/charles-streamer/reference/VersionNo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ## Cypress CyAPI C++ library version number header file (VersionNo.h) 3 | ## ======================================================= 4 | ## 5 | ## Copyright Cypress Semiconductor Corporation, 2009-2012, 6 | ## All Rights Reserved 7 | ## UNPUBLISHED, LICENSED SOFTWARE. 8 | ## 9 | ## CONFIDENTIAL AND PROPRIETARY INFORMATION 10 | ## WHICH IS THE PROPERTY OF CYPRESS. 11 | ## 12 | ## Use of this file is governed 13 | ## by the license agreement included in the file 14 | ## 15 | ## /license/license.rtf 16 | ## 17 | ## where is the Cypress software 18 | ## install root directory path. 19 | ## 20 | ## ======================================================= 21 | */ 22 | #define FILEVER 1,2,1,0 23 | #define PRODUCTVER 1,2,1,0 24 | #define STRFILEVER "1, 2, 1, 0" 25 | #define STRPRODUCTVER "1, 2, 1, 0" 26 | #define STRFILEVER_ASSENBLY "1.2.1.0" 27 | -------------------------------------------------------------------------------- /isotest/charles-streamer/reference/ccyusb_c_bindings.h: -------------------------------------------------------------------------------- 1 | #ifndef _CCYUSB_C_BINDINGS 2 | #define _CCYUSB_C_BINDINGS 3 | 4 | ////////////////////////////////////////////////////////////////////// 5 | /////////// CORE BINDINGS FROM CyAPI.h /////////////////////////// 6 | ////////////////////////////////////////////////////////////////////// 7 | 8 | #include "reference/cyusb30_def.h" 9 | 10 | /* Data straucture for the Vendor request and data */ 11 | typedef struct vendorCmdData 12 | { 13 | UCHAR *buf; /* Pointer to the data */ 14 | UCHAR opCode; /* Vendor request code */ 15 | UINT addr; /* Read/Write address */ 16 | long size; /* Size of the read/write */ 17 | bool isRead; /* Read or write */ 18 | } vendorCmdData ; 19 | 20 | #ifndef __USB200_H__ 21 | #define __USB200_H__ 22 | #pragma pack(push,1) 23 | typedef struct _USB_DEVICE_DESCRIPTOR { 24 | UCHAR bLength; 25 | UCHAR bDescriptorType; 26 | USHORT bcdUSB; 27 | UCHAR bDeviceClass; 28 | UCHAR bDeviceSubClass; 29 | UCHAR bDeviceProtocol; 30 | UCHAR bMaxPacketSize0; 31 | USHORT idVendor; 32 | USHORT idProduct; 33 | USHORT bcdDevice; 34 | UCHAR iManufacturer; 35 | UCHAR iProduct; 36 | UCHAR iSerialNumber; 37 | UCHAR bNumConfigurations; 38 | } USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR; 39 | 40 | typedef struct _USB_ENDPOINT_DESCRIPTOR { 41 | UCHAR bLength; 42 | UCHAR bDescriptorType; 43 | UCHAR bEndpointAddress; 44 | UCHAR bmAttributes; 45 | USHORT wMaxPacketSize; 46 | UCHAR bInterval; 47 | } USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR; 48 | 49 | typedef struct _USB_CONFIGURATION_DESCRIPTOR { 50 | UCHAR bLength; 51 | UCHAR bDescriptorType; 52 | USHORT wTotalLength; 53 | UCHAR bNumInterfaces; 54 | UCHAR bConfigurationValue; 55 | UCHAR iConfiguration; 56 | UCHAR bmAttributes; 57 | UCHAR MaxPower; 58 | } USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR; 59 | 60 | typedef struct _USB_INTERFACE_DESCRIPTOR { 61 | UCHAR bLength; 62 | UCHAR bDescriptorType; 63 | UCHAR bInterfaceNumber; 64 | UCHAR bAlternateSetting; 65 | UCHAR bNumEndpoints; 66 | UCHAR bInterfaceClass; 67 | UCHAR bInterfaceSubClass; 68 | UCHAR bInterfaceProtocol; 69 | UCHAR iInterface; 70 | } USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR; 71 | 72 | typedef struct _USB_STRING_DESCRIPTOR { 73 | UCHAR bLength; 74 | UCHAR bDescriptorType; 75 | WCHAR bString[1]; 76 | } USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR; 77 | 78 | typedef struct _USB_COMMON_DESCRIPTOR { 79 | UCHAR bLength; 80 | UCHAR bDescriptorType; 81 | } USB_COMMON_DESCRIPTOR, *PUSB_COMMON_DESCRIPTOR; 82 | #pragma pack(pop) 83 | #endif 84 | 85 | /*******************************************************************************/ 86 | class CCyIsoPktInfo { 87 | public: 88 | LONG Status; 89 | LONG Length; 90 | }; 91 | 92 | /*******************************************************************************/ 93 | 94 | 95 | /* {AE18AA60-7F6A-11d4-97DD-00010229B959} */ 96 | static GUID CYUSBDRV_GUID = {0xae18aa60, 0x7f6a, 0x11d4, 0x97, 0xdd, 0x0, 0x1, 0x2, 0x29, 0xb9, 0x59}; 97 | 98 | typedef enum {TGT_DEVICE, TGT_INTFC, TGT_ENDPT, TGT_OTHER } CTL_XFER_TGT_TYPE; 99 | typedef enum {REQ_STD, REQ_CLASS, REQ_VENDOR } CTL_XFER_REQ_TYPE; 100 | typedef enum {DIR_TO_DEVICE, DIR_FROM_DEVICE } CTL_XFER_DIR_TYPE; 101 | typedef enum {XMODE_BUFFERED, XMODE_DIRECT } XFER_MODE_TYPE; 102 | 103 | const int MAX_ENDPTS = 32; 104 | const int MAX_INTERFACES = 255; 105 | const int USB_STRING_MAXLEN = 256; 106 | 107 | #define BUFSIZE_UPORT 2048 //4096 - CDT 130492 108 | typedef enum { RAM = 1, I2CE2PROM, SPIFLASH } FX3_FWDWNLOAD_MEDIA_TYPE ; 109 | typedef enum { SUCCESS = 0, FAILED, INVALID_MEDIA_TYPE, INVALID_FWSIGNATURE, DEVICE_CREATE_FAILED, INCORRECT_IMAGE_LENGTH, INVALID_FILE, SPILASH_ERASE_FAILED, CORRUPT_FIRMWARE_IMAGE_FILE,I2CE2PROM_UNKNOWN_I2C_SIZE } FX3_FWDWNLOAD_ERROR_CODE; 110 | 111 | 112 | 113 | 114 | struct CCyUSBDevice 115 | { 116 | }; 117 | 118 | #endif 119 | 120 | -------------------------------------------------------------------------------- /isotest/charles-streamer/reference/cyioctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | ## Cypress CyAPI C++ library IOCTL defination header file (cyioctl.h) 3 | ## ======================================================= 4 | ## 5 | ## Copyright Cypress Semiconductor Corporation, 2009-2012, 6 | ## All Rights Reserved 7 | ## UNPUBLISHED, LICENSED SOFTWARE. 8 | ## 9 | ## CONFIDENTIAL AND PROPRIETARY INFORMATION 10 | ## WHICH IS THE PROPERTY OF CYPRESS. 11 | ## 12 | ## Use of this file is governed 13 | ## by the license agreement included in the file 14 | ## 15 | ## /license/license.rtf 16 | ## 17 | ## where is the Cypress software 18 | ## install root directory path. 19 | ## 20 | ## ======================================================= 21 | */ 22 | #ifndef __IOCTL_H__ 23 | #define __IOCTL_H__ 24 | 25 | 26 | #ifndef DRIVER 27 | 28 | #ifndef CTL_CODE 29 | #include 30 | #endif 31 | 32 | #ifndef BM_REQUEST_TYPE 33 | #include "usb200.h" 34 | #endif 35 | 36 | #include 37 | 38 | #define DIR_HOST_TO_DEVICE 0 39 | #define DIR_DEVICE_TO_HOST 1 40 | 41 | #define DEVICE_SPEED_UNKNOWN 0x00000000 42 | #define DEVICE_SPEED_LOW_FULL 0x00000001 43 | #define DEVICE_SPEED_HIGH 0x00000002 44 | #define DEVICE_SPEED_SUPER 0x00000004 45 | 46 | typedef struct _WORD_SPLIT { 47 | UCHAR lowByte; 48 | UCHAR hiByte; 49 | } WORD_SPLIT, *PWORD_SPLIT; 50 | 51 | typedef struct _BM_REQ_TYPE { 52 | UCHAR Recipient:2; 53 | UCHAR Reserved:3; 54 | UCHAR Type:2; 55 | UCHAR Direction:1; 56 | } BM_REQ_TYPE, *PBM_REQ_TYPE; 57 | 58 | typedef struct _SETUP_PACKET { 59 | 60 | union { 61 | BM_REQ_TYPE bmReqType; 62 | UCHAR bmRequest; 63 | }; 64 | 65 | UCHAR bRequest; 66 | 67 | union { 68 | WORD_SPLIT wVal; 69 | USHORT wValue; 70 | }; 71 | 72 | union { 73 | WORD_SPLIT wIndx; 74 | USHORT wIndex; 75 | }; 76 | 77 | union { 78 | WORD_SPLIT wLen; 79 | USHORT wLength; 80 | }; 81 | 82 | ULONG ulTimeOut; 83 | 84 | } SETUP_PACKET, *PSETUP_PACKET; 85 | 86 | #define USB_ISO_ID 0x4945 87 | #define USB_ISO_CMD_ASAP 0x8000 88 | #define USB_ISO_CMD_CURRENT_FRAME 0x8001 89 | #define USB_ISO_CMD_SET_FRAME 0x8002 90 | 91 | typedef struct _ISO_ADV_PARAMS { 92 | 93 | USHORT isoId; 94 | USHORT isoCmd; 95 | 96 | ULONG ulParam1; 97 | ULONG ulParam2; 98 | 99 | } ISO_ADV_PARAMS, *PISO_ADV_PARAMS; 100 | 101 | typedef struct _ISO_PACKET_INFO { 102 | ULONG Status; 103 | ULONG Length; 104 | } ISO_PACKET_INFO, *PISO_PACKET_INFO; 105 | 106 | 107 | typedef struct _SINGLE_TRANSFER { 108 | union { 109 | SETUP_PACKET SetupPacket; 110 | ISO_ADV_PARAMS IsoParams; 111 | }; 112 | 113 | UCHAR reserved; 114 | 115 | UCHAR ucEndpointAddress; 116 | ULONG NtStatus; 117 | ULONG UsbdStatus; 118 | ULONG IsoPacketOffset; 119 | ULONG IsoPacketLength; 120 | ULONG BufferOffset; 121 | ULONG BufferLength; 122 | } SINGLE_TRANSFER, *PSINGLE_TRANSFER; 123 | 124 | #endif // #ifndef DRIVER 125 | 126 | typedef struct _SET_TRANSFER_SIZE_INFO { 127 | UCHAR EndpointAddress; 128 | ULONG TransferSize; 129 | } SET_TRANSFER_SIZE_INFO, *PSET_TRANSFER_SIZE_INFO; 130 | 131 | 132 | // 133 | // Macro to extract function out of the device io control code 134 | // 135 | #ifdef WIN_98_DDK 136 | #define DEVICE_TYPE_FROM_CTL_CODE(ctrlCode) (((ULONG)(ctrlCode & 0xffff0000)) >> 16) 137 | #endif 138 | #define FUNCTION_FROM_CTL_CODE(ctrlCode) (((ULONG)(ctrlCode & 0x00003FFC)) >> 2) 139 | #define ACCESS_FROM_CTL_CODE(ctrlCode) (((ULONG)(ctrlCode & 0x000C0000)) >> 14) 140 | //#define METHOD_FROM_CTL_CODE(ctrlCode) (((ULONG)(ctrlCode & 0x00000003))) 141 | 142 | 143 | #define IOCTL_ADAPT_INDEX 0x0000 144 | 145 | // Get the driver version 146 | #define IOCTL_ADAPT_GET_DRIVER_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX, METHOD_BUFFERED, FILE_ANY_ACCESS) 147 | 148 | // Get the current USBDI version 149 | #define IOCTL_ADAPT_GET_USBDI_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+1, METHOD_BUFFERED, FILE_ANY_ACCESS) 150 | 151 | // Get the current device alt interface settings from driver 152 | #define IOCTL_ADAPT_GET_ALT_INTERFACE_SETTING CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+2, METHOD_BUFFERED, FILE_ANY_ACCESS) 153 | 154 | // Set the device interface and alt interface setting 155 | #define IOCTL_ADAPT_SELECT_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+3, METHOD_BUFFERED, FILE_ANY_ACCESS) 156 | 157 | // Get device address from driver 158 | #define IOCTL_ADAPT_GET_ADDRESS CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+4, METHOD_BUFFERED, FILE_ANY_ACCESS) 159 | 160 | // Get number of endpoints for current interface and alt interface setting from driver 161 | #define IOCTL_ADAPT_GET_NUMBER_ENDPOINTS CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+5, METHOD_BUFFERED, FILE_ANY_ACCESS) 162 | 163 | // Get the current device power state 164 | #define IOCTL_ADAPT_GET_DEVICE_POWER_STATE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+6, METHOD_BUFFERED, FILE_ANY_ACCESS) 165 | 166 | // Set the device power state 167 | #define IOCTL_ADAPT_SET_DEVICE_POWER_STATE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+7, METHOD_BUFFERED, FILE_ANY_ACCESS) 168 | 169 | // Send a raw packet to endpoint 0 170 | #define IOCTL_ADAPT_SEND_EP0_CONTROL_TRANSFER CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+8, METHOD_BUFFERED, FILE_ANY_ACCESS) 171 | 172 | // Send/receive data to/from nonep0 173 | #define IOCTL_ADAPT_SEND_NON_EP0_TRANSFER CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+9, METHOD_BUFFERED, FILE_ANY_ACCESS) 174 | 175 | // Simulate a disconnect/reconnect 176 | #define IOCTL_ADAPT_CYCLE_PORT CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+10, METHOD_BUFFERED, FILE_ANY_ACCESS) 177 | 178 | // Reset the pipe 179 | #define IOCTL_ADAPT_RESET_PIPE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+11, METHOD_BUFFERED, FILE_ANY_ACCESS) 180 | 181 | // Reset the device 182 | #define IOCTL_ADAPT_RESET_PARENT_PORT CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+12, METHOD_BUFFERED, FILE_ANY_ACCESS) 183 | 184 | // Get the current transfer size of an endpoint (in number of bytes) 185 | #define IOCTL_ADAPT_GET_TRANSFER_SIZE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+13, METHOD_BUFFERED, FILE_ANY_ACCESS) 186 | 187 | // Set the transfer size of an endpoint (in number of bytes) 188 | #define IOCTL_ADAPT_SET_TRANSFER_SIZE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+14, METHOD_BUFFERED, FILE_ANY_ACCESS) 189 | 190 | // Return the name of the device 191 | #define IOCTL_ADAPT_GET_DEVICE_NAME CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+15, METHOD_BUFFERED, FILE_ANY_ACCESS) 192 | 193 | // Return the "Friendly Name" of the device 194 | #define IOCTL_ADAPT_GET_FRIENDLY_NAME CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+16, METHOD_BUFFERED, FILE_ANY_ACCESS) 195 | 196 | // Abort all outstanding transfers on the pipe 197 | #define IOCTL_ADAPT_ABORT_PIPE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+17, METHOD_BUFFERED, FILE_ANY_ACCESS) 198 | 199 | // Send/receive data to/from nonep0 w/ direct buffer acccess (no buffering) 200 | #define IOCTL_ADAPT_SEND_NON_EP0_DIRECT CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+18, METHOD_NEITHER, FILE_ANY_ACCESS) 201 | 202 | // Return device speed 203 | #define IOCTL_ADAPT_GET_DEVICE_SPEED CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+19, METHOD_BUFFERED, FILE_ANY_ACCESS) 204 | 205 | // Get the current USB frame number 206 | #define IOCTL_ADAPT_GET_CURRENT_FRAME CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+20, METHOD_BUFFERED, FILE_ANY_ACCESS) 207 | 208 | #define NUMBER_OF_ADAPT_IOCTLS 21 // Last IOCTL_ADAPT_INDEX + 1 209 | 210 | 211 | #include 212 | 213 | #endif // __IOCTL_H__ 214 | -------------------------------------------------------------------------------- /isotest/charles-streamer/reference/usb100.h: -------------------------------------------------------------------------------- 1 | #ifndef __USB100_H__ 2 | #define __USB100_H__ 3 | 4 | 5 | #include 6 | 7 | 8 | //bmRequest.Dir 9 | #define BMREQUEST_HOST_TO_DEVICE 0 10 | #define BMREQUEST_DEVICE_TO_HOST 1 11 | 12 | //bmRequest.Type 13 | #define BMREQUEST_STANDARD 0 14 | #define BMREQUEST_CLASS 1 15 | #define BMREQUEST_VENDOR 2 16 | 17 | //bmRequest.Recipient 18 | #define BMREQUEST_TO_DEVICE 0 19 | #define BMREQUEST_TO_INTERFACE 1 20 | #define BMREQUEST_TO_ENDPOINT 2 21 | #define BMREQUEST_TO_OTHER 3 22 | 23 | 24 | #define MAXIMUM_USB_STRING_LENGTH 255 25 | 26 | // values for the bits returned by the USB GET_STATUS command 27 | #define USB_GETSTATUS_SELF_POWERED 0x01 28 | #define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED 0x02 29 | 30 | 31 | #define USB_DEVICE_DESCRIPTOR_TYPE 0x01 32 | #define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02 33 | #define USB_STRING_DESCRIPTOR_TYPE 0x03 34 | #define USB_INTERFACE_DESCRIPTOR_TYPE 0x04 35 | #define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05 36 | 37 | // descriptor types defined by DWG documents 38 | #define USB_RESERVED_DESCRIPTOR_TYPE 0x06 39 | #define USB_CONFIG_POWER_DESCRIPTOR_TYPE 0x07 40 | #define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 0x08 41 | 42 | #define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) ((USHORT)((USHORT)d<<8 | i)) 43 | 44 | // 45 | // Values for bmAttributes field of an 46 | // endpoint descriptor 47 | // 48 | 49 | #define USB_ENDPOINT_TYPE_MASK 0x03 50 | 51 | #define USB_ENDPOINT_TYPE_CONTROL 0x00 52 | #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01 53 | #define USB_ENDPOINT_TYPE_BULK 0x02 54 | #define USB_ENDPOINT_TYPE_INTERRUPT 0x03 55 | 56 | 57 | // 58 | // definitions for bits in the bmAttributes field of a 59 | // configuration descriptor. 60 | // 61 | #define USB_CONFIG_POWERED_MASK 0xc0 62 | 63 | #define USB_CONFIG_BUS_POWERED 0x80 64 | #define USB_CONFIG_SELF_POWERED 0x40 65 | #define USB_CONFIG_REMOTE_WAKEUP 0x20 66 | 67 | // 68 | // Endpoint direction bit, stored in address 69 | // 70 | 71 | #define USB_ENDPOINT_DIRECTION_MASK 0x80 72 | 73 | // test direction bit in the bEndpointAddress field of 74 | // an endpoint descriptor. 75 | #define USB_ENDPOINT_DIRECTION_OUT(addr) (!((addr) & USB_ENDPOINT_DIRECTION_MASK)) 76 | #define USB_ENDPOINT_DIRECTION_IN(addr) ((addr) & USB_ENDPOINT_DIRECTION_MASK) 77 | 78 | // 79 | // USB defined request codes 80 | // see chapter 9 of the USB 1.0 specifcation for 81 | // more information. 82 | // 83 | 84 | // These are the correct values based on the USB 1.0 85 | // specification 86 | 87 | #define USB_REQUEST_GET_STATUS 0x00 88 | #define USB_REQUEST_CLEAR_FEATURE 0x01 89 | 90 | #define USB_REQUEST_SET_FEATURE 0x03 91 | 92 | #define USB_REQUEST_SET_ADDRESS 0x05 93 | #define USB_REQUEST_GET_DESCRIPTOR 0x06 94 | #define USB_REQUEST_SET_DESCRIPTOR 0x07 95 | #define USB_REQUEST_GET_CONFIGURATION 0x08 96 | #define USB_REQUEST_SET_CONFIGURATION 0x09 97 | #define USB_REQUEST_GET_INTERFACE 0x0A 98 | #define USB_REQUEST_SET_INTERFACE 0x0B 99 | #define USB_REQUEST_SYNC_FRAME 0x0C 100 | 101 | 102 | // 103 | // defined USB device classes 104 | // 105 | 106 | 107 | #define USB_DEVICE_CLASS_RESERVED 0x00 108 | #define USB_DEVICE_CLASS_AUDIO 0x01 109 | #define USB_DEVICE_CLASS_COMMUNICATIONS 0x02 110 | #define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03 111 | #define USB_DEVICE_CLASS_MONITOR 0x04 112 | #define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05 113 | #define USB_DEVICE_CLASS_POWER 0x06 114 | #define USB_DEVICE_CLASS_PRINTER 0x07 115 | #define USB_DEVICE_CLASS_STORAGE 0x08 116 | #define USB_DEVICE_CLASS_HUB 0x09 117 | #define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF 118 | 119 | // 120 | // USB Core defined Feature selectors 121 | // 122 | 123 | #define USB_FEATURE_ENDPOINT_STALL 0x0000 124 | #define USB_FEATURE_REMOTE_WAKEUP 0x0001 125 | 126 | // 127 | // USB DWG defined Feature selectors 128 | // 129 | 130 | #define USB_FEATURE_INTERFACE_POWER_D0 0x0002 131 | #define USB_FEATURE_INTERFACE_POWER_D1 0x0003 132 | #define USB_FEATURE_INTERFACE_POWER_D2 0x0004 133 | #define USB_FEATURE_INTERFACE_POWER_D3 0x0005 134 | 135 | typedef struct _USB_DEVICE_DESCRIPTOR { 136 | UCHAR bLength; 137 | UCHAR bDescriptorType; 138 | USHORT bcdUSB; 139 | UCHAR bDeviceClass; 140 | UCHAR bDeviceSubClass; 141 | UCHAR bDeviceProtocol; 142 | UCHAR bMaxPacketSize0; 143 | USHORT idVendor; 144 | USHORT idProduct; 145 | USHORT bcdDevice; 146 | UCHAR iManufacturer; 147 | UCHAR iProduct; 148 | UCHAR iSerialNumber; 149 | UCHAR bNumConfigurations; 150 | } USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR; 151 | 152 | typedef struct _USB_ENDPOINT_DESCRIPTOR { 153 | UCHAR bLength; 154 | UCHAR bDescriptorType; 155 | UCHAR bEndpointAddress; 156 | UCHAR bmAttributes; 157 | USHORT wMaxPacketSize; 158 | UCHAR bInterval; 159 | } USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR; 160 | 161 | typedef struct _USB_CONFIGURATION_DESCRIPTOR { 162 | UCHAR bLength; 163 | UCHAR bDescriptorType; 164 | USHORT wTotalLength; 165 | UCHAR bNumInterfaces; 166 | UCHAR bConfigurationValue; 167 | UCHAR iConfiguration; 168 | UCHAR bmAttributes; 169 | UCHAR MaxPower; 170 | } USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR; 171 | 172 | typedef struct _USB_INTERFACE_DESCRIPTOR { 173 | UCHAR bLength; 174 | UCHAR bDescriptorType; 175 | UCHAR bInterfaceNumber; 176 | UCHAR bAlternateSetting; 177 | UCHAR bNumEndpoints; 178 | UCHAR bInterfaceClass; 179 | UCHAR bInterfaceSubClass; 180 | UCHAR bInterfaceProtocol; 181 | UCHAR iInterface; 182 | } USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR; 183 | 184 | typedef struct _USB_STRING_DESCRIPTOR { 185 | UCHAR bLength; 186 | UCHAR bDescriptorType; 187 | WCHAR bString[1]; 188 | } USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR; 189 | 190 | typedef struct _USB_COMMON_DESCRIPTOR { 191 | UCHAR bLength; 192 | UCHAR bDescriptorType; 193 | } USB_COMMON_DESCRIPTOR, *PUSB_COMMON_DESCRIPTOR; 194 | 195 | 196 | // 197 | // Standard USB HUB definitions 198 | // 199 | // See Chapter 11 USB core specification 200 | // 201 | 202 | typedef struct _USB_HUB_DESCRIPTOR { 203 | UCHAR bDescriptorLength; // Length of this descriptor 204 | UCHAR bDescriptorType; // Hub configuration type 205 | UCHAR bNumberOfPorts; // number of ports on this hub 206 | USHORT wHubCharacteristics; // Hub Charateristics 207 | UCHAR bPowerOnToPowerGood; // port power on till power good in 2ms 208 | UCHAR bHubControlCurrent; // max current in mA 209 | // 210 | // room for 255 ports power control and removable bitmask 211 | UCHAR bRemoveAndPowerMask[64]; 212 | } USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR; 213 | 214 | 215 | // 216 | // Structures defined by various DWG feature documents 217 | // 218 | 219 | 220 | // 221 | // See DWG USB Feature Specification: Interface Power Management 222 | // 223 | 224 | #define USB_SUPPORT_D0_COMMAND 0x01 225 | #define USB_SUPPORT_D1_COMMAND 0x02 226 | #define USB_SUPPORT_D2_COMMAND 0x04 227 | #define USB_SUPPORT_D3_COMMAND 0x08 228 | 229 | #define USB_SUPPORT_D1_WAKEUP 0x10 230 | #define USB_SUPPORT_D2_WAKEUP 0x20 231 | 232 | 233 | typedef struct _USB_CONFIGURATION_POWER_DESCRIPTOR { 234 | UCHAR bLength; 235 | UCHAR bDescriptorType; 236 | UCHAR SelfPowerConsumedD0[3]; 237 | UCHAR bPowerSummaryId; 238 | UCHAR bBusPowerSavingD1; 239 | UCHAR bSelfPowerSavingD1; 240 | UCHAR bBusPowerSavingD2; 241 | UCHAR bSelfPowerSavingD2; 242 | UCHAR bBusPowerSavingD3; 243 | UCHAR bSelfPowerSavingD3; 244 | USHORT TransitionTimeFromD1; 245 | USHORT TransitionTimeFromD2; 246 | USHORT TransitionTimeFromD3; 247 | } USB_CONFIGURATION_POWER_DESCRIPTOR, *PUSB_CONFIGURATION_POWER_DESCRIPTOR; 248 | 249 | 250 | typedef struct _USB_INTERFACE_POWER_DESCRIPTOR { 251 | UCHAR bLength; 252 | UCHAR bDescriptorType; 253 | UCHAR bmCapabilitiesFlags; 254 | UCHAR bBusPowerSavingD1; 255 | UCHAR bSelfPowerSavingD1; 256 | UCHAR bBusPowerSavingD2; 257 | UCHAR bSelfPowerSavingD2; 258 | UCHAR bBusPowerSavingD3; 259 | UCHAR bSelfPowerSavingD3; 260 | USHORT TransitionTimeFromD1; 261 | USHORT TransitionTimeFromD2; 262 | USHORT TransitionTimeFromD3; 263 | } USB_INTERFACE_POWER_DESCRIPTOR, *PUSB_INTERFACE_POWER_DESCRIPTOR; 264 | 265 | 266 | #include 267 | 268 | 269 | #endif /* __USB100_H__ */ 270 | 271 | -------------------------------------------------------------------------------- /isotest/charles-streamer/reference/usb200.h: -------------------------------------------------------------------------------- 1 | #ifndef __USB200_H__ 2 | #define __USB200_H__ 3 | 4 | #include "usb100.h" 5 | 6 | 7 | #include 8 | 9 | typedef enum _USB_DEVICE_SPEED { 10 | UsbLowSpeed = 0, 11 | UsbFullSpeed, 12 | UsbHighSpeed 13 | } USB_DEVICE_SPEED; 14 | 15 | typedef enum _USB_DEVICE_TYPE { 16 | Usb11Device = 0, 17 | Usb20Device 18 | } USB_DEVICE_TYPE; 19 | 20 | // standard definiions for the port status 21 | // word of the HUB port register 22 | 23 | #define USB_PORT_STATUS_CONNECT 0x0001 24 | #define USB_PORT_STATUS_ENABLE 0x0002 25 | #define USB_PORT_STATUS_SUSPEND 0x0004 26 | #define USB_PORT_STATUS_OVER_CURRENT 0x0008 27 | #define USB_PORT_STATUS_RESET 0x0010 28 | #define USB_PORT_STATUS_POWER 0x0100 29 | #define USB_PORT_STATUS_LOW_SPEED 0x0200 30 | #define USB_PORT_STATUS_HIGH_SPEED 0x0400 31 | 32 | typedef union _BM_REQUEST_TYPE { 33 | struct _BM { 34 | UCHAR Recipient:2; 35 | UCHAR Reserved:3; 36 | UCHAR Type:2; 37 | UCHAR Dir:1; 38 | }; 39 | UCHAR B; 40 | } BM_REQUEST_TYPE, *PBM_REQUEST_TYPE; 41 | 42 | typedef struct _USB_DEFAULT_PIPE_SETUP_PACKET { 43 | BM_REQUEST_TYPE bmRequestType; 44 | UCHAR bRequest; 45 | 46 | union _wValue { 47 | struct { 48 | UCHAR LowByte; 49 | UCHAR HiByte; 50 | }; 51 | USHORT W; 52 | } wValue; 53 | 54 | union _wIndex { 55 | struct { 56 | UCHAR LowByte; 57 | UCHAR HiByte; 58 | }; 59 | USHORT W; 60 | } wIndex; 61 | USHORT wLength; 62 | } USB_DEFAULT_PIPE_SETUP_PACKET, *PUSB_DEFAULT_PIPE_SETUP_PACKET; 63 | 64 | // setup packet is eight bytes -- defined by spec 65 | C_ASSERT(sizeof(USB_DEFAULT_PIPE_SETUP_PACKET) == 8); 66 | 67 | 68 | #define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE 0x06 69 | 70 | typedef struct _USB_DEVICE_QUALIFIER_DESCRIPTOR { 71 | UCHAR bLength; 72 | UCHAR bDescriptorType; 73 | USHORT bcdUSB; 74 | UCHAR bDeviceClass; 75 | UCHAR bDeviceSubClass; 76 | UCHAR bDeviceProtocol; 77 | UCHAR bMaxPacketSize0; 78 | UCHAR bNumConfigurations; 79 | UCHAR bReserved; 80 | } USB_DEVICE_QUALIFIER_DESCRIPTOR, *PUSB_DEVICE_QUALIFIER_DESCRIPTOR; 81 | 82 | 83 | typedef union _USB_HIGH_SPEED_MAXPACKET { 84 | struct _MP { 85 | USHORT MaxPacket:11; /* 0..10 */ 86 | USHORT HSmux:2; /* 11..12 */ 87 | USHORT Reserved:3; /* 13..15 */ 88 | }; 89 | USHORT us; 90 | } USB_HIGH_SPEED_MAXPACKET, *PUSB_HIGH_SPEED_MAXPACKET; 91 | 92 | #define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE 0x0B 93 | 94 | typedef struct _USB_INTERFACE_ASSOCIATION_DESCRIPTOR { 95 | 96 | UCHAR bLength; 97 | UCHAR bDescriptorType; 98 | UCHAR bFirstInterface; 99 | UCHAR bInterfaceCount; 100 | UCHAR bFunctionClass; 101 | UCHAR bFunctionSubClass; 102 | UCHAR bFunctionProtocol; 103 | UCHAR iFunction; 104 | 105 | } USB_INTERFACE_ASSOCIATION_DESCRIPTOR, *PUSB_INTERFACE_ASSOCIATION_DESCRIPTOR; 106 | 107 | 108 | #include 109 | 110 | #endif __USB200_H__ 111 | 112 | -------------------------------------------------------------------------------- /isotest/compile.bat: -------------------------------------------------------------------------------- 1 | set TCC=C:\tcc\tcc.exe 2 | set CFLAGS=-DTCC -DWINDOWS -DHIDAPI -DWIN32 -Os -I. -I../libcyprio 3 | set LDFLAGS=-s C:/windows/system32/kernel32.dll -lgdi32 -luser32 -lsetupapi -ldbghelp 4 | 5 | del teststream.exe recstream.exe 6 | 7 | %TCC% -o teststream.exe teststream.c ../libcyprio/libcyprio.c os_generic.c %CFLAGS% %LDFLAGS% 8 | %TCC% -o recstream.exe recstream.c ../libcyprio/libcyprio.c os_generic.c %CFLAGS% %LDFLAGS% 9 | 10 | -------------------------------------------------------------------------------- /isotest/os_generic.c: -------------------------------------------------------------------------------- 1 | #include "os_generic.h" 2 | 3 | #ifdef USE_WINDOWS 4 | 5 | #include 6 | 7 | void OGSleep( int is ) 8 | { 9 | Sleep( is*1000 ); 10 | } 11 | 12 | void OGUSleep( int ius ) 13 | { 14 | Sleep( ius/1000 ); 15 | } 16 | 17 | double OGGetAbsoluteTime() 18 | { 19 | static LARGE_INTEGER lpf; 20 | LARGE_INTEGER li; 21 | 22 | if( !lpf.QuadPart ) 23 | { 24 | QueryPerformanceFrequency( &lpf ); 25 | } 26 | 27 | QueryPerformanceCounter( &li ); 28 | return (double)li.QuadPart / (double)lpf.QuadPart; 29 | } 30 | 31 | 32 | double OGGetFileTime( const char * file ) 33 | { 34 | FILETIME ft; 35 | 36 | HANDLE h = CreateFile(file, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); 37 | 38 | if( h==INVALID_HANDLE_VALUE ) 39 | return -1; 40 | 41 | GetFileTime( h, 0, 0, &ft ); 42 | 43 | CloseHandle( h ); 44 | 45 | return ft.dwHighDateTime + ft.dwLowDateTime; 46 | } 47 | 48 | 49 | og_thread_t OGCreateThread( void * (routine)( void * ), void * parameter ) 50 | { 51 | return (og_thread_t)CreateThread( 0, 0, (LPTHREAD_START_ROUTINE)routine, parameter, 0, 0 ); 52 | } 53 | 54 | void * OGJoinThread( og_thread_t ot ) 55 | { 56 | WaitForSingleObject( ot, INFINITE ); 57 | CloseHandle( ot ); 58 | return 0; 59 | } 60 | 61 | void OGCancelThread( og_thread_t ot ) 62 | { 63 | CloseHandle( ot ); 64 | } 65 | 66 | og_mutex_t OGCreateMutex() 67 | { 68 | return CreateMutex( 0, 0, 0 ); 69 | } 70 | 71 | void OGLockMutex( og_mutex_t om ) 72 | { 73 | WaitForSingleObject(om, INFINITE); 74 | } 75 | 76 | void OGUnlockMutex( og_mutex_t om ) 77 | { 78 | ReleaseMutex(om); 79 | } 80 | 81 | void OGDeleteMutex( og_mutex_t om ) 82 | { 83 | CloseHandle( om ); 84 | } 85 | 86 | 87 | 88 | og_sema_t OGCreateSema() 89 | { 90 | HANDLE sem = CreateSemaphore( 0, 0, 32767, 0 ); 91 | return (og_sema_t)sem; 92 | } 93 | 94 | int OGGetSema( og_sema_t os ) 95 | { 96 | typedef LONG NTSTATUS; 97 | HANDLE sem = (HANDLE)os; 98 | typedef NTSTATUS (NTAPI *_NtQuerySemaphore)( 99 | HANDLE SemaphoreHandle, 100 | DWORD SemaphoreInformationClass, /* Would be SEMAPHORE_INFORMATION_CLASS */ 101 | PVOID SemaphoreInformation, /* but this is to much to dump here */ 102 | ULONG SemaphoreInformationLength, 103 | PULONG ReturnLength OPTIONAL 104 | ); 105 | 106 | typedef struct _SEMAPHORE_BASIC_INFORMATION { 107 | ULONG CurrentCount; 108 | ULONG MaximumCount; 109 | } SEMAPHORE_BASIC_INFORMATION; 110 | 111 | 112 | static _NtQuerySemaphore NtQuerySemaphore; 113 | SEMAPHORE_BASIC_INFORMATION BasicInfo; 114 | NTSTATUS Status; 115 | 116 | if( !NtQuerySemaphore ) 117 | { 118 | NtQuerySemaphore = (_NtQuerySemaphore)GetProcAddress (GetModuleHandle ("ntdll.dll"), "NtQuerySemaphore"); 119 | if( !NtQuerySemaphore ) 120 | { 121 | return -1; 122 | } 123 | } 124 | 125 | 126 | Status = NtQuerySemaphore (sem, 0 /*SemaphoreBasicInformation*/, 127 | &BasicInfo, sizeof (SEMAPHORE_BASIC_INFORMATION), NULL); 128 | 129 | if (Status == ERROR_SUCCESS) 130 | { 131 | return BasicInfo.CurrentCount; 132 | } 133 | 134 | return -2; 135 | } 136 | 137 | void OGLockSema( og_sema_t os ) 138 | { 139 | WaitForSingleObject( (HANDLE)os, INFINITE ); 140 | } 141 | 142 | void OGUnlockSema( og_sema_t os ) 143 | { 144 | ReleaseSemaphore( (HANDLE)os, 1, 0 ); 145 | } 146 | 147 | void OGDeleteSema( og_sema_t os ) 148 | { 149 | CloseHandle( os ); 150 | } 151 | 152 | #else 153 | 154 | #define _GNU_SOURCE 155 | 156 | 157 | #include 158 | #include 159 | #include 160 | #include 161 | #include 162 | #include 163 | 164 | pthread_mutex_t g_RawMutexStart = PTHREAD_MUTEX_INITIALIZER; 165 | 166 | void OGSleep( int is ) 167 | { 168 | sleep( is ); 169 | } 170 | 171 | void OGUSleep( int ius ) 172 | { 173 | usleep( ius ); 174 | } 175 | 176 | double OGGetAbsoluteTime() 177 | { 178 | struct timeval tv; 179 | gettimeofday( &tv, 0 ); 180 | return ((double)tv.tv_usec)/1000000. + (tv.tv_sec); 181 | } 182 | 183 | double OGGetFileTime( const char * file ) 184 | { 185 | struct stat buff; 186 | 187 | int r = stat( file, &buff ); 188 | 189 | if( r < 0 ) 190 | { 191 | return -1; 192 | } 193 | 194 | return buff.st_mtime; 195 | } 196 | 197 | 198 | 199 | og_thread_t OGCreateThread( void * (routine)( void * ), void * parameter ) 200 | { 201 | pthread_t * ret = malloc( sizeof( pthread_t ) ); 202 | int r = pthread_create( ret, 0, routine, parameter ); 203 | if( r ) 204 | { 205 | free( ret ); 206 | return 0; 207 | } 208 | return (og_thread_t)ret; 209 | } 210 | 211 | void * OGJoinThread( og_thread_t ot ) 212 | { 213 | void * retval; 214 | if( !ot ) 215 | { 216 | return 0; 217 | } 218 | pthread_join( *(pthread_t*)ot, &retval ); 219 | free( ot ); 220 | return retval; 221 | } 222 | 223 | void OGCancelThread( og_thread_t ot ) 224 | { 225 | if( !ot ) 226 | { 227 | return; 228 | } 229 | pthread_cancel( *(pthread_t*)ot ); 230 | free( ot ); 231 | } 232 | 233 | og_mutex_t OGCreateMutex() 234 | { 235 | pthread_mutexattr_t mta; 236 | og_mutex_t r = malloc( sizeof( pthread_mutex_t ) ); 237 | 238 | pthread_mutexattr_init(&mta); 239 | pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_RECURSIVE); 240 | 241 | pthread_mutex_init( (pthread_mutex_t *)r, &mta ); 242 | 243 | return r; 244 | } 245 | 246 | void OGLockMutex( og_mutex_t om ) 247 | { 248 | if( !om ) 249 | { 250 | return; 251 | } 252 | pthread_mutex_lock( (pthread_mutex_t*)om ); 253 | } 254 | 255 | void OGUnlockMutex( og_mutex_t om ) 256 | { 257 | if( !om ) 258 | { 259 | return; 260 | } 261 | pthread_mutex_unlock( (pthread_mutex_t*)om ); 262 | } 263 | 264 | void OGDeleteMutex( og_mutex_t om ) 265 | { 266 | if( !om ) 267 | { 268 | return; 269 | } 270 | 271 | pthread_mutex_destroy( (pthread_mutex_t*)om ); 272 | free( om ); 273 | } 274 | 275 | 276 | 277 | 278 | og_sema_t OGCreateSema() 279 | { 280 | sem_t * sem = malloc( sizeof( sem_t ) ); 281 | sem_init( sem, 0, 0 ); 282 | return (og_sema_t)sem; 283 | } 284 | 285 | int OGGetSema( og_sema_t os ) 286 | { 287 | int valp; 288 | sem_getvalue( os, &valp ); 289 | return valp; 290 | } 291 | 292 | 293 | void OGLockSema( og_sema_t os ) 294 | { 295 | sem_wait( os ); 296 | } 297 | 298 | void OGUnlockSema( og_sema_t os ) 299 | { 300 | sem_post( os ); 301 | } 302 | 303 | void OGDeleteSema( og_sema_t os ) 304 | { 305 | sem_destroy( os ); 306 | free(os); 307 | } 308 | 309 | 310 | 311 | #endif 312 | 313 | //Date Stamp: 2012-02-15 314 | 315 | /* 316 | Copyright (c) 2011-2012 <>< Charles Lohr 317 | 318 | Permission is hereby granted, free of charge, to any person obtaining a 319 | copy of this software and associated documentation files (the "Software"), 320 | to deal in the Software without restriction, including without limitation 321 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 322 | and/or sell copies of the Software, and to permit persons to whom the 323 | Software is furnished to do so, subject to the following conditions: 324 | 325 | The above copyright notice and this permission notice shall be included in 326 | all copies or substantial portions of this file. 327 | 328 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 329 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 330 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 331 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 332 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 333 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 334 | IN THE SOFTWARE. 335 | */ 336 | 337 | -------------------------------------------------------------------------------- /isotest/os_generic.h: -------------------------------------------------------------------------------- 1 | #ifndef _OS_GENERIC_H 2 | #define _OS_GENERIC_H 3 | 4 | #if defined( WIN32 ) || defined (WINDOWS) || defined( _WIN32) 5 | #define USE_WINDOWS 6 | #endif 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | //Things that shouldn't be macro'd 13 | double OGGetAbsoluteTime(); 14 | void OGSleep( int is ); 15 | void OGUSleep( int ius ); 16 | double OGGetFileTime( const char * file ); 17 | 18 | //Threads and Mutices 19 | typedef void* og_thread_t; 20 | typedef void* og_mutex_t; 21 | typedef void* og_sema_t; 22 | 23 | og_thread_t OGCreateThread( void * (routine)( void * ), void * parameter ); 24 | void * OGJoinThread( og_thread_t ot ); 25 | void OGCancelThread( og_thread_t ot ); 26 | 27 | //Always a recrusive mutex. 28 | og_mutex_t OGCreateMutex(); 29 | void OGLockMutex( og_mutex_t om ); 30 | void OGUnlockMutex( og_mutex_t om ); 31 | void OGDeleteMutex( og_mutex_t om ); 32 | 33 | //Always a semaphore 34 | og_sema_t OGCreateSema(); //Create a semaphore, comes locked initially. NOTE: Max count is 32767 35 | void OGLockSema( og_sema_t os ); 36 | int OGGetSema( og_sema_t os ); //if <0 there was a failure. 37 | void OGUnlockSema( og_sema_t os ); 38 | void OGDeleteSema( og_sema_t os ); 39 | 40 | #ifdef __cplusplus 41 | }; 42 | #endif 43 | 44 | 45 | 46 | #endif 47 | 48 | 49 | //Date Stamp: 2012-02-15 50 | 51 | /* 52 | NOTE: Portions (namely the top section) are part of headers from other 53 | sources. 54 | 55 | Copyright (c) 2011-2012 <>< Charles Lohr 56 | 57 | Permission is hereby granted, free of charge, to any person obtaining a 58 | copy of this software and associated documentation files (the "Software"), 59 | to deal in the Software without restriction, including without limitation 60 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 61 | and/or sell copies of the Software, and to permit persons to whom the 62 | Software is furnished to do so, subject to the following conditions: 63 | 64 | The above copyright notice and this permission notice shall be included in 65 | all copies or substantial portions of this file. 66 | 67 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 68 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 69 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 70 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 71 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 72 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 73 | IN THE SOFTWARE. 74 | */ 75 | 76 | -------------------------------------------------------------------------------- /isotest/recstream.c: -------------------------------------------------------------------------------- 1 | /* 2 | Tool to test Cypress FX3 isochronous transfers using the stream test firmware 3 | (C) 2017 C. Lohr, under the MIT-x11 or NewBSD License. You decide. 4 | Tested on Windows, working full functionality 12/30/2017 5 | Tested on Linux, working full functionality 7/22/2018 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include "os_generic.h" 12 | 13 | #if defined(WINDOWS) || defined( WIN32 ) 14 | #include 15 | #else 16 | #include 17 | #include 18 | #endif 19 | 20 | double Last; 21 | double bytes; 22 | 23 | struct CyprIO eps; 24 | FILE * fout; 25 | 26 | void TickCypr() 27 | { 28 | char buf[64]; 29 | printf( "Control\n" ); 30 | int e = CyprIOControlTransfer( &eps, 0xc0, 0xaa, 0x0102, 0x0304, buf, 50, 10 ); 31 | printf( "GOT: %d:", e ); 32 | int i; 33 | for( i = 0; i < e; i++ ) 34 | { 35 | printf( "%02x ", (uint8_t)buf[i] ); 36 | } 37 | printf( "\n" ); 38 | } 39 | 40 | 41 | void * TickThread( void * v ) 42 | { 43 | while(1) 44 | { 45 | TickCypr(); 46 | OGSleep(1); 47 | } 48 | } 49 | 50 | uint8_t ubigbuf[8192*1024]; 51 | 52 | int callback( void * id, struct CyprIOEndpoint * ep, uint8_t * data, uint32_t length ) 53 | { 54 | bytes += length; 55 | double Now = OGGetAbsoluteTime(); 56 | //if( data[0] != 0xaa ) printf( "Bad data\n" ); 57 | //printf( "%d %02x %02x\n", length, data[0], data[100] ); 58 | 59 | #if 1 60 | #ifdef SIXTEEN_BITS 61 | fwrite( data, length, 1, fout ); 62 | #else 63 | int i; 64 | length/=2; 65 | for( i = 0; i < length; i++ ) 66 | { 67 | ubigbuf[i] = ((uint16_t*)data)[i]; 68 | } 69 | fwrite( ubigbuf, length, 1, fout ); 70 | #endif 71 | #endif 72 | 73 | if( Last + 1 < Now ) 74 | { 75 | printf( "Got %.3f kB/s [%02x %02x] [%d pack]\n", bytes/1000, data[0], data[1], length ); 76 | Last++; 77 | bytes = 0; 78 | 79 | } 80 | return 0; 81 | } 82 | 83 | #if !defined(WINDOWS) && !defined(WIN32) 84 | void CtrlCSignal() 85 | { 86 | eps.shutdown = 1; 87 | usleep(100000); 88 | CyprIODestroy( &eps ); 89 | } 90 | #endif 91 | 92 | int main() 93 | { 94 | fout = fopen( "data.dat", "wb" ); 95 | printf( "Test streamer\n" ); 96 | 97 | #if !defined(WINDOWS) && !defined(WIN32) 98 | signal(SIGINT, CtrlCSignal); 99 | #endif 100 | int r = CyprIOConnect( &eps, 0, 0x04b4, 0x00f1 ); 101 | if( r ) 102 | { 103 | fprintf( stderr, "Error: Could not connect to USB device\n" ); 104 | return -1; 105 | } 106 | r = CyprIOGetDevDescriptorInformation( &eps ); 107 | if( r ) 108 | { 109 | fprintf( stderr, "Error: Couldn't get all info needed from device\n" ); 110 | return -1; 111 | } 112 | r = CyprIOSetup( &eps, 0, 2 ); 113 | if( r ) 114 | { 115 | fprintf( stderr, "Error: Could not setup USB device\n" ); 116 | return -1; 117 | } 118 | 119 | printf( "Connected successfully\n" ); 120 | #if 0 121 | Last = OGGetAbsoluteTime(); 122 | bytes = 0; 123 | while(1) 124 | { 125 | uint8_t buf[32768]; 126 | uint32_t bufLen = sizeof(buf); 127 | struct CyprCyIsoPktInfo Status; 128 | CyprDataXfer( &eps.CypIOEndpoints[0], buf, &bufLen, &Status); 129 | int i; 130 | //printf( "%d\n", bufLen ); 131 | bytes += bufLen; 132 | 133 | double Now = OGGetAbsoluteTime(); 134 | if( Last + 1 < Now ) 135 | { 136 | Last++; 137 | printf( "%.3f KB/s\n", bytes/1024.0 ); 138 | bytes = 0; 139 | } 140 | #if 0 141 | for( i = 0; i < bufLen; i++ ) 142 | { 143 | printf( "%02x ", buf[i] ); 144 | } 145 | #endif 146 | } 147 | 148 | #elif 0 149 | 150 | int i; 151 | for( i = 0; i < 10; i++ ) 152 | { 153 | char buf[64]; 154 | memcpy( buf, "hello", 5 ); 155 | //CyprIOControl( ep->parent, 0xc0, buf, 5 ); 156 | // PSINGLE_TRANSFER pSingleTransfer = FillSingleControlTransfer( buf, 0xc0, 0xc0, 0xc0, 0xcc, 5 ); 157 | // int e = CyprIOControl( &eps.CypIOEndpoints[0], IOCTL_ADAPT_SEND_EP0_CONTROL_TRANSFER, buf, sizeof(SINGLE_TRANSFER)+2 ); 158 | // int e = CyprIOControl( &eps.CypIOEndpoints[0], 0x40, buf, 5 ); 159 | int e = CyprIOControlTransfer( &eps, 0xc0, 0xaa, 0x0102, 0x0304, buf, 50, 5000 ); 160 | printf( "GOT: %d:", e ); 161 | int i; 162 | for( i = 0; i < e; i++ ) 163 | { 164 | printf( "%02x ", (uint8_t)buf[i] ); 165 | } 166 | printf( "\n" ); 167 | } 168 | return 0; 169 | 170 | #else 171 | 172 | Last = OGGetAbsoluteTime(); 173 | 174 | OGCreateThread( TickThread, 0 ); 175 | #if defined( WINDOWS ) || defined( WIN32) 176 | CyprIODoCircularDataXferTx( &eps.CypIOEndpoints[0], 65536*16, 8, callback, 0 ); 177 | #else 178 | CyprIODoCircularDataXferTx( &eps.CypIOEndpoints[0], 32768, 8, callback, 0 ); 179 | #endif 180 | printf( "Done with circular data xfer\n" ); 181 | 182 | #endif 183 | 184 | 185 | return 0; 186 | } 187 | -------------------------------------------------------------------------------- /isotest/recstream.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/fx3fun/b36d2d7eadebfef53769dc09c573807a1a2a71f4/isotest/recstream.exe -------------------------------------------------------------------------------- /isotest/teststream.c: -------------------------------------------------------------------------------- 1 | /* 2 | Tool to test Cypress FX3 isochronous transfers using the stream test firmware 3 | (C) 2017 C. Lohr, under the MIT-x11 or NewBSD License. You decide. 4 | Tested on Windows, working full functionality 12/30/2017 5 | Tested on Linux, working full functionality 7/22/2018 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include "os_generic.h" 12 | 13 | #if defined(WINDOWS) || defined( WIN32 ) 14 | #include 15 | #else 16 | #include 17 | #include 18 | #endif 19 | 20 | double Last; 21 | double bytes; 22 | 23 | struct CyprIO eps; 24 | 25 | 26 | void TickCypr() 27 | { 28 | char buf[64]; 29 | printf( "Control\n" ); 30 | int e = CyprIOControlTransfer( &eps, 0xc0, 0xaa, 0x0102, 0x0304, buf, 50, 10 ); 31 | printf( "GOT: %d:", e ); 32 | int i; 33 | for( i = 0; i < e; i++ ) 34 | { 35 | printf( "%02x ", (uint8_t)buf[i] ); 36 | } 37 | printf( "\n" ); 38 | } 39 | 40 | 41 | void * TickThread( void * v ) 42 | { 43 | while(1) 44 | { 45 | TickCypr(); 46 | OGSleep(1); 47 | } 48 | } 49 | 50 | int callback( void * id, struct CyprIOEndpoint * ep, uint8_t * data, uint32_t length ) 51 | { 52 | bytes += length; 53 | double Now = OGGetAbsoluteTime(); 54 | //if( data[0] != 0xaa ) printf( "Bad data\n" ); 55 | //printf( "%d %02x %02x\n", length, data[0], data[100] ); 56 | if( Last + 1 < Now ) 57 | { 58 | printf( "Got %.3f kB/s %d\n", bytes/1000.0, length ); 59 | // int j; 60 | // for( j = 0; j < length; j += 8192 ) 61 | // { 62 | // printf( "[%02x %02x]", data[j+0], data[j+1] ); 63 | // } 64 | Last++; 65 | bytes = 0; 66 | 67 | } 68 | 69 | int j; 70 | for( j = 0; j < length; j += 8192 ) 71 | { 72 | if( data[j] == 0 ) 73 | { 74 | printf( "Zero at: %d\n", j ); 75 | return 0; 76 | } 77 | } 78 | return 0; 79 | } 80 | 81 | #if !defined(WINDOWS) && !defined(WIN32) 82 | void CtrlCSignal() 83 | { 84 | eps.shutdown = 1; 85 | usleep(100000); 86 | CyprIODestroy( &eps ); 87 | } 88 | #endif 89 | 90 | 91 | int main() 92 | { 93 | printf( "Test streamer\n" ); 94 | #if !defined(WINDOWS) && !defined(WIN32) 95 | signal(SIGINT, CtrlCSignal); 96 | #endif 97 | int r = CyprIOConnect( &eps, 0, 0x04b4, 0x00f1 ); 98 | if( r ) 99 | { 100 | fprintf( stderr, "Error: Could not connect to USB device\n" ); 101 | return -1; 102 | } 103 | r = CyprIOGetDevDescriptorInformation( &eps ); 104 | if( r ) 105 | { 106 | fprintf( stderr, "Error: Couldn't get all info needed from device\n" ); 107 | return -1; 108 | } 109 | r = CyprIOSetup( &eps, 0, 2 ); 110 | if( r ) 111 | { 112 | fprintf( stderr, "Error: Could not setup USB device\n" ); 113 | return -1; 114 | } 115 | 116 | printf( "Connected successfully\n" ); 117 | #if 0 118 | Last = OGGetAbsoluteTime(); 119 | bytes = 0; 120 | while(1) 121 | { 122 | uint8_t buf[32768]; 123 | uint32_t bufLen = sizeof(buf); 124 | struct CyprCyIsoPktInfo Status; 125 | CyprDataXfer( &eps.CypIOEndpoints[0], buf, &bufLen, &Status); 126 | int i; 127 | //printf( "%d\n", bufLen ); 128 | bytes += bufLen; 129 | 130 | double Now = OGGetAbsoluteTime(); 131 | if( Last + 1 < Now ) 132 | { 133 | Last++; 134 | printf( "%.3f kB/s\n", bytes/1000.0 ); 135 | bytes = 0; 136 | } 137 | #if 0 138 | for( i = 0; i < bufLen; i++ ) 139 | { 140 | printf( "%02x ", buf[i] ); 141 | } 142 | #endif 143 | } 144 | 145 | #elif 0 146 | 147 | int i; 148 | for( i = 0; i < 10; i++ ) 149 | { 150 | char buf[64]; 151 | memcpy( buf, "hello", 5 ); 152 | //CyprIOControl( ep->parent, 0xc0, buf, 5 ); 153 | // PSINGLE_TRANSFER pSingleTransfer = FillSingleControlTransfer( buf, 0xc0, 0xc0, 0xc0, 0xcc, 5 ); 154 | // int e = CyprIOControl( &eps.CypIOEndpoints[0], IOCTL_ADAPT_SEND_EP0_CONTROL_TRANSFER, buf, sizeof(SINGLE_TRANSFER)+2 ); 155 | // int e = CyprIOControl( &eps.CypIOEndpoints[0], 0x40, buf, 5 ); 156 | int e = CyprIOControlTransfer( &eps, 0xc0, 0xaa, 0x0102, 0x0304, buf, 50, 5000 ); 157 | printf( "GOT: %d:", e ); 158 | int i; 159 | for( i = 0; i < e; i++ ) 160 | { 161 | printf( "%02x ", (uint8_t)buf[i] ); 162 | } 163 | printf( "\n" ); 164 | } 165 | return 0; 166 | 167 | #else 168 | 169 | Last = OGGetAbsoluteTime(); 170 | 171 | OGCreateThread( TickThread, 0 ); 172 | #if defined( WINDOWS ) || defined( WIN32) 173 | CyprIODoCircularDataXferTx( &eps.CypIOEndpoints[0], 65536*16, 8, callback, 0 ); 174 | #else 175 | CyprIODoCircularDataXferTx( &eps.CypIOEndpoints[0], 32768, 16, callback, 0 ); 176 | #endif 177 | printf( "Done with circular data xfer\n" ); 178 | 179 | #endif 180 | 181 | 182 | return 0; 183 | } 184 | -------------------------------------------------------------------------------- /isotest/teststream.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/fx3fun/b36d2d7eadebfef53769dc09c573807a1a2a71f4/isotest/teststream.exe -------------------------------------------------------------------------------- /latencytest/Makefile: -------------------------------------------------------------------------------- 1 | all : latencytest 2 | 3 | LCYPRIO:=../libcyprio 4 | CFLAGS:=-I$(LCYPRIO) -O1 -g 5 | LDFLAGS:=-lusb-1.0 -lpthread 6 | 7 | CYPRIO:=$(LCYPRIO)/libcyprio.c $(LCYPRIO)/libcyprio_util.c 8 | 9 | latencytest : latencytest.c $(CYPRIO) 10 | gcc -o $@ $^ $(CFLAGS) $(LDFLAGS) 11 | 12 | clean : 13 | rm -rf *.o *~ latencytest 14 | -------------------------------------------------------------------------------- /latencytest/compile.bat: -------------------------------------------------------------------------------- 1 | set CFLAGS=-DTCC -DWINDOWS -DHIDAPI -DWIN32 -O2 -m64 -I. -I../libcyprio -Irawdraw -g -rdynamic -DTCCCRASH_STANDALONE 2 | set LDFLAGS=-s C:/windows/system32/kernel32.dll -lgdi32 -luser32 -lsetupapi -lws2_32 -ldbghelp C:\\windows\\system32\\opengl32.dll C:\\windows\\system32\msvcrt.dll 3 | del latencytest.exe 4 | C:\tcc\tcc latencytest.c ../libcyprio/libcyprio.c -o latencytest.exe %CFLAGS% %LDFLAGS% 5 | 6 | -------------------------------------------------------------------------------- /latencytest/latencytest.c: -------------------------------------------------------------------------------- 1 | /* 2 | Connect a wire from CTRL[8] to D[0] 3 | 4 | This will toggle it and time the amount of time it takes to change state 5 | and see change. 6 | 7 | */ 8 | 9 | #include 10 | #include "libcyprio.h" 11 | #include "os_generic.h" 12 | 13 | 14 | struct CyprIO eps; 15 | 16 | int bytes; 17 | 18 | double RiseTime = 0; 19 | int last1; 20 | int callback( void * id, struct CyprIOEndpoint * ep, uint8_t * data, uint32_t length ) 21 | { 22 | bytes += length; 23 | double Now = OGGetAbsoluteTime(); 24 | uint8_t final = data[length-1]; 25 | if( (!!(final&1)) != (!!(last1&1)) ) 26 | { 27 | if( !!(final&1) ) 28 | RiseTime = OGGetAbsoluteTime(); 29 | } 30 | last1 = final; 31 | return 0; 32 | } 33 | void * CallbackThread( void * v ) 34 | { 35 | while( 1 ) 36 | { 37 | printf( "Callback Thread\n" ); 38 | #if defined( WINDOWS ) || defined( WIN32) 39 | CyprIODoCircularDataXferTx( &eps.CypIOEndpoints[0], 65536*4, 32, callback, 0 ); 40 | #else 41 | CyprIODoCircularDataXferTx( &eps.CypIOEndpoints[0], 16834, 16, callback, 0 ); 42 | #endif 43 | printf( "CALLBACK THREAD FAILED\n" ); 44 | OGUSleep( 100000 ); 45 | } 46 | } 47 | 48 | #define DDCMD( opcode, par1, par2, par3 ) ( e = CyprIOControlTransfer( &eps, 0xc0, 0xdd, (opcode) | ((par1)<<8), (par2) | ((par3)<<8), buffer, 48, 10 ), buffer[0] ) 49 | 50 | int main() 51 | { 52 | uint8_t buffer[64]; 53 | int e; 54 | 55 | int r = CyprIOConnect( &eps, 0, 0x04b4, 0x00f1 ); 56 | if( r ) 57 | { 58 | fprintf( stderr, "Error: Could not connect to USB device\n" ); 59 | return; 60 | } 61 | printf( "CYPRIO CONNECT: %d\n", r ); 62 | r = CyprIOGetDevDescriptorInformation( &eps ); 63 | if( r ) 64 | { 65 | fprintf( stderr, "Error: Couldn't get all info needed from device\n" ); 66 | CyprIODestroy( &eps ); 67 | return; 68 | } 69 | printf( "CONNECT 3: %d\n", r ); 70 | r = CyprIOSetup( &eps, 0, 2 ); 71 | printf( "Cyprio setup returned: %d\n", r ); 72 | 73 | 74 | OGUSleep( 20000 ); 75 | 76 | printf( "Doing data XFERs\n" ); 77 | DDCMD( 0x10, 32/*divisor*/, 2 /*bitfield &1 = half div, &2 = use DLL clock*/, 1 /*GPIF Selected*/ ); 78 | printf( "DDCMD FOR 0x10 (speed drive) %d [%02x %02x %02x]\n", e, buffer[0], buffer[1], buffer[2] ); 79 | 80 | OGCreateThread( CallbackThread, 0 ); 81 | OGUSleep( 20000 ); 82 | 83 | e = CyprIOControlTransfer( &eps, 0xc0, 0xbb, 0x0102, 0x0304, buffer, 50, 10 ); 84 | OGUSleep( 20000 ); 85 | e = CyprIOControlTransfer( &eps, 0xc0, 0xaa, 0x0102, 0x0304, buffer, 50, 10 ); 86 | 87 | double Last; 88 | double SumTimes = 0; 89 | int counts = 0; 90 | while( 1 ) 91 | { 92 | DDCMD( 0x01, 25, 2, 0 ); //Drive low 93 | OGUSleep( 40000 ); 94 | double TimeCommandLow = OGGetAbsoluteTime(); 95 | DDCMD( 0x01, 25, 9, 0 ); //Drive high 96 | OGUSleep( 40000 ); 97 | double Now = OGGetAbsoluteTime(); 98 | SumTimes += RiseTime - TimeCommandLow; 99 | counts++; 100 | printf( "%f : AVG %f ms %d %f\n", (RiseTime - TimeCommandLow)*1000, SumTimes/counts*1000, bytes, bytes/(Now-Last) ); bytes = 0; 101 | Last=Now; 102 | } 103 | CyprIODestroy( &eps ); 104 | } 105 | -------------------------------------------------------------------------------- /latencytest/os_generic.h: -------------------------------------------------------------------------------- 1 | #ifndef _OS_GENERIC_H 2 | #define _OS_GENERIC_H 3 | /* 4 | "osgeneric" Generic, platform independent tool for threads and time. 5 | Geared around Windows and Linux. Designed for operation on MSVC, 6 | TCC, GCC and clang. Others may work. 7 | 8 | It offers the following operations: 9 | 10 | Delay functions: 11 | void OGSleep( int is ); 12 | void OGUSleep( int ius ); 13 | 14 | Getting current time (may be time from program start, boot, or epoc) 15 | double OGGetAbsoluteTime(); 16 | double OGGetFileTime( const char * file ); 17 | 18 | Thread functions 19 | og_thread_t OGCreateThread( void * (routine)( void * ), void * parameter ); 20 | void * OGJoinThread( og_thread_t ot ); 21 | void OGCancelThread( og_thread_t ot ); 22 | 23 | Mutex functions, used for protecting data structures. 24 | (recursive on platforms where available.) 25 | og_mutex_t OGCreateMutex(); 26 | void OGLockMutex( og_mutex_t om ); 27 | void OGUnlockMutex( og_mutex_t om ); 28 | void OGDeleteMutex( og_mutex_t om ); 29 | 30 | Always a semaphore (not recursive) 31 | og_sema_t OGCreateSema(); //Create a semaphore, comes locked initially. 32 | NOTE: For platform compatibility, max count is 32767 33 | void OGLockSema( og_sema_t os ); 34 | int OGGetSema( og_sema_t os ); //if <0 there was a failure. 35 | void OGUnlockSema( og_sema_t os ); 36 | void OGDeleteSema( og_sema_t os ); 37 | 38 | TLS (Thread-Local Storage) 39 | og_tls_t OGCreateTLS(); 40 | void OGDeleteTLS( og_tls_t tls ); 41 | void OGSetTLS( og_tls_t tls, void * data ); 42 | void * OGGetTLS( og_tls_t tls ); 43 | 44 | You can permute the operations of this file by the following means: 45 | OSG_NO_IMPLEMENTATION 46 | OSG_PREFIX 47 | OSG_NOSTATIC 48 | 49 | The default behavior is to do static inline. 50 | 51 | Copyright (c) 2011-2012,2013,2016,2018,2019,2020 <>< Charles Lohr 52 | 53 | This file may be licensed under the MIT/x11 license, NewBSD or CC0 licenses 54 | 55 | Permission is hereby granted, free of charge, to any person obtaining a 56 | copy of this software and associated documentation files (the "Software"), 57 | to deal in the Software without restriction, including without limitation 58 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 59 | and/or sell copies of the Software, and to permit persons to whom the 60 | Software is furnished to do so, subject to the following conditions: 61 | 62 | The above copyright notice and this permission notice shall be included in 63 | all copies or substantial portions of this file. 64 | 65 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 66 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 67 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 68 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 69 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 70 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 71 | IN THE SOFTWARE. 72 | 73 | Date Stamp: 2019-09-05 CNL: Allow for noninstantiation and added TLS. 74 | Date Stamp: 2018-03-25 CNL: Switched to header-only format. 75 | */ 76 | 77 | 78 | #if defined( OSG_NOSTATIC ) && OSG_NOSTATIC != 0 79 | #ifndef OSG_PREFIX 80 | #define OSG_PREFIX 81 | #endif 82 | #ifndef OSG_NO_IMPLEMENTATION 83 | #define OSG_NO_IMPLEMENTATION 84 | #endif 85 | #endif 86 | 87 | #ifndef OSG_PREFIX 88 | #ifdef __wasm__ 89 | #define OSG_PREFIX 90 | #else 91 | #define OSG_PREFIX static inline 92 | #endif 93 | #endif 94 | 95 | //In case you want to hook the closure of a thread, i.e. if your system has thread-local storage. 96 | #ifndef OSG_TERM_THREAD_CODE 97 | #define OSG_TERM_THREAD_CODE 98 | #endif 99 | 100 | typedef void* og_thread_t; 101 | typedef void* og_mutex_t; 102 | typedef void* og_sema_t; 103 | typedef void* og_tls_t; 104 | 105 | #ifdef __cplusplus 106 | extern "C" { 107 | #endif 108 | 109 | OSG_PREFIX void OGSleep( int is ); 110 | OSG_PREFIX void OGUSleep( int ius ); 111 | OSG_PREFIX double OGGetAbsoluteTime(); 112 | OSG_PREFIX double OGGetFileTime( const char * file ); 113 | OSG_PREFIX og_thread_t OGCreateThread( void * (routine)( void * ), void * parameter ); 114 | OSG_PREFIX void * OGJoinThread( og_thread_t ot ); 115 | OSG_PREFIX void OGCancelThread( og_thread_t ot ); 116 | OSG_PREFIX og_mutex_t OGCreateMutex(); 117 | OSG_PREFIX void OGLockMutex( og_mutex_t om ); 118 | OSG_PREFIX void OGUnlockMutex( og_mutex_t om ); 119 | OSG_PREFIX void OGDeleteMutex( og_mutex_t om ); 120 | OSG_PREFIX og_sema_t OGCreateSema(); 121 | OSG_PREFIX int OGGetSema( og_sema_t os ); 122 | OSG_PREFIX void OGLockSema( og_sema_t os ); 123 | OSG_PREFIX void OGUnlockSema( og_sema_t os ); 124 | OSG_PREFIX void OGDeleteSema( og_sema_t os ); 125 | OSG_PREFIX og_tls_t OGCreateTLS(); 126 | OSG_PREFIX void OGDeleteTLS( og_tls_t key ); 127 | OSG_PREFIX void * OGGetTLS( og_tls_t key ); 128 | OSG_PREFIX void OGSetTLS( og_tls_t key, void * data ); 129 | 130 | #ifdef __cplusplus 131 | }; 132 | #endif 133 | 134 | #ifndef OSG_NO_IMPLEMENTATION 135 | 136 | #if defined( WIN32 ) || defined (WINDOWS) || defined( _WIN32) 137 | #define USE_WINDOWS 138 | #endif 139 | 140 | 141 | #ifdef __cplusplus 142 | extern "C" { 143 | #endif 144 | 145 | 146 | #ifdef USE_WINDOWS 147 | 148 | #include 149 | #include 150 | 151 | OSG_PREFIX void OGSleep( int is ) 152 | { 153 | Sleep( is*1000 ); 154 | } 155 | 156 | OSG_PREFIX void OGUSleep( int ius ) 157 | { 158 | Sleep( ius/1000 ); 159 | } 160 | 161 | OSG_PREFIX double OGGetAbsoluteTime() 162 | { 163 | static LARGE_INTEGER lpf; 164 | LARGE_INTEGER li; 165 | 166 | if( !lpf.QuadPart ) 167 | { 168 | QueryPerformanceFrequency( &lpf ); 169 | } 170 | 171 | QueryPerformanceCounter( &li ); 172 | return (double)li.QuadPart / (double)lpf.QuadPart; 173 | } 174 | 175 | 176 | OSG_PREFIX double OGGetFileTime( const char * file ) 177 | { 178 | FILETIME ft; 179 | 180 | HANDLE h = CreateFile(file, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); 181 | 182 | if( h==INVALID_HANDLE_VALUE ) 183 | return -1; 184 | 185 | GetFileTime( h, 0, 0, &ft ); 186 | 187 | CloseHandle( h ); 188 | 189 | return ft.dwHighDateTime + ft.dwLowDateTime; 190 | } 191 | 192 | 193 | OSG_PREFIX og_thread_t OGCreateThread( void * (routine)( void * ), void * parameter ) 194 | { 195 | return (og_thread_t)CreateThread( 0, 0, (LPTHREAD_START_ROUTINE)routine, parameter, 0, 0 ); 196 | } 197 | 198 | OSG_PREFIX void * OGJoinThread( og_thread_t ot ) 199 | { 200 | WaitForSingleObject( ot, INFINITE ); 201 | OSG_TERM_THREAD_CODE 202 | CloseHandle( ot ); 203 | return 0; 204 | } 205 | 206 | OSG_PREFIX void OGCancelThread( og_thread_t ot ) 207 | { 208 | OSG_TERM_THREAD_CODE 209 | TerminateThread( ot, 0); 210 | CloseHandle( ot ); 211 | } 212 | 213 | OSG_PREFIX og_mutex_t OGCreateMutex() 214 | { 215 | return CreateMutex( 0, 0, 0 ); 216 | } 217 | 218 | OSG_PREFIX void OGLockMutex( og_mutex_t om ) 219 | { 220 | WaitForSingleObject(om, INFINITE); 221 | } 222 | 223 | OSG_PREFIX void OGUnlockMutex( og_mutex_t om ) 224 | { 225 | ReleaseMutex(om); 226 | } 227 | 228 | OSG_PREFIX void OGDeleteMutex( og_mutex_t om ) 229 | { 230 | CloseHandle( om ); 231 | } 232 | 233 | 234 | 235 | OSG_PREFIX og_sema_t OGCreateSema() 236 | { 237 | HANDLE sem = CreateSemaphore( 0, 0, 32767, 0 ); 238 | return (og_sema_t)sem; 239 | } 240 | 241 | OSG_PREFIX int OGGetSema( og_sema_t os ) 242 | { 243 | typedef LONG NTSTATUS; 244 | HANDLE sem = (HANDLE)os; 245 | typedef NTSTATUS (NTAPI *_NtQuerySemaphore)( 246 | HANDLE SemaphoreHandle, 247 | DWORD SemaphoreInformationClass, /* Would be SEMAPHORE_INFORMATION_CLASS */ 248 | PVOID SemaphoreInformation, /* but this is to much to dump here */ 249 | ULONG SemaphoreInformationLength, 250 | PULONG ReturnLength OPTIONAL 251 | ); 252 | 253 | typedef struct _SEMAPHORE_BASIC_INFORMATION { 254 | ULONG CurrentCount; 255 | ULONG MaximumCount; 256 | } SEMAPHORE_BASIC_INFORMATION; 257 | 258 | 259 | static _NtQuerySemaphore NtQuerySemaphore; 260 | SEMAPHORE_BASIC_INFORMATION BasicInfo; 261 | NTSTATUS Status; 262 | 263 | if( !NtQuerySemaphore ) 264 | { 265 | NtQuerySemaphore = (_NtQuerySemaphore)GetProcAddress (GetModuleHandle ("ntdll.dll"), "NtQuerySemaphore"); 266 | if( !NtQuerySemaphore ) 267 | { 268 | return -1; 269 | } 270 | } 271 | 272 | 273 | Status = NtQuerySemaphore (sem, 0 /*SemaphoreBasicInformation*/, 274 | &BasicInfo, sizeof (SEMAPHORE_BASIC_INFORMATION), NULL); 275 | 276 | if (Status == ERROR_SUCCESS) 277 | { 278 | return BasicInfo.CurrentCount; 279 | } 280 | 281 | return -2; 282 | } 283 | 284 | OSG_PREFIX void OGLockSema( og_sema_t os ) 285 | { 286 | WaitForSingleObject( (HANDLE)os, INFINITE ); 287 | } 288 | 289 | OSG_PREFIX void OGUnlockSema( og_sema_t os ) 290 | { 291 | ReleaseSemaphore( (HANDLE)os, 1, 0 ); 292 | } 293 | 294 | OSG_PREFIX void OGDeleteSema( og_sema_t os ) 295 | { 296 | CloseHandle( os ); 297 | } 298 | 299 | OSG_PREFIX og_tls_t OGCreateTLS() 300 | { 301 | return (og_tls_t)(intptr_t)TlsAlloc(); 302 | } 303 | 304 | OSG_PREFIX void OGDeleteTLS( og_tls_t key ) 305 | { 306 | TlsFree( (DWORD)(intptr_t)key ); 307 | } 308 | 309 | OSG_PREFIX void * OGGetTLS( og_tls_t key ) 310 | { 311 | return TlsGetValue( (DWORD)(intptr_t)key ); 312 | } 313 | 314 | OSG_PREFIX void OGSetTLS( og_tls_t key, void * data ) 315 | { 316 | TlsSetValue( (DWORD)(intptr_t)key, data ); 317 | } 318 | 319 | #elif defined( __wasm__ ) 320 | 321 | //We don't actually have any function defintions here. 322 | //The outside system will handle it. 323 | 324 | #else 325 | 326 | #ifndef _GNU_SOURCE 327 | #define _GNU_SOURCE 328 | #endif 329 | 330 | #include 331 | #include 332 | #include 333 | #include 334 | #include 335 | #include 336 | 337 | OSG_PREFIX void OGSleep( int is ) 338 | { 339 | sleep( is ); 340 | } 341 | 342 | OSG_PREFIX void OGUSleep( int ius ) 343 | { 344 | usleep( ius ); 345 | } 346 | 347 | OSG_PREFIX double OGGetAbsoluteTime() 348 | { 349 | struct timeval tv; 350 | gettimeofday( &tv, 0 ); 351 | return ((double)tv.tv_usec)/1000000. + (tv.tv_sec); 352 | } 353 | 354 | OSG_PREFIX double OGGetFileTime( const char * file ) 355 | { 356 | struct stat buff; 357 | 358 | int r = stat( file, &buff ); 359 | 360 | if( r < 0 ) 361 | { 362 | return -1; 363 | } 364 | 365 | return buff.st_mtime; 366 | } 367 | 368 | 369 | 370 | OSG_PREFIX og_thread_t OGCreateThread( void * (routine)( void * ), void * parameter ) 371 | { 372 | pthread_t * ret = (pthread_t *)malloc( sizeof( pthread_t ) ); 373 | if( !ret ) return 0; 374 | int r = pthread_create( ret, 0, routine, parameter ); 375 | if( r ) 376 | { 377 | free( ret ); 378 | return 0; 379 | } 380 | return (og_thread_t)ret; 381 | } 382 | 383 | OSG_PREFIX void * OGJoinThread( og_thread_t ot ) 384 | { 385 | void * retval; 386 | if( !ot ) 387 | { 388 | return 0; 389 | } 390 | pthread_join( *(pthread_t*)ot, &retval ); 391 | OSG_TERM_THREAD_CODE 392 | free( ot ); 393 | return retval; 394 | } 395 | 396 | OSG_PREFIX void OGCancelThread( og_thread_t ot ) 397 | { 398 | if( !ot ) 399 | { 400 | return; 401 | } 402 | #ifdef ANDROID 403 | pthread_kill( *(pthread_t*)ot, SIGTERM ); 404 | #else 405 | pthread_cancel( *(pthread_t*)ot ); 406 | #endif 407 | OSG_TERM_THREAD_CODE 408 | free( ot ); 409 | } 410 | 411 | OSG_PREFIX og_mutex_t OGCreateMutex() 412 | { 413 | pthread_mutexattr_t mta; 414 | og_mutex_t r = malloc( sizeof( pthread_mutex_t ) ); 415 | if( !r ) return 0; 416 | 417 | pthread_mutexattr_init(&mta); 418 | pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_RECURSIVE); 419 | 420 | pthread_mutex_init( (pthread_mutex_t *)r, &mta ); 421 | 422 | return r; 423 | } 424 | 425 | OSG_PREFIX void OGLockMutex( og_mutex_t om ) 426 | { 427 | if( !om ) 428 | { 429 | return; 430 | } 431 | pthread_mutex_lock( (pthread_mutex_t*)om ); 432 | } 433 | 434 | OSG_PREFIX void OGUnlockMutex( og_mutex_t om ) 435 | { 436 | if( !om ) 437 | { 438 | return; 439 | } 440 | pthread_mutex_unlock( (pthread_mutex_t*)om ); 441 | } 442 | 443 | OSG_PREFIX void OGDeleteMutex( og_mutex_t om ) 444 | { 445 | if( !om ) 446 | { 447 | return; 448 | } 449 | 450 | pthread_mutex_destroy( (pthread_mutex_t*)om ); 451 | free( om ); 452 | } 453 | 454 | 455 | 456 | 457 | OSG_PREFIX og_sema_t OGCreateSema() 458 | { 459 | sem_t * sem = (sem_t *)malloc( sizeof( sem_t ) ); 460 | if( !sem ) return 0; 461 | sem_init( sem, 0, 0 ); 462 | return (og_sema_t)sem; 463 | } 464 | 465 | OSG_PREFIX int OGGetSema( og_sema_t os ) 466 | { 467 | int valp; 468 | sem_getvalue( (sem_t*)os, &valp ); 469 | return valp; 470 | } 471 | 472 | 473 | OSG_PREFIX void OGLockSema( og_sema_t os ) 474 | { 475 | sem_wait( (sem_t*)os ); 476 | } 477 | 478 | OSG_PREFIX void OGUnlockSema( og_sema_t os ) 479 | { 480 | sem_post( (sem_t*)os ); 481 | } 482 | 483 | OSG_PREFIX void OGDeleteSema( og_sema_t os ) 484 | { 485 | sem_destroy( (sem_t*)os ); 486 | free(os); 487 | } 488 | 489 | OSG_PREFIX og_tls_t OGCreateTLS() 490 | { 491 | pthread_key_t ret = 0; 492 | pthread_key_create(&ret, 0); 493 | return (og_tls_t)(intptr_t)ret; 494 | } 495 | 496 | OSG_PREFIX void OGDeleteTLS( og_tls_t key ) 497 | { 498 | pthread_key_delete( (pthread_key_t)(intptr_t)key ); 499 | } 500 | 501 | OSG_PREFIX void * OGGetTLS( og_tls_t key ) 502 | { 503 | return pthread_getspecific( (pthread_key_t)(intptr_t)key ); 504 | } 505 | 506 | OSG_PREFIX void OGSetTLS( og_tls_t key, void * data ) 507 | { 508 | pthread_setspecific( (pthread_key_t)(intptr_t)key, data ); 509 | } 510 | 511 | #endif 512 | 513 | #ifdef __cplusplus 514 | }; 515 | #endif 516 | 517 | #endif //OSG_NO_IMPLEMENTATION 518 | 519 | #endif //_OS_GENERIC_H 520 | 521 | -------------------------------------------------------------------------------- /libcyprio/cyprio_aux.h: -------------------------------------------------------------------------------- 1 | #ifndef _DEVAUX_HEADER 2 | #define _DEVAUX_HEADER 3 | 4 | 5 | 6 | 7 | #if defined( WINDOWS ) || defined( WIN32 ) 8 | #include 9 | #else 10 | #define UCHAR uint8_t 11 | #define USHORT uint16_t 12 | #define ULONG uint32_t 13 | #define WCHAR uint16_t 14 | #define ZeroMemory( mem, size ) memset( (mem), (0), (size) ) 15 | #endif 16 | 17 | 18 | #if defined( WINDOWS ) || defined( WIN32 ) 19 | #include 20 | #ifdef TCC 21 | typedef struct _SP_DEVINFO_DATA { 22 | DWORD cbSize; 23 | GUID ClassGuid; 24 | DWORD DevInst; 25 | ULONG_PTR Reserved; 26 | } SP_DEVINFO_DATA, *PSP_DEVINFO_DATA; 27 | typedef struct _SP_DEVICE_INTERFACE_DATA { 28 | DWORD cbSize; 29 | GUID InterfaceClassGuid; 30 | DWORD Flags; 31 | ULONG_PTR Reserved; 32 | } SP_DEVICE_INTERFACE_DATA, *PSP_DEVICE_INTERFACE_DATA; 33 | typedef struct _SP_DEVICE_INTERFACE_DETAIL_DATA { 34 | DWORD cbSize; 35 | CHAR DevicePath[ANYSIZE_ARRAY]; 36 | } SP_DEVICE_INTERFACE_DETAIL_DATA_A, *PSP_DEVICE_INTERFACE_DETAIL_DATA_A; 37 | typedef PVOID HDEVINFO; 38 | 39 | HDEVINFO WINAPI SetupDiGetClassDevsA(CONST GUID*,PCSTR,HWND,DWORD); 40 | 41 | BOOL SetupDiGetDeviceInterfaceDetailA( 42 | HDEVINFO DeviceInfoSet, 43 | PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, 44 | PSP_DEVICE_INTERFACE_DETAIL_DATA_A DeviceInterfaceDetailData, 45 | DWORD DeviceInterfaceDetailDataSize, 46 | PDWORD RequiredSize, 47 | PSP_DEVINFO_DATA DeviceInfoData 48 | ); 49 | 50 | BOOL SetupDiEnumDeviceInterfaces( 51 | HDEVINFO DeviceInfoSet, 52 | PSP_DEVINFO_DATA DeviceInfoData, 53 | const GUID *InterfaceClassGuid, 54 | DWORD MemberIndex, 55 | PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData ); 56 | 57 | BOOL SetupDiDestroyDeviceInfoList( HDEVINFO DeviceInfoSet ); 58 | 59 | 60 | #define DIGCF_PRESENT 0x00000002 61 | #define DIGCF_INTERFACEDEVICE 0x00000010 62 | #define DIGCF_DEVICEINTERFACE 0x00000010 63 | #define SPDRP_CLASS 7 64 | #define SPDRP_DRIVER 9 65 | #define FILE_DEVICE_KEYBOARD 0x0000000b 66 | #define METHOD_OUT_DIRECT 2 67 | 68 | #if 0 69 | //In case you find a platform which needs this. 70 | enum 71 | { 72 | FILE_ANY_ACCESS = 0x00000000UL, 73 | FILE_SPECIAL_ACCESS = FILE_ANY_ACCESS, 74 | FILE_READ_ACCESS = 0x00000001UL, 75 | FILE_WRITE_ACCESS = 0x00000002UL 76 | }; 77 | #define CTL_CODE(t,f,m,a) (((t)<<16)|((a)<<14)|((f)<<2)|(m)) 78 | #endif 79 | 80 | 81 | #define FILE_DEVICE_UNKNOWN 0x00000022 82 | 83 | 84 | BOOL WINAPI __declspec(dllimport) DeviceIoControl( 85 | HANDLE hDevice, 86 | DWORD dwIoControlCode, 87 | LPVOID lpInBuffer, 88 | DWORD nInBufferSize, 89 | LPVOID lpOutBuffer, 90 | DWORD nOutBufferSize, 91 | LPDWORD lpBytesReturned, 92 | LPOVERLAPPED lpOverlapped 93 | ); 94 | 95 | 96 | #else 97 | #include 98 | #include 99 | #endif 100 | 101 | 102 | #pragma pack(1) 103 | #pragma warning( push ) 104 | #pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union 105 | #pragma warning( disable : 4214 ) // nonstandard extension used : bit field types other than int 106 | 107 | //These are from cyioctl.h 108 | 109 | #define DIR_HOST_TO_DEVICE 0 110 | #define DIR_DEVICE_TO_HOST 1 111 | 112 | 113 | #define DEVICE_SPEED_UNKNOWN 0x00000000 114 | #define DEVICE_SPEED_LOW_FULL 0x00000001 115 | #define DEVICE_SPEED_HIGH 0x00000002 116 | #define DEVICE_SPEED_SUPER 0x00000004 117 | 118 | 119 | typedef struct _ISO_PACKET_INFO { 120 | ULONG Status; 121 | ULONG Length; 122 | } ISO_PACKET_INFO, *PISO_PACKET_INFO; 123 | 124 | typedef struct _WORD_SPLIT { 125 | UCHAR lowByte; 126 | UCHAR hiByte; 127 | } WORD_SPLIT, *PWORD_SPLIT; 128 | 129 | typedef struct _BM_REQ_TYPE { 130 | UCHAR Recipient:2; 131 | UCHAR Reserved:3; 132 | UCHAR Type:2; 133 | UCHAR Direction:1; 134 | } BM_REQ_TYPE, *PBM_REQ_TYPE; 135 | 136 | typedef struct _SETUP_PACKET { 137 | 138 | union { 139 | BM_REQ_TYPE bmReqType; 140 | UCHAR bmRequest; 141 | }; 142 | 143 | UCHAR bRequest; 144 | 145 | union { 146 | WORD_SPLIT wVal; 147 | USHORT wValue; 148 | }; 149 | 150 | union { 151 | WORD_SPLIT wIndx; 152 | USHORT wIndex; 153 | }; 154 | 155 | union { 156 | WORD_SPLIT wLen; 157 | USHORT wLength; 158 | }; 159 | 160 | ULONG ulTimeOut; 161 | 162 | } SETUP_PACKET, *PSETUP_PACKET; 163 | 164 | 165 | #define USB_ISO_ID 0x4945 166 | #define USB_ISO_CMD_ASAP 0x8000 167 | #define USB_ISO_CMD_CURRENT_FRAME 0x8001 168 | #define USB_ISO_CMD_SET_FRAME 0x8002 169 | 170 | 171 | typedef struct _ISO_ADV_PARAMS { 172 | 173 | USHORT isoId; 174 | USHORT isoCmd; 175 | 176 | ULONG ulParam1; 177 | ULONG ulParam2; 178 | 179 | } ISO_ADV_PARAMS, *PISO_ADV_PARAMS; 180 | 181 | typedef struct _SINGLE_TRANSFER { 182 | union { 183 | SETUP_PACKET SetupPacket; 184 | ISO_ADV_PARAMS IsoParams; 185 | }; 186 | 187 | UCHAR reserved; 188 | 189 | UCHAR ucEndpointAddress; 190 | ULONG NtStatus; 191 | ULONG UsbdStatus; 192 | ULONG IsoPacketOffset; 193 | ULONG IsoPacketLength; 194 | ULONG BufferOffset; 195 | ULONG BufferLength; 196 | } SINGLE_TRANSFER, *PSINGLE_TRANSFER; 197 | 198 | 199 | #define METHOD_BUFFERED 0 200 | #define METHOD_IN_DIRECT 1 201 | #define METHOD_OUT_DIRECT 2 202 | #define METHOD_NEITHER 3 203 | 204 | #define IOCTL_ADAPT_INDEX 0x0000 205 | 206 | // Get the driver version 207 | #define IOCTL_ADAPT_GET_DRIVER_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX, METHOD_BUFFERED, FILE_ANY_ACCESS) 208 | 209 | // Get the current USBDI version 210 | #define IOCTL_ADAPT_GET_USBDI_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+1, METHOD_BUFFERED, FILE_ANY_ACCESS) 211 | 212 | // Get the current device alt interface settings from driver 213 | #define IOCTL_ADAPT_GET_ALT_INTERFACE_SETTING CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+2, METHOD_BUFFERED, FILE_ANY_ACCESS) 214 | 215 | // Set the device interface and alt interface setting 216 | #define IOCTL_ADAPT_SELECT_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+3, METHOD_BUFFERED, FILE_ANY_ACCESS) 217 | 218 | // Get device address from driver 219 | #define IOCTL_ADAPT_GET_ADDRESS CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+4, METHOD_BUFFERED, FILE_ANY_ACCESS) 220 | 221 | // Get number of endpoints for current interface and alt interface setting from driver 222 | #define IOCTL_ADAPT_GET_NUMBER_ENDPOINTS CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+5, METHOD_BUFFERED, FILE_ANY_ACCESS) 223 | 224 | // Get the current device power state 225 | #define IOCTL_ADAPT_GET_DEVICE_POWER_STATE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+6, METHOD_BUFFERED, FILE_ANY_ACCESS) 226 | 227 | // Set the device power state 228 | #define IOCTL_ADAPT_SET_DEVICE_POWER_STATE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+7, METHOD_BUFFERED, FILE_ANY_ACCESS) 229 | 230 | // Send a raw packet to endpoint 0 231 | #define IOCTL_ADAPT_SEND_EP0_CONTROL_TRANSFER CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+8, METHOD_BUFFERED, FILE_ANY_ACCESS) 232 | 233 | // Send/receive data to/from nonep0 234 | #define IOCTL_ADAPT_SEND_NON_EP0_TRANSFER CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+9, METHOD_BUFFERED, FILE_ANY_ACCESS) 235 | 236 | // Simulate a disconnect/reconnect 237 | #define IOCTL_ADAPT_CYCLE_PORT CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+10, METHOD_BUFFERED, FILE_ANY_ACCESS) 238 | 239 | // Reset the pipe 240 | #define IOCTL_ADAPT_RESET_PIPE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+11, METHOD_BUFFERED, FILE_ANY_ACCESS) 241 | 242 | // Reset the device 243 | #define IOCTL_ADAPT_RESET_PARENT_PORT CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+12, METHOD_BUFFERED, FILE_ANY_ACCESS) 244 | 245 | // Get the current transfer size of an endpoint (in number of bytes) 246 | #define IOCTL_ADAPT_GET_TRANSFER_SIZE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+13, METHOD_BUFFERED, FILE_ANY_ACCESS) 247 | 248 | // Set the transfer size of an endpoint (in number of bytes) 249 | #define IOCTL_ADAPT_SET_TRANSFER_SIZE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+14, METHOD_BUFFERED, FILE_ANY_ACCESS) 250 | 251 | // Return the name of the device 252 | #define IOCTL_ADAPT_GET_DEVICE_NAME CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+15, METHOD_BUFFERED, FILE_ANY_ACCESS) 253 | 254 | // Return the "Friendly Name" of the device 255 | #define IOCTL_ADAPT_GET_FRIENDLY_NAME CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+16, METHOD_BUFFERED, FILE_ANY_ACCESS) 256 | 257 | // Abort all outstanding transfers on the pipe 258 | #define IOCTL_ADAPT_ABORT_PIPE CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+17, METHOD_BUFFERED, FILE_ANY_ACCESS) 259 | 260 | // Send/receive data to/from nonep0 w/ direct buffer acccess (no buffering) 261 | #define IOCTL_ADAPT_SEND_NON_EP0_DIRECT CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+18, METHOD_NEITHER, FILE_ANY_ACCESS) 262 | 263 | // Return device speed 264 | #define IOCTL_ADAPT_GET_DEVICE_SPEED CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+19, METHOD_BUFFERED, FILE_ANY_ACCESS) 265 | 266 | // Get the current USB frame number 267 | #define IOCTL_ADAPT_GET_CURRENT_FRAME CTL_CODE(FILE_DEVICE_UNKNOWN, IOCTL_ADAPT_INDEX+20, METHOD_BUFFERED, FILE_ANY_ACCESS) 268 | 269 | #define NUMBER_OF_ADAPT_IOCTLS 21 // Last IOCTL_ADAPT_INDEX + 1 270 | 271 | #else 272 | #include 273 | #endif 274 | 275 | 276 | 277 | 278 | 279 | //These are from cyusb30_def.hDevice 280 | // USB3.0 specific constant defination 281 | #define BCDUSBJJMASK 0xFF00 //(0xJJMN JJ - Major version,M Minor version, N sub-minor vesion) 282 | #define USB30MAJORVER 0x0300 283 | #define USB20MAJORVER 0x0200 284 | 285 | #define USB_BOS_DESCRIPTOR_TYPE 0x0F 286 | #define USB_DEVICE_CAPABILITY 0x10 287 | #define USB_SUPERSPEED_ENDPOINT_COMPANION 0x30 288 | #define USB_BOS_CAPABILITY_TYPE_Wireless_USB 0x01 289 | #define USB_BOS_CAPABILITY_TYPE_USB20_EXT 0x02 290 | #define USB_BOS_CAPABILITY_TYPE_SUPERSPEED_USB 0x03 291 | #define USB_BOS_CAPABILITY_TYPE_CONTAINER_ID 0x04 292 | #define USB_BOS_CAPABILITY_TYPE_CONTAINER_ID_SIZE 0x10 293 | 294 | #define USB_BOS_DEVICE_CAPABILITY_TYPE_INDEX 0x2 295 | //constant defination 296 | typedef struct _USB_BOS_DESCRIPTOR 297 | { 298 | UCHAR bLength;/* Descriptor length*/ 299 | UCHAR bDescriptorType;/* Descriptor Type */ 300 | USHORT wTotalLength;/* Total length of descriptor ( icluding device capability*/ 301 | UCHAR bNumDeviceCaps;/* Number of device capability descriptors in BOS */ 302 | }USB_BOS_DESCRIPTOR,*PUSB_BOS_DESCRIPTOR; 303 | 304 | 305 | 306 | typedef struct _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR 307 | { 308 | UCHAR bLength; 309 | UCHAR bDescriptorType; 310 | UCHAR bMaxBurst; 311 | UCHAR bmAttributes; 312 | USHORT bBytesPerInterval; 313 | }USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR,*PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR; 314 | 315 | #pragma pack() 316 | #pragma warning( pop ) 317 | 318 | #endif 319 | -------------------------------------------------------------------------------- /libcyprio/cyprio_usb100.h: -------------------------------------------------------------------------------- 1 | #ifndef __USB100_H__ 2 | #define __USB100_H__ 3 | 4 | #if defined(WINDOWS) || defined( WIN32 ) 5 | #include 6 | #else 7 | #include "cyprio_aux.h" 8 | #endif 9 | 10 | 11 | //bmRequest.Dir 12 | #define BMREQUEST_HOST_TO_DEVICE 0 13 | #define BMREQUEST_DEVICE_TO_HOST 1 14 | 15 | //bmRequest.Type 16 | #define BMREQUEST_STANDARD 0 17 | #define BMREQUEST_CLASS 1 18 | #define BMREQUEST_VENDOR 2 19 | 20 | //bmRequest.Recipient 21 | #define BMREQUEST_TO_DEVICE 0 22 | #define BMREQUEST_TO_INTERFACE 1 23 | #define BMREQUEST_TO_ENDPOINT 2 24 | #define BMREQUEST_TO_OTHER 3 25 | 26 | 27 | #define MAXIMUM_USB_STRING_LENGTH 255 28 | 29 | // values for the bits returned by the USB GET_STATUS command 30 | #define USB_GETSTATUS_SELF_POWERED 0x01 31 | #define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED 0x02 32 | 33 | 34 | #define USB_DEVICE_DESCRIPTOR_TYPE 0x01 35 | #define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02 36 | #define USB_STRING_DESCRIPTOR_TYPE 0x03 37 | #define USB_INTERFACE_DESCRIPTOR_TYPE 0x04 38 | #define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05 39 | 40 | // descriptor types defined by DWG documents 41 | #define USB_RESERVED_DESCRIPTOR_TYPE 0x06 42 | #define USB_CONFIG_POWER_DESCRIPTOR_TYPE 0x07 43 | #define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 0x08 44 | 45 | #define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) ((USHORT)((USHORT)d<<8 | i)) 46 | 47 | // 48 | // Values for bmAttributes field of an 49 | // endpoint descriptor 50 | // 51 | 52 | #define USB_ENDPOINT_TYPE_MASK 0x03 53 | 54 | #define USB_ENDPOINT_TYPE_CONTROL 0x00 55 | #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01 56 | #define USB_ENDPOINT_TYPE_BULK 0x02 57 | #define USB_ENDPOINT_TYPE_INTERRUPT 0x03 58 | 59 | 60 | // 61 | // definitions for bits in the bmAttributes field of a 62 | // configuration descriptor. 63 | // 64 | #define USB_CONFIG_POWERED_MASK 0xc0 65 | 66 | #define USB_CONFIG_BUS_POWERED 0x80 67 | #define USB_CONFIG_SELF_POWERED 0x40 68 | #define USB_CONFIG_REMOTE_WAKEUP 0x20 69 | 70 | // 71 | // Endpoint direction bit, stored in address 72 | // 73 | 74 | #define USB_ENDPOINT_DIRECTION_MASK 0x80 75 | 76 | // test direction bit in the bEndpointAddress field of 77 | // an endpoint descriptor. 78 | #define USB_ENDPOINT_DIRECTION_OUT(addr) (!((addr) & USB_ENDPOINT_DIRECTION_MASK)) 79 | #define USB_ENDPOINT_DIRECTION_IN(addr) ((addr) & USB_ENDPOINT_DIRECTION_MASK) 80 | 81 | // 82 | // USB defined request codes 83 | // see chapter 9 of the USB 1.0 specifcation for 84 | // more information. 85 | // 86 | 87 | // These are the correct values based on the USB 1.0 88 | // specification 89 | 90 | #define USB_REQUEST_GET_STATUS 0x00 91 | #define USB_REQUEST_CLEAR_FEATURE 0x01 92 | 93 | #define USB_REQUEST_SET_FEATURE 0x03 94 | 95 | #define USB_REQUEST_SET_ADDRESS 0x05 96 | #define USB_REQUEST_GET_DESCRIPTOR 0x06 97 | #define USB_REQUEST_SET_DESCRIPTOR 0x07 98 | #define USB_REQUEST_GET_CONFIGURATION 0x08 99 | #define USB_REQUEST_SET_CONFIGURATION 0x09 100 | #define USB_REQUEST_GET_INTERFACE 0x0A 101 | #define USB_REQUEST_SET_INTERFACE 0x0B 102 | #define USB_REQUEST_SYNC_FRAME 0x0C 103 | 104 | 105 | // 106 | // defined USB device classes 107 | // 108 | 109 | 110 | #define USB_DEVICE_CLASS_RESERVED 0x00 111 | #define USB_DEVICE_CLASS_AUDIO 0x01 112 | #define USB_DEVICE_CLASS_COMMUNICATIONS 0x02 113 | #define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03 114 | #define USB_DEVICE_CLASS_MONITOR 0x04 115 | #define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05 116 | #define USB_DEVICE_CLASS_POWER 0x06 117 | #define USB_DEVICE_CLASS_PRINTER 0x07 118 | #define USB_DEVICE_CLASS_STORAGE 0x08 119 | #define USB_DEVICE_CLASS_HUB 0x09 120 | #define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF 121 | 122 | // 123 | // USB Core defined Feature selectors 124 | // 125 | 126 | #define USB_FEATURE_ENDPOINT_STALL 0x0000 127 | #define USB_FEATURE_REMOTE_WAKEUP 0x0001 128 | 129 | // 130 | // USB DWG defined Feature selectors 131 | // 132 | 133 | #define USB_FEATURE_INTERFACE_POWER_D0 0x0002 134 | #define USB_FEATURE_INTERFACE_POWER_D1 0x0003 135 | #define USB_FEATURE_INTERFACE_POWER_D2 0x0004 136 | #define USB_FEATURE_INTERFACE_POWER_D3 0x0005 137 | 138 | typedef struct _USB_DEVICE_DESCRIPTOR { 139 | UCHAR bLength; 140 | UCHAR bDescriptorType; 141 | USHORT bcdUSB; 142 | UCHAR bDeviceClass; 143 | UCHAR bDeviceSubClass; 144 | UCHAR bDeviceProtocol; 145 | UCHAR bMaxPacketSize0; 146 | USHORT idVendor; 147 | USHORT idProduct; 148 | USHORT bcdDevice; 149 | UCHAR iManufacturer; 150 | UCHAR iProduct; 151 | UCHAR iSerialNumber; 152 | UCHAR bNumConfigurations; 153 | } USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR; 154 | 155 | typedef struct _USB_ENDPOINT_DESCRIPTOR { 156 | UCHAR bLength; 157 | UCHAR bDescriptorType; 158 | UCHAR bEndpointAddress; 159 | UCHAR bmAttributes; 160 | USHORT wMaxPacketSize; 161 | UCHAR bInterval; 162 | } USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR; 163 | 164 | typedef struct _USB_CONFIGURATION_DESCRIPTOR { 165 | UCHAR bLength; 166 | UCHAR bDescriptorType; 167 | USHORT wTotalLength; 168 | UCHAR bNumInterfaces; 169 | UCHAR bConfigurationValue; 170 | UCHAR iConfiguration; 171 | UCHAR bmAttributes; 172 | UCHAR MaxPower; 173 | } USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR; 174 | 175 | typedef struct _USB_INTERFACE_DESCRIPTOR { 176 | UCHAR bLength; 177 | UCHAR bDescriptorType; 178 | UCHAR bInterfaceNumber; 179 | UCHAR bAlternateSetting; 180 | UCHAR bNumEndpoints; 181 | UCHAR bInterfaceClass; 182 | UCHAR bInterfaceSubClass; 183 | UCHAR bInterfaceProtocol; 184 | UCHAR iInterface; 185 | } USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR; 186 | 187 | typedef struct _USB_STRING_DESCRIPTOR { 188 | UCHAR bLength; 189 | UCHAR bDescriptorType; 190 | WCHAR bString[1]; 191 | } USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR; 192 | 193 | typedef struct _USB_COMMON_DESCRIPTOR { 194 | UCHAR bLength; 195 | UCHAR bDescriptorType; 196 | } USB_COMMON_DESCRIPTOR, *PUSB_COMMON_DESCRIPTOR; 197 | 198 | 199 | // 200 | // Standard USB HUB definitions 201 | // 202 | // See Chapter 11 USB core specification 203 | // 204 | 205 | typedef struct _USB_HUB_DESCRIPTOR { 206 | UCHAR bDescriptorLength; // Length of this descriptor 207 | UCHAR bDescriptorType; // Hub configuration type 208 | UCHAR bNumberOfPorts; // number of ports on this hub 209 | USHORT wHubCharacteristics; // Hub Charateristics 210 | UCHAR bPowerOnToPowerGood; // port power on till power good in 2ms 211 | UCHAR bHubControlCurrent; // max current in mA 212 | // 213 | // room for 255 ports power control and removable bitmask 214 | UCHAR bRemoveAndPowerMask[64]; 215 | } USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR; 216 | 217 | 218 | // 219 | // Structures defined by various DWG feature documents 220 | // 221 | 222 | 223 | // 224 | // See DWG USB Feature Specification: Interface Power Management 225 | // 226 | 227 | #define USB_SUPPORT_D0_COMMAND 0x01 228 | #define USB_SUPPORT_D1_COMMAND 0x02 229 | #define USB_SUPPORT_D2_COMMAND 0x04 230 | #define USB_SUPPORT_D3_COMMAND 0x08 231 | 232 | #define USB_SUPPORT_D1_WAKEUP 0x10 233 | #define USB_SUPPORT_D2_WAKEUP 0x20 234 | 235 | 236 | typedef struct _USB_CONFIGURATION_POWER_DESCRIPTOR { 237 | UCHAR bLength; 238 | UCHAR bDescriptorType; 239 | UCHAR SelfPowerConsumedD0[3]; 240 | UCHAR bPowerSummaryId; 241 | UCHAR bBusPowerSavingD1; 242 | UCHAR bSelfPowerSavingD1; 243 | UCHAR bBusPowerSavingD2; 244 | UCHAR bSelfPowerSavingD2; 245 | UCHAR bBusPowerSavingD3; 246 | UCHAR bSelfPowerSavingD3; 247 | USHORT TransitionTimeFromD1; 248 | USHORT TransitionTimeFromD2; 249 | USHORT TransitionTimeFromD3; 250 | } USB_CONFIGURATION_POWER_DESCRIPTOR, *PUSB_CONFIGURATION_POWER_DESCRIPTOR; 251 | 252 | 253 | typedef struct _USB_INTERFACE_POWER_DESCRIPTOR { 254 | UCHAR bLength; 255 | UCHAR bDescriptorType; 256 | UCHAR bmCapabilitiesFlags; 257 | UCHAR bBusPowerSavingD1; 258 | UCHAR bSelfPowerSavingD1; 259 | UCHAR bBusPowerSavingD2; 260 | UCHAR bSelfPowerSavingD2; 261 | UCHAR bBusPowerSavingD3; 262 | UCHAR bSelfPowerSavingD3; 263 | USHORT TransitionTimeFromD1; 264 | USHORT TransitionTimeFromD2; 265 | USHORT TransitionTimeFromD3; 266 | } USB_INTERFACE_POWER_DESCRIPTOR, *PUSB_INTERFACE_POWER_DESCRIPTOR; 267 | 268 | 269 | #if defined(WINDOWS) || defined( WIN32 ) 270 | #include 271 | #endif 272 | 273 | #endif /* __USB100_H__ */ 274 | 275 | -------------------------------------------------------------------------------- /libcyprio/libcyprio.h: -------------------------------------------------------------------------------- 1 | /* 2 | Cypress FX3 library for easier C access directly to FX3 boards (mostly via CyUSB3.sys) 3 | 4 | (C) 2017 C. Lohr, under the MIT-x11 or NewBSD License. You decide. 5 | */ 6 | 7 | #ifndef CYPRIO_H 8 | #define CYPRIO_H 9 | 10 | #include 11 | #include "cyprio_aux.h" 12 | #include "cyprio_usb100.h" 13 | 14 | //Portions of this code are based on CyAPI's internal codebase. (Specifically in enumeration) 15 | // I intend to rewrite that soon. Also, I intend to clean up support for streaming isochronous out as well. 16 | // Other people can feel free to contribute!!! 17 | 18 | #ifndef BOOL 19 | #define BOOL char 20 | #endif 21 | 22 | #define USB_STRING_MAXLEN 256 23 | #define MAX_INTERFACES 8 24 | #define MAX_ENDPOINTS 8 25 | #define MAX_CONFIG_DESCRIPTORS 2 26 | 27 | struct CyprIO; 28 | 29 | struct CyprIOEndpoint //Mimicing CCyUSBEndPoint 30 | { 31 | struct CyprIO * parent; 32 | int assoc_iface; 33 | 34 | int is_superspeed; 35 | 36 | /* The fields of an EndPoint Descriptor */ 37 | uint8_t DscLen; 38 | uint8_t DscType; 39 | uint8_t Address; 40 | uint8_t Attributes; 41 | uint16_t MaxPktSize; 42 | uint16_t PktsPerFrame; 43 | uint8_t Interval; 44 | /* This are the fields for Super speed endpoint */ 45 | uint8_t ssdscLen; 46 | uint8_t ssdscType; 47 | uint8_t ssmaxburst; /* Maximum number of packets endpoint can send in one burst */ 48 | uint8_t ssbmAttribute; /* store endpoint attribute like for bulk it will be number of streams */ 49 | uint16_t ssbytesperinterval; 50 | 51 | BOOL bIn; 52 | }; 53 | 54 | struct CyprCyIsoPktInfo { 55 | int32_t Status; 56 | int32_t Length; 57 | }; 58 | 59 | 60 | struct CyprIO 61 | { 62 | USB_DEVICE_DESCRIPTOR USBDeviceDescriptor; 63 | int BytesXferedLastControl; 64 | int LastError; 65 | int StrLangID; 66 | WCHAR Manufacturer[USB_STRING_MAXLEN]; 67 | WCHAR Product[USB_STRING_MAXLEN]; 68 | WCHAR SerialNumber[USB_STRING_MAXLEN]; 69 | PUSB_BOS_DESCRIPTOR pUsbBosDescriptor; 70 | PUSB_CONFIGURATION_DESCRIPTOR USBConfigDescriptors[MAX_CONFIG_DESCRIPTORS]; //Must check and free. 71 | PUSB_INTERFACE_DESCRIPTOR USBIfaceDescriptors[MAX_INTERFACES]; 72 | int USBIfaceAltSettings[MAX_INTERFACES]; 73 | struct CyprIOEndpoint CypIOEndpoints[MAX_ENDPOINTS]; 74 | int CyprIONumEps; 75 | 76 | int Interfaces, AltInterfaces; 77 | int SelInterface; 78 | 79 | uint8_t is_usb_3; 80 | 81 | volatile uint8_t shutdown; 82 | 83 | #if defined(WINDOWS) || defined( WIN32 ) 84 | HANDLE hDevice; 85 | #else 86 | struct libusb_device_handle * hDevice; 87 | #endif 88 | }; 89 | 90 | struct CyprIOFwInfo 91 | { 92 | char BuildTimestamp[22]; 93 | char GitHash[16]; 94 | } ; 95 | 96 | //Setup 97 | int CyprIOConnect( struct CyprIO * ths, int index, int vid, int pid); 98 | int CyprIOGetDevDescriptorInformation( struct CyprIO * ths ); 99 | int CyprIOSetup( struct CyprIO * ths, int use_config, int use_iface ); 100 | void CyprIODestroy( struct CyprIO * ths ); 101 | void CyprIOGetFwInformation( struct CyprIO * ths, struct CyprIOFwInfo * fw_info ); 102 | 103 | //Sort of utiltiy that binds the above 2. Mimics libusb_control_transfer from libusb, to ease portability. Only for IOCTL_ADAPT_SEND_EP0_CONTROL_TRANSFER. Other messages must be done using the other mechanisms. This however, can only make regular control message calls. 104 | int CyprIOControlTransfer( struct CyprIO * ths, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned char * data, uint16_t wLength, unsigned int timeout ); 105 | 106 | 107 | //Set up a high performance asynchronous transfer in from an ISO endpoint. NOTE: Callback should return 0. Returning nonzero will abort DataXferTx. 108 | typedef int ( *CyprIOXferCB_t )( void *, struct CyprIOEndpoint *, uint8_t *, uint32_t ); 109 | int CyprIODoCircularDataXferTx( struct CyprIOEndpoint *ep, int buffersize, int nrbuffers, CyprIOXferCB_t callback, void *id ); 110 | 111 | int CyprIOGetString( struct CyprIO * ths, WCHAR *str, uint8_t sIndex); 112 | 113 | 114 | 115 | /////////////////////////////////////////////////////////////////////// 116 | // CyprIO Utilities 117 | 118 | //Tries to see if it can find a bootloader device, then flash the specified firmware. 119 | int CyprIOBootloaderImage( const char * fwfile ); 120 | 121 | #endif 122 | -------------------------------------------------------------------------------- /libcyprio/libcyprio_util.c: -------------------------------------------------------------------------------- 1 | /* 2 | API Routine to boot Cypress FX3 to a specific firmware image. 3 | (C) 2017 C. Lohr, under the MIT-x11 or NewBSD License. You decide. 4 | Tested on Windows, working full functionality 12/30/2017 5 | Tested on Linux, working full functionality 12/31/2017 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | int CyprIOBootloaderImage( const char * fwfile ) 13 | { 14 | FILE * firmware = 0; 15 | struct CyprIO eps; 16 | 17 | int r = CyprIOConnect( &eps, 0, 0x04b4, 0x00f3 ); 18 | if( r ) 19 | { 20 | fprintf( stderr, "Error: Could not connect to USB device\n" ); 21 | goto error; 22 | } 23 | /* 24 | //Not needed if we're not using pipes/etc. 25 | r = CyprIOGetDevDescriptorInformation( &eps ); 26 | if( r ) 27 | { 28 | fprintf( stderr, "Error: Couldn't get all info needed from device\n" ); 29 | goto error; 30 | } 31 | r = CyprIOSetup( &eps, 0, 2 ); 32 | if( r ) 33 | { 34 | fprintf( stderr, "Error: Could not setup USB device\n" ); 35 | goto error; 36 | } 37 | */ 38 | 39 | 40 | 41 | printf( "Connected successfully\n" ); 42 | uint8_t buf[2048]; 43 | uint8_t comp[2048]; 44 | 45 | int k = CyprIOControlTransfer( &eps, 0xc0, 0xa0, 0, 0, comp, 1, 5000 ); 46 | if( k != 1 ) 47 | { 48 | fprintf( stderr, "Error: Control message returned confusing result (%d / %02x)\n", k, comp[0] ); 49 | goto error; 50 | } 51 | 52 | firmware = fopen( fwfile, "rb" ); 53 | uint8_t header[4]; 54 | r = fread( header, 4, 1, firmware ); 55 | 56 | if( r < 1 || header[0] != 'C' || header[1] != 'Y' ) 57 | { 58 | fprintf( stderr, "Invalid image file.\n" ); 59 | goto error; 60 | } 61 | 62 | uint32_t flashspot = 0x100; 63 | uint32_t remain = 0; 64 | while( !feof( firmware ) && !ferror( firmware ) ) 65 | { 66 | uint8_t arr[8]; 67 | int r = fread( arr, 1, 8, firmware ); 68 | if( r == 4 ) 69 | { 70 | //Checksum or something at the end of the file? Eh, don't care. 71 | printf( "Flashing done.\n" ); 72 | break; 73 | } 74 | if( r != 8 ) 75 | { 76 | fprintf( stderr, "Can't read header section in firmware at %d (%d)\n", (int)ftell(firmware), r ); 77 | goto error; 78 | } 79 | 80 | //43 59 1C B0 ||| 8A 08 00 00 00 01 00 00 = Read 2228 bytes. 088a * 4 = 2228 81 | // (@2234) 00 40 00 00 00 30 00 40 = Read ??? 82 | flashspot = arr[4] | (arr[5]<<8) | (arr[6]<<16) | (arr[7]<<24); 83 | remain = arr[0] | (arr[1]<<8) | (arr[2]<<16) | (arr[3]<<24); 84 | remain *= 4; 85 | 86 | if( remain == 0 ) 87 | { 88 | int e = CyprIOControlTransfer( &eps, 0x40, 0xa0, flashspot, flashspot>>16, buf, 0, 5000 ); 89 | printf( "Special operation with size zero return value: %d\n", e ); 90 | continue; 91 | } 92 | 93 | printf( "Flashing section %08x with %d bytes (@%08x)\n", flashspot, remain, (int)ftell (firmware ) ); 94 | 95 | while( !feof( firmware ) && !ferror( firmware ) && remain > 0 ) 96 | { 97 | int toread = (remain<2048)?remain:2048; 98 | int r = fread( buf, toread, 1, firmware ); 99 | if( r <= 0 ) 100 | { 101 | fprintf( stderr, "Error reading firmware file at address %d\n", (int)ftell(firmware) ); 102 | goto error; 103 | } 104 | remain -= toread; 105 | int tries = 0; 106 | 107 | do 108 | { 109 | int e = CyprIOControlTransfer( &eps, 0x40, 0xa0, flashspot, flashspot>>16, buf, toread, 5000 ); 110 | int k = CyprIOControlTransfer( &eps, 0xc0, 0xa0, flashspot, flashspot>>16, comp, toread, 5000 ); 111 | flashspot += toread; 112 | if( e != k || e != toread || memcmp( comp, buf, toread ) != 0 ) 113 | { 114 | fprintf( stderr, "Retrying... (%d/%d/%d)", e, k, toread ); 115 | if( tries++ > 10 ) 116 | { 117 | fprintf( stderr, "Error: Can't flash.\n" ); 118 | goto error; 119 | } 120 | } 121 | else 122 | { 123 | break; 124 | } 125 | } while( 1 ); 126 | } 127 | } 128 | CyprIODestroy( &eps ); 129 | return 0; 130 | error: 131 | if( firmware ) fclose( firmware ); 132 | CyprIODestroy( &eps ); 133 | return -1; 134 | } 135 | -------------------------------------------------------------------------------- /testproject/.gitignore: -------------------------------------------------------------------------------- 1 | .metadata 2 | SRAMMaster 3 | USBIsoSource/Debug 4 | -------------------------------------------------------------------------------- /testproject/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.cdt.debug.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.cdt.debug.core.cDebug.default_source_containers=\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n 3 | -------------------------------------------------------------------------------- /testproject/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.core.prefs: -------------------------------------------------------------------------------- 1 | //org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.applicationLaunchType=org.eclipse.cdt.dsf.gdb.launch.localCLaunch,debug;org.eclipse.cdt.cdi.launch.localCLaunch,run 2 | //org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.attachLaunchType=org.eclipse.cdt.dsf.gdb.launch.attachCLaunch,debug 3 | //org.eclipse.debug.core.PREFERRED_DELEGATES/org.eclipse.cdt.launch.postmortemLaunchType=org.eclipse.cdt.dsf.gdb.launch.coreCLaunch,debug 4 | eclipse.preferences.version=1 5 | -------------------------------------------------------------------------------- /testproject/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=\r\n\r\n 3 | preferredTargets=org.eclipse.cdt.debug.ui.toggleCBreakpointTarget\:org.eclipse.cdt.debug.ui.toggleCBreakpointTarget| 4 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/.gitignore: -------------------------------------------------------------------------------- 1 | /Release 2 | version.h 3 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | USBIsoSource 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 25 | 26 | 27 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/Makefile: -------------------------------------------------------------------------------- 1 | ## Copyright Cypress Semiconductor Corporation, 2010-2011, 2 | ## All Rights Reserved 3 | ## UNPUBLISHED, LICENSED SOFTWARE. 4 | ## 5 | ## CONFIDENTIAL AND PROPRIETARY INFORMATION 6 | ## WHICH IS THE PROPERTY OF CYPRESS. 7 | ## 8 | ## Use of this file is governed 9 | ## by the license agreement included in the file 10 | ## 11 | ## /license/license.txt 12 | ## 13 | ## where is the Cypress software 14 | ## installation root directory path. 15 | ## 16 | 17 | FX3FWROOT=../../../cyfx3sdk 18 | 19 | all:compile 20 | 21 | include $(FX3FWROOT)/fw_build/fx3_fw/fx3_build_config.mak 22 | 23 | $(shell echo -e "#define GIT_COMMIT \"$$(git describe --always --dirty --match 'NOT A TAG')\"" > version.h) 24 | 25 | MODULE = cyfxisosrc 26 | 27 | SOURCE= $(MODULE).c \ 28 | cyfxisodscr.c \ 29 | cyfxtx.c 30 | 31 | ifeq ($(CYFXBUILD),arm) 32 | SOURCE_ASM=cyfx_startup.S 33 | else 34 | SOURCE_ASM=cyfx_gcc_startup.S 35 | endif 36 | 37 | C_OBJECT=$(SOURCE:%.c=./%.o) 38 | A_OBJECT=$(SOURCE_ASM:%.S=./%.o) 39 | 40 | EXES = $(MODULE).$(EXEEXT) 41 | 42 | $(MODULE).$(EXEEXT): $(A_OBJECT) $(C_OBJECT) 43 | $(LINK) 44 | 45 | cyfxtx.c: 46 | cp $(FX3FWROOT)/fw_build/fx3_fw/cyfxtx.c . 47 | 48 | cyfx_startup.S: 49 | cp $(FX3FWROOT)/fw_build/fx3_fw/cyfx_startup.S . 50 | 51 | cyfx_gcc_startup.S: 52 | cp $(FX3FWROOT)/fw_build/fx3_fw/cyfx_gcc_startup.S . 53 | 54 | $(C_OBJECT) : %.o : %.c 55 | $(COMPILE) 56 | 57 | $(A_OBJECT) : %.o : %.S 58 | $(ASSEMBLE) 59 | 60 | clean: 61 | rm -f ./$(MODULE).$(EXEEXT) 62 | rm -f ./$(MODULE).map 63 | rm -f ./*.o 64 | rm -f cyfxtx.c cyfx_startup.S cyfx_gcc_startup.S 65 | 66 | 67 | compile: $(C_OBJECT) $(A_OBJECT) $(EXES) 68 | 69 | #[]# 70 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/Release/USBIsoSource.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnlohr/fx3fun/b36d2d7eadebfef53769dc09c573807a1a2a71f4/testproject/USBIsoSource/Release/USBIsoSource.img -------------------------------------------------------------------------------- /testproject/USBIsoSource/complex_gpif2.cydsn/complex_gpif2.cyfx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/complex_gpif2.cydsn/cyfxgpif2config_complex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Name: complex_gpif2.cyfx 3 | * Time : 05/21/2021 18:40:54 4 | * Device Type: FX3 5 | * Project Type: GPIF2 6 | * 7 | * 8 | * 9 | * 10 | * This is a generated file and should not be modified 11 | * This file need to be included only once in the firmware 12 | * This file is generated by Gpif2 designer tool version - 1.0.1198.2 13 | * 14 | */ 15 | 16 | #ifndef _INCLUDED__ 17 | #define _INCLUDED__ 18 | #include "cyu3types.h" 19 | #include "cyu3gpif.h" 20 | 21 | /* Summary 22 | Number of states in the state machine 23 | */ 24 | #define CY_NUMBER_OF_STATES 10 25 | 26 | /* Summary 27 | Mapping of user defined state names to state indices 28 | */ 29 | #define START 0 30 | #define STATE0 2 31 | #define STATE3 4 32 | #define STATE4 1 33 | #define STATE1 5 34 | #define STATE2 3 35 | #define STATE5 8 36 | #define STATE6 9 37 | #define STATE7 6 38 | #define STATE8 7 39 | 40 | 41 | /* Summary 42 | Initial value of early outputs from the state machine. 43 | */ 44 | #define ALPHA_START 0x0 45 | 46 | 47 | /* Summary 48 | Transition function values used in the state machine. 49 | */ 50 | uint16_t CyFxGpifTransition[] = { 51 | 0x0000, 0xAAAA, 0xFFFF, 0xCCCC 52 | }; 53 | 54 | /* Summary 55 | Table containing the transition information for various states. 56 | This table has to be stored in the WAVEFORM Registers. 57 | This array consists of non-replicated waveform descriptors and acts as a 58 | waveform table. 59 | */ 60 | CyU3PGpifWaveData CyFxGpifWavedata[] = { 61 | {{0x2E739C01,0x00000500,0x800000A0},{0x00000000,0x00000000,0x00000000}}, 62 | {{0x1E727402,0x20090106,0x80000040},{0x00000000,0x00000000,0x00000000}}, 63 | {{0x2E739C03,0x20400100,0xC0000000},{0x1E727404,0x24050106,0x80000040}}, 64 | {{0x2E739C07,0x20000100,0x83800000},{0x00000000,0x00000000,0x00000000}}, 65 | {{0x2E739C05,0x24400100,0xC0000000},{0x1E727402,0x20090106,0x80000040}}, 66 | {{0x2E739C06,0x24000100,0x83800000},{0x00000000,0x00000000,0x00000000}}, 67 | {{0x2E739C08,0x24400900,0x80000010},{0x00000000,0x00000000,0x00000000}}, 68 | {{0x2E739C09,0x20400500,0x80000010},{0x00000000,0x00000000,0x00000000}}, 69 | {{0x1E727404,0x24050106,0x80000040},{0x00000000,0x00000000,0x00000000}} 70 | }; 71 | 72 | /* Summary 73 | Table that maps state indices to the descriptor table indices. 74 | */ 75 | uint8_t CyFxGpifWavedataPosition[] = { 76 | 0,1,2,3,4,5,6,7,8,1 77 | }; 78 | 79 | /* Summary 80 | GPIF II configuration register values. 81 | */ 82 | uint32_t CyFxGpifRegValue[] = { 83 | 0x80008338, /* CY_U3P_PIB_GPIF_CONFIG */ 84 | 0x00000003, /* CY_U3P_PIB_GPIF_BUS_CONFIG */ 85 | 0x00000000, /* CY_U3P_PIB_GPIF_BUS_CONFIG2 */ 86 | 0x00000052, /* CY_U3P_PIB_GPIF_AD_CONFIG */ 87 | 0x00000000, /* CY_U3P_PIB_GPIF_STATUS */ 88 | 0x00000000, /* CY_U3P_PIB_GPIF_INTR */ 89 | 0x00000000, /* CY_U3P_PIB_GPIF_INTR_MASK */ 90 | 0x00000082, /* CY_U3P_PIB_GPIF_SERIAL_IN_CONFIG */ 91 | 0x00000782, /* CY_U3P_PIB_GPIF_SERIAL_OUT_CONFIG */ 92 | 0x00000055, /* CY_U3P_PIB_GPIF_CTRL_BUS_DIRECTION */ 93 | 0x0000FFFF, /* CY_U3P_PIB_GPIF_CTRL_BUS_DEFAULT */ 94 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_POLARITY */ 95 | 0x0000000F, /* CY_U3P_PIB_GPIF_CTRL_BUS_TOGGLE */ 96 | 0x00000008, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 97 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 98 | 0x00000001, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 99 | 0x00000002, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 100 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 101 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 102 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 103 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 104 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 105 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 106 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 107 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 108 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 109 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 110 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 111 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 112 | 0x00000006, /* CY_U3P_PIB_GPIF_CTRL_COUNT_CONFIG */ 113 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_COUNT_RESET */ 114 | 0x0000FFFF, /* CY_U3P_PIB_GPIF_CTRL_COUNT_LIMIT */ 115 | 0x0000010B, /* CY_U3P_PIB_GPIF_ADDR_COUNT_CONFIG */ 116 | 0x00000000, /* CY_U3P_PIB_GPIF_ADDR_COUNT_RESET */ 117 | 0x00000080, /* CY_U3P_PIB_GPIF_ADDR_COUNT_LIMIT */ 118 | 0x00000000, /* CY_U3P_PIB_GPIF_STATE_COUNT_CONFIG */ 119 | 0x0000FFFF, /* CY_U3P_PIB_GPIF_STATE_COUNT_LIMIT */ 120 | 0x0000010B, /* CY_U3P_PIB_GPIF_DATA_COUNT_CONFIG */ 121 | 0x00000000, /* CY_U3P_PIB_GPIF_DATA_COUNT_RESET */ 122 | 0x0000006E, /* CY_U3P_PIB_GPIF_DATA_COUNT_LIMIT */ 123 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_COMP_VALUE */ 124 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_COMP_MASK */ 125 | 0x00000000, /* CY_U3P_PIB_GPIF_DATA_COMP_VALUE */ 126 | 0x00000000, /* CY_U3P_PIB_GPIF_DATA_COMP_MASK */ 127 | 0x00000000, /* CY_U3P_PIB_GPIF_ADDR_COMP_VALUE */ 128 | 0x00000000, /* CY_U3P_PIB_GPIF_ADDR_COMP_MASK */ 129 | 0x00000000, /* CY_U3P_PIB_GPIF_DATA_CTRL */ 130 | 0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_DATA */ 131 | 0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_DATA */ 132 | 0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_DATA */ 133 | 0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_DATA */ 134 | 0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_DATA */ 135 | 0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_DATA */ 136 | 0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_DATA */ 137 | 0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_DATA */ 138 | 0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_ADDRESS */ 139 | 0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_ADDRESS */ 140 | 0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_ADDRESS */ 141 | 0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_ADDRESS */ 142 | 0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_ADDRESS */ 143 | 0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_ADDRESS */ 144 | 0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_ADDRESS */ 145 | 0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_ADDRESS */ 146 | 0x80010400, /* CY_U3P_PIB_GPIF_THREAD_CONFIG */ 147 | 0x80010401, /* CY_U3P_PIB_GPIF_THREAD_CONFIG */ 148 | 0x80010402, /* CY_U3P_PIB_GPIF_THREAD_CONFIG */ 149 | 0x80010403, /* CY_U3P_PIB_GPIF_THREAD_CONFIG */ 150 | 0x00000000, /* CY_U3P_PIB_GPIF_LAMBDA_STAT */ 151 | 0x00000000, /* CY_U3P_PIB_GPIF_ALPHA_STAT */ 152 | 0x00000000, /* CY_U3P_PIB_GPIF_BETA_STAT */ 153 | 0x00000000, /* CY_U3P_PIB_GPIF_WAVEFORM_CTRL_STAT */ 154 | 0x00000000, /* CY_U3P_PIB_GPIF_WAVEFORM_SWITCH */ 155 | 0x00000000, /* CY_U3P_PIB_GPIF_WAVEFORM_SWITCH_TIMEOUT */ 156 | 0x00000000, /* CY_U3P_PIB_GPIF_CRC_CONFIG */ 157 | 0x00000000, /* CY_U3P_PIB_GPIF_CRC_DATA */ 158 | 0xFFFFFFC1 /* CY_U3P_PIB_GPIF_BETA_DEASSERT */ 159 | }; 160 | 161 | /* Summary 162 | This structure holds all the configuration inputs for the GPIF II. 163 | */ 164 | const CyU3PGpifConfig_t CyFxGpifConfig = { 165 | (uint16_t)(sizeof(CyFxGpifWavedataPosition)/sizeof(uint8_t)), 166 | CyFxGpifWavedata, 167 | CyFxGpifWavedataPosition, 168 | (uint16_t)(sizeof(CyFxGpifTransition)/sizeof(uint16_t)), 169 | CyFxGpifTransition, 170 | (uint16_t)(sizeof(CyFxGpifRegValue)/sizeof(uint32_t)), 171 | CyFxGpifRegValue 172 | }; 173 | 174 | #endif /* _INCLUDED__ */ 175 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/complex_gpif2.cydsn/projectfiles/gpif2model.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | False 6 | True 7 | False 8 | False 9 | False 10 | Master 11 | Synchronous 12 | Internal 13 | Negative 14 | LittleEndian 15 | Bit8 16 | 0 17 | 18 | 19 | 20 | 21 | OUTPUT0 22 | GPIO_17 23 | Low 24 | ActiveHigh 25 | Beta 26 | Toggle 27 | 28 | 29 | OUTPUT1 30 | GPIO_18 31 | Low 32 | ActiveHigh 33 | Alpha 34 | Toggle 35 | 36 | 37 | OUTPUT2 38 | GPIO_19 39 | Low 40 | ActiveHigh 41 | Alpha 42 | Toggle 43 | 44 | 45 | OUTPUT3 46 | GPIO_20 47 | Low 48 | ActiveHigh 49 | Alpha 50 | Toggle 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | START 64 | True 65 | 0 66 | 67 | 68 | STATE0 69 | True 70 | 0 71 | 72 | Socket 73 | Thread0 74 | True 75 | True 76 | 77 | 78 | OUTPUT1 79 | 80 | 81 | 82 | 83 | STATE3 84 | True 85 | 0 86 | 87 | Socket 88 | Thread1 89 | True 90 | True 91 | 92 | 93 | OUTPUT2 94 | 95 | 96 | 97 | 98 | STATE4 99 | True 100 | 0 101 | 102 | Up 103 | 0 104 | 128 105 | Enable 106 | 1 107 | Mask 108 | 109 | 110 | Up 111 | 0 112 | 110 113 | Enable 114 | 1 115 | Mask 116 | 117 | 118 | 119 | STATE1 120 | False 121 | 0 122 | 123 | Socket 124 | Thread1 125 | True 126 | True 127 | 128 | 129 | OUTPUT0 130 | 131 | 132 | 133 | STATE2 134 | False 135 | 0 136 | 137 | Socket 138 | Thread0 139 | True 140 | True 141 | 142 | 143 | OUTPUT0 144 | 145 | 146 | 147 | STATE5 148 | True 149 | 0 150 | 151 | Socket 152 | Thread1 153 | True 154 | True 155 | 156 | 157 | OUTPUT0 158 | 159 | 160 | 161 | 162 | STATE6 163 | True 164 | 0 165 | 166 | Socket 167 | Thread0 168 | True 169 | True 170 | 171 | 172 | OUTPUT0 173 | 174 | 175 | 176 | 177 | STATE7 178 | True 179 | 14 180 | 181 | Socket 182 | Thread1 183 | True 184 | True 185 | 186 | 187 | 188 | STATE8 189 | True 190 | 14 191 | 192 | Socket 193 | Thread0 194 | True 195 | True 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/complex_gpif2.cydsn/projectfiles/gpif2timingsimulation.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 100 4 | 512 5 | 0 6 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/complex_gpif2.cydsn/projectfiles/gpif2view.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 1256 6 | 311.446666666667 7 | 83 8 | 70 9 | STATE0 10 | STATE0 11 | 1 12 | False 13 | 00000000-0000-0000-0000-000000000000 14 | 15 | 16 | 403 17 | 470 18 | 83 19 | 70 20 | STATE3 21 | STATE3 22 | 1 23 | False 24 | 00000000-0000-0000-0000-000000000000 25 | 26 | 27 | 744 28 | 60.41 29 | 83 30 | 70 31 | STATE4 32 | STATE4 33 | 1 34 | False 35 | 00000000-0000-0000-0000-000000000000 36 | 37 | 38 | 227 39 | 292.41 40 | 83 41 | 70 42 | STATE1 43 | STATE1 44 | 1 45 | False 46 | 00000000-0000-0000-0000-000000000000 47 | 48 | 49 | 1339 50 | 452.41 51 | 83 52 | 70 53 | STATE2 54 | STATE2 55 | 1 56 | False 57 | 00000000-0000-0000-0000-000000000000 58 | 59 | 60 | 560 61 | 255.41 62 | 83 63 | 70 64 | STATE5 65 | STATE5 66 | 1 67 | False 68 | 00000000-0000-0000-0000-000000000000 69 | 70 | 71 | 1142 72 | 494.41 73 | 83 74 | 70 75 | STATE6 76 | STATE6 77 | 1 78 | False 79 | 00000000-0000-0000-0000-000000000000 80 | 81 | 82 | 374 83 | 173.41 84 | 83 85 | 70 86 | STATE7 87 | STATE7 88 | 1 89 | False 90 | 00000000-0000-0000-0000-000000000000 91 | 92 | 93 | 1260 94 | 550.41 95 | 83 96 | 70 97 | STATE8 98 | STATE8 99 | 1 100 | False 101 | 00000000-0000-0000-0000-000000000000 102 | 103 | 104 | 265 105 | 55.4466666666667 106 | 83 107 | 70 108 | STARTSTATE0 109 | START 110 | 1 111 | False 112 | 00000000-0000-0000-0000-000000000000 113 | 114 | 115 | 116 | 117 | TRANSITION5 118 | LOGIC_ONE 119 | STATE8 120 | STATE6 121 | Connector 122 | Connector 123 | None 124 | Arrow 125 | 0 126 | 127 | 128 | TRANSITION4 129 | LOGIC_ONE 130 | STATE2 131 | STATE8 132 | Connector 133 | Connector 134 | None 135 | Arrow 136 | 0 137 | 138 | 139 | TRANSITION3 140 | LOGIC_ONE 141 | STATE7 142 | STATE5 143 | Connector 144 | Connector 145 | None 146 | Arrow 147 | 0 148 | 149 | 150 | TRANSITION2 151 | LOGIC_ONE 152 | STATE1 153 | STATE7 154 | Connector 155 | Connector 156 | None 157 | Arrow 158 | 0 159 | 160 | 161 | TRANSITION19 162 | LOGIC_ONE 163 | STATE6 164 | STATE0 165 | Connector 166 | Connector 167 | None 168 | Arrow 169 | 0 170 | 171 | 172 | TRANSITION17 173 | LOGIC_ONE 174 | STATE5 175 | STATE3 176 | Connector 177 | Connector 178 | None 179 | Arrow 180 | 0 181 | 182 | 183 | TRANSITION15 184 | ADDR_CNT_HIT 185 | STATE0 186 | STATE3 187 | Connector 188 | Connector 189 | None 190 | Arrow 191 | 0 192 | 193 | 194 | TRANSITION14 195 | ADDR_CNT_HIT 196 | STATE3 197 | STATE0 198 | Connector 199 | Connector 200 | None 201 | Arrow 202 | 0 203 | 204 | 205 | TRANSITION9 206 | DATA_CNT_HIT 207 | STATE3 208 | STATE1 209 | Connector 210 | Connector 211 | None 212 | Arrow 213 | 0 214 | 215 | 216 | TRANSITION7 217 | DATA_CNT_HIT 218 | STATE0 219 | STATE2 220 | Connector 221 | Connector 222 | None 223 | Arrow 224 | 0 225 | 226 | 227 | TRANSITION1 228 | LOGIC_ONE 229 | STATE4 230 | STATE0 231 | Connector 232 | Connector 233 | None 234 | Arrow 235 | 0 236 | 237 | 238 | TRANSITION0 239 | LOGIC_ONE 240 | STARTSTATE0 241 | STATE4 242 | Connector 243 | Connector 244 | None 245 | Arrow 246 | 0 247 | 248 | 249 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/complex_gpif_load.c: -------------------------------------------------------------------------------- 1 | #include //XXX CNL 2 | 3 | #define CyFxGpifConfig CyFxGpifConfig_Complex 4 | #define CyFxGpifRegValue CyFxGpifRegValue_Complex 5 | #define CyFxGpifWavedataPosition CyFxGpifWavedataPosition_Complex 6 | #define CyFxGpifWavedata CyFxGpifWavedata_Complex 7 | #define CyFxGpifTransition CyFxGpifTransition_Complex 8 | 9 | #include "complex_gpif2.cydsn/cyfxgpif2config_complex.h" 10 | 11 | int ComplexGPIFLoad() 12 | { 13 | return CyU3PGpifLoad(&CyFxGpifConfig_Complex); 14 | } 15 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/cyfx_gcc_startup.S: -------------------------------------------------------------------------------- 1 | # Copyright Cypress Semiconductor Corporation, 2010-2018, 2 | # All Rights Reserved 3 | # UNPUBLISHED, LICENSED SOFTWARE. 4 | # 5 | # CONFIDENTIAL AND PROPRIETARY INFORMATION 6 | # WHICH IS THE PROPERTY OF CYPRESS. 7 | # 8 | # Use of this file is governed 9 | # by the license agreement included in the file 10 | # 11 | # /license/license.txt 12 | # 13 | # where is the Cypress software 14 | # installation root directory path. 15 | # 16 | 17 | # Cypress FX3 Firmware Startup code 18 | 19 | 20 | .section .text 21 | .code 32 22 | 23 | .global jump 24 | jump: 25 | bx R0 26 | 27 | .global CyU3PToolChainInit 28 | CyU3PToolChainInit: 29 | 30 | # clear the BSS area 31 | __main: 32 | mov R0, #0 33 | ldr R1, =_bss_start 34 | ldr R2, =_bss_end 35 | 1: cmp R1, R2 36 | strlo R0, [R1], #4 37 | blo 1b 38 | 39 | b main 40 | 41 | 42 | .global __user_initial_stackheap 43 | __user_initial_stackheap: 44 | 45 | # The tool chain is not expected to place the stack. 46 | # No heap is expected to be used by USB 3.0 platform drivers. 47 | # Place them as required by the user code 48 | .if INTER == TRUE 49 | bx lr 50 | .else 51 | mov pc, lr 52 | .endif 53 | 54 | .end 55 | 56 | # [] 57 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/cyfxisodscr.c: -------------------------------------------------------------------------------- 1 | /* 2 | ## Cypress USB 3.0 Platform header file (cyfxisodscr.c) 3 | ## =========================== 4 | ## 5 | ## Copyright Cypress Semiconductor Corporation, 2010-2011, 6 | ## All Rights Reserved 7 | ## UNPUBLISHED, LICENSED SOFTWARE. 8 | ## 9 | ## CONFIDENTIAL AND PROPRIETARY INFORMATION 10 | ## WHICH IS THE PROPERTY OF CYPRESS. 11 | ## 12 | ## Use of this file is governed 13 | ## by the license agreement included in the file 14 | ## 15 | ## /license/license.txt 16 | ## 17 | ## where is the Cypress software 18 | ## installation root directory path. 19 | ## 20 | ## =========================== 21 | */ 22 | 23 | /* This file contains the USB enumeration descriptors for the ISO source application example. 24 | * The descriptor arrays must be 32 byte aligned and multiple of 32 bytes if the D-cache is 25 | * turned on. If the linker used is not capable of supporting the aligned feature for this, 26 | * either the descriptors must be placed in a different section and the section should be 27 | * 32 byte aligned and 32 byte multiple; or dynamically allocated buffer allocated using 28 | * CyU3PDmaBufferAlloc must be used, and the descriptor must be loaded into it. The example 29 | * assumes that the aligned attribute for 32 bytes is supported by the linker. Do not add 30 | * any other variables to this file other than USB descriptors. This is not the only 31 | * pre-requisite to enabling the D-cache. Refer to the documentation for 32 | * CyU3PDeviceCacheControl for more information. 33 | */ 34 | 35 | #include "cyfxisosrc.h" 36 | 37 | /* Standard device descriptor for USB 3.0 */ 38 | const uint8_t CyFxUSB30DeviceDscr[] __attribute__ ((aligned (32))) = 39 | { 40 | 0x12, /* Descriptor size */ 41 | CY_U3P_USB_DEVICE_DESCR, /* Device descriptor type */ 42 | 0x00,0x03, /* USB 3.0 */ 43 | 0x00, /* Device class */ 44 | 0x00, /* Device sub-class */ 45 | 0x00, /* Device protocol */ 46 | 0x09, /* Maxpacket size for EP0 : 2^9 */ 47 | 0xB4,0x04, /* Vendor ID */ 48 | 0xF1,0x00, /* Product ID */ 49 | 0x00,0x00, /* Device release number */ 50 | 0x01, /* Manufacture string index */ 51 | 0x02, /* Product string index */ 52 | 0x00, /* Serial number string index */ 53 | 0x01 /* Number of configurations */ 54 | }; 55 | 56 | /* Standard device descriptor for USB 2.0 */ 57 | const uint8_t CyFxUSB20DeviceDscr[] __attribute__ ((aligned (32))) = 58 | { 59 | 0x12, /* Descriptor size */ 60 | CY_U3P_USB_DEVICE_DESCR, /* Device descriptor type */ 61 | 0x10,0x02, /* USB 2.10 */ 62 | 0x00, /* Device class */ 63 | 0x00, /* Device sub-class */ 64 | 0x00, /* Device protocol */ 65 | 0x40, /* Maxpacket size for EP0 : 64 bytes */ 66 | 0xB4,0x04, /* Vendor ID */ 67 | 0xF1,0x00, /* Product ID */ 68 | 0x00,0x00, /* Device release number */ 69 | 0x01, /* Manufacture string index */ 70 | 0x02, /* Product string index */ 71 | 0x00, /* Serial number string index */ 72 | 0x01 /* Number of configurations */ 73 | }; 74 | 75 | /* Binary device object store descriptor */ 76 | const uint8_t CyFxUSBBOSDscr[] __attribute__ ((aligned (32))) = 77 | { 78 | 0x05, /* Descriptor size */ 79 | CY_U3P_BOS_DESCR, /* Device descriptor type */ 80 | 0x16,0x00, /* Length of this descriptor and all sub descriptors */ 81 | 0x02, /* Number of device capability descriptors */ 82 | 83 | /* USB 2.0 extension */ 84 | 0x07, /* Descriptor size */ 85 | CY_U3P_DEVICE_CAPB_DESCR, /* Device capability type descriptor */ 86 | CY_U3P_USB2_EXTN_CAPB_TYPE, /* USB 2.0 extension capability type */ 87 | 0x02,0x00,0x00,0x00, /* Supported device level features: LPM support */ 88 | 89 | /* SuperSpeed device capability */ 90 | 0x0A, /* Descriptor size */ 91 | CY_U3P_DEVICE_CAPB_DESCR, /* Device capability type descriptor */ 92 | CY_U3P_SS_USB_CAPB_TYPE, /* SuperSpeed device capability type */ 93 | 0x00, /* Supported device level features */ 94 | 0x0E,0x00, /* Speeds supported by the device : SS, HS and FS */ 95 | 0x03, /* Functionality support */ 96 | 0x00, /* U1 Device Exit latency */ 97 | 0x00,0x00 /* U2 Device Exit latency */ 98 | }; 99 | 100 | /* Standard device qualifier descriptor */ 101 | const uint8_t CyFxUSBDeviceQualDscr[] __attribute__ ((aligned (32))) = 102 | { 103 | 0x0A, /* Descriptor size */ 104 | CY_U3P_USB_DEVQUAL_DESCR, /* Device qualifier descriptor type */ 105 | 0x00,0x02, /* USB 2.0 */ 106 | 0x00, /* Device class */ 107 | 0x00, /* Device sub-class */ 108 | 0x00, /* Device protocol */ 109 | 0x40, /* Maxpacket size for EP0 : 64 bytes */ 110 | 0x01, /* Number of configurations */ 111 | 0x00 /* Reserved */ 112 | }; 113 | 114 | #define HI8(x) ((x)>>8) 115 | #define LO8(x) ((x)&0xFF) 116 | #define LOHI(x) LO8(x), HI8(x) 117 | 118 | /* Standard super speed configuration descriptor */ 119 | const uint8_t CyFxUSBSSConfigDscr[] __attribute__ ((aligned (32))) = 120 | { 121 | /* Configuration descriptor */ 122 | 0x09, /* Descriptor size */ 123 | CY_U3P_USB_CONFIG_DESCR, /* Configuration descriptor type */ 124 | 0x3E,0x00, /* Length of this descriptor and all sub descriptors */ 125 | 0x01, /* Number of interfaces */ 126 | 0x01, /* Configuration number */ 127 | 0x00, /* COnfiguration string index */ 128 | 0x80, /* Config characteristics - Bus powered */ 129 | 0x32, /* Max power consumption of device (in 8mA unit) : 400mA */ 130 | 131 | /* Interface 0, Alt. Setting 0: No endpoints */ 132 | 0x09, /* Descriptor size */ 133 | CY_U3P_USB_INTRFC_DESCR, /* Interface Descriptor type */ 134 | 0x00, /* Interface number */ 135 | 0x00, /* Alternate setting number */ 136 | 0x00, /* Number of end points */ 137 | 0xFF, /* Interface class */ 138 | 0x00, /* Interface sub class */ 139 | 0x00, /* Interface protocol code */ 140 | 0x00, /* Interface descriptor string index */ 141 | 142 | /* Interface 0, Alt. Setting 1: One ISO IN endpoint with single burst per uFrame. */ 143 | 0x09, /* Descriptor size */ 144 | CY_U3P_USB_INTRFC_DESCR, /* Interface Descriptor type */ 145 | 0x00, /* Interface number */ 146 | 0x01, /* Alternate setting number */ 147 | 0x01, /* Number of end points */ 148 | 0xFF, /* Interface class */ 149 | 0x00, /* Interface sub class */ 150 | 0x00, /* Interface protocol code */ 151 | 0x00, /* Interface descriptor string index */ 152 | 153 | /* Endpoint descriptor for IN EP */ 154 | 0x07, /* Descriptor size */ 155 | CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type */ 156 | CY_FX_EP_CONSUMER, /* Endpoint address and description */ 157 | CY_U3P_USB_EP_ISO, /* ISO endpoint type */ 158 | LOHI(MAX_PACKET_SIZE), /* Max packet size = 1024 bytes */ 159 | 0x01, /* Servicing interval for data transfers : 1 uFrame */ 160 | 161 | /* Super speed endpoint companion descriptor. */ 162 | 0x06, /* Descriptor size */ 163 | CY_U3P_SS_EP_COMPN_DESCR, /* SS endpoint companion descriptor type */ 164 | (CY_FX_ISO_BURST - 1), /* Max no. of packets in a burst(0-15) - 0: burst 1 packet at a time */ 165 | 0, /* Only one 16KB burst per micro-frame. */ 166 | LOHI(MAX_PACKET_SIZE*CY_FX_ISO_BURST), /* Bytes per interval : 1024 * 1 * burst */ 167 | 168 | /* Interface 0, Alt. Setting 2: One ISO IN endpoint with multiple bursts per uFrame. */ 169 | 0x09, /* Descriptor size */ 170 | CY_U3P_USB_INTRFC_DESCR, /* Interface Descriptor type */ 171 | 0x00, /* Interface number */ 172 | 0x02, /* Alternate setting number */ 173 | 0x01, /* Number of end points */ 174 | 0xFF, /* Interface class */ 175 | 0x00, /* Interface sub class */ 176 | 0x00, /* Interface protocol code */ 177 | 0x00, /* Interface descriptor string index */ 178 | 179 | /* Endpoint descriptor for consumer EP */ 180 | 0x07, /* Descriptor size */ 181 | CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type */ 182 | CY_FX_EP_CONSUMER, /* Endpoint address and description */ 183 | CY_U3P_USB_EP_ISO, /* ISO endpoint type */ 184 | LOHI(MAX_PACKET_SIZE), /* Max packet size = 1024 bytes */ 185 | 0x01, /* Servicing interval for data transfers : 1 uFrame */ 186 | 187 | /* Super speed endpoint companion descriptor. */ 188 | 0x06, /* Descriptor size */ 189 | CY_U3P_SS_EP_COMPN_DESCR, /* SS endpoint companion descriptor type */ 190 | (CY_FX_ISO_BURST - 1), /* Max no. of packets in a burst(0-15) - 0: burst 1 packet at a time */ 191 | (CY_FX_ISO_PKTS - 1), /* Mult.: Max number of packets : CY_FX_ISO_PKTS */ 192 | LOHI(MAX_PACKET_SIZE * CY_FX_ISO_PKTS * CY_FX_ISO_BURST), /* Bytes per interval : 1024 * isoPkts * burst */ 193 | }; 194 | 195 | /* Standard high speed configuration descriptor */ 196 | const uint8_t CyFxUSBHSConfigDscr[] __attribute__ ((aligned (32))) = 197 | { 198 | /* Configuration descriptor */ 199 | 0x09, /* Descriptor size */ 200 | CY_U3P_USB_CONFIG_DESCR, /* Configuration descriptor type */ 201 | 0x22,0x00, /* Length of this descriptor and all sub descriptors */ 202 | 0x01, /* Number of interfaces */ 203 | 0x01, /* Configuration number */ 204 | 0x00, /* COnfiguration string index */ 205 | 0x80, /* Config characteristics - bus powered */ 206 | 0x32, /* Max power consumption of device (in 2mA unit) : 100mA */ 207 | 208 | /* Interface 0, Alt. Setting 0: No endpoints. */ 209 | 0x09, /* Descriptor size */ 210 | CY_U3P_USB_INTRFC_DESCR, /* Interface Descriptor type */ 211 | 0x00, /* Interface number */ 212 | 0x00, /* Alternate setting number */ 213 | 0x00, /* Number of endpoints */ 214 | 0xFF, /* Interface class */ 215 | 0x00, /* Interface sub class */ 216 | 0x00, /* Interface protocol code */ 217 | 0x00, /* Interface descriptor string index */ 218 | 219 | /* Interface 0, Alt. Setting 1: ISO IN endpoint. */ 220 | 0x09, /* Descriptor size */ 221 | CY_U3P_USB_INTRFC_DESCR, /* Interface Descriptor type */ 222 | 0x00, /* Interface number */ 223 | 0x01, /* Alternate setting number */ 224 | 0x01, /* Number of endpoints */ 225 | 0xFF, /* Interface class */ 226 | 0x00, /* Interface sub class */ 227 | 0x00, /* Interface protocol code */ 228 | 0x00, /* Interface descriptor string index */ 229 | 230 | /* Endpoint descriptor for consumer EP */ 231 | 0x07, /* Descriptor size */ 232 | CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type */ 233 | CY_FX_EP_CONSUMER, /* Endpoint address and description */ 234 | CY_U3P_USB_EP_ISO, /* ISO endpoint type */ 235 | LOHI(1024), /* Max packet size = 1024 bytes, mult CY_FX_ISO_PKTS */ 236 | 0x01 /* Servicing interval for data transfers */ 237 | }; 238 | 239 | /* Standard full speed configuration descriptor */ 240 | const uint8_t CyFxUSBFSConfigDscr[] __attribute__ ((aligned (32))) = 241 | { 242 | /* Configuration descriptor */ 243 | 0x09, /* Descriptor size */ 244 | CY_U3P_USB_CONFIG_DESCR, /* Configuration descriptor type */ 245 | 0x22,0x00, /* Length of this descriptor and all sub descriptors */ 246 | 0x01, /* Number of interfaces */ 247 | 0x01, /* Configuration number */ 248 | 0x00, /* COnfiguration string index */ 249 | 0x80, /* Config characteristics - bus powered */ 250 | 0x32, /* Max power consumption of device (in 2mA unit) : 100mA */ 251 | 252 | /* Interface 0, Alt. Setting 0: No endpoints. */ 253 | 0x09, /* Descriptor size */ 254 | CY_U3P_USB_INTRFC_DESCR, /* Interface descriptor type */ 255 | 0x00, /* Interface number */ 256 | 0x00, /* Alternate setting number */ 257 | 0x00, /* Number of endpoints */ 258 | 0xFF, /* Interface class */ 259 | 0x00, /* Interface sub class */ 260 | 0x00, /* Interface protocol code */ 261 | 0x00, /* Interface descriptor string index */ 262 | 263 | /* Interface 0, Alt. Setting 1: ISO IN endpoint. */ 264 | 0x09, /* Descriptor size */ 265 | CY_U3P_USB_INTRFC_DESCR, /* Interface descriptor type */ 266 | 0x00, /* Interface number */ 267 | 0x01, /* Alternate setting number */ 268 | 0x01, /* Number of endpoints */ 269 | 0xFF, /* Interface class */ 270 | 0x00, /* Interface sub class */ 271 | 0x00, /* Interface protocol code */ 272 | 0x00, /* Interface descriptor string index */ 273 | 274 | /* Endpoint descriptor for consumer EP */ 275 | 0x07, /* Descriptor size */ 276 | CY_U3P_USB_ENDPNT_DESCR, /* Endpoint descriptor type */ 277 | CY_FX_EP_CONSUMER, /* Endpoint address and description */ 278 | CY_U3P_USB_EP_ISO, /* ISO endpoint type */ 279 | 0x40,0x00, /* Max packet size = 64 bytes */ 280 | 0x01 /* Servicing interval for data transfers */ 281 | }; 282 | 283 | /* Standard language ID string descriptor */ 284 | const uint8_t CyFxUSBStringLangIDDscr[] __attribute__ ((aligned (32))) = 285 | { 286 | 0x04, /* Descriptor size */ 287 | CY_U3P_USB_STRING_DESCR, /* Device descriptor type */ 288 | 0x09,0x04 /* Language ID supported */ 289 | }; 290 | 291 | /* Standard manufacturer string descriptor */ 292 | const uint8_t CyFxUSBManufactureDscr[] __attribute__ ((aligned (32))) = 293 | { 294 | 0x10, /* Descriptor size */ 295 | CY_U3P_USB_STRING_DESCR, /* Device descriptor type */ 296 | 'C',0x00, 297 | 'y',0x00, 298 | 'p',0x00, 299 | 'r',0x00, 300 | 'e',0x00, 301 | 's',0x00, 302 | 's',0x00 303 | }; 304 | 305 | /* Standard product string descriptor */ 306 | const uint8_t CyFxUSBProductDscr[] __attribute__ ((aligned (32))) = 307 | { 308 | 0x08, /* Descriptor size */ 309 | CY_U3P_USB_STRING_DESCR, /* Device descriptor type */ 310 | 'F',0x00, 311 | 'X',0x00, 312 | '3',0x00 313 | }; 314 | 315 | /* Place this buffer as the last buffer so that no other variable / code shares 316 | * the same cache line. Do not add any other variables / arrays in this file. 317 | * This will lead to variables sharing the same cache line. */ 318 | const uint8_t CyFxUsbDscrAlignBuffer[32] __attribute__ ((aligned (32))); 319 | 320 | /* [ ] */ 321 | 322 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/cyfxisosrc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ## Cypress USB 3.0 Platform header file (cyfxisosrc.h) 3 | ## =========================== 4 | ## 5 | ## Copyright Cypress Semiconductor Corporation, 2010-2011, 6 | ## All Rights Reserved 7 | ## UNPUBLISHED, LICENSED SOFTWARE. 8 | ## 9 | ## CONFIDENTIAL AND PROPRIETARY INFORMATION 10 | ## WHICH IS THE PROPERTY OF CYPRESS. 11 | ## 12 | ## Use of this file is governed 13 | ## by the license agreement included in the file 14 | ## 15 | ## /license/license.txt 16 | ## 17 | ## where is the Cypress software 18 | ## installation root directory path. 19 | ## 20 | ## =========================== 21 | */ 22 | 23 | /* This file contains the constants used by the ISO source application example */ 24 | 25 | #ifndef _INCLUDED_CYFXISOSRC_H_ 26 | #define _INCLUDED_CYFXISOSRC_H_ 27 | 28 | #include "cyu3types.h" 29 | #include "cyu3usbconst.h" 30 | #include "cyu3externcstart.h" 31 | 32 | 33 | 34 | 35 | 36 | //#define CY_FX_ISOSRC_DMA_TX_SIZE (0) /* DMA transfer size is set to infinite */ 37 | #define CY_FX_ISOSRC_THREAD_STACK (0x1000) /* Application thread stack size */ 38 | #define CY_FX_ISOSRC_THREAD_PRIORITY (8) /* Application thread priority */ 39 | 40 | /* Endpoint and socket definitions for the bulkloop application */ 41 | /* Note: For USB 2.0 the endpoints and corresponding sockets are one-to-one mapped 42 | i.e. EP 1 is mapped to UIB socket 1 and EP 2 to socket 2 so on */ 43 | #define CY_FX_EP_CONSUMER 0x83 /* EP 3 IN */ 44 | #define CY_FX_EP_CONSUMER_SOCKET CY_U3P_UIB_SOCKET_CONS_3 /* Socket 3 is consumer */ 45 | 46 | /* Burst mode definitions: Only for super speed operation. The maximum burst mode 47 | * supported is limited by the USB hosts available. The maximum value for this is 16 48 | * and the minimum (no-burst) is 1. */ 49 | 50 | #define CY_FX_ISOSRC_DMA_BUF_COUNT (1) /* Number of buffers in the DMA channel. (Now applied to GPIF) */ 51 | /* NOTE: Count is per socket! */ 52 | #define CY_FX_ISO_PKTS (2) /* Number of bursts per microframe. */ 53 | #define CY_FX_ISO_BURST (16) /* Number of packets per burst. */ 54 | #define MAX_PACKET_SIZE 1024 55 | #define MULTI_CHANNEL_XFER_SIZE 16384 56 | 57 | 58 | #define CY_FX_DEBUG_PRIORITY (4) /* Sets the debug print priority level */ 59 | 60 | #define DMAMULTI //Needed for continuous operation (Should remove where this is false) 61 | 62 | /* Extern definitions for the USB Descriptors */ 63 | extern const uint8_t CyFxUSB20DeviceDscr[]; 64 | extern const uint8_t CyFxUSB30DeviceDscr[]; 65 | extern const uint8_t CyFxUSBDeviceQualDscr[]; 66 | extern const uint8_t CyFxUSBFSConfigDscr[]; 67 | extern const uint8_t CyFxUSBHSConfigDscr[]; 68 | extern const uint8_t CyFxUSBBOSDscr[]; 69 | extern const uint8_t CyFxUSBSSConfigDscr[]; 70 | extern const uint8_t CyFxUSBStringLangIDDscr[]; 71 | extern const uint8_t CyFxUSBManufactureDscr[]; 72 | extern const uint8_t CyFxUSBProductDscr[]; 73 | 74 | #include "cyu3externcend.h" 75 | 76 | #endif /* _INCLUDED_CYFXISOSRC_H_ */ 77 | 78 | /*[]*/ 79 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/fast_gpif2.cydsn/cyfxgpif2config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Name: fast_gpif2.cyfx 3 | * Time : 04/22/2021 18:52:54 4 | * Device Type: FX3 5 | * Project Type: GPIF2 6 | * 7 | * 8 | * 9 | * 10 | * This is a generated file and should not be modified 11 | * This file need to be included only once in the firmware 12 | * This file is generated by Gpif2 designer tool version - 1.0.1198.2 13 | * 14 | */ 15 | 16 | #ifndef _INCLUDED__ 17 | #define _INCLUDED__ 18 | #include "cyu3types.h" 19 | #include "cyu3gpif.h" 20 | 21 | /* Summary 22 | Number of states in the state machine 23 | */ 24 | #define CY_NUMBER_OF_STATES 4 25 | 26 | /* Summary 27 | Mapping of user defined state names to state indices 28 | */ 29 | #define START 0 30 | #define STATE0 2 31 | #define STATE3 3 32 | #define STATE4 1 33 | 34 | 35 | /* Summary 36 | Initial value of early outputs from the state machine. 37 | */ 38 | #define ALPHA_START 0x0 39 | 40 | 41 | /* Summary 42 | Transition function values used in the state machine. 43 | */ 44 | uint16_t CyFxGpifTransition[] = { 45 | 0x0000, 0xAAAA, 0xFFFF 46 | }; 47 | 48 | /* Summary 49 | Table containing the transition information for various states. 50 | This table has to be stored in the WAVEFORM Registers. 51 | This array consists of non-replicated waveform descriptors and acts as a 52 | waveform table. 53 | */ 54 | CyU3PGpifWaveData CyFxGpifWavedata[] = { 55 | {{0x2E739C01,0x00000500,0x800000A0},{0x00000000,0x00000000,0x00000000}}, 56 | {{0x1E739402,0x20000900,0x80000040},{0x00000000,0x00000000,0x00000000}}, 57 | {{0x1E739303,0x24000500,0x80000010},{0x00000000,0x00000000,0x00000000}} 58 | }; 59 | 60 | /* Summary 61 | Table that maps state indices to the descriptor table indices. 62 | */ 63 | uint8_t CyFxGpifWavedataPosition[] = { 64 | 0,1,2,1 65 | }; 66 | 67 | /* Summary 68 | GPIF II configuration register values. 69 | */ 70 | uint32_t CyFxGpifRegValue[] = { 71 | 0x80008330, /* CY_U3P_PIB_GPIF_CONFIG */ 72 | 0x00000003, /* CY_U3P_PIB_GPIF_BUS_CONFIG */ 73 | 0x00000000, /* CY_U3P_PIB_GPIF_BUS_CONFIG2 */ 74 | 0x00000052, /* CY_U3P_PIB_GPIF_AD_CONFIG */ 75 | 0x00000000, /* CY_U3P_PIB_GPIF_STATUS */ 76 | 0x00000000, /* CY_U3P_PIB_GPIF_INTR */ 77 | 0x00000000, /* CY_U3P_PIB_GPIF_INTR_MASK */ 78 | 0x00000082, /* CY_U3P_PIB_GPIF_SERIAL_IN_CONFIG */ 79 | 0x00000782, /* CY_U3P_PIB_GPIF_SERIAL_OUT_CONFIG */ 80 | 0x00000005, /* CY_U3P_PIB_GPIF_CTRL_BUS_DIRECTION */ 81 | 0x0000FFFF, /* CY_U3P_PIB_GPIF_CTRL_BUS_DEFAULT */ 82 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_POLARITY */ 83 | 0x00000003, /* CY_U3P_PIB_GPIF_CTRL_BUS_TOGGLE */ 84 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 85 | 0x00000001, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 86 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 87 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 88 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 89 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 90 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 91 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 92 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 93 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 94 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 95 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 96 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 97 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 98 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 99 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_BUS_SELECT */ 100 | 0x00000006, /* CY_U3P_PIB_GPIF_CTRL_COUNT_CONFIG */ 101 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_COUNT_RESET */ 102 | 0x0000FFFF, /* CY_U3P_PIB_GPIF_CTRL_COUNT_LIMIT */ 103 | 0x0000010B, /* CY_U3P_PIB_GPIF_ADDR_COUNT_CONFIG */ 104 | 0x00000000, /* CY_U3P_PIB_GPIF_ADDR_COUNT_RESET */ 105 | 0x00003FFF, /* CY_U3P_PIB_GPIF_ADDR_COUNT_LIMIT */ 106 | 0x00000000, /* CY_U3P_PIB_GPIF_STATE_COUNT_CONFIG */ 107 | 0x0000FFFF, /* CY_U3P_PIB_GPIF_STATE_COUNT_LIMIT */ 108 | 0x0000010B, /* CY_U3P_PIB_GPIF_DATA_COUNT_CONFIG */ 109 | 0x00000000, /* CY_U3P_PIB_GPIF_DATA_COUNT_RESET */ 110 | 0x00003FFF, /* CY_U3P_PIB_GPIF_DATA_COUNT_LIMIT */ 111 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_COMP_VALUE */ 112 | 0x00000000, /* CY_U3P_PIB_GPIF_CTRL_COMP_MASK */ 113 | 0x00000000, /* CY_U3P_PIB_GPIF_DATA_COMP_VALUE */ 114 | 0x00000000, /* CY_U3P_PIB_GPIF_DATA_COMP_MASK */ 115 | 0x00000000, /* CY_U3P_PIB_GPIF_ADDR_COMP_VALUE */ 116 | 0x00000000, /* CY_U3P_PIB_GPIF_ADDR_COMP_MASK */ 117 | 0x00000000, /* CY_U3P_PIB_GPIF_DATA_CTRL */ 118 | 0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_DATA */ 119 | 0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_DATA */ 120 | 0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_DATA */ 121 | 0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_DATA */ 122 | 0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_DATA */ 123 | 0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_DATA */ 124 | 0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_DATA */ 125 | 0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_DATA */ 126 | 0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_ADDRESS */ 127 | 0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_ADDRESS */ 128 | 0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_ADDRESS */ 129 | 0x00000000, /* CY_U3P_PIB_GPIF_INGRESS_ADDRESS */ 130 | 0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_ADDRESS */ 131 | 0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_ADDRESS */ 132 | 0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_ADDRESS */ 133 | 0x00000000, /* CY_U3P_PIB_GPIF_EGRESS_ADDRESS */ 134 | 0x80010400, /* CY_U3P_PIB_GPIF_THREAD_CONFIG */ 135 | 0x80010401, /* CY_U3P_PIB_GPIF_THREAD_CONFIG */ 136 | 0x80010402, /* CY_U3P_PIB_GPIF_THREAD_CONFIG */ 137 | 0x80010403, /* CY_U3P_PIB_GPIF_THREAD_CONFIG */ 138 | 0x00000000, /* CY_U3P_PIB_GPIF_LAMBDA_STAT */ 139 | 0x00000000, /* CY_U3P_PIB_GPIF_ALPHA_STAT */ 140 | 0x00000000, /* CY_U3P_PIB_GPIF_BETA_STAT */ 141 | 0x00000000, /* CY_U3P_PIB_GPIF_WAVEFORM_CTRL_STAT */ 142 | 0x00000000, /* CY_U3P_PIB_GPIF_WAVEFORM_SWITCH */ 143 | 0x00000000, /* CY_U3P_PIB_GPIF_WAVEFORM_SWITCH_TIMEOUT */ 144 | 0x00000000, /* CY_U3P_PIB_GPIF_CRC_CONFIG */ 145 | 0x00000000, /* CY_U3P_PIB_GPIF_CRC_DATA */ 146 | 0xFFFFFFC1 /* CY_U3P_PIB_GPIF_BETA_DEASSERT */ 147 | }; 148 | 149 | /* Summary 150 | This structure holds all the configuration inputs for the GPIF II. 151 | */ 152 | const CyU3PGpifConfig_t CyFxGpifConfig = { 153 | (uint16_t)(sizeof(CyFxGpifWavedataPosition)/sizeof(uint8_t)), 154 | CyFxGpifWavedata, 155 | CyFxGpifWavedataPosition, 156 | (uint16_t)(sizeof(CyFxGpifTransition)/sizeof(uint16_t)), 157 | CyFxGpifTransition, 158 | (uint16_t)(sizeof(CyFxGpifRegValue)/sizeof(uint32_t)), 159 | CyFxGpifRegValue 160 | }; 161 | 162 | #endif /* _INCLUDED__ */ 163 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/fast_gpif2.cydsn/fast_gpif2.cyfx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/fast_gpif2.cydsn/projectfiles/gpif2model.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | False 6 | True 7 | False 8 | False 9 | False 10 | Master 11 | Synchronous 12 | Internal 13 | Positive 14 | LittleEndian 15 | Bit8 16 | 0 17 | 18 | 19 | 20 | 21 | OUTPUT0 22 | GPIO_17 23 | Low 24 | ActiveHigh 25 | Alpha 26 | Toggle 27 | 28 | 29 | OUTPUT1 30 | GPIO_18 31 | Low 32 | ActiveHigh 33 | Alpha 34 | Toggle 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | START 48 | True 49 | 0 50 | 51 | 52 | STATE0 53 | True 54 | 0 55 | 56 | 57 | Socket 58 | Thread0 59 | True 60 | True 61 | 62 | 63 | OUTPUT0 64 | 65 | 66 | 67 | STATE3 68 | True 69 | 0 70 | 71 | 72 | Socket 73 | Thread1 74 | True 75 | True 76 | 77 | 78 | OUTPUT1 79 | 80 | 81 | 82 | STATE4 83 | True 84 | 0 85 | 86 | Up 87 | 0 88 | 16383 89 | Enable 90 | 1 91 | Mask 92 | 93 | 94 | Up 95 | 0 96 | 16383 97 | Enable 98 | 1 99 | Mask 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/fast_gpif2.cydsn/projectfiles/gpif2timingsimulation.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 100 4 | 512 5 | 0 6 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/fast_gpif2.cydsn/projectfiles/gpif2view.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 224 6 | 171.446666666667 7 | 83 8 | 70 9 | STATE0 10 | STATE0 11 | 1 12 | False 13 | 00000000-0000-0000-0000-000000000000 14 | 15 | 16 | 407 17 | 319 18 | 83 19 | 70 20 | STATE3 21 | STATE3 22 | 1 23 | False 24 | 00000000-0000-0000-0000-000000000000 25 | 26 | 27 | 31 28 | 166.41 29 | 83 30 | 70 31 | STATE4 32 | STATE4 33 | 1 34 | False 35 | 00000000-0000-0000-0000-000000000000 36 | 37 | 38 | 153 39 | 55.4466666666667 40 | 83 41 | 70 42 | STARTSTATE0 43 | START 44 | 1 45 | False 46 | 00000000-0000-0000-0000-000000000000 47 | 48 | 49 | 50 | 51 | TRANSITION3 52 | DATA_CNT_HIT 53 | STATE0 54 | STATE3 55 | Connector 56 | Connector 57 | None 58 | Arrow 59 | 0 60 | 61 | 62 | TRANSITION2 63 | ADDR_CNT_HIT 64 | STATE3 65 | STATE0 66 | Connector 67 | Connector 68 | None 69 | Arrow 70 | 0 71 | 72 | 73 | TRANSITION1 74 | LOGIC_ONE 75 | STATE4 76 | STATE0 77 | Connector 78 | Connector 79 | None 80 | Arrow 81 | 0 82 | 83 | 84 | TRANSITION0 85 | LOGIC_ONE 86 | STARTSTATE0 87 | STATE4 88 | Connector 89 | Connector 90 | None 91 | Arrow 92 | 0 93 | 94 | 95 | -------------------------------------------------------------------------------- /testproject/USBIsoSource/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | CYPRESS SEMICONDUCTOR CORPORATION 3 | FX3 SDK 4 | 5 | USB ISO SOURCE EXAMPLE 6 | ---------------------- 7 | 8 | This example illustrates the use of the FX3 firmware APIs to implement 9 | a variable data rate ISO IN endpoint. 10 | 11 | The device enumerates as a vendor specific USB device with an ISO IN endpoint 12 | (3-IN). 13 | 14 | The data transfer is achieved with the help of a a DMA MANUAL_OUT channel. 15 | A constant data pattern is continuously loaded into the DMA MANUAL_OUT channel 16 | and sent to the host. Multiple alternate settings with different transfer 17 | rates are supported. 18 | 19 | Files: 20 | 21 | * cyfx_gcc_startup.S : Start-up code for the ARM-9 core on the FX3 device. 22 | This assembly source file follows the syntax for the GNU assembler. 23 | 24 | * cyfxisosrc.h : Constant definitions for the iso source 25 | application. The properties of the endpoint can be selected through 26 | definitions in this file. 27 | 28 | * cyfxisodscr.c : C source file containing the USB descriptors that 29 | are used by this firmware example. 30 | 31 | * cyfxtx.c : ThreadX RTOS wrappers and utility functions required 32 | by the FX3 API library. 33 | 34 | * cyfxisosrc.c : Main C source file that implements the iso source 35 | example. 36 | 37 | * makefile : GNU make compliant build script for compiling this 38 | example. 39 | 40 | [] 41 | 42 | --------------------------------------------------------------------------------