├── .gitattributes ├── .gitignore ├── Eagle ├── Version 0.1 │ ├── AtMega88.brd │ ├── AtMega88.dxf │ ├── AtMega88.sch │ ├── AtMega88_.dxf │ └── eagle.epf └── Version 0.2 │ ├── AtMega88.b#1 │ ├── AtMega88.b#2 │ ├── AtMega88.brd │ ├── AtMega88.s#1 │ ├── AtMega88.s#2 │ ├── AtMega88.s#3 │ ├── AtMega88.sch │ └── eagle.epf ├── Media └── pics │ ├── version 0.1 │ ├── 2014-02-14 20.49.06.jpg │ ├── 2014-02-18 00.33.10.jpg │ ├── 2014-02-18 00.33.19.jpg │ ├── 2014-02-18 00.33.46.jpg │ ├── 2014-02-18 23.15.42.jpg │ ├── 2014-02-18 23.15.52.jpg │ ├── 2014-02-18 23.16.02.jpg │ └── 2014-02-18 23.16.31.jpg │ └── version 0.2 │ ├── 01-03-2014 14-36-56.png │ ├── 2014-02-24 00.38.48.jpg │ ├── 2014-02-24 00.38.54.jpg │ ├── 2014-02-24 00.38.57.jpg │ ├── 2014-02-27 22.28.31.jpg │ ├── 2014-02-27 22.28.41.jpg │ ├── 2014-02-27 22.28.56.jpg │ ├── 2014-02-27 22.29.02.jpg │ └── 2014-03-01 14.11.54.jpg ├── Mikrocontroller └── 3DMouse │ ├── 3DMouse.atsln │ ├── 3DMouse.atsuo │ └── 3DMouse │ ├── 3DMouse.cproj │ ├── main.c │ ├── main.h │ ├── mouse.c │ ├── mouse.h │ ├── ppm.c │ ├── ppm.h │ ├── usbconfig.h │ └── usbdrv │ ├── Changelog.txt │ ├── CommercialLicense.txt │ ├── License.txt │ ├── Readme.txt │ ├── USB-ID-FAQ.txt │ ├── USB-IDs-for-free.txt │ ├── asmcommon.inc │ ├── oddebug.c │ ├── oddebug.h │ ├── usbconfig-prototype.h │ ├── usbdrv.c │ ├── usbdrv.h │ ├── usbdrvasm.S │ ├── usbdrvasm.asm │ ├── usbdrvasm12.inc │ ├── usbdrvasm128.inc │ ├── usbdrvasm15.inc │ ├── usbdrvasm16.inc │ ├── usbdrvasm165.inc │ ├── usbdrvasm18-crc.inc │ ├── usbdrvasm20.inc │ └── usbportability.h ├── README.md ├── SolidWorks ├── Version 0.1 │ ├── 3DMaus.SLDASM │ ├── KnobBottom.SLDPRT │ ├── KnobTop.SLDPRT │ ├── Render │ │ └── render1.png │ ├── STL │ │ ├── KnobBottom.STL │ │ ├── KnobTop.STL │ │ ├── bottom.STL │ │ ├── case.STL │ │ └── connector.STL │ ├── bottom.SLDPRT │ ├── bottom_1.SLDPRT │ ├── bottom_alt.SLDPRT │ ├── case.SLDPRT │ ├── connector.SLDPRT │ └── pcb │ │ ├── components.SLDPRT │ │ └── pcb.SLDPRT ├── Version 0.2 │ ├── 3d-mouse.SLDASM │ ├── base.SLDPRT │ ├── case.SLDPRT │ ├── knob_bottom.SLDPRT │ ├── knob_top.SLDPRT │ ├── plate_bottom.SLDPRT │ ├── poti_spring_wall.SLDPRT │ ├── poti_wall.SLDPRT │ ├── rod-bow.SLDPRT │ ├── rod.SLDPRT │ ├── spring_wall.SLDPRT │ ├── stick.SLDPRT │ ├── stl │ │ ├── base.STL │ │ ├── case.STL │ │ ├── knob_bottom.STL │ │ ├── knob_top.STL │ │ ├── poti_wall.STL │ │ ├── rod-bow.STL │ │ ├── rod.STL │ │ ├── spring_wall.STL │ │ ├── stick.STL │ │ └── top_spring.STL │ ├── top.SLDPRT │ └── top_spring.SLDPRT ├── Version 0.3 │ ├── stl │ │ └── top_spring_2.STL │ └── top_spring_2.SLDPRT └── Version 0.4 │ ├── stl │ └── top_spring_3.STL │ ├── top_spring_3.SLDPRT │ └── top_spring_3_instruction.txt └── Windows ├── 3DMouseTranslator ├── 3DMouseTranslator.sln └── 3DMouseTranslator │ ├── 3DMouseTranslator.csproj │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── Program.cs │ ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings │ ├── SimpleJoystick.cs │ └── bin │ └── Release │ └── 3DMouseTranslator.exe ├── SlimDX Runtime .NET 4.0 x64 (January 2012).msi └── how-to-build.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | 46 | [Dd]ebug/ 47 | [Rr]elease/ 48 | x64/ 49 | build/ 50 | [Bb]in/ 51 | [Oo]bj/ 52 | 53 | # MSTest test Results 54 | [Tt]est[Rr]esult*/ 55 | [Bb]uild[Ll]og.* 56 | 57 | *_i.c 58 | *_p.c 59 | *.ilk 60 | *.meta 61 | *.obj 62 | *.pch 63 | *.pdb 64 | *.pgc 65 | *.pgd 66 | *.rsp 67 | *.sbr 68 | *.tlb 69 | *.tli 70 | *.tlh 71 | *.tmp 72 | *.tmp_proj 73 | *.log 74 | *.vspscc 75 | *.vssscc 76 | .builds 77 | *.pidb 78 | *.log 79 | *.scc 80 | 81 | # Visual C++ cache files 82 | ipch/ 83 | *.aps 84 | *.ncb 85 | *.opensdf 86 | *.sdf 87 | *.cachefile 88 | 89 | # Visual Studio profiler 90 | *.psess 91 | *.vsp 92 | *.vspx 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | 101 | # TeamCity is a build add-in 102 | _TeamCity* 103 | 104 | # DotCover is a Code Coverage Tool 105 | *.dotCover 106 | 107 | # NCrunch 108 | *.ncrunch* 109 | .*crunch*.local.xml 110 | 111 | # Installshield output folder 112 | [Ee]xpress/ 113 | 114 | # DocProject is a documentation generator add-in 115 | DocProject/buildhelp/ 116 | DocProject/Help/*.HxT 117 | DocProject/Help/*.HxC 118 | DocProject/Help/*.hhc 119 | DocProject/Help/*.hhk 120 | DocProject/Help/*.hhp 121 | DocProject/Help/Html2 122 | DocProject/Help/html 123 | 124 | # Click-Once directory 125 | publish/ 126 | 127 | # Publish Web Output 128 | *.Publish.xml 129 | *.pubxml 130 | 131 | # NuGet Packages Directory 132 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 133 | #packages/ 134 | 135 | # Windows Azure Build Output 136 | csx 137 | *.build.csdef 138 | 139 | # Windows Store app package directory 140 | AppPackages/ 141 | 142 | # Others 143 | sql/ 144 | *.Cache 145 | ClientBin/ 146 | [Ss]tyle[Cc]op.* 147 | ~$* 148 | *~ 149 | *.dbmdl 150 | *.[Pp]ublish.xml 151 | *.pfx 152 | *.publishsettings 153 | 154 | # RIA/Silverlight projects 155 | Generated_Code/ 156 | 157 | # Backup & report files from converting an old project file to a newer 158 | # Visual Studio version. Backup files are not needed, because we have git ;-) 159 | _UpgradeReport_Files/ 160 | Backup*/ 161 | UpgradeLog*.XML 162 | UpgradeLog*.htm 163 | 164 | # SQL Server files 165 | App_Data/*.mdf 166 | App_Data/*.ldf 167 | 168 | ############# 169 | ## Windows detritus 170 | ############# 171 | 172 | # Windows image file caches 173 | Thumbs.db 174 | ehthumbs.db 175 | 176 | # Folder config file 177 | Desktop.ini 178 | 179 | # Recycle Bin used on file shares 180 | $RECYCLE.BIN/ 181 | 182 | # Mac crap 183 | .DS_Store 184 | 185 | 186 | ############# 187 | ## Python 188 | ############# 189 | 190 | *.py[co] 191 | 192 | # Packages 193 | *.egg 194 | *.egg-info 195 | dist/ 196 | build/ 197 | eggs/ 198 | parts/ 199 | var/ 200 | sdist/ 201 | develop-eggs/ 202 | .installed.cfg 203 | 204 | # Installer logs 205 | pip-log.txt 206 | 207 | # Unit test / coverage reports 208 | .coverage 209 | .tox 210 | 211 | #Translations 212 | *.mo 213 | 214 | #Mr Developer 215 | .mr.developer.cfg 216 | -------------------------------------------------------------------------------- /Media/pics/version 0.1/2014-02-14 20.49.06.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Media/pics/version 0.1/2014-02-14 20.49.06.jpg -------------------------------------------------------------------------------- /Media/pics/version 0.1/2014-02-18 00.33.10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Media/pics/version 0.1/2014-02-18 00.33.10.jpg -------------------------------------------------------------------------------- /Media/pics/version 0.1/2014-02-18 00.33.19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Media/pics/version 0.1/2014-02-18 00.33.19.jpg -------------------------------------------------------------------------------- /Media/pics/version 0.1/2014-02-18 00.33.46.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Media/pics/version 0.1/2014-02-18 00.33.46.jpg -------------------------------------------------------------------------------- /Media/pics/version 0.1/2014-02-18 23.15.42.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Media/pics/version 0.1/2014-02-18 23.15.42.jpg -------------------------------------------------------------------------------- /Media/pics/version 0.1/2014-02-18 23.15.52.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Media/pics/version 0.1/2014-02-18 23.15.52.jpg -------------------------------------------------------------------------------- /Media/pics/version 0.1/2014-02-18 23.16.02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Media/pics/version 0.1/2014-02-18 23.16.02.jpg -------------------------------------------------------------------------------- /Media/pics/version 0.1/2014-02-18 23.16.31.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Media/pics/version 0.1/2014-02-18 23.16.31.jpg -------------------------------------------------------------------------------- /Media/pics/version 0.2/01-03-2014 14-36-56.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Media/pics/version 0.2/01-03-2014 14-36-56.png -------------------------------------------------------------------------------- /Media/pics/version 0.2/2014-02-24 00.38.48.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Media/pics/version 0.2/2014-02-24 00.38.48.jpg -------------------------------------------------------------------------------- /Media/pics/version 0.2/2014-02-24 00.38.54.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Media/pics/version 0.2/2014-02-24 00.38.54.jpg -------------------------------------------------------------------------------- /Media/pics/version 0.2/2014-02-24 00.38.57.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Media/pics/version 0.2/2014-02-24 00.38.57.jpg -------------------------------------------------------------------------------- /Media/pics/version 0.2/2014-02-27 22.28.31.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Media/pics/version 0.2/2014-02-27 22.28.31.jpg -------------------------------------------------------------------------------- /Media/pics/version 0.2/2014-02-27 22.28.41.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Media/pics/version 0.2/2014-02-27 22.28.41.jpg -------------------------------------------------------------------------------- /Media/pics/version 0.2/2014-02-27 22.28.56.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Media/pics/version 0.2/2014-02-27 22.28.56.jpg -------------------------------------------------------------------------------- /Media/pics/version 0.2/2014-02-27 22.29.02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Media/pics/version 0.2/2014-02-27 22.29.02.jpg -------------------------------------------------------------------------------- /Media/pics/version 0.2/2014-03-01 14.11.54.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Media/pics/version 0.2/2014-03-01 14.11.54.jpg -------------------------------------------------------------------------------- /Mikrocontroller/3DMouse/3DMouse.atsln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Atmel Studio Solution File, Format Version 11.00 4 | Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "3DMouse", "3DMouse\3DMouse.cproj", "{3778DF37-7F3B-4525-967F-00CBB454FC4E}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|AVR = Debug|AVR 9 | Release|AVR = Release|AVR 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {3778DF37-7F3B-4525-967F-00CBB454FC4E}.Debug|AVR.ActiveCfg = Debug|AVR 13 | {3778DF37-7F3B-4525-967F-00CBB454FC4E}.Debug|AVR.Build.0 = Debug|AVR 14 | {3778DF37-7F3B-4525-967F-00CBB454FC4E}.Release|AVR.ActiveCfg = Release|AVR 15 | {3778DF37-7F3B-4525-967F-00CBB454FC4E}.Release|AVR.Build.0 = Release|AVR 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /Mikrocontroller/3DMouse/3DMouse.atsuo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Mikrocontroller/3DMouse/3DMouse.atsuo -------------------------------------------------------------------------------- /Mikrocontroller/3DMouse/3DMouse/3DMouse.cproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 2.0 5 | 6.1 6 | com.Atmel.AVRGCC8.C 7 | {3778df37-7f3b-4525-967f-00cbb454fc4e} 8 | ATmega88PA 9 | none 10 | Executable 11 | C 12 | $(MSBuildProjectName) 13 | .elf 14 | $(MSBuildProjectDirectory)\$(Configuration) 15 | 3DMouse 16 | 3DMouse 17 | 3DMouse 18 | Native 19 | true 20 | false 21 | true 22 | true 23 | 24 | 25 | 26 | 2 27 | 1 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | True 45 | True 46 | True 47 | True 48 | True 49 | True 50 | 51 | 52 | NDEBUG 53 | 54 | 55 | Optimize for size (-Os) 56 | True 57 | True 58 | True 59 | 60 | 61 | libm 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | True 71 | True 72 | True 73 | True 74 | True 75 | True 76 | 77 | 78 | DEBUG 79 | 80 | 81 | Optimize (-O1) 82 | True 83 | True 84 | Default (-g2) 85 | True 86 | 87 | 88 | libm 89 | 90 | 91 | Default (-Wa,-g) 92 | 93 | 94 | 95 | 96 | 97 | compile 98 | 99 | 100 | compile 101 | 102 | 103 | compile 104 | 105 | 106 | compile 107 | 108 | 109 | compile 110 | 111 | 112 | compile 113 | 114 | 115 | compile 116 | 117 | 118 | compile 119 | 120 | 121 | compile 122 | 123 | 124 | compile 125 | 126 | 127 | compile 128 | 129 | 130 | compile 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | compile 139 | 140 | 141 | compile 142 | 143 | 144 | compile 145 | 146 | 147 | compile 148 | 149 | 150 | compile 151 | 152 | 153 | compile 154 | 155 | 156 | compile 157 | 158 | 159 | compile 160 | 161 | 162 | compile 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /Mikrocontroller/3DMouse/3DMouse/main.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | 3 | #include 4 | #include 5 | #include /* for sei() */ 6 | #include /* for _delay_ms() */ 7 | 8 | #include /* required by usbdrv.h */ 9 | #include "usbdrv/usbdrv.h" 10 | #include "usbdrv/oddebug.h" 11 | #include "ppm.h" 12 | #include "mouse.h" 13 | 14 | /* ------------------------------------------------------------------------- */ 15 | /* ----------------------------- USB interface ----------------------------- */ 16 | /* ------------------------------------------------------------------------- */ 17 | 18 | PROGMEM char const usbHidReportDescriptor[50] = { /* USB report descriptor, size must match usbconfig.h */ 19 | 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 20 | 0x15, 0x00, // LOGICAL_MINIMUM (0) 21 | 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255) 22 | 0x75, 0x08, // REPORT_SIZE (6) 23 | 0x09, 0x04, // USAGE (Joystick) 24 | 0xa1, 0x01, // COLLECTION (Application) 25 | 0x09, 0x01, // USAGE (Pointer) 26 | 0xa1, 0x00, // COLLECTION (Physical) 27 | 0x09, 0x30, // USAGE (X) 28 | 0x09, 0x31, // USAGE (Y) 29 | 0x95, 0x02, // REPORT_COUNT (2) 30 | 0x81, 0x82, // INPUT (Data,Var,Abs,Vol) 31 | 0xc0, // END_COLLECTION 32 | 0xa1, 0x00, // COLLECTION (Physical) 33 | 0x09, 0x32, // USAGE (Z) 34 | 0x09, 0x33, // USAGE (Rx) 35 | 0x95, 0x02, // REPORT_COUNT (2) 36 | 0x81, 0x82, // INPUT (Data,Var,Abs,Vol) 37 | 0xc0, // END_COLLECTION 38 | 0x09, 0x34, // USAGE (Ry) 39 | 0x09, 0x35, // USAGE (Rz) 40 | 0x09, 0x36, // USAGE (Slider) 41 | 0x09, 0x37, // USAGE (Dial) 42 | 0x95, 0x04, // REPORT_COUNT (2) 43 | 0x81, 0x82, // INPUT (Data,Var,Abs,Vol) 44 | 0xc0 // END_COLLECTION 45 | }; 46 | //PROGMEM const char usbHidReportDescriptor[50] = { 47 | //0x05, 0x01, // USAGE_PAGE (Generic Desktop) 48 | //0x09, 0x02, // USAGE (Mouse) 49 | //0xa1, 0x01, // COLLECTION (Application) 50 | //0x09, 0x01, // USAGE (Pointer) 51 | //0xa1, 0x00, // COLLECTION (Physical) 52 | //0x05, 0x09, // USAGE_PAGE (Button) 53 | //0x19, 0x01, // USAGE_MINIMUM (Button 1) 54 | //0x29, 0x03, // USAGE_MAXIMUM (Button 3) 55 | //0x15, 0x00, // LOGICAL_MINIMUM (0) 56 | //0x25, 0x01, // LOGICAL_MAXIMUM (1) 57 | //0x95, 0x03, // REPORT_COUNT (3) 58 | //0x75, 0x01, // REPORT_SIZE (1) 59 | //0x81, 0x02, // INPUT (Data,Var,Abs) 60 | //0x95, 0x01, // REPORT_COUNT (1) 61 | //0x75, 0x05, // REPORT_SIZE (5) 62 | //0x81, 0x03, // INPUT (Cnst,Var,Abs) 63 | //0x05, 0x01, // USAGE_PAGE (Generic Desktop) 64 | //0x09, 0x30, // USAGE (X) 65 | //0x09, 0x31, // USAGE (Y) 66 | //0x15, 0x81, // LOGICAL_MINIMUM (-127) 67 | //0x25, 0x7f, // LOGICAL_MAXIMUM (127) 68 | //0x75, 0x08, // REPORT_SIZE (8) 69 | //0x95, 0x02, // REPORT_COUNT (2) 70 | //0x81, 0x06, // INPUT (Data,Var,Rel) 71 | //0xc0, // END_COLLECTION 72 | //0xc0 // END_COLLECTION 73 | //}; 74 | // 75 | 76 | static uchar reportBuffer[8]; 77 | static uchar idleRate; /* repeat rate for keyboards, never used for mice */ 78 | 79 | 80 | /* ------------------------------------------------------------------------- */ 81 | 82 | usbMsgLen_t usbFunctionSetup(uchar data[8]) 83 | { 84 | usbRequest_t *rq = (void *)data; 85 | 86 | if((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS){ /* class request type */ 87 | DBG1(0x50, &rq->bRequest, 1); /* debug output: print our request */ 88 | if(rq->bRequest == USBRQ_HID_GET_REPORT){ /* wValue: ReportType (highbyte), ReportID (lowbyte) */ 89 | /* we only have one report type, so don't look at wValue */ 90 | usbMsgPtr = (void *)&reportBuffer; 91 | return sizeof(reportBuffer); 92 | }else if(rq->bRequest == USBRQ_HID_GET_IDLE){ 93 | usbMsgPtr = &idleRate; 94 | return 1; 95 | }else if(rq->bRequest == USBRQ_HID_SET_IDLE){ 96 | idleRate = rq->wValue.bytes[1]; 97 | } 98 | }else{ 99 | /* no vendor specific requests implemented */ 100 | } 101 | return 0; /* default for not implemented requests: return no data back to host */ 102 | } 103 | // 104 | //uchar usbFunctionSetup(uchar data[8]) 105 | //{ 106 | //usbRequest_t *rq = (void *)data; 107 | // 108 | //usbMsgPtr = reportBuffer; 109 | //if((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS){ 110 | //if(rq->bRequest == USBRQ_HID_GET_REPORT){ 111 | //return sizeof(reportBuffer); 112 | //} 113 | //}else{ 114 | ///* no vendor specific requests implemented */ 115 | //} 116 | //return 0; 117 | //} 118 | 119 | 120 | /* ------------------------------------------------------------------------- */ 121 | 122 | int main(void) { 123 | wdt_enable(WDTO_1S); 124 | 125 | //odDebugInit(); 126 | //DBG1(0x00, 0, 0); /* debug output: main starts */ 127 | 128 | mouseInit(); 129 | 130 | usbInit(); 131 | 132 | usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */ 133 | uchar i = 0; 134 | while(--i){ /* fake USB disconnect for > 250 ms */ 135 | wdt_reset(); 136 | _delay_ms(1); 137 | } 138 | usbDeviceConnect(); 139 | 140 | sei(); 141 | //DBG1(0x01, 0, 0); /* debug output: main loop starts */ 142 | 143 | 144 | for(;;){ /* main event loop */ 145 | //DBG1(0x02, 0, 0); /* debug output: main loop iterates */ 146 | wdt_reset(); 147 | usbPoll(); 148 | 149 | reportBuffer[0]=getXAxis(); 150 | reportBuffer[1]=getYAxis(); 151 | reportBuffer[2]=getZAxis(); 152 | 153 | if(usbInterruptIsReady()){ 154 | // called after every poll of the interrupt endpoint 155 | //DBG1(0x03, 0, 0); // debug output: interrupt report prepared 156 | usbSetInterrupt((void *)&reportBuffer, sizeof(reportBuffer)); 157 | } 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /Mikrocontroller/3DMouse/3DMouse/main.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef F_CPU 3 | #define F_CPU 12000000UL 4 | #endif 5 | -------------------------------------------------------------------------------- /Mikrocontroller/3DMouse/3DMouse/mouse.c: -------------------------------------------------------------------------------- 1 | 2 | #include "main.h" 3 | #include "mouse.h" 4 | #include "avr/io.h" 5 | 6 | void mouseInit() 7 | { 8 | adcInit(); // Init ADC 9 | //getADCValue(0); // Test Measurement 10 | } 11 | 12 | void adcInit() 13 | { 14 | ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); // Set ADC prescalar to 128 - 125KHz sample rate @ 16MHz 15 | 16 | ADMUX |= (1 << REFS0); // Set ADC reference to AVCC 17 | ADMUX |= (1 << ADLAR); // Left adjust ADC result to allow easy 8 bit reading 18 | 19 | 20 | //ADCSRB &= ~((1 << ADTS0)|(1 << ADTS1)|(1 << ADTS2)); // Set ADC to Free-Running Mode 21 | //ADCSRA |= (1< 3 | #include "ppm.h" 4 | #include "main.h" 5 | #include 6 | 7 | #define PPM_TCNT TCNT1 8 | 9 | #define CHANNELS (8) 10 | volatile unsigned int ppm[CHANNELS]; 11 | volatile int chan=-1; 12 | 13 | #define T_MIN (1*F_CPU/1000) // 1ms = 12000 Ticks @ 12Mhz = Stick min position 14 | #define T_MAX (2*F_CPU/1000) // 2ms = 24000 Ticks @ 12Mhz = Stick max position 15 | #define T_OUT (3*F_CPU/1000) // 3ms = 36000 Ticks @ 12Mhz = Timeout 16 | 17 | volatile char ppmNewData; 18 | volatile unsigned int timeOld; 19 | 20 | /** 21 | * Interrupt: Compare 1A match = timeout 22 | */ 23 | ISR(TIMER1_COMPA_vect){ 24 | 25 | if (chan!=-1) { 26 | ppmNewData=1; 27 | } 28 | chan=-1; 29 | } 30 | 31 | /** 32 | * Interrupt: ICP-Edge detect 33 | */ 34 | ISR(TIMER1_CAPT_vect){ 35 | unsigned int time=ICR1; 36 | OCR1A=time+T_OUT; 37 | if (time>timeOld) { 38 | time=time-timeOld; 39 | } else { 40 | time=time+(0xffff-timeOld)+1; 41 | } 42 | timeOld=ICR1; 43 | if (chan>=0 && chan 0...255 78 | if (t255) t=255; 82 | 83 | return ((unsigned char)t); 84 | } 85 | 86 | -------------------------------------------------------------------------------- /Mikrocontroller/3DMouse/3DMouse/ppm.h: -------------------------------------------------------------------------------- 1 | extern volatile char ppmNewData; 2 | void ppmInit(); 3 | unsigned char ppmGet(int n); 4 | 5 | -------------------------------------------------------------------------------- /Mikrocontroller/3DMouse/3DMouse/usbconfig.h: -------------------------------------------------------------------------------- 1 | /* Name: usbconfig.h 2 | * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2005-04-01 5 | * Tabsize: 4 6 | * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH 7 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 8 | * This Revision: $Id: usbconfig-prototype.h 785 2010-05-30 17:57:07Z cs $ 9 | */ 10 | 11 | #ifndef __usbconfig_h_included__ 12 | #define __usbconfig_h_included__ 13 | 14 | /* 15 | General Description: 16 | This file is an example configuration (with inline documentation) for the USB 17 | driver. It configures V-USB for USB D+ connected to Port D bit 2 (which is 18 | also hardware interrupt 0 on many devices) and USB D- to Port D bit 4. You may 19 | wire the lines to any other port, as long as D+ is also wired to INT0 (or any 20 | other hardware interrupt, as long as it is the highest level interrupt, see 21 | section at the end of this file). 22 | */ 23 | 24 | /* ---------------------------- Hardware Config ---------------------------- */ 25 | 26 | #define USB_CFG_IOPORTNAME D 27 | /* This is the port where the USB bus is connected. When you configure it to 28 | * "B", the registers PORTB, PINB and DDRB will be used. 29 | */ 30 | #define USB_CFG_DMINUS_BIT 4 31 | /* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected. 32 | * This may be any bit in the port. 33 | */ 34 | #define USB_CFG_DPLUS_BIT 2 35 | /* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected. 36 | * This may be any bit in the port. Please note that D+ must also be connected 37 | * to interrupt pin INT0! [You can also use other interrupts, see section 38 | * "Optional MCU Description" below, or you can connect D- to the interrupt, as 39 | * it is required if you use the USB_COUNT_SOF feature. If you use D- for the 40 | * interrupt, the USB interrupt will also be triggered at Start-Of-Frame 41 | * markers every millisecond.] 42 | */ 43 | #define USB_CFG_CLOCK_KHZ (F_CPU/1000) 44 | /* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000, 45 | * 16500, 18000 and 20000. The 12.8 MHz and 16.5 MHz versions of the code 46 | * require no crystal, they tolerate +/- 1% deviation from the nominal 47 | * frequency. All other rates require a precision of 2000 ppm and thus a 48 | * crystal! 49 | * Since F_CPU should be defined to your actual clock rate anyway, you should 50 | * not need to modify this setting. 51 | */ 52 | #define USB_CFG_CHECK_CRC 0 53 | /* Define this to 1 if you want that the driver checks integrity of incoming 54 | * data packets (CRC checks). CRC checks cost quite a bit of code size and are 55 | * currently only available for 18 MHz crystal clock. You must choose 56 | * USB_CFG_CLOCK_KHZ = 18000 if you enable this option. 57 | */ 58 | 59 | /* ----------------------- Optional Hardware Config ------------------------ */ 60 | 61 | /* #define USB_CFG_PULLUP_IOPORTNAME D */ 62 | /* If you connect the 1.5k pullup resistor from D- to a port pin instead of 63 | * V+, you can connect and disconnect the device from firmware by calling 64 | * the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h). 65 | * This constant defines the port on which the pullup resistor is connected. 66 | */ 67 | /* #define USB_CFG_PULLUP_BIT 4 */ 68 | /* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined 69 | * above) where the 1.5k pullup resistor is connected. See description 70 | * above for details. 71 | */ 72 | 73 | /* --------------------------- Functional Range ---------------------------- */ 74 | 75 | #define USB_CFG_HAVE_INTRIN_ENDPOINT 1 76 | /* Define this to 1 if you want to compile a version with two endpoints: The 77 | * default control endpoint 0 and an interrupt-in endpoint (any other endpoint 78 | * number). 79 | */ 80 | #define USB_CFG_HAVE_INTRIN_ENDPOINT3 0 81 | /* Define this to 1 if you want to compile a version with three endpoints: The 82 | * default control endpoint 0, an interrupt-in endpoint 3 (or the number 83 | * configured below) and a catch-all default interrupt-in endpoint as above. 84 | * You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature. 85 | */ 86 | #define USB_CFG_EP3_NUMBER 3 87 | /* If the so-called endpoint 3 is used, it can now be configured to any other 88 | * endpoint number (except 0) with this macro. Default if undefined is 3. 89 | */ 90 | /* #define USB_INITIAL_DATATOKEN USBPID_DATA1 */ 91 | /* The above macro defines the startup condition for data toggling on the 92 | * interrupt/bulk endpoints 1 and 3. Defaults to USBPID_DATA1. 93 | * Since the token is toggled BEFORE sending any data, the first packet is 94 | * sent with the oposite value of this configuration! 95 | */ 96 | #define USB_CFG_IMPLEMENT_HALT 0 97 | /* Define this to 1 if you also want to implement the ENDPOINT_HALT feature 98 | * for endpoint 1 (interrupt endpoint). Although you may not need this feature, 99 | * it is required by the standard. We have made it a config option because it 100 | * bloats the code considerably. 101 | */ 102 | #define USB_CFG_SUPPRESS_INTR_CODE 0 103 | /* Define this to 1 if you want to declare interrupt-in endpoints, but don't 104 | * want to send any data over them. If this macro is defined to 1, functions 105 | * usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if 106 | * you need the interrupt-in endpoints in order to comply to an interface 107 | * (e.g. HID), but never want to send any data. This option saves a couple 108 | * of bytes in flash memory and the transmit buffers in RAM. 109 | */ 110 | #define USB_CFG_INTR_POLL_INTERVAL 10 111 | /* If you compile a version with endpoint 1 (interrupt-in), this is the poll 112 | * interval. The value is in milliseconds and must not be less than 10 ms for 113 | * low speed devices. 114 | */ 115 | #define USB_CFG_IS_SELF_POWERED 0 116 | /* Define this to 1 if the device has its own power supply. Set it to 0 if the 117 | * device is powered from the USB bus. 118 | */ 119 | #define USB_CFG_MAX_BUS_POWER 20 120 | /* Set this variable to the maximum USB bus power consumption of your device. 121 | * The value is in milliamperes. [It will be divided by two since USB 122 | * communicates power requirements in units of 2 mA.] 123 | */ 124 | #define USB_CFG_IMPLEMENT_FN_WRITE 0 125 | /* Set this to 1 if you want usbFunctionWrite() to be called for control-out 126 | * transfers. Set it to 0 if you don't need it and want to save a couple of 127 | * bytes. 128 | */ 129 | #define USB_CFG_IMPLEMENT_FN_READ 0 130 | /* Set this to 1 if you need to send control replies which are generated 131 | * "on the fly" when usbFunctionRead() is called. If you only want to send 132 | * data from a static buffer, set it to 0 and return the data from 133 | * usbFunctionSetup(). This saves a couple of bytes. 134 | */ 135 | #define USB_CFG_IMPLEMENT_FN_WRITEOUT 0 136 | /* Define this to 1 if you want to use interrupt-out (or bulk out) endpoints. 137 | * You must implement the function usbFunctionWriteOut() which receives all 138 | * interrupt/bulk data sent to any endpoint other than 0. The endpoint number 139 | * can be found in 'usbRxToken'. 140 | */ 141 | #define USB_CFG_HAVE_FLOWCONTROL 0 142 | /* Define this to 1 if you want flowcontrol over USB data. See the definition 143 | * of the macros usbDisableAllRequests() and usbEnableAllRequests() in 144 | * usbdrv.h. 145 | */ 146 | #define USB_CFG_DRIVER_FLASH_PAGE 0 147 | /* If the device has more than 64 kBytes of flash, define this to the 64 k page 148 | * where the driver's constants (descriptors) are located. Or in other words: 149 | * Define this to 1 for boot loaders on the ATMega128. 150 | */ 151 | #define USB_CFG_LONG_TRANSFERS 0 152 | /* Define this to 1 if you want to send/receive blocks of more than 254 bytes 153 | * in a single control-in or control-out transfer. Note that the capability 154 | * for long transfers increases the driver size. 155 | */ 156 | /* #define USB_RX_USER_HOOK(data, len) if(usbRxToken == (uchar)USBPID_SETUP) blinkLED(); */ 157 | /* This macro is a hook if you want to do unconventional things. If it is 158 | * defined, it's inserted at the beginning of received message processing. 159 | * If you eat the received message and don't want default processing to 160 | * proceed, do a return after doing your things. One possible application 161 | * (besides debugging) is to flash a status LED on each packet. 162 | */ 163 | /* #define USB_RESET_HOOK(resetStarts) if(!resetStarts){hadUsbReset();} */ 164 | /* This macro is a hook if you need to know when an USB RESET occurs. It has 165 | * one parameter which distinguishes between the start of RESET state and its 166 | * end. 167 | */ 168 | /* #define USB_SET_ADDRESS_HOOK() hadAddressAssigned(); */ 169 | /* This macro (if defined) is executed when a USB SET_ADDRESS request was 170 | * received. 171 | */ 172 | #define USB_COUNT_SOF 0 173 | /* define this macro to 1 if you need the global variable "usbSofCount" which 174 | * counts SOF packets. This feature requires that the hardware interrupt is 175 | * connected to D- instead of D+. 176 | */ 177 | /* #ifdef __ASSEMBLER__ 178 | * macro myAssemblerMacro 179 | * in YL, TCNT0 180 | * sts timer0Snapshot, YL 181 | * endm 182 | * #endif 183 | * #define USB_SOF_HOOK myAssemblerMacro 184 | * This macro (if defined) is executed in the assembler module when a 185 | * Start Of Frame condition is detected. It is recommended to define it to 186 | * the name of an assembler macro which is defined here as well so that more 187 | * than one assembler instruction can be used. The macro may use the register 188 | * YL and modify SREG. If it lasts longer than a couple of cycles, USB messages 189 | * immediately after an SOF pulse may be lost and must be retried by the host. 190 | * What can you do with this hook? Since the SOF signal occurs exactly every 191 | * 1 ms (unless the host is in sleep mode), you can use it to tune OSCCAL in 192 | * designs running on the internal RC oscillator. 193 | * Please note that Start Of Frame detection works only if D- is wired to the 194 | * interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES! 195 | */ 196 | #define USB_CFG_CHECK_DATA_TOGGLING 0 197 | /* define this macro to 1 if you want to filter out duplicate data packets 198 | * sent by the host. Duplicates occur only as a consequence of communication 199 | * errors, when the host does not receive an ACK. Please note that you need to 200 | * implement the filtering yourself in usbFunctionWriteOut() and 201 | * usbFunctionWrite(). Use the global usbCurrentDataToken and a static variable 202 | * for each control- and out-endpoint to check for duplicate packets. 203 | */ 204 | #define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0 205 | /* define this macro to 1 if you want the function usbMeasureFrameLength() 206 | * compiled in. This function can be used to calibrate the AVR's RC oscillator. 207 | */ 208 | #define USB_USE_FAST_CRC 0 209 | /* The assembler module has two implementations for the CRC algorithm. One is 210 | * faster, the other is smaller. This CRC routine is only used for transmitted 211 | * messages where timing is not critical. The faster routine needs 31 cycles 212 | * per byte while the smaller one needs 61 to 69 cycles. The faster routine 213 | * may be worth the 32 bytes bigger code size if you transmit lots of data and 214 | * run the AVR close to its limit. 215 | */ 216 | 217 | /* -------------------------- Device Description --------------------------- */ 218 | 219 | #define USB_CFG_VENDOR_ID 0xc0, 0x16 // 0x16c0 220 | #define USB_CFG_DEVICE_ID 0xdb, 0x27 // 0x27db 221 | 222 | #define USB_CFG_DEVICE_VERSION 0x00, 0x01 223 | /* Version number of the device: Minor number first, then major number. 224 | */ 225 | #define USB_CFG_VENDOR_NAME 0x53, 0x61, 0x6d, 0x75, 0x65, 0x6c, 0x4b, 0x72, 0x61, 0x6e, 0x7a 226 | #define USB_CFG_VENDOR_NAME_LEN 11 227 | 228 | #define USB_CFG_DEVICE_NAME 0x33, 0x44, 0x2d, 0x4d, 0x6f, 0x75, 0x73, 0x65 229 | #define USB_CFG_DEVICE_NAME_LEN 8 230 | 231 | #define USB_CFG_VENDOR_NAME 0x33, 0x44, 0x2d, 0x4d, 0x6f, 0x75, 0x73, 0x65 232 | #define USB_CFG_VENDOR_NAME_LEN 8 233 | 234 | 235 | #define USB_CFG_SERIAL_NUMBER 0x33, 0x44, 0x2d, 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x3a, 0x30, 0x30, 0x31 236 | #define USB_CFG_SERIAL_NUMBER_LEN 12 237 | 238 | #define USB_CFG_DEVICE_CLASS 0 239 | #define USB_CFG_DEVICE_SUBCLASS 0 240 | /* See USB specification if you want to conform to an existing device class. 241 | * Class 0xff is "vendor specific". 242 | */ 243 | #define USB_CFG_INTERFACE_CLASS 3 244 | #define USB_CFG_INTERFACE_SUBCLASS 0 245 | #define USB_CFG_INTERFACE_PROTOCOL 0 246 | /* See USB specification if you want to conform to an existing device class or 247 | * protocol. The following classes must be set at interface level: 248 | * HID class is 3, no subclass and protocol required (but may be useful!) 249 | * CDC class is 2, use subclass 2 and protocol 1 for ACM 250 | */ 251 | #define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 50 252 | /* Define this to the length of the HID report descriptor, if you implement 253 | * an HID device. Otherwise don't define it or define it to 0. 254 | * If you use this define, you must add a PROGMEM character array named 255 | * "usbHidReportDescriptor" to your code which contains the report descriptor. 256 | * Don't forget to keep the array and this define in sync! 257 | */ 258 | 259 | /* #define USB_PUBLIC static */ 260 | /* Use the define above if you #include usbdrv.c instead of linking against it. 261 | * This technique saves a couple of bytes in flash memory. 262 | */ 263 | 264 | /* ------------------- Fine Control over USB Descriptors ------------------- */ 265 | /* If you don't want to use the driver's default USB descriptors, you can 266 | * provide our own. These can be provided as (1) fixed length static data in 267 | * flash memory, (2) fixed length static data in RAM or (3) dynamically at 268 | * runtime in the function usbFunctionDescriptor(). See usbdrv.h for more 269 | * information about this function. 270 | * Descriptor handling is configured through the descriptor's properties. If 271 | * no properties are defined or if they are 0, the default descriptor is used. 272 | * Possible properties are: 273 | * + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched 274 | * at runtime via usbFunctionDescriptor(). If the usbMsgPtr mechanism is 275 | * used, the data is in FLASH by default. Add property USB_PROP_IS_RAM if 276 | * you want RAM pointers. 277 | * + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found 278 | * in static memory is in RAM, not in flash memory. 279 | * + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash), 280 | * the driver must know the descriptor's length. The descriptor itself is 281 | * found at the address of a well known identifier (see below). 282 | * List of static descriptor names (must be declared PROGMEM if in flash): 283 | * char usbDescriptorDevice[]; 284 | * char usbDescriptorConfiguration[]; 285 | * char usbDescriptorHidReport[]; 286 | * char usbDescriptorString0[]; 287 | * int usbDescriptorStringVendor[]; 288 | * int usbDescriptorStringDevice[]; 289 | * int usbDescriptorStringSerialNumber[]; 290 | * Other descriptors can't be provided statically, they must be provided 291 | * dynamically at runtime. 292 | * 293 | * Descriptor properties are or-ed or added together, e.g.: 294 | * #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18)) 295 | * 296 | * The following descriptors are defined: 297 | * USB_CFG_DESCR_PROPS_DEVICE 298 | * USB_CFG_DESCR_PROPS_CONFIGURATION 299 | * USB_CFG_DESCR_PROPS_STRINGS 300 | * USB_CFG_DESCR_PROPS_STRING_0 301 | * USB_CFG_DESCR_PROPS_STRING_VENDOR 302 | * USB_CFG_DESCR_PROPS_STRING_PRODUCT 303 | * USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 304 | * USB_CFG_DESCR_PROPS_HID 305 | * USB_CFG_DESCR_PROPS_HID_REPORT 306 | * USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver) 307 | * 308 | * Note about string descriptors: String descriptors are not just strings, they 309 | * are Unicode strings prefixed with a 2 byte header. Example: 310 | * int serialNumberDescriptor[] = { 311 | * USB_STRING_DESCRIPTOR_HEADER(6), 312 | * 'S', 'e', 'r', 'i', 'a', 'l' 313 | * }; 314 | */ 315 | 316 | #define USB_CFG_DESCR_PROPS_DEVICE 0 317 | #define USB_CFG_DESCR_PROPS_CONFIGURATION 0 318 | #define USB_CFG_DESCR_PROPS_STRINGS 0 319 | #define USB_CFG_DESCR_PROPS_STRING_0 0 320 | #define USB_CFG_DESCR_PROPS_STRING_VENDOR 0 321 | #define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0 322 | #define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0 323 | #define USB_CFG_DESCR_PROPS_HID 0 324 | #define USB_CFG_DESCR_PROPS_HID_REPORT 0 325 | #define USB_CFG_DESCR_PROPS_UNKNOWN 0 326 | 327 | /* ----------------------- Optional MCU Description ------------------------ */ 328 | 329 | /* The following configurations have working defaults in usbdrv.h. You 330 | * usually don't need to set them explicitly. Only if you want to run 331 | * the driver on a device which is not yet supported or with a compiler 332 | * which is not fully supported (such as IAR C) or if you use a differnt 333 | * interrupt than INT0, you may have to define some of these. 334 | */ 335 | /* #define USB_INTR_CFG MCUCR */ 336 | /* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) */ 337 | /* #define USB_INTR_CFG_CLR 0 */ 338 | /* #define USB_INTR_ENABLE GIMSK */ 339 | /* #define USB_INTR_ENABLE_BIT INT0 */ 340 | /* #define USB_INTR_PENDING GIFR */ 341 | /* #define USB_INTR_PENDING_BIT INTF0 */ 342 | /* #define USB_INTR_VECTOR INT0_vect */ 343 | 344 | #endif /* __usbconfig_h_included__ */ 345 | -------------------------------------------------------------------------------- /Mikrocontroller/3DMouse/3DMouse/usbdrv/Changelog.txt: -------------------------------------------------------------------------------- 1 | This file documents changes in the firmware-only USB driver for atmel's AVR 2 | microcontrollers. New entries are always appended to the end of the file. 3 | Scroll down to the bottom to see the most recent changes. 4 | 5 | 2005-04-01: 6 | - Implemented endpoint 1 as interrupt-in endpoint. 7 | - Moved all configuration options to usbconfig.h which is not part of the 8 | driver. 9 | - Changed interface for usbVendorSetup(). 10 | - Fixed compatibility with ATMega8 device. 11 | - Various minor optimizations. 12 | 13 | 2005-04-11: 14 | - Changed interface to application: Use usbFunctionSetup(), usbFunctionRead() 15 | and usbFunctionWrite() now. Added configuration options to choose which 16 | of these functions to compile in. 17 | - Assembler module delivers receive data non-inverted now. 18 | - Made register and bit names compatible with more AVR devices. 19 | 20 | 2005-05-03: 21 | - Allow address of usbRxBuf on any memory page as long as the buffer does 22 | not cross 256 byte page boundaries. 23 | - Better device compatibility: works with Mega88 now. 24 | - Code optimization in debugging module. 25 | - Documentation updates. 26 | 27 | 2006-01-02: 28 | - Added (free) default Vendor- and Product-IDs bought from voti.nl. 29 | - Added USBID-License.txt file which defines the rules for using the free 30 | shared VID/PID pair. 31 | - Added Readme.txt to the usbdrv directory which clarifies administrative 32 | issues. 33 | 34 | 2006-01-25: 35 | - Added "configured state" to become more standards compliant. 36 | - Added "HALT" state for interrupt endpoint. 37 | - Driver passes the "USB Command Verifier" test from usb.org now. 38 | - Made "serial number" a configuration option. 39 | - Minor optimizations, we now recommend compiler option "-Os" for best 40 | results. 41 | - Added a version number to usbdrv.h 42 | 43 | 2006-02-03: 44 | - New configuration variable USB_BUFFER_SECTION for the memory section where 45 | the USB rx buffer will go. This defaults to ".bss" if not defined. Since 46 | this buffer MUST NOT cross 256 byte pages (not even touch a page at the 47 | end), the user may want to pass a linker option similar to 48 | "-Wl,--section-start=.mybuffer=0x800060". 49 | - Provide structure for usbRequest_t. 50 | - New defines for USB constants. 51 | - Prepared for HID implementations. 52 | - Increased data size limit for interrupt transfers to 8 bytes. 53 | - New macro usbInterruptIsReady() to query interrupt buffer state. 54 | 55 | 2006-02-18: 56 | - Ensure that the data token which is sent as an ack to an OUT transfer is 57 | always zero sized. This fixes a bug where the host reports an error after 58 | sending an out transfer to the device, although all data arrived at the 59 | device. 60 | - Updated docs in usbdrv.h to reflect changed API in usbFunctionWrite(). 61 | 62 | * Release 2006-02-20 63 | 64 | - Give a compiler warning when compiling with debugging turned on. 65 | - Added Oleg Semyonov's changes for IAR-cc compatibility. 66 | - Added new (optional) functions usbDeviceConnect() and usbDeviceDisconnect() 67 | (also thanks to Oleg!). 68 | - Rearranged tests in usbPoll() to save a couple of instructions in the most 69 | likely case that no actions are pending. 70 | - We need a delay between the SET ADDRESS request until the new address 71 | becomes active. This delay was handled in usbPoll() until now. Since the 72 | spec says that the delay must not exceed 2ms, previous versions required 73 | aggressive polling during the enumeration phase. We have now moved the 74 | handling of the delay into the interrupt routine. 75 | - We must not reply with NAK to a SETUP transaction. We can only achieve this 76 | by making sure that the rx buffer is empty when SETUP tokens are expected. 77 | We therefore don't pass zero sized data packets from the status phase of 78 | a transfer to usbPoll(). This change MAY cause troubles if you rely on 79 | receiving a less than 8 bytes long packet in usbFunctionWrite() to 80 | identify the end of a transfer. usbFunctionWrite() will NEVER be called 81 | with a zero length. 82 | 83 | * Release 2006-03-14 84 | 85 | - Improved IAR C support: tiny memory model, more devices 86 | - Added template usbconfig.h file under the name usbconfig-prototype.h 87 | 88 | * Release 2006-03-26 89 | 90 | - Added provision for one more interrupt-in endpoint (endpoint 3). 91 | - Added provision for one interrupt-out endpoint (endpoint 1). 92 | - Added flowcontrol macros for USB. 93 | - Added provision for custom configuration descriptor. 94 | - Allow ANY two port bits for D+ and D-. 95 | - Merged (optional) receive endpoint number into global usbRxToken variable. 96 | - Use USB_CFG_IOPORTNAME instead of USB_CFG_IOPORT. We now construct the 97 | variable name from the single port letter instead of computing the address 98 | of related ports from the output-port address. 99 | 100 | * Release 2006-06-26 101 | 102 | - Updated documentation in usbdrv.h and usbconfig-prototype.h to reflect the 103 | new features. 104 | - Removed "#warning" directives because IAR does not understand them. Use 105 | unused static variables instead to generate a warning. 106 | - Do not include when compiling with IAR. 107 | - Introduced USB_CFG_DESCR_PROPS_* in usbconfig.h to configure how each 108 | USB descriptor should be handled. It is now possible to provide descriptor 109 | data in Flash, RAM or dynamically at runtime. 110 | - STALL is now a status in usbTxLen* instead of a message. We can now conform 111 | to the spec and leave the stall status pending until it is cleared. 112 | - Made usbTxPacketCnt1 and usbTxPacketCnt3 public. This allows the 113 | application code to reset data toggling on interrupt pipes. 114 | 115 | * Release 2006-07-18 116 | 117 | - Added an #if !defined __ASSEMBLER__ to the warning in usbdrv.h. This fixes 118 | an assembler error. 119 | - usbDeviceDisconnect() takes pull-up resistor to high impedance now. 120 | 121 | * Release 2007-02-01 122 | 123 | - Merged in some code size improvements from usbtiny (thanks to Dick 124 | Streefland for these optimizations!) 125 | - Special alignment requirement for usbRxBuf not required any more. Thanks 126 | again to Dick Streefland for this hint! 127 | - Reverted to "#warning" instead of unused static variables -- new versions 128 | of IAR CC should handle this directive. 129 | - Changed Open Source license to GNU GPL v2 in order to make linking against 130 | other free libraries easier. We no longer require publication of the 131 | circuit diagrams, but we STRONGLY encourage it. If you improve the driver 132 | itself, PLEASE grant us a royalty free license to your changes for our 133 | commercial license. 134 | 135 | * Release 2007-03-29 136 | 137 | - New configuration option "USB_PUBLIC" in usbconfig.h. 138 | - Set USB version number to 1.10 instead of 1.01. 139 | - Code used USB_CFG_DESCR_PROPS_STRING_DEVICE and 140 | USB_CFG_DESCR_PROPS_STRING_PRODUCT inconsistently. Changed all occurrences 141 | to USB_CFG_DESCR_PROPS_STRING_PRODUCT. 142 | - New assembler module for 16.5 MHz RC oscillator clock with PLL in receiver 143 | code. 144 | - New assembler module for 16 MHz crystal. 145 | - usbdrvasm.S contains common code only, clock-specific parts have been moved 146 | to usbdrvasm12.S, usbdrvasm16.S and usbdrvasm165.S respectively. 147 | 148 | * Release 2007-06-25 149 | 150 | - 16 MHz module: Do SE0 check in stuffed bits as well. 151 | 152 | * Release 2007-07-07 153 | 154 | - Define hi8(x) for IAR compiler to limit result to 8 bits. This is necessary 155 | for negative values. 156 | - Added 15 MHz module contributed by V. Bosch. 157 | - Interrupt vector name can now be configured. This is useful if somebody 158 | wants to use a different hardware interrupt than INT0. 159 | 160 | * Release 2007-08-07 161 | 162 | - Moved handleIn3 routine in usbdrvasm16.S so that relative jump range is 163 | not exceeded. 164 | - More config options: USB_RX_USER_HOOK(), USB_INITIAL_DATATOKEN, 165 | USB_COUNT_SOF 166 | - USB_INTR_PENDING can now be a memory address, not just I/O 167 | 168 | * Release 2007-09-19 169 | 170 | - Split out common parts of assembler modules into separate include file 171 | - Made endpoint numbers configurable so that given interface definitions 172 | can be matched. See USB_CFG_EP3_NUMBER in usbconfig-prototype.h. 173 | - Store endpoint number for interrupt/bulk-out so that usbFunctionWriteOut() 174 | can handle any number of endpoints. 175 | - Define usbDeviceConnect() and usbDeviceDisconnect() even if no 176 | USB_CFG_PULLUP_IOPORTNAME is defined. Directly set D+ and D- to 0 in this 177 | case. 178 | 179 | * Release 2007-12-01 180 | 181 | - Optimize usbDeviceConnect() and usbDeviceDisconnect() for less code size 182 | when USB_CFG_PULLUP_IOPORTNAME is not defined. 183 | 184 | * Release 2007-12-13 185 | 186 | - Renamed all include-only assembler modules from *.S to *.inc so that 187 | people don't add them to their project sources. 188 | - Distribute leap bits in tx loop more evenly for 16 MHz module. 189 | - Use "macro" and "endm" instead of ".macro" and ".endm" for IAR 190 | - Avoid compiler warnings for constant expr range by casting some values in 191 | USB descriptors. 192 | 193 | * Release 2008-01-21 194 | 195 | - Fixed bug in 15 and 16 MHz module where the new address set with 196 | SET_ADDRESS was already accepted at the next NAK or ACK we send, not at 197 | the next data packet we send. This caused problems when the host polled 198 | too fast. Thanks to Alexander Neumann for his help and patience debugging 199 | this issue! 200 | 201 | * Release 2008-02-05 202 | 203 | - Fixed bug in 16.5 MHz module where a register was used in the interrupt 204 | handler before it was pushed. This bug was introduced with version 205 | 2007-09-19 when common parts were moved to a separate file. 206 | - Optimized CRC routine (thanks to Reimar Doeffinger). 207 | 208 | * Release 2008-02-16 209 | 210 | - Removed outdated IAR compatibility stuff (code sections). 211 | - Added hook macros for USB_RESET_HOOK() and USB_SET_ADDRESS_HOOK(). 212 | - Added optional routine usbMeasureFrameLength() for calibration of the 213 | internal RC oscillator. 214 | 215 | * Release 2008-02-28 216 | 217 | - USB_INITIAL_DATATOKEN defaults to USBPID_DATA1 now, which means that we 218 | start with sending USBPID_DATA0. 219 | - Changed defaults in usbconfig-prototype.h 220 | - Added free USB VID/PID pair for MIDI class devices 221 | - Restructured AVR-USB as separate package, not part of PowerSwitch any more. 222 | 223 | * Release 2008-04-18 224 | 225 | - Restructured usbdrv.c so that it is easier to read and understand. 226 | - Better code optimization with gcc 4. 227 | - If a second interrupt in endpoint is enabled, also add it to config 228 | descriptor. 229 | - Added config option for long transfers (above 254 bytes), see 230 | USB_CFG_LONG_TRANSFERS in usbconfig.h. 231 | - Added 20 MHz module contributed by Jeroen Benschop. 232 | 233 | * Release 2008-05-13 234 | 235 | - Fixed bug in libs-host/hiddata.c function usbhidGetReport(): length 236 | was not incremented, pointer to length was incremented instead. 237 | - Added code to command line tool(s) which claims an interface. This code 238 | is disabled by default, but may be necessary on newer Linux kernels. 239 | - Added usbconfig.h option "USB_CFG_CHECK_DATA_TOGGLING". 240 | - New header "usbportability.h" prepares ports to other development 241 | environments. 242 | - Long transfers (above 254 bytes) did not work when usbFunctionRead() was 243 | used to supply the data. Fixed this bug. [Thanks to Alexander Neumann!] 244 | - In hiddata.c (example code for sending/receiving data over HID), use 245 | USB_RECIP_DEVICE instead of USB_RECIP_INTERFACE for control transfers so 246 | that we need not claim the interface. 247 | - in usbPoll() loop 20 times polling for RESET state instead of 10 times. 248 | This accounts for the higher clock rates we now support. 249 | - Added a module for 12.8 MHz RC oscillator with PLL in receiver loop. 250 | - Added hook to SOF code so that oscillator can be tuned to USB frame clock. 251 | - Added timeout to waitForJ loop. Helps preventing unexpected hangs. 252 | - Added example code for oscillator tuning to libs-device (thanks to 253 | Henrik Haftmann for the idea to this routine). 254 | - Implemented option USB_CFG_SUPPRESS_INTR_CODE. 255 | 256 | * Release 2008-10-22 257 | 258 | - Fixed libs-device/osctune.h: OSCCAL is memory address on ATMega88 and 259 | similar, not offset of 0x20 needs to be added. 260 | - Allow distribution under GPLv3 for those who have to link against other 261 | code distributed under GPLv3. 262 | 263 | * Release 2008-11-26 264 | 265 | - Removed libusb-win32 dependency for hid-data example in Makefile.windows. 266 | It was never required and confused many people. 267 | - Added extern uchar usbRxToken to usbdrv.h. 268 | - Integrated a module with CRC checks at 18 MHz by Lukas Schrittwieser. 269 | 270 | * Release 2009-03-23 271 | 272 | - Hid-mouse example used settings from hid-data example, fixed that. 273 | - Renamed project to V-USB due to a trademark issue with Atmel(r). 274 | - Changed CommercialLicense.txt and USBID-License.txt to make the 275 | background of USB ID registration clearer. 276 | 277 | * Release 2009-04-15 278 | 279 | - Changed CommercialLicense.txt to reflect the new range of PIDs from 280 | Jason Kotzin. 281 | - Removed USBID-License.txt in favor of USB-IDs-for-free.txt and 282 | USB-ID-FAQ.txt 283 | - Fixed a bug in the 12.8 MHz module: End Of Packet decection was made in 284 | the center between bit 0 and 1 of each byte. This is where the data lines 285 | are expected to change and the sampled data may therefore be nonsense. 286 | We therefore check EOP ONLY if bits 0 AND 1 have both been read as 0 on D-. 287 | - Fixed a bitstuffing problem in the 16 MHz module: If bit 6 was stuffed, 288 | the unstuffing code in the receiver routine was 1 cycle too long. If 289 | multiple bytes had the unstuffing in bit 6, the error summed up until the 290 | receiver was out of sync. 291 | - Included option for faster CRC routine. 292 | Thanks to Slawomir Fras (BoskiDialer) for this code! 293 | - Updated bits in Configuration Descriptor's bmAttributes according to 294 | USB 1.1 (in particular bit 7, it is a must-be-set bit now). 295 | 296 | * Release 2009-08-22 297 | 298 | - Moved first DBG1() after odDebugInit() in all examples. 299 | - Use vector INT0_vect instead of SIG_INTERRUPT0 if defined. This makes 300 | V-USB compatible with the new "p" suffix devices (e.g. ATMega328p). 301 | - USB_CFG_CLOCK_KHZ setting is now required in usbconfig.h (no default any 302 | more). 303 | - New option USB_CFG_DRIVER_FLASH_PAGE allows boot loaders on devices with 304 | more than 64 kB flash. 305 | - Built-in configuration descriptor allows custom definition for second 306 | endpoint now. 307 | 308 | * Release 2010-07-15 309 | -------------------------------------------------------------------------------- /Mikrocontroller/3DMouse/3DMouse/usbdrv/CommercialLicense.txt: -------------------------------------------------------------------------------- 1 | V-USB Driver Software License Agreement 2 | Version 2009-08-03 3 | 4 | THIS LICENSE AGREEMENT GRANTS YOU CERTAIN RIGHTS IN A SOFTWARE. YOU CAN 5 | ENTER INTO THIS AGREEMENT AND ACQUIRE THE RIGHTS OUTLINED BELOW BY PAYING 6 | THE AMOUNT ACCORDING TO SECTION 4 ("PAYMENT") TO OBJECTIVE DEVELOPMENT. 7 | 8 | 9 | 1 DEFINITIONS 10 | 11 | 1.1 "OBJECTIVE DEVELOPMENT" shall mean OBJECTIVE DEVELOPMENT Software GmbH, 12 | Grosse Schiffgasse 1A/7, 1020 Wien, AUSTRIA. 13 | 14 | 1.2 "You" shall mean the Licensee. 15 | 16 | 1.3 "V-USB" shall mean all files included in the package distributed under 17 | the name "vusb" by OBJECTIVE DEVELOPMENT (http://www.obdev.at/vusb/) 18 | unless otherwise noted. This includes the firmware-only USB device 19 | implementation for Atmel AVR microcontrollers, some simple device examples 20 | and host side software examples and libraries. 21 | 22 | 23 | 2 LICENSE GRANTS 24 | 25 | 2.1 Source Code. OBJECTIVE DEVELOPMENT shall furnish you with the source 26 | code of V-USB. 27 | 28 | 2.2 Distribution and Use. OBJECTIVE DEVELOPMENT grants you the 29 | non-exclusive right to use, copy and distribute V-USB with your hardware 30 | product(s), restricted by the limitations in section 3 below. 31 | 32 | 2.3 Modifications. OBJECTIVE DEVELOPMENT grants you the right to modify 33 | the source code and your copy of V-USB according to your needs. 34 | 35 | 2.4 USB IDs. OBJECTIVE DEVELOPMENT furnishes you with one or two USB 36 | Product ID(s), sent to you in e-mail. These Product IDs are reserved 37 | exclusively for you. OBJECTIVE DEVELOPMENT has obtained USB Product ID 38 | ranges under the Vendor ID 5824 from Wouter van Ooijen (Van Ooijen 39 | Technische Informatica, www.voti.nl) and under the Vendor ID 8352 from 40 | Jason Kotzin (Clay Logic, www.claylogic.com). Both owners of the Vendor IDs 41 | have obtained these IDs from the USB Implementers Forum, Inc. 42 | (www.usb.org). OBJECTIVE DEVELOPMENT disclaims all liability which might 43 | arise from the assignment of USB IDs. 44 | 45 | 2.5 USB Certification. Although not part of this agreement, we want to make 46 | it clear that you cannot become USB certified when you use V-USB or a USB 47 | Product ID assigned by OBJECTIVE DEVELOPMENT. AVR microcontrollers don't 48 | meet the electrical specifications required by the USB specification and 49 | the USB Implementers Forum certifies only members who bought a Vendor ID of 50 | their own. 51 | 52 | 53 | 3 LICENSE RESTRICTIONS 54 | 55 | 3.1 Number of Units. Only one of the following three definitions is 56 | applicable. Which one is determined by the amount you pay to OBJECTIVE 57 | DEVELOPMENT, see section 4 ("Payment") below. 58 | 59 | Hobby License: You may use V-USB according to section 2 above in no more 60 | than 5 hardware units. These units must not be sold for profit. 61 | 62 | Entry Level License: You may use V-USB according to section 2 above in no 63 | more than 150 hardware units. 64 | 65 | Professional License: You may use V-USB according to section 2 above in 66 | any number of hardware units, except for large scale production ("unlimited 67 | fair use"). Quantities below 10,000 units are not considered large scale 68 | production. If your reach quantities which are obviously large scale 69 | production, you must pay a license fee of 0.10 EUR per unit for all units 70 | above 10,000. 71 | 72 | 3.2 Rental. You may not rent, lease, or lend V-USB or otherwise encumber 73 | any copy of V-USB, or any of the rights granted herein. 74 | 75 | 3.3 Transfer. You may not transfer your rights under this Agreement to 76 | another party without OBJECTIVE DEVELOPMENT's prior written consent. If 77 | such consent is obtained, you may permanently transfer this License to 78 | another party. The recipient of such transfer must agree to all terms and 79 | conditions of this Agreement. 80 | 81 | 3.4 Reservation of Rights. OBJECTIVE DEVELOPMENT retains all rights not 82 | expressly granted. 83 | 84 | 3.5 Non-Exclusive Rights. Your license rights under this Agreement are 85 | non-exclusive. 86 | 87 | 3.6 Third Party Rights. This Agreement cannot grant you rights controlled 88 | by third parties. In particular, you are not allowed to use the USB logo or 89 | other trademarks owned by the USB Implementers Forum, Inc. without their 90 | consent. Since such consent depends on USB certification, it should be 91 | noted that V-USB will not pass certification because it does not 92 | implement checksum verification and the microcontroller ports do not meet 93 | the electrical specifications. 94 | 95 | 96 | 4 PAYMENT 97 | 98 | The payment amount depends on the variation of this agreement (according to 99 | section 3.1) into which you want to enter. Concrete prices are listed on 100 | OBJECTIVE DEVELOPMENT's web site, usually at 101 | http://www.obdev.at/vusb/license.html. You agree to pay the amount listed 102 | there to OBJECTIVE DEVELOPMENT or OBJECTIVE DEVELOPMENT's payment processor 103 | or reseller. 104 | 105 | 106 | 5 COPYRIGHT AND OWNERSHIP 107 | 108 | V-USB is protected by copyright laws and international copyright 109 | treaties, as well as other intellectual property laws and treaties. V-USB 110 | is licensed, not sold. 111 | 112 | 113 | 6 TERM AND TERMINATION 114 | 115 | 6.1 Term. This Agreement shall continue indefinitely. However, OBJECTIVE 116 | DEVELOPMENT may terminate this Agreement and revoke the granted license and 117 | USB-IDs if you fail to comply with any of its terms and conditions. 118 | 119 | 6.2 Survival of Terms. All provisions regarding secrecy, confidentiality 120 | and limitation of liability shall survive termination of this agreement. 121 | 122 | 123 | 7 DISCLAIMER OF WARRANTY AND LIABILITY 124 | 125 | LIMITED WARRANTY. V-USB IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 126 | KIND. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, OBJECTIVE 127 | DEVELOPMENT AND ITS SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES, EITHER 128 | EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 129 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND 130 | NON-INFRINGEMENT, WITH REGARD TO V-USB, AND THE PROVISION OF OR FAILURE 131 | TO PROVIDE SUPPORT SERVICES. THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL 132 | RIGHTS. YOU MAY HAVE OTHERS, WHICH VARY FROM STATE/JURISDICTION TO 133 | STATE/JURISDICTION. 134 | 135 | LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, 136 | IN NO EVENT SHALL OBJECTIVE DEVELOPMENT OR ITS SUPPLIERS BE LIABLE FOR ANY 137 | SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER 138 | (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, 139 | BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY 140 | LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE V-USB OR THE 141 | PROVISION OF OR FAILURE TO PROVIDE SUPPORT SERVICES, EVEN IF OBJECTIVE 142 | DEVELOPMENT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN ANY 143 | CASE, OBJECTIVE DEVELOPMENT'S ENTIRE LIABILITY UNDER ANY PROVISION OF THIS 144 | AGREEMENT SHALL BE LIMITED TO THE AMOUNT ACTUALLY PAID BY YOU FOR V-USB. 145 | 146 | 147 | 8 MISCELLANEOUS TERMS 148 | 149 | 8.1 Marketing. OBJECTIVE DEVELOPMENT has the right to mention for marketing 150 | purposes that you entered into this agreement. 151 | 152 | 8.2 Entire Agreement. This document represents the entire agreement between 153 | OBJECTIVE DEVELOPMENT and you. It may only be modified in writing signed by 154 | an authorized representative of both, OBJECTIVE DEVELOPMENT and you. 155 | 156 | 8.3 Severability. In case a provision of these terms and conditions should 157 | be or become partly or entirely invalid, ineffective, or not executable, 158 | the validity of all other provisions shall not be affected. 159 | 160 | 8.4 Applicable Law. This agreement is governed by the laws of the Republic 161 | of Austria. 162 | 163 | 8.5 Responsible Courts. The responsible courts in Vienna/Austria will have 164 | exclusive jurisdiction regarding all disputes in connection with this 165 | agreement. 166 | 167 | -------------------------------------------------------------------------------- /Mikrocontroller/3DMouse/3DMouse/usbdrv/Readme.txt: -------------------------------------------------------------------------------- 1 | This is the Readme file to Objective Development's firmware-only USB driver 2 | for Atmel AVR microcontrollers. For more information please visit 3 | http://www.obdev.at/vusb/ 4 | 5 | This directory contains the USB firmware only. Copy it as-is to your own 6 | project and add all .c and .S files to your project (these files are marked 7 | with an asterisk in the list below). Then copy usbconfig-prototype.h as 8 | usbconfig.h to your project and edit it according to your configuration. 9 | 10 | 11 | TECHNICAL DOCUMENTATION 12 | ======================= 13 | The technical documentation (API) for the firmware driver is contained in the 14 | file "usbdrv.h". Please read all of it carefully! Configuration options are 15 | documented in "usbconfig-prototype.h". 16 | 17 | The driver consists of the following files: 18 | Readme.txt ............. The file you are currently reading. 19 | Changelog.txt .......... Release notes for all versions of the driver. 20 | usbdrv.h ............... Driver interface definitions and technical docs. 21 | * usbdrv.c ............... High level language part of the driver. Link this 22 | module to your code! 23 | * usbdrvasm.S ............ Assembler part of the driver. This module is mostly 24 | a stub and includes one of the usbdrvasm*.S files 25 | depending on processor clock. Link this module to 26 | your code! 27 | usbdrvasm*.inc ......... Assembler routines for particular clock frequencies. 28 | Included by usbdrvasm.S, don't link it directly! 29 | asmcommon.inc .......... Common assembler routines. Included by 30 | usbdrvasm*.inc, don't link it directly! 31 | usbconfig-prototype.h .. Prototype for your own usbdrv.h file. 32 | * oddebug.c .............. Debug functions. Only used when DEBUG_LEVEL is 33 | defined to a value greater than 0. Link this module 34 | to your code! 35 | oddebug.h .............. Interface definitions of the debug module. 36 | usbportability.h ....... Header with compiler-dependent stuff. 37 | usbdrvasm.asm .......... Compatibility stub for IAR-C-compiler. Use this 38 | module instead of usbdrvasm.S when you assembler 39 | with IAR's tools. 40 | License.txt ............ Open Source license for this driver. 41 | CommercialLicense.txt .. Optional commercial license for this driver. 42 | USB-ID-FAQ.txt ......... General infos about USB Product- and Vendor-IDs. 43 | USB-IDs-for-free.txt ... List and terms of use for free shared PIDs. 44 | 45 | (*) ... These files should be linked to your project. 46 | 47 | 48 | CPU CORE CLOCK FREQUENCY 49 | ======================== 50 | We supply assembler modules for clock frequencies of 12 MHz, 12.8 MHz, 15 MHz, 51 | 16 MHz, 16.5 MHz 18 MHz and 20 MHz. Other clock rates are not supported. The 52 | actual clock rate must be configured in usbconfig.h. 53 | 54 | 12 MHz Clock 55 | This is the traditional clock rate of V-USB because it's the lowest clock 56 | rate where the timing constraints of the USB spec can be met. 57 | 58 | 15 MHz Clock 59 | Similar to 12 MHz, but some NOPs inserted. On the other hand, the higher clock 60 | rate allows for some loops which make the resulting code size somewhat smaller 61 | than the 12 MHz version. 62 | 63 | 16 MHz Clock 64 | This clock rate has been added for users of the Arduino board and other 65 | ready-made boards which come with a fixed 16 MHz crystal. It's also an option 66 | if you need the slightly higher clock rate for performance reasons. Since 67 | 16 MHz is not divisible by the USB low speed bit clock of 1.5 MHz, the code 68 | is somewhat tricky and has to insert a leap cycle every third byte. 69 | 70 | 12.8 MHz and 16.5 MHz Clock 71 | The assembler modules for these clock rates differ from the other modules 72 | because they have been built for an RC oscillator with only 1% precision. The 73 | receiver code inserts leap cycles to compensate for clock deviations. 1% is 74 | also the precision which can be achieved by calibrating the internal RC 75 | oscillator of the AVR. Please note that only AVRs with internal 64 MHz PLL 76 | oscillator can reach 16.5 MHz with the RC oscillator. This includes the very 77 | popular ATTiny25, ATTiny45, ATTiny85 series as well as the ATTiny26. Almost 78 | all AVRs can reach 12.8 MHz, although this is outside the specified range. 79 | 80 | See the EasyLogger example at http://www.obdev.at/vusb/easylogger.html for 81 | code which calibrates the RC oscillator based on the USB frame clock. 82 | 83 | 18 MHz Clock 84 | This module is closer to the USB specification because it performs an on the 85 | fly CRC check for incoming packets. Packets with invalid checksum are 86 | discarded as required by the spec. If you also implement checks for data 87 | PID toggling on application level (see option USB_CFG_CHECK_DATA_TOGGLING 88 | in usbconfig.h for more info), this ensures data integrity. Due to the CRC 89 | tables and alignment requirements, this code is bigger than modules for other 90 | clock rates. To activate this module, you must define USB_CFG_CHECK_CRC to 1 91 | and USB_CFG_CLOCK_KHZ to 18000 in usbconfig.h. 92 | 93 | 20 MHz Clock 94 | This module is for people who won't do it with less than the maximum. Since 95 | 20 MHz is not divisible by the USB low speed bit clock of 1.5 MHz, the code 96 | uses similar tricks as the 16 MHz module to insert leap cycles. 97 | 98 | 99 | USB IDENTIFIERS 100 | =============== 101 | Every USB device needs a vendor- and a product-identifier (VID and PID). VIDs 102 | are obtained from usb.org for a price of 1,500 USD. Once you have a VID, you 103 | can assign PIDs at will. 104 | 105 | Since an entry level cost of 1,500 USD is too high for most small companies 106 | and hobbyists, we provide some VID/PID pairs for free. See the file 107 | USB-IDs-for-free.txt for details. 108 | 109 | Objective Development also has some license offerings which include product 110 | IDs. See http://www.obdev.at/vusb/ for details. 111 | 112 | 113 | DEVELOPMENT SYSTEM 114 | ================== 115 | This driver has been developed and optimized for the GNU compiler version 3 116 | and 4. We recommend that you use the GNU compiler suite because it is freely 117 | available. V-USB has also been ported to the IAR compiler and assembler. It 118 | has been tested with IAR 4.10B/W32 and 4.12A/W32 on an ATmega8 with the 119 | "small" and "tiny" memory model. Not every release is tested with IAR CC and 120 | the driver may therefore fail to compile with IAR. Please note that gcc is 121 | more efficient for usbdrv.c because this module has been deliberately 122 | optimized for gcc. 123 | 124 | Gcc version 3 produces smaller code than version 4 due to new optimizing 125 | capabilities which don't always improve things on 8 bit CPUs. The code size 126 | generated by gcc 4 can be reduced with the compiler options 127 | -fno-move-loop-invariants, -fno-tree-scev-cprop and 128 | -fno-inline-small-functions in addition to -Os. On devices with more than 129 | 8k of flash memory, we also recommend the linker option --relax (written as 130 | -Wl,--relax for gcc) to convert absolute calls into relative where possible. 131 | 132 | For more information about optimizing options see: 133 | 134 | http://www.tty1.net/blog/2008-04-29-avr-gcc-optimisations_en.html 135 | 136 | These optimizations are good for gcc 4.x. Version 3.x of gcc does not support 137 | most of these options and produces good code anyway. 138 | 139 | 140 | USING V-USB FOR FREE 141 | ==================== 142 | The AVR firmware driver is published under the GNU General Public License 143 | Version 2 (GPL2) and the GNU General Public License Version 3 (GPL3). It is 144 | your choice whether you apply the terms of version 2 or version 3. 145 | 146 | If you decide for the free GPL2 or GPL3, we STRONGLY ENCOURAGE you to do the 147 | following things IN ADDITION to the obligations from the GPL: 148 | 149 | (1) Publish your entire project on a web site and drop us a note with the URL. 150 | Use the form at http://www.obdev.at/vusb/feedback.html for your submission. 151 | If you don't have a web site, you can publish the project in obdev's 152 | documentation wiki at 153 | http://www.obdev.at/goto.php?t=vusb-wiki&p=hosted-projects. 154 | 155 | (2) Adhere to minimum publication standards. Please include AT LEAST: 156 | - a circuit diagram in PDF, PNG or GIF format 157 | - full source code for the host software 158 | - a Readme.txt file in ASCII format which describes the purpose of the 159 | project and what can be found in which directories and which files 160 | - a reference to http://www.obdev.at/vusb/ 161 | 162 | (3) If you improve the driver firmware itself, please give us a free license 163 | to your modifications for our commercial license offerings. 164 | 165 | 166 | COMMERCIAL LICENSES FOR V-USB 167 | ============================= 168 | If you don't want to publish your source code under the terms of the GPL, 169 | you can simply pay money for V-USB. As an additional benefit you get 170 | USB PIDs for free, reserved exclusively to you. See the file 171 | "CommercialLicense.txt" for details. 172 | 173 | -------------------------------------------------------------------------------- /Mikrocontroller/3DMouse/3DMouse/usbdrv/USB-ID-FAQ.txt: -------------------------------------------------------------------------------- 1 | Version 2009-08-22 2 | 3 | ========================== 4 | WHY DO WE NEED THESE IDs? 5 | ========================== 6 | 7 | USB is more than a low level protocol for data transport. It also defines a 8 | common set of requests which must be understood by all devices. And as part 9 | of these common requests, the specification defines data structures, the 10 | USB Descriptors, which are used to describe the properties of the device. 11 | 12 | From the perspective of an operating system, it is therefore possible to find 13 | out basic properties of a device (such as e.g. the manufacturer and the name 14 | of the device) without a device-specific driver. This is essential because 15 | the operating system can choose a driver to load based on this information 16 | (Plug-And-Play). 17 | 18 | Among the most important properties in the Device Descriptor are the USB 19 | Vendor- and Product-ID. Both are 16 bit integers. The most simple form of 20 | driver matching is based on these IDs. The driver announces the Vendor- and 21 | Product-IDs of the devices it can handle and the operating system loads the 22 | appropriate driver when the device is connected. 23 | 24 | It is obvious that this technique only works if the pair Vendor- plus 25 | Product-ID is unique: Only devices which require the same driver can have the 26 | same pair of IDs. 27 | 28 | 29 | ===================================================== 30 | HOW DOES THE USB STANDARD ENSURE THAT IDs ARE UNIQUE? 31 | ===================================================== 32 | 33 | Since it is so important that USB IDs are unique, the USB Implementers Forum, 34 | Inc. (usb.org) needs a way to enforce this legally. It is not forbidden by 35 | law to build a device and assign it any random numbers as IDs. Usb.org 36 | therefore needs an agreement to regulate the use of USB IDs. The agreement 37 | binds only parties who agreed to it, of course. Everybody else is free to use 38 | any numbers for their IDs. 39 | 40 | So how can usb.org ensure that every manufacturer of USB devices enters into 41 | an agreement with them? They do it via trademark licensing. Usb.org has 42 | registered the trademark "USB", all associated logos and related terms. If 43 | you want to put an USB logo on your product or claim that it is USB 44 | compliant, you must license these trademarks from usb.org. And this is where 45 | you enter into an agreement. See the "USB-IF Trademark License Agreement and 46 | Usage Guidelines for the USB-IF Logo" at 47 | http://www.usb.org/developers/logo_license/. 48 | 49 | Licensing the USB trademarks requires that you buy a USB Vendor-ID from 50 | usb.org (one-time fee of ca. 2,000 USD), that you become a member of usb.org 51 | (yearly fee of ca. 4,000 USD) and that you meet all the technical 52 | specifications from the USB spec. 53 | 54 | This means that most hobbyists and small companies will never be able to 55 | become USB compliant, just because membership is so expensive. And you can't 56 | be compliant with a driver based on V-USB anyway, because the AVR's port pins 57 | don't meet the electrical specifications for USB. So, in principle, all 58 | hobbyists and small companies are free to choose any random numbers for their 59 | IDs. They have nothing to lose... 60 | 61 | There is one exception worth noting, though: If you use a sub-component which 62 | implements USB, the vendor of the sub-components may guarantee USB 63 | compliance. This might apply to some or all of FTDI's solutions. 64 | 65 | 66 | ======================================================================= 67 | WHY SHOULD YOU OBTAIN USB IDs EVEN IF YOU DON'T LICENSE USB TRADEMARKS? 68 | ======================================================================= 69 | 70 | You have learned in the previous section that you are free to choose any 71 | numbers for your IDs anyway. So why not do exactly this? There is still the 72 | technical issue. If you choose IDs which are already in use by somebody else, 73 | operating systems will load the wrong drivers and your device won't work. 74 | Even if you choose IDs which are not currently in use, they may be in use in 75 | the next version of the operating system or even after an automatic update. 76 | 77 | So what you need is a pair of Vendor- and Product-IDs for which you have the 78 | guarantee that no USB compliant product uses them. This implies that no 79 | operating system will ever ship with drivers responsible for these IDs. 80 | 81 | 82 | ============================================== 83 | HOW DOES OBJECTIVE DEVELOPMENT HANDLE USB IDs? 84 | ============================================== 85 | 86 | Objective Development gives away pairs of USB-IDs with their V-USB licenses. 87 | In order to ensure that these IDs are unique, Objective Development has an 88 | agreement with the company/person who has bought the USB Vendor-ID from 89 | usb.org. This agreement ensures that a range of USB Product-IDs is reserved 90 | for assignment by Objective Development and that the owner of the Vendor-ID 91 | won't give it to anybody else. 92 | 93 | This means that you have to trust three parties to ensure uniqueness of 94 | your IDs: 95 | 96 | - Objective Development, that they don't give the same PID to more than 97 | one person. 98 | - The owner of the Vendor-ID that they don't assign PIDs from the range 99 | assigned to Objective Development to anybody else. 100 | - Usb.org that they don't assign the same Vendor-ID a second time. 101 | 102 | 103 | ================================== 104 | WHO IS THE OWNER OF THE VENDOR-ID? 105 | ================================== 106 | 107 | Objective Development has obtained ranges of USB Product-IDs under two 108 | Vendor-IDs: Under Vendor-ID 5824 from Wouter van Ooijen (Van Ooijen 109 | Technische Informatica, www.voti.nl) and under Vendor-ID 8352 from Jason 110 | Kotzin (Clay Logic, www.claylogic.com). Both VID owners have received their 111 | Vendor-ID directly from usb.org. 112 | 113 | 114 | ========================================================================= 115 | CAN I USE USB-IDs FROM OBJECTIVE DEVELOPMENT WITH OTHER DRIVERS/HARDWARE? 116 | ========================================================================= 117 | 118 | The short answer is: Yes. All you get is a guarantee that the IDs are never 119 | assigned to anybody else. What more do you need? 120 | 121 | 122 | ============================ 123 | WHAT ABOUT SHARED ID PAIRS? 124 | ============================ 125 | 126 | Objective Development has reserved some PID/VID pairs for shared use. You 127 | have no guarantee of uniqueness for them, except that no USB compliant device 128 | uses them. In order to avoid technical problems, we must ensure that all 129 | devices with the same pair of IDs use the same driver on kernel level. For 130 | details, see the file USB-IDs-for-free.txt. 131 | 132 | 133 | ====================================================== 134 | I HAVE HEARD THAT SUB-LICENSING OF USB-IDs IS ILLEGAL? 135 | ====================================================== 136 | 137 | A 16 bit integer number cannot be protected by copyright laws. It is not 138 | sufficiently complex. And since none of the parties involved entered into the 139 | USB-IF Trademark License Agreement, we are not bound by this agreement. So 140 | there is no reason why it should be illegal to sub-license USB-IDs. 141 | 142 | 143 | ============================================= 144 | WHO IS LIABLE IF THERE ARE INCOMPATIBILITIES? 145 | ============================================= 146 | 147 | Objective Development disclaims all liabilities which might arise from the 148 | assignment of IDs. If you guarantee product features to your customers 149 | without proper disclaimer, YOU are liable for that. 150 | -------------------------------------------------------------------------------- /Mikrocontroller/3DMouse/3DMouse/usbdrv/USB-IDs-for-free.txt: -------------------------------------------------------------------------------- 1 | Version 2009-08-22 2 | 3 | =========================== 4 | FREE USB-IDs FOR SHARED USE 5 | =========================== 6 | 7 | Objective Development has reserved a set of USB Product-IDs for use according 8 | to the guidelines outlined below. For more information about the concept of 9 | USB IDs please see the file USB-ID-FAQ.txt. Objective Development guarantees 10 | that the IDs listed below are not used by any USB compliant devices. 11 | 12 | 13 | ==================== 14 | MECHANISM OF SHARING 15 | ==================== 16 | 17 | From a technical point of view, two different devices can share the same USB 18 | Vendor- and Product-ID if they require the same driver on operating system 19 | level. We make use of this fact by assigning separate IDs for various device 20 | classes. On application layer, devices must be distinguished by their textual 21 | name or serial number. We offer separate sets of IDs for discrimination by 22 | textual name and for serial number. 23 | 24 | Examples for shared use of USB IDs are included with V-USB in the "examples" 25 | subdirectory. 26 | 27 | 28 | ====================================== 29 | IDs FOR DISCRIMINATION BY TEXTUAL NAME 30 | ====================================== 31 | 32 | If you use one of the IDs listed below, your device and host-side software 33 | must conform to these rules: 34 | 35 | (1) The USB device MUST provide a textual representation of the manufacturer 36 | and product identification. The manufacturer identification MUST be available 37 | at least in USB language 0x0409 (English/US). 38 | 39 | (2) The textual manufacturer identification MUST contain either an Internet 40 | domain name (e.g. "mycompany.com") registered and owned by you, or an e-mail 41 | address under your control (e.g. "myname@gmx.net"). You can embed the domain 42 | name or e-mail address in any string you like, e.g. "Objective Development 43 | http://www.obdev.at/vusb/". 44 | 45 | (3) You are responsible for retaining ownership of the domain or e-mail 46 | address for as long as any of your products are in use. 47 | 48 | (4) You may choose any string for the textual product identification, as long 49 | as this string is unique within the scope of your textual manufacturer 50 | identification. 51 | 52 | (5) Application side device look-up MUST be based on the textual manufacturer 53 | and product identification in addition to VID/PID matching. The driver 54 | matching MUST be a comparison of the entire strings, NOT a sub-string match. 55 | 56 | (6) For devices which implement a particular USB device class (e.g. HID), the 57 | operating system's default class driver MUST be used. If an operating system 58 | driver for Vendor Class devices is needed, this driver must be libusb or 59 | libusb-win32 (see http://libusb.org/ and 60 | http://libusb-win32.sourceforge.net/). 61 | 62 | Table if IDs for discrimination by textual name: 63 | 64 | PID dec (hex) | VID dec (hex) | Description of use 65 | ==============+===============+============================================ 66 | 1500 (0x05dc) | 5824 (0x16c0) | For Vendor Class devices with libusb 67 | --------------+---------------+-------------------------------------------- 68 | 1503 (0x05df) | 5824 (0x16c0) | For generic HID class devices (which are 69 | | | NOT mice, keyboards or joysticks) 70 | --------------+---------------+-------------------------------------------- 71 | 1505 (0x05e1) | 5824 (0x16c0) | For CDC-ACM class devices (modems) 72 | --------------+---------------+-------------------------------------------- 73 | 1508 (0x05e4) | 5824 (0x16c0) | For MIDI class devices 74 | --------------+---------------+-------------------------------------------- 75 | 76 | Note that Windows caches the textual product- and vendor-description for 77 | mice, keyboards and joysticks. Name-bsed discrimination is therefore not 78 | recommended for these device classes. 79 | 80 | 81 | ======================================= 82 | IDs FOR DISCRIMINATION BY SERIAL NUMBER 83 | ======================================= 84 | 85 | If you use one of the IDs listed below, your device and host-side software 86 | must conform to these rules: 87 | 88 | (1) The USB device MUST provide a textual representation of the serial 89 | number. The serial number string MUST be available at least in USB language 90 | 0x0409 (English/US). 91 | 92 | (2) The serial number MUST start with either an Internet domain name (e.g. 93 | "mycompany.com") registered and owned by you, or an e-mail address under your 94 | control (e.g. "myname@gmx.net"), both terminated with a colon (":") character. 95 | You MAY append any string you like for further discrimination of your devices. 96 | 97 | (3) You are responsible for retaining ownership of the domain or e-mail 98 | address for as long as any of your products are in use. 99 | 100 | (5) Application side device look-up MUST be based on the serial number string 101 | in addition to VID/PID matching. The matching must start at the first 102 | character of the serial number string and include the colon character 103 | terminating your domain or e-mail address. It MAY stop anywhere after that. 104 | 105 | (6) For devices which implement a particular USB device class (e.g. HID), the 106 | operating system's default class driver MUST be used. If an operating system 107 | driver for Vendor Class devices is needed, this driver must be libusb or 108 | libusb-win32 (see http://libusb.org/ and 109 | http://libusb-win32.sourceforge.net/). 110 | 111 | Table if IDs for discrimination by serial number string: 112 | 113 | PID dec (hex) | VID dec (hex) | Description of use 114 | ===============+===============+=========================================== 115 | 10200 (0x27d8) | 5824 (0x16c0) | For Vendor Class devices with libusb 116 | ---------------+---------------+------------------------------------------- 117 | 10201 (0x27d9) | 5824 (0x16c0) | For generic HID class devices (which are 118 | | | NOT mice, keyboards or joysticks) 119 | ---------------+---------------+------------------------------------------- 120 | 10202 (0x27da) | 5824 (0x16c0) | For USB Mice 121 | ---------------+---------------+------------------------------------------- 122 | 10203 (0x27db) | 5824 (0x16c0) | For USB Keyboards 123 | ---------------+---------------+------------------------------------------- 124 | 10204 (0x27db) | 5824 (0x16c0) | For USB Joysticks 125 | ---------------+---------------+------------------------------------------- 126 | 10205 (0x27dc) | 5824 (0x16c0) | For CDC-ACM class devices (modems) 127 | ---------------+---------------+------------------------------------------- 128 | 10206 (0x27dd) | 5824 (0x16c0) | For MIDI class devices 129 | ---------------+---------------+------------------------------------------- 130 | 131 | 132 | ================= 133 | ORIGIN OF USB-IDs 134 | ================= 135 | 136 | OBJECTIVE DEVELOPMENT Software GmbH has obtained all VID/PID pairs listed 137 | here from Wouter van Ooijen (see www.voti.nl) for exclusive disposition. 138 | Wouter van Ooijen has obtained the VID from the USB Implementers Forum, Inc. 139 | (see www.usb.org). The VID is registered for the company name "Van Ooijen 140 | Technische Informatica". 141 | 142 | 143 | ========== 144 | DISCLAIMER 145 | ========== 146 | 147 | OBJECTIVE DEVELOPMENT Software GmbH disclaims all liability for any 148 | problems which are caused by the shared use of these VID/PID pairs. 149 | -------------------------------------------------------------------------------- /Mikrocontroller/3DMouse/3DMouse/usbdrv/asmcommon.inc: -------------------------------------------------------------------------------- 1 | /* Name: asmcommon.inc 2 | * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2007-11-05 5 | * Tabsize: 4 6 | * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH 7 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 8 | * Revision: $Id$ 9 | */ 10 | 11 | /* Do not link this file! Link usbdrvasm.S instead, which includes the 12 | * appropriate implementation! 13 | */ 14 | 15 | /* 16 | General Description: 17 | This file contains assembler code which is shared among the USB driver 18 | implementations for different CPU cocks. Since the code must be inserted 19 | in the middle of the module, it's split out into this file and #included. 20 | 21 | Jump destinations called from outside: 22 | sofError: Called when no start sequence was found. 23 | se0: Called when a package has been successfully received. 24 | overflow: Called when receive buffer overflows. 25 | doReturn: Called after sending data. 26 | 27 | Outside jump destinations used by this module: 28 | waitForJ: Called to receive an already arriving packet. 29 | sendAckAndReti: 30 | sendNakAndReti: 31 | sendCntAndReti: 32 | usbSendAndReti: 33 | 34 | The following macros must be defined before this file is included: 35 | .macro POP_STANDARD 36 | .endm 37 | .macro POP_RETI 38 | .endm 39 | */ 40 | 41 | #define token x1 42 | 43 | overflow: 44 | ldi x2, 1< 0 14 | 15 | #warning "Never compile production devices with debugging enabled" 16 | 17 | static void uartPutc(char c) 18 | { 19 | while(!(ODDBG_USR & (1 << ODDBG_UDRE))); /* wait for data register empty */ 20 | ODDBG_UDR = c; 21 | } 22 | 23 | static uchar hexAscii(uchar h) 24 | { 25 | h &= 0xf; 26 | if(h >= 10) 27 | h += 'a' - (uchar)10 - '0'; 28 | h += '0'; 29 | return h; 30 | } 31 | 32 | static void printHex(uchar c) 33 | { 34 | uartPutc(hexAscii(c >> 4)); 35 | uartPutc(hexAscii(c)); 36 | } 37 | 38 | void odDebug(uchar prefix, uchar *data, uchar len) 39 | { 40 | printHex(prefix); 41 | uartPutc(':'); 42 | while(len--){ 43 | uartPutc(' '); 44 | printHex(*data++); 45 | } 46 | uartPutc('\r'); 47 | uartPutc('\n'); 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /Mikrocontroller/3DMouse/3DMouse/usbdrv/oddebug.h: -------------------------------------------------------------------------------- 1 | /* Name: oddebug.h 2 | * Project: AVR library 3 | * Author: Christian Starkjohann 4 | * Creation Date: 2005-01-16 5 | * Tabsize: 4 6 | * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH 7 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) 8 | * This Revision: $Id: oddebug.h 692 2008-11-07 15:07:40Z cs $ 9 | */ 10 | 11 | #ifndef __oddebug_h_included__ 12 | #define __oddebug_h_included__ 13 | 14 | /* 15 | General Description: 16 | This module implements a function for debug logs on the serial line of the 17 | AVR microcontroller. Debugging can be configured with the define 18 | 'DEBUG_LEVEL'. If this macro is not defined or defined to 0, all debugging 19 | calls are no-ops. If it is 1, DBG1 logs will appear, but not DBG2. If it is 20 | 2, DBG1 and DBG2 logs will be printed. 21 | 22 | A debug log consists of a label ('prefix') to indicate which debug log created 23 | the output and a memory block to dump in hex ('data' and 'len'). 24 | */ 25 | 26 | 27 | #ifndef F_CPU 28 | # define F_CPU 12000000 /* 12 MHz */ 29 | #endif 30 | 31 | /* make sure we have the UART defines: */ 32 | #include "usbportability.h" 33 | 34 | #ifndef uchar 35 | # define uchar unsigned char 36 | #endif 37 | 38 | #if DEBUG_LEVEL > 0 && !(defined TXEN || defined TXEN0) /* no UART in device */ 39 | # warning "Debugging disabled because device has no UART" 40 | # undef DEBUG_LEVEL 41 | #endif 42 | 43 | #ifndef DEBUG_LEVEL 44 | # define DEBUG_LEVEL 0 45 | #endif 46 | 47 | /* ------------------------------------------------------------------------- */ 48 | 49 | #if DEBUG_LEVEL > 0 50 | # define DBG1(prefix, data, len) odDebug(prefix, data, len) 51 | #else 52 | # define DBG1(prefix, data, len) 53 | #endif 54 | 55 | #if DEBUG_LEVEL > 1 56 | # define DBG2(prefix, data, len) odDebug(prefix, data, len) 57 | #else 58 | # define DBG2(prefix, data, len) 59 | #endif 60 | 61 | /* ------------------------------------------------------------------------- */ 62 | 63 | #if DEBUG_LEVEL > 0 64 | extern void odDebug(uchar prefix, uchar *data, uchar len); 65 | 66 | /* Try to find our control registers; ATMEL likes to rename these */ 67 | 68 | #if defined UBRR 69 | # define ODDBG_UBRR UBRR 70 | #elif defined UBRRL 71 | # define ODDBG_UBRR UBRRL 72 | #elif defined UBRR0 73 | # define ODDBG_UBRR UBRR0 74 | #elif defined UBRR0L 75 | # define ODDBG_UBRR UBRR0L 76 | #endif 77 | 78 | #if defined UCR 79 | # define ODDBG_UCR UCR 80 | #elif defined UCSRB 81 | # define ODDBG_UCR UCSRB 82 | #elif defined UCSR0B 83 | # define ODDBG_UCR UCSR0B 84 | #endif 85 | 86 | #if defined TXEN 87 | # define ODDBG_TXEN TXEN 88 | #else 89 | # define ODDBG_TXEN TXEN0 90 | #endif 91 | 92 | #if defined USR 93 | # define ODDBG_USR USR 94 | #elif defined UCSRA 95 | # define ODDBG_USR UCSRA 96 | #elif defined UCSR0A 97 | # define ODDBG_USR UCSR0A 98 | #endif 99 | 100 | #if defined UDRE 101 | # define ODDBG_UDRE UDRE 102 | #else 103 | # define ODDBG_UDRE UDRE0 104 | #endif 105 | 106 | #if defined UDR 107 | # define ODDBG_UDR UDR 108 | #elif defined UDR0 109 | # define ODDBG_UDR UDR0 110 | #endif 111 | 112 | static inline void odDebugInit(void) 113 | { 114 | ODDBG_UCR |= (1< max 25 cycles interrupt disable 39 | ;max stack usage: [ret(2), YL, SREG, YH, shift, x1, x2, x3, cnt, x4] = 11 bytes 40 | ;Numbers in brackets are maximum cycles since SOF. 41 | USB_INTR_VECTOR: 42 | ;order of registers pushed: YL, SREG [sofError], YH, shift, x1, x2, x3, cnt 43 | push YL ;2 [35] push only what is necessary to sync with edge ASAP 44 | in YL, SREG ;1 [37] 45 | push YL ;2 [39] 46 | ;---------------------------------------------------------------------------- 47 | ; Synchronize with sync pattern: 48 | ;---------------------------------------------------------------------------- 49 | ;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] 50 | ;sync up with J to K edge during sync pattern -- use fastest possible loops 51 | ;The first part waits at most 1 bit long since we must be in sync pattern. 52 | ;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to 53 | ;waitForJ, ensure that this prerequisite is met. 54 | waitForJ: 55 | inc YL 56 | sbis USBIN, USBMINUS 57 | brne waitForJ ; just make sure we have ANY timeout 58 | waitForK: 59 | ;The following code results in a sampling window of 1/4 bit which meets the spec. 60 | sbis USBIN, USBMINUS 61 | rjmp foundK 62 | sbis USBIN, USBMINUS 63 | rjmp foundK 64 | sbis USBIN, USBMINUS 65 | rjmp foundK 66 | sbis USBIN, USBMINUS 67 | rjmp foundK 68 | sbis USBIN, USBMINUS 69 | rjmp foundK 70 | #if USB_COUNT_SOF 71 | lds YL, usbSofCount 72 | inc YL 73 | sts usbSofCount, YL 74 | #endif /* USB_COUNT_SOF */ 75 | #ifdef USB_SOF_HOOK 76 | USB_SOF_HOOK 77 | #endif 78 | rjmp sofError 79 | foundK: 80 | ;{3, 5} after falling D- edge, average delay: 4 cycles [we want 4 for center sampling] 81 | ;we have 1 bit time for setup purposes, then sample again. Numbers in brackets 82 | ;are cycles from center of first sync (double K) bit after the instruction 83 | push YH ;2 [2] 84 | lds YL, usbInputBufOffset;2 [4] 85 | clr YH ;1 [5] 86 | subi YL, lo8(-(usbRxBuf));1 [6] 87 | sbci YH, hi8(-(usbRxBuf));1 [7] 88 | 89 | sbis USBIN, USBMINUS ;1 [8] we want two bits K [sample 1 cycle too early] 90 | rjmp haveTwoBitsK ;2 [10] 91 | pop YH ;2 [11] undo the push from before 92 | rjmp waitForK ;2 [13] this was not the end of sync, retry 93 | haveTwoBitsK: 94 | ;---------------------------------------------------------------------------- 95 | ; push more registers and initialize values while we sample the first bits: 96 | ;---------------------------------------------------------------------------- 97 | push shift ;2 [16] 98 | push x1 ;2 [12] 99 | push x2 ;2 [14] 100 | 101 | in x1, USBIN ;1 [17] <-- sample bit 0 102 | ldi shift, 0xff ;1 [18] 103 | bst x1, USBMINUS ;1 [19] 104 | bld shift, 0 ;1 [20] 105 | push x3 ;2 [22] 106 | push cnt ;2 [24] 107 | 108 | in x2, USBIN ;1 [25] <-- sample bit 1 109 | ser x3 ;1 [26] [inserted init instruction] 110 | eor x1, x2 ;1 [27] 111 | bst x1, USBMINUS ;1 [28] 112 | bld shift, 1 ;1 [29] 113 | ldi cnt, USB_BUFSIZE;1 [30] [inserted init instruction] 114 | rjmp rxbit2 ;2 [32] 115 | 116 | ;---------------------------------------------------------------------------- 117 | ; Receiver loop (numbers in brackets are cycles within byte after instr) 118 | ;---------------------------------------------------------------------------- 119 | 120 | unstuff0: ;1 (branch taken) 121 | andi x3, ~0x01 ;1 [15] 122 | mov x1, x2 ;1 [16] x2 contains last sampled (stuffed) bit 123 | in x2, USBIN ;1 [17] <-- sample bit 1 again 124 | ori shift, 0x01 ;1 [18] 125 | rjmp didUnstuff0 ;2 [20] 126 | 127 | unstuff1: ;1 (branch taken) 128 | mov x2, x1 ;1 [21] x1 contains last sampled (stuffed) bit 129 | andi x3, ~0x02 ;1 [22] 130 | ori shift, 0x02 ;1 [23] 131 | nop ;1 [24] 132 | in x1, USBIN ;1 [25] <-- sample bit 2 again 133 | rjmp didUnstuff1 ;2 [27] 134 | 135 | unstuff2: ;1 (branch taken) 136 | andi x3, ~0x04 ;1 [29] 137 | ori shift, 0x04 ;1 [30] 138 | mov x1, x2 ;1 [31] x2 contains last sampled (stuffed) bit 139 | nop ;1 [32] 140 | in x2, USBIN ;1 [33] <-- sample bit 3 141 | rjmp didUnstuff2 ;2 [35] 142 | 143 | unstuff3: ;1 (branch taken) 144 | in x2, USBIN ;1 [34] <-- sample stuffed bit 3 [one cycle too late] 145 | andi x3, ~0x08 ;1 [35] 146 | ori shift, 0x08 ;1 [36] 147 | rjmp didUnstuff3 ;2 [38] 148 | 149 | unstuff4: ;1 (branch taken) 150 | andi x3, ~0x10 ;1 [40] 151 | in x1, USBIN ;1 [41] <-- sample stuffed bit 4 152 | ori shift, 0x10 ;1 [42] 153 | rjmp didUnstuff4 ;2 [44] 154 | 155 | unstuff5: ;1 (branch taken) 156 | andi x3, ~0x20 ;1 [48] 157 | in x2, USBIN ;1 [49] <-- sample stuffed bit 5 158 | ori shift, 0x20 ;1 [50] 159 | rjmp didUnstuff5 ;2 [52] 160 | 161 | unstuff6: ;1 (branch taken) 162 | andi x3, ~0x40 ;1 [56] 163 | in x1, USBIN ;1 [57] <-- sample stuffed bit 6 164 | ori shift, 0x40 ;1 [58] 165 | rjmp didUnstuff6 ;2 [60] 166 | 167 | ; extra jobs done during bit interval: 168 | ; bit 0: store, clear [SE0 is unreliable here due to bit dribbling in hubs] 169 | ; bit 1: se0 check 170 | ; bit 2: overflow check 171 | ; bit 3: recovery from delay [bit 0 tasks took too long] 172 | ; bit 4: none 173 | ; bit 5: none 174 | ; bit 6: none 175 | ; bit 7: jump, eor 176 | rxLoop: 177 | eor x3, shift ;1 [0] reconstruct: x3 is 0 at bit locations we changed, 1 at others 178 | in x1, USBIN ;1 [1] <-- sample bit 0 179 | st y+, x3 ;2 [3] store data 180 | ser x3 ;1 [4] 181 | nop ;1 [5] 182 | eor x2, x1 ;1 [6] 183 | bst x2, USBMINUS;1 [7] 184 | bld shift, 0 ;1 [8] 185 | in x2, USBIN ;1 [9] <-- sample bit 1 (or possibly bit 0 stuffed) 186 | andi x2, USBMASK ;1 [10] 187 | breq se0 ;1 [11] SE0 check for bit 1 188 | andi shift, 0xf9 ;1 [12] 189 | didUnstuff0: 190 | breq unstuff0 ;1 [13] 191 | eor x1, x2 ;1 [14] 192 | bst x1, USBMINUS;1 [15] 193 | bld shift, 1 ;1 [16] 194 | rxbit2: 195 | in x1, USBIN ;1 [17] <-- sample bit 2 (or possibly bit 1 stuffed) 196 | andi shift, 0xf3 ;1 [18] 197 | breq unstuff1 ;1 [19] do remaining work for bit 1 198 | didUnstuff1: 199 | subi cnt, 1 ;1 [20] 200 | brcs overflow ;1 [21] loop control 201 | eor x2, x1 ;1 [22] 202 | bst x2, USBMINUS;1 [23] 203 | bld shift, 2 ;1 [24] 204 | in x2, USBIN ;1 [25] <-- sample bit 3 (or possibly bit 2 stuffed) 205 | andi shift, 0xe7 ;1 [26] 206 | breq unstuff2 ;1 [27] 207 | didUnstuff2: 208 | eor x1, x2 ;1 [28] 209 | bst x1, USBMINUS;1 [29] 210 | bld shift, 3 ;1 [30] 211 | didUnstuff3: 212 | andi shift, 0xcf ;1 [31] 213 | breq unstuff3 ;1 [32] 214 | in x1, USBIN ;1 [33] <-- sample bit 4 215 | eor x2, x1 ;1 [34] 216 | bst x2, USBMINUS;1 [35] 217 | bld shift, 4 ;1 [36] 218 | didUnstuff4: 219 | andi shift, 0x9f ;1 [37] 220 | breq unstuff4 ;1 [38] 221 | nop2 ;2 [40] 222 | in x2, USBIN ;1 [41] <-- sample bit 5 223 | eor x1, x2 ;1 [42] 224 | bst x1, USBMINUS;1 [43] 225 | bld shift, 5 ;1 [44] 226 | didUnstuff5: 227 | andi shift, 0x3f ;1 [45] 228 | breq unstuff5 ;1 [46] 229 | nop2 ;2 [48] 230 | in x1, USBIN ;1 [49] <-- sample bit 6 231 | eor x2, x1 ;1 [50] 232 | bst x2, USBMINUS;1 [51] 233 | bld shift, 6 ;1 [52] 234 | didUnstuff6: 235 | cpi shift, 0x02 ;1 [53] 236 | brlo unstuff6 ;1 [54] 237 | nop2 ;2 [56] 238 | in x2, USBIN ;1 [57] <-- sample bit 7 239 | eor x1, x2 ;1 [58] 240 | bst x1, USBMINUS;1 [59] 241 | bld shift, 7 ;1 [60] 242 | didUnstuff7: 243 | cpi shift, 0x04 ;1 [61] 244 | brsh rxLoop ;2 [63] loop control 245 | unstuff7: 246 | andi x3, ~0x80 ;1 [63] 247 | ori shift, 0x80 ;1 [64] 248 | in x2, USBIN ;1 [65] <-- sample stuffed bit 7 249 | nop ;1 [66] 250 | rjmp didUnstuff7 ;2 [68] 251 | 252 | macro POP_STANDARD ; 12 cycles 253 | pop cnt 254 | pop x3 255 | pop x2 256 | pop x1 257 | pop shift 258 | pop YH 259 | endm 260 | macro POP_RETI ; 5 cycles 261 | pop YL 262 | out SREG, YL 263 | pop YL 264 | endm 265 | 266 | #include "asmcommon.inc" 267 | 268 | ;---------------------------------------------------------------------------- 269 | ; Transmitting data 270 | ;---------------------------------------------------------------------------- 271 | 272 | txByteLoop: 273 | txBitloop: 274 | stuffN1Delay: ; [03] 275 | ror shift ;[-5] [11] [59] 276 | brcc doExorN1 ;[-4] [60] 277 | subi x4, 1 ;[-3] 278 | brne commonN1 ;[-2] 279 | lsl shift ;[-1] compensate ror after rjmp stuffDelay 280 | nop ;[00] stuffing consists of just waiting 8 cycles 281 | rjmp stuffN1Delay ;[01] after ror, C bit is reliably clear 282 | 283 | sendNakAndReti: ;0 [-19] 19 cycles until SOP 284 | ldi x3, USBPID_NAK ;1 [-18] 285 | rjmp usbSendX3 ;2 [-16] 286 | sendAckAndReti: ;0 [-19] 19 cycles until SOP 287 | ldi x3, USBPID_ACK ;1 [-18] 288 | rjmp usbSendX3 ;2 [-16] 289 | sendCntAndReti: ;0 [-17] 17 cycles until SOP 290 | mov x3, cnt ;1 [-16] 291 | usbSendX3: ;0 [-16] 292 | ldi YL, 20 ;1 [-15] 'x3' is R20 293 | ldi YH, 0 ;1 [-14] 294 | ldi cnt, 2 ;1 [-13] 295 | ; rjmp usbSendAndReti fallthrough 296 | 297 | ; USB spec says: 298 | ; idle = J 299 | ; J = (D+ = 0), (D- = 1) or USBOUT = 0x01 300 | ; K = (D+ = 1), (D- = 0) or USBOUT = 0x02 301 | ; Spec allows 7.5 bit times from EOP to SOP for replies (= 60 cycles) 302 | 303 | ;usbSend: 304 | ;pointer to data in 'Y' 305 | ;number of bytes in 'cnt' -- including sync byte 306 | ;uses: x1...x2, x4, shift, cnt, Y [x1 = mirror USBOUT, x2 = USBMASK, x4 = bitstuff cnt] 307 | ;Numbers in brackets are time since first bit of sync pattern is sent (start of instruction) 308 | usbSendAndReti: 309 | in x2, USBDDR ;[-12] 12 cycles until SOP 310 | ori x2, USBMASK ;[-11] 311 | sbi USBOUT, USBMINUS ;[-10] prepare idle state; D+ and D- must have been 0 (no pullups) 312 | out USBDDR, x2 ;[-8] <--- acquire bus 313 | in x1, USBOUT ;[-7] port mirror for tx loop 314 | ldi shift, 0x40 ;[-6] sync byte is first byte sent (we enter loop after ror) 315 | ldi x2, USBMASK ;[-5] 316 | push x4 ;[-4] 317 | doExorN1: 318 | eor x1, x2 ;[-2] [06] [62] 319 | ldi x4, 6 ;[-1] [07] [63] 320 | commonN1: 321 | stuffN2Delay: 322 | out USBOUT, x1 ;[00] [08] [64] <--- set bit 323 | ror shift ;[01] 324 | brcc doExorN2 ;[02] 325 | subi x4, 1 ;[03] 326 | brne commonN2 ;[04] 327 | lsl shift ;[05] compensate ror after rjmp stuffDelay 328 | rjmp stuffN2Delay ;[06] after ror, C bit is reliably clear 329 | doExorN2: 330 | eor x1, x2 ;[04] [12] 331 | ldi x4, 6 ;[05] [13] 332 | commonN2: 333 | nop ;[06] [14] 334 | subi cnt, 171 ;[07] [15] trick: (3 * 171) & 0xff = 1 335 | out USBOUT, x1 ;[08] [16] <--- set bit 336 | brcs txBitloop ;[09] [25] [41] 337 | 338 | stuff6Delay: 339 | ror shift ;[42] [50] 340 | brcc doExor6 ;[43] 341 | subi x4, 1 ;[44] 342 | brne common6 ;[45] 343 | lsl shift ;[46] compensate ror after rjmp stuffDelay 344 | nop ;[47] stuffing consists of just waiting 8 cycles 345 | rjmp stuff6Delay ;[48] after ror, C bit is reliably clear 346 | doExor6: 347 | eor x1, x2 ;[45] [53] 348 | ldi x4, 6 ;[46] 349 | common6: 350 | stuff7Delay: 351 | ror shift ;[47] [55] 352 | out USBOUT, x1 ;[48] <--- set bit 353 | brcc doExor7 ;[49] 354 | subi x4, 1 ;[50] 355 | brne common7 ;[51] 356 | lsl shift ;[52] compensate ror after rjmp stuffDelay 357 | rjmp stuff7Delay ;[53] after ror, C bit is reliably clear 358 | doExor7: 359 | eor x1, x2 ;[51] [59] 360 | ldi x4, 6 ;[52] 361 | common7: 362 | ld shift, y+ ;[53] 363 | tst cnt ;[55] 364 | out USBOUT, x1 ;[56] <--- set bit 365 | brne txByteLoop ;[57] 366 | 367 | ;make SE0: 368 | cbr x1, USBMASK ;[58] prepare SE0 [spec says EOP may be 15 to 18 cycles] 369 | lds x2, usbNewDeviceAddr;[59] 370 | lsl x2 ;[61] we compare with left shifted address 371 | subi YL, 2 + 20 ;[62] Only assign address on data packets, not ACK/NAK in x3 372 | sbci YH, 0 ;[63] 373 | out USBOUT, x1 ;[00] <-- out SE0 -- from now 2 bits = 16 cycles until bus idle 374 | ;2006-03-06: moved transfer of new address to usbDeviceAddr from C-Code to asm: 375 | ;set address only after data packet was sent, not after handshake 376 | breq skipAddrAssign ;[01] 377 | sts usbDeviceAddr, x2 ; if not skipped: SE0 is one cycle longer 378 | skipAddrAssign: 379 | ;end of usbDeviceAddress transfer 380 | ldi x2, 1< 10.6666666 cycles per bit, 85.333333333 cycles per byte 30 | ; Numbers in brackets are clocks counted from center of last sync bit 31 | ; when instruction starts 32 | 33 | USB_INTR_VECTOR: 34 | ;order of registers pushed: YL, SREG YH, [sofError], bitcnt, shift, x1, x2, x3, x4, cnt 35 | push YL ;[-25] push only what is necessary to sync with edge ASAP 36 | in YL, SREG ;[-23] 37 | push YL ;[-22] 38 | push YH ;[-20] 39 | ;---------------------------------------------------------------------------- 40 | ; Synchronize with sync pattern: 41 | ;---------------------------------------------------------------------------- 42 | ;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] 43 | ;sync up with J to K edge during sync pattern -- use fastest possible loops 44 | ;The first part waits at most 1 bit long since we must be in sync pattern. 45 | ;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to 46 | ;waitForJ, ensure that this prerequisite is met. 47 | waitForJ: 48 | inc YL 49 | sbis USBIN, USBMINUS 50 | brne waitForJ ; just make sure we have ANY timeout 51 | waitForK: 52 | ;The following code results in a sampling window of < 1/4 bit which meets the spec. 53 | sbis USBIN, USBMINUS ;[-15] 54 | rjmp foundK ;[-14] 55 | sbis USBIN, USBMINUS 56 | rjmp foundK 57 | sbis USBIN, USBMINUS 58 | rjmp foundK 59 | sbis USBIN, USBMINUS 60 | rjmp foundK 61 | sbis USBIN, USBMINUS 62 | rjmp foundK 63 | sbis USBIN, USBMINUS 64 | rjmp foundK 65 | #if USB_COUNT_SOF 66 | lds YL, usbSofCount 67 | inc YL 68 | sts usbSofCount, YL 69 | #endif /* USB_COUNT_SOF */ 70 | #ifdef USB_SOF_HOOK 71 | USB_SOF_HOOK 72 | #endif 73 | rjmp sofError 74 | foundK: ;[-12] 75 | ;{3, 5} after falling D- edge, average delay: 4 cycles [we want 5 for center sampling] 76 | ;we have 1 bit time for setup purposes, then sample again. Numbers in brackets 77 | ;are cycles from center of first sync (double K) bit after the instruction 78 | push bitcnt ;[-12] 79 | ; [---] ;[-11] 80 | lds YL, usbInputBufOffset;[-10] 81 | ; [---] ;[-9] 82 | clr YH ;[-8] 83 | subi YL, lo8(-(usbRxBuf));[-7] [rx loop init] 84 | sbci YH, hi8(-(usbRxBuf));[-6] [rx loop init] 85 | push shift ;[-5] 86 | ; [---] ;[-4] 87 | ldi bitcnt, 0x55 ;[-3] [rx loop init] 88 | sbis USBIN, USBMINUS ;[-2] we want two bits K (sample 2 cycles too early) 89 | rjmp haveTwoBitsK ;[-1] 90 | pop shift ;[0] undo the push from before 91 | pop bitcnt ;[2] undo the push from before 92 | rjmp waitForK ;[4] this was not the end of sync, retry 93 | ; The entire loop from waitForK until rjmp waitForK above must not exceed two 94 | ; bit times (= 21 cycles). 95 | 96 | ;---------------------------------------------------------------------------- 97 | ; push more registers and initialize values while we sample the first bits: 98 | ;---------------------------------------------------------------------------- 99 | haveTwoBitsK: 100 | push x1 ;[1] 101 | push x2 ;[3] 102 | push x3 ;[5] 103 | ldi shift, 0 ;[7] 104 | ldi x3, 1<<4 ;[8] [rx loop init] first sample is inverse bit, compensate that 105 | push x4 ;[9] == leap 106 | 107 | in x1, USBIN ;[11] <-- sample bit 0 108 | andi x1, USBMASK ;[12] 109 | bst x1, USBMINUS ;[13] 110 | bld shift, 7 ;[14] 111 | push cnt ;[15] 112 | ldi leap, 0 ;[17] [rx loop init] 113 | ldi cnt, USB_BUFSIZE;[18] [rx loop init] 114 | rjmp rxbit1 ;[19] arrives at [21] 115 | 116 | ;---------------------------------------------------------------------------- 117 | ; Receiver loop (numbers in brackets are cycles within byte after instr) 118 | ;---------------------------------------------------------------------------- 119 | 120 | ; duration of unstuffing code should be 10.66666667 cycles. We adjust "leap" 121 | ; accordingly to approximate this value in the long run. 122 | 123 | unstuff6: 124 | andi x2, USBMASK ;[03] 125 | ori x3, 1<<6 ;[04] will not be shifted any more 126 | andi shift, ~0x80;[05] 127 | mov x1, x2 ;[06] sampled bit 7 is actually re-sampled bit 6 128 | subi leap, -1 ;[07] total duration = 11 bits -> subtract 1/3 129 | rjmp didUnstuff6 ;[08] 130 | 131 | unstuff7: 132 | ori x3, 1<<7 ;[09] will not be shifted any more 133 | in x2, USBIN ;[00] [10] re-sample bit 7 134 | andi x2, USBMASK ;[01] 135 | andi shift, ~0x80;[02] 136 | subi leap, 2 ;[03] total duration = 10 bits -> add 1/3 137 | rjmp didUnstuff7 ;[04] 138 | 139 | unstuffEven: 140 | ori x3, 1<<6 ;[09] will be shifted right 6 times for bit 0 141 | in x1, USBIN ;[00] [10] 142 | andi shift, ~0x80;[01] 143 | andi x1, USBMASK ;[02] 144 | breq se0 ;[03] 145 | subi leap, -1 ;[04] total duration = 11 bits -> subtract 1/3 146 | nop2 ;[05] 147 | rjmp didUnstuffE ;[06] 148 | 149 | unstuffOdd: 150 | ori x3, 1<<5 ;[09] will be shifted right 4 times for bit 1 151 | in x2, USBIN ;[00] [10] 152 | andi shift, ~0x80;[01] 153 | andi x2, USBMASK ;[02] 154 | breq se0 ;[03] 155 | subi leap, -1 ;[04] total duration = 11 bits -> subtract 1/3 156 | nop2 ;[05] 157 | rjmp didUnstuffO ;[06] 158 | 159 | rxByteLoop: 160 | andi x1, USBMASK ;[03] 161 | eor x2, x1 ;[04] 162 | subi leap, 1 ;[05] 163 | brpl skipLeap ;[06] 164 | subi leap, -3 ;1 one leap cycle every 3rd byte -> 85 + 1/3 cycles per byte 165 | nop ;1 166 | skipLeap: 167 | subi x2, 1 ;[08] 168 | ror shift ;[09] 169 | didUnstuff6: 170 | cpi shift, 0xfc ;[10] 171 | in x2, USBIN ;[00] [11] <-- sample bit 7 172 | brcc unstuff6 ;[01] 173 | andi x2, USBMASK ;[02] 174 | eor x1, x2 ;[03] 175 | subi x1, 1 ;[04] 176 | ror shift ;[05] 177 | didUnstuff7: 178 | cpi shift, 0xfc ;[06] 179 | brcc unstuff7 ;[07] 180 | eor x3, shift ;[08] reconstruct: x3 is 1 at bit locations we changed, 0 at others 181 | st y+, x3 ;[09] store data 182 | rxBitLoop: 183 | in x1, USBIN ;[00] [11] <-- sample bit 0/2/4 184 | andi x1, USBMASK ;[01] 185 | eor x2, x1 ;[02] 186 | andi x3, 0x3f ;[03] topmost two bits reserved for 6 and 7 187 | subi x2, 1 ;[04] 188 | ror shift ;[05] 189 | cpi shift, 0xfc ;[06] 190 | brcc unstuffEven ;[07] 191 | didUnstuffE: 192 | lsr x3 ;[08] 193 | lsr x3 ;[09] 194 | rxbit1: 195 | in x2, USBIN ;[00] [10] <-- sample bit 1/3/5 196 | andi x2, USBMASK ;[01] 197 | breq se0 ;[02] 198 | eor x1, x2 ;[03] 199 | subi x1, 1 ;[04] 200 | ror shift ;[05] 201 | cpi shift, 0xfc ;[06] 202 | brcc unstuffOdd ;[07] 203 | didUnstuffO: 204 | subi bitcnt, 0xab;[08] == addi 0x55, 0x55 = 0x100/3 205 | brcs rxBitLoop ;[09] 206 | 207 | subi cnt, 1 ;[10] 208 | in x1, USBIN ;[00] [11] <-- sample bit 6 209 | brcc rxByteLoop ;[01] 210 | rjmp overflow 211 | 212 | macro POP_STANDARD ; 14 cycles 213 | pop cnt 214 | pop x4 215 | pop x3 216 | pop x2 217 | pop x1 218 | pop shift 219 | pop bitcnt 220 | endm 221 | macro POP_RETI ; 7 cycles 222 | pop YH 223 | pop YL 224 | out SREG, YL 225 | pop YL 226 | endm 227 | 228 | #include "asmcommon.inc" 229 | 230 | ; USB spec says: 231 | ; idle = J 232 | ; J = (D+ = 0), (D- = 1) 233 | ; K = (D+ = 1), (D- = 0) 234 | ; Spec allows 7.5 bit times from EOP to SOP for replies 235 | 236 | bitstuffN: 237 | eor x1, x4 ;[5] 238 | ldi x2, 0 ;[6] 239 | nop2 ;[7] 240 | nop ;[9] 241 | out USBOUT, x1 ;[10] <-- out 242 | rjmp didStuffN ;[0] 243 | 244 | bitstuff6: 245 | eor x1, x4 ;[5] 246 | ldi x2, 0 ;[6] Carry is zero due to brcc 247 | rol shift ;[7] compensate for ror shift at branch destination 248 | rjmp didStuff6 ;[8] 249 | 250 | bitstuff7: 251 | ldi x2, 0 ;[2] Carry is zero due to brcc 252 | rjmp didStuff7 ;[3] 253 | 254 | 255 | sendNakAndReti: 256 | ldi x3, USBPID_NAK ;[-18] 257 | rjmp sendX3AndReti ;[-17] 258 | sendAckAndReti: 259 | ldi cnt, USBPID_ACK ;[-17] 260 | sendCntAndReti: 261 | mov x3, cnt ;[-16] 262 | sendX3AndReti: 263 | ldi YL, 20 ;[-15] x3==r20 address is 20 264 | ldi YH, 0 ;[-14] 265 | ldi cnt, 2 ;[-13] 266 | ; rjmp usbSendAndReti fallthrough 267 | 268 | ;usbSend: 269 | ;pointer to data in 'Y' 270 | ;number of bytes in 'cnt' -- including sync byte [range 2 ... 12] 271 | ;uses: x1...x4, btcnt, shift, cnt, Y 272 | ;Numbers in brackets are time since first bit of sync pattern is sent 273 | ;We don't match the transfer rate exactly (don't insert leap cycles every third 274 | ;byte) because the spec demands only 1.5% precision anyway. 275 | usbSendAndReti: ; 12 cycles until SOP 276 | in x2, USBDDR ;[-12] 277 | ori x2, USBMASK ;[-11] 278 | sbi USBOUT, USBMINUS;[-10] prepare idle state; D+ and D- must have been 0 (no pullups) 279 | in x1, USBOUT ;[-8] port mirror for tx loop 280 | out USBDDR, x2 ;[-7] <- acquire bus 281 | ; need not init x2 (bitstuff history) because sync starts with 0 282 | ldi x4, USBMASK ;[-6] exor mask 283 | ldi shift, 0x80 ;[-5] sync byte is first byte sent 284 | txByteLoop: 285 | ldi bitcnt, 0x35 ;[-4] [6] binary 0011 0101 286 | txBitLoop: 287 | sbrs shift, 0 ;[-3] [7] 288 | eor x1, x4 ;[-2] [8] 289 | out USBOUT, x1 ;[-1] [9] <-- out N 290 | ror shift ;[0] [10] 291 | ror x2 ;[1] 292 | didStuffN: 293 | cpi x2, 0xfc ;[2] 294 | brcc bitstuffN ;[3] 295 | lsr bitcnt ;[4] 296 | brcc txBitLoop ;[5] 297 | brne txBitLoop ;[6] 298 | 299 | sbrs shift, 0 ;[7] 300 | eor x1, x4 ;[8] 301 | didStuff6: 302 | out USBOUT, x1 ;[-1] [9] <-- out 6 303 | ror shift ;[0] [10] 304 | ror x2 ;[1] 305 | cpi x2, 0xfc ;[2] 306 | brcc bitstuff6 ;[3] 307 | ror shift ;[4] 308 | didStuff7: 309 | ror x2 ;[5] 310 | sbrs x2, 7 ;[6] 311 | eor x1, x4 ;[7] 312 | nop ;[8] 313 | cpi x2, 0xfc ;[9] 314 | out USBOUT, x1 ;[-1][10] <-- out 7 315 | brcc bitstuff7 ;[0] [11] 316 | ld shift, y+ ;[1] 317 | dec cnt ;[3] 318 | brne txByteLoop ;[4] 319 | ;make SE0: 320 | cbr x1, USBMASK ;[5] prepare SE0 [spec says EOP may be 21 to 25 cycles] 321 | lds x2, usbNewDeviceAddr;[6] 322 | lsl x2 ;[8] we compare with left shifted address 323 | subi YL, 20 + 2 ;[9] Only assign address on data packets, not ACK/NAK in x3 324 | sbci YH, 0 ;[10] 325 | out USBOUT, x1 ;[11] <-- out SE0 -- from now 2 bits = 22 cycles until bus idle 326 | ;2006-03-06: moved transfer of new address to usbDeviceAddr from C-Code to asm: 327 | ;set address only after data packet was sent, not after handshake 328 | breq skipAddrAssign ;[0] 329 | sts usbDeviceAddr, x2; if not skipped: SE0 is one cycle longer 330 | skipAddrAssign: 331 | ;end of usbDeviceAddress transfer 332 | ldi x2, 1< 13.333333 cycles per bit, 106.666667 cycles per byte 38 | ; Numbers in brackets are clocks counted from center of last sync bit 39 | ; when instruction starts 40 | ;register use in receive loop: 41 | ; shift assembles the byte currently being received 42 | ; x1 holds the D+ and D- line state 43 | ; x2 holds the previous line state 44 | ; x4 (leap) is used to add a leap cycle once every three bytes received 45 | ; X3 (leap2) is used to add a leap cycle once every three stuff bits received 46 | ; bitcnt is used to determine when a stuff bit is due 47 | ; cnt holds the number of bytes left in the receive buffer 48 | 49 | USB_INTR_VECTOR: 50 | ;order of registers pushed: YL, SREG YH, [sofError], bitcnt, shift, x1, x2, x3, x4, cnt 51 | push YL ;[-28] push only what is necessary to sync with edge ASAP 52 | in YL, SREG ;[-26] 53 | push YL ;[-25] 54 | push YH ;[-23] 55 | ;---------------------------------------------------------------------------- 56 | ; Synchronize with sync pattern: 57 | ;---------------------------------------------------------------------------- 58 | ;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] 59 | ;sync up with J to K edge during sync pattern -- use fastest possible loops 60 | ;The first part waits at most 1 bit long since we must be in sync pattern. 61 | ;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to 62 | ;waitForJ, ensure that this prerequisite is met. 63 | waitForJ: 64 | inc YL 65 | sbis USBIN, USBMINUS 66 | brne waitForJ ; just make sure we have ANY timeout 67 | waitForK: 68 | ;The following code results in a sampling window of < 1/4 bit which meets the spec. 69 | sbis USBIN, USBMINUS ;[-19] 70 | rjmp foundK ;[-18] 71 | sbis USBIN, USBMINUS 72 | rjmp foundK 73 | sbis USBIN, USBMINUS 74 | rjmp foundK 75 | sbis USBIN, USBMINUS 76 | rjmp foundK 77 | sbis USBIN, USBMINUS 78 | rjmp foundK 79 | sbis USBIN, USBMINUS 80 | rjmp foundK 81 | sbis USBIN, USBMINUS 82 | rjmp foundK 83 | sbis USBIN, USBMINUS 84 | rjmp foundK 85 | sbis USBIN, USBMINUS 86 | rjmp foundK 87 | #if USB_COUNT_SOF 88 | lds YL, usbSofCount 89 | inc YL 90 | sts usbSofCount, YL 91 | #endif /* USB_COUNT_SOF */ 92 | #ifdef USB_SOF_HOOK 93 | USB_SOF_HOOK 94 | #endif 95 | rjmp sofError 96 | foundK: ;[-16] 97 | ;{3, 5} after falling D- edge, average delay: 4 cycles 98 | ;bit0 should be at 34 for center sampling. Currently at 4 so 30 cylces till bit 0 sample 99 | ;use 1 bit time for setup purposes, then sample again. Numbers in brackets 100 | ;are cycles from center of first sync (double K) bit after the instruction 101 | push bitcnt ;[-16] 102 | ; [---] ;[-15] 103 | lds YL, usbInputBufOffset;[-14] 104 | ; [---] ;[-13] 105 | clr YH ;[-12] 106 | subi YL, lo8(-(usbRxBuf));[-11] [rx loop init] 107 | sbci YH, hi8(-(usbRxBuf));[-10] [rx loop init] 108 | push shift ;[-9] 109 | ; [---] ;[-8] 110 | ldi shift,0x40 ;[-7] set msb to "1" so processing bit7 can be detected 111 | nop2 ;[-6] 112 | ; [---] ;[-5] 113 | ldi bitcnt, 5 ;[-4] [rx loop init] 114 | sbis USBIN, USBMINUS ;[-3] we want two bits K (sample 3 cycles too early) 115 | rjmp haveTwoBitsK ;[-2] 116 | pop shift ;[-1] undo the push from before 117 | pop bitcnt ;[1] 118 | rjmp waitForK ;[3] this was not the end of sync, retry 119 | ; The entire loop from waitForK until rjmp waitForK above must not exceed two 120 | ; bit times (= 27 cycles). 121 | 122 | ;---------------------------------------------------------------------------- 123 | ; push more registers and initialize values while we sample the first bits: 124 | ;---------------------------------------------------------------------------- 125 | haveTwoBitsK: 126 | push x1 ;[0] 127 | push x2 ;[2] 128 | push x3 ;[4] (leap2) 129 | ldi leap2, 0x55 ;[6] add leap cycle on 2nd,5th,8th,... stuff bit 130 | push x4 ;[7] == leap 131 | ldi leap, 0x55 ;[9] skip leap cycle on 2nd,5th,8th,... byte received 132 | push cnt ;[10] 133 | ldi cnt, USB_BUFSIZE ;[12] [rx loop init] 134 | ldi x2, 1< 39 | #ifndef __IAR_SYSTEMS_ASM__ 40 | # include 41 | #endif 42 | 43 | #define __attribute__(arg) /* not supported on IAR */ 44 | 45 | #ifdef __IAR_SYSTEMS_ASM__ 46 | # define __ASSEMBLER__ /* IAR does not define standard macro for asm */ 47 | #endif 48 | 49 | #ifdef __HAS_ELPM__ 50 | # define PROGMEM __farflash 51 | #else 52 | # define PROGMEM __flash 53 | #endif 54 | 55 | #define USB_READ_FLASH(addr) (*(PROGMEM char *)(addr)) 56 | 57 | /* The following definitions are not needed by the driver, but may be of some 58 | * help if you port a gcc based project to IAR. 59 | */ 60 | #define cli() __disable_interrupt() 61 | #define sei() __enable_interrupt() 62 | #define wdt_reset() __watchdog_reset() 63 | #define _BV(x) (1 << (x)) 64 | 65 | /* assembler compatibility macros */ 66 | #define nop2 rjmp $+2 /* jump to next instruction */ 67 | #define XL r26 68 | #define XH r27 69 | #define YL r28 70 | #define YH r29 71 | #define ZL r30 72 | #define ZH r31 73 | #define lo8(x) LOW(x) 74 | #define hi8(x) (((x)>>8) & 0xff) /* not HIGH to allow XLINK to make a proper range check */ 75 | 76 | /* Depending on the device you use, you may get problems with the way usbdrv.h 77 | * handles the differences between devices. Since IAR does not use #defines 78 | * for MCU registers, we can't check for the existence of a particular 79 | * register with an #ifdef. If the autodetection mechanism fails, include 80 | * definitions for the required USB_INTR_* macros in your usbconfig.h. See 81 | * usbconfig-prototype.h and usbdrv.h for details. 82 | */ 83 | 84 | /* ------------------------------------------------------------------------- */ 85 | #elif __CODEVISIONAVR__ /* check for CodeVision AVR */ 86 | /* ------------------------------------------------------------------------- */ 87 | /* This port is not working (yet) */ 88 | 89 | /* #define F_CPU _MCU_CLOCK_FREQUENCY_ seems to be defined automatically */ 90 | 91 | #include 92 | #include 93 | 94 | #define __attribute__(arg) /* not supported on IAR */ 95 | 96 | #define PROGMEM __flash 97 | #define USB_READ_FLASH(addr) (*(PROGMEM char *)(addr)) 98 | 99 | #ifndef __ASSEMBLER__ 100 | static inline void cli(void) 101 | { 102 | #asm("cli"); 103 | } 104 | static inline void sei(void) 105 | { 106 | #asm("sei"); 107 | } 108 | #endif 109 | #define _delay_ms(t) delay_ms(t) 110 | #define _BV(x) (1 << (x)) 111 | #define USB_CFG_USE_SWITCH_STATEMENT 1 /* macro for if() cascase fails for unknown reason */ 112 | 113 | #define macro .macro 114 | #define endm .endmacro 115 | #define nop2 rjmp .+0 /* jump to next instruction */ 116 | 117 | /* ------------------------------------------------------------------------- */ 118 | #else /* default development environment is avr-gcc/avr-libc */ 119 | /* ------------------------------------------------------------------------- */ 120 | 121 | #include 122 | #ifdef __ASSEMBLER__ 123 | # define _VECTOR(N) __vector_ ## N /* io.h does not define this for asm */ 124 | #else 125 | # include 126 | #endif 127 | 128 | #if USB_CFG_DRIVER_FLASH_PAGE 129 | # define USB_READ_FLASH(addr) pgm_read_byte_far(((long)USB_CFG_DRIVER_FLASH_PAGE << 16) | (long)(addr)) 130 | #else 131 | # define USB_READ_FLASH(addr) pgm_read_byte(addr) 132 | #endif 133 | 134 | #define macro .macro 135 | #define endm .endm 136 | #define nop2 rjmp .+0 /* jump to next instruction */ 137 | 138 | #endif /* development environment */ 139 | 140 | /* for conveniecne, ensure that PRG_RDB exists */ 141 | #ifndef PRG_RDB 142 | # define PRG_RDB(addr) USB_READ_FLASH(addr) 143 | #endif 144 | #endif /* __usbportability_h_INCLUDED__ */ 145 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CADMouse 2 | ======== 3 | 4 | fully 3D printable CAD-Mouse with host software for solidworks. 5 | 6 | CAD-Mouse is connected as Joystick. Windows host software translates Axis movements to Solidworks view translation commands. 7 | (Any standard joystick could be use) 8 | 9 | Thingiverse: http://www.thingiverse.com/thing:260830 10 | Warning : some parts have been upgraded, check latest version on github. 11 | 12 | ![](https://github.com/secures92/CADMouse/blob/master/Media/pics/version%200.2/2014-03-01%2014.11.54.jpg?raw=true) 13 | 14 | Video 15 | ------ 16 | New top spring and added translate / zoom : 17 | [![IMAGE ALT TEXT HERE](https://i.ytimg.com/vi/kaDWCsqc0LQ/maxresdefault.jpg)](http://youtu.be/kaDWCsqc0LQ) 18 | 19 | Original demo 20 | [![IMAGE ALT TEXT HERE](http://i1.ytimg.com/vi/4gp94MjgFCs/maxresdefault.jpg)](http://youtu.be/4gp94MjgFCs) 21 | -------------------------------------------------------------------------------- /SolidWorks/Version 0.1/3DMaus.SLDASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.1/3DMaus.SLDASM -------------------------------------------------------------------------------- /SolidWorks/Version 0.1/KnobBottom.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.1/KnobBottom.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.1/KnobTop.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.1/KnobTop.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.1/Render/render1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.1/Render/render1.png -------------------------------------------------------------------------------- /SolidWorks/Version 0.1/STL/KnobBottom.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.1/STL/KnobBottom.STL -------------------------------------------------------------------------------- /SolidWorks/Version 0.1/STL/KnobTop.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.1/STL/KnobTop.STL -------------------------------------------------------------------------------- /SolidWorks/Version 0.1/STL/bottom.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.1/STL/bottom.STL -------------------------------------------------------------------------------- /SolidWorks/Version 0.1/STL/case.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.1/STL/case.STL -------------------------------------------------------------------------------- /SolidWorks/Version 0.1/STL/connector.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.1/STL/connector.STL -------------------------------------------------------------------------------- /SolidWorks/Version 0.1/bottom.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.1/bottom.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.1/bottom_1.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.1/bottom_1.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.1/bottom_alt.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.1/bottom_alt.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.1/case.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.1/case.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.1/connector.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.1/connector.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.1/pcb/components.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.1/pcb/components.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.1/pcb/pcb.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.1/pcb/pcb.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/3d-mouse.SLDASM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/3d-mouse.SLDASM -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/base.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/base.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/case.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/case.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/knob_bottom.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/knob_bottom.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/knob_top.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/knob_top.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/plate_bottom.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/plate_bottom.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/poti_spring_wall.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/poti_spring_wall.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/poti_wall.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/poti_wall.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/rod-bow.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/rod-bow.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/rod.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/rod.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/spring_wall.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/spring_wall.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/stick.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/stick.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/stl/base.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/stl/base.STL -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/stl/case.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/stl/case.STL -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/stl/knob_bottom.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/stl/knob_bottom.STL -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/stl/knob_top.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/stl/knob_top.STL -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/stl/poti_wall.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/stl/poti_wall.STL -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/stl/rod-bow.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/stl/rod-bow.STL -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/stl/rod.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/stl/rod.STL -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/stl/spring_wall.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/stl/spring_wall.STL -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/stl/stick.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/stl/stick.STL -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/stl/top_spring.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/stl/top_spring.STL -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/top.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/top.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.2/top_spring.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.2/top_spring.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.3/stl/top_spring_2.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.3/stl/top_spring_2.STL -------------------------------------------------------------------------------- /SolidWorks/Version 0.3/top_spring_2.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.3/top_spring_2.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.4/stl/top_spring_3.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.4/stl/top_spring_3.STL -------------------------------------------------------------------------------- /SolidWorks/Version 0.4/top_spring_3.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/SolidWorks/Version 0.4/top_spring_3.SLDPRT -------------------------------------------------------------------------------- /SolidWorks/Version 0.4/top_spring_3_instruction.txt: -------------------------------------------------------------------------------- 1 | This new spring is to be use without knob bottom. -------------------------------------------------------------------------------- /Windows/3DMouseTranslator/3DMouseTranslator.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2012 for Windows Desktop 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "3DMouseTranslator", "3DMouseTranslator\3DMouseTranslator.csproj", "{F0D373A8-7D3D-414A-A3FF-886CAD15EF23}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {F0D373A8-7D3D-414A-A3FF-886CAD15EF23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {F0D373A8-7D3D-414A-A3FF-886CAD15EF23}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {F0D373A8-7D3D-414A-A3FF-886CAD15EF23}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {F0D373A8-7D3D-414A-A3FF-886CAD15EF23}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /Windows/3DMouseTranslator/3DMouseTranslator/3DMouseTranslator.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {F0D373A8-7D3D-414A-A3FF-886CAD15EF23} 8 | WinExe 9 | Properties 10 | _3DMouseTranslator 11 | 3DMouseTranslator 12 | v4.0 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | False 37 | ..\..\..\..\..\..\..\Program Files (x86)\SlimDX SDK (January 2012)\Bin\net40\x64\SlimDX.dll 38 | 39 | 40 | E:\outils\Nouveau dossier\SolidWorks\SolidWorks.Interop.sldworks.dll 41 | True 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | Form 57 | 58 | 59 | Form1.cs 60 | 61 | 62 | 63 | 64 | 65 | Form1.cs 66 | 67 | 68 | ResXFileCodeGenerator 69 | Resources.Designer.cs 70 | Designer 71 | 72 | 73 | True 74 | Resources.resx 75 | 76 | 77 | SettingsSingleFileGenerator 78 | Settings.Designer.cs 79 | 80 | 81 | True 82 | Settings.settings 83 | True 84 | 85 | 86 | 87 | 94 | -------------------------------------------------------------------------------- /Windows/3DMouseTranslator/3DMouseTranslator/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace _3DMouseTranslator 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// Erforderliche Designervariable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Verwendete Ressourcen bereinigen. 12 | /// 13 | /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Vom Windows Form-Designer generierter Code 24 | 25 | /// 26 | /// Erforderliche Methode für die Designerunterstützung. 27 | /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | this.button1 = new System.Windows.Forms.Button(); 33 | this.timer1 = new System.Windows.Forms.Timer(this.components); 34 | this.label1 = new System.Windows.Forms.Label(); 35 | this.timer2 = new System.Windows.Forms.Timer(this.components); 36 | this.label2 = new System.Windows.Forms.Label(); 37 | this.cb_threshold = new System.Windows.Forms.ComboBox(); 38 | this.label3 = new System.Windows.Forms.Label(); 39 | this.tb_sensivity = new System.Windows.Forms.TrackBar(); 40 | this.label4 = new System.Windows.Forms.Label(); 41 | ((System.ComponentModel.ISupportInitialize)(this.tb_sensivity)).BeginInit(); 42 | this.SuspendLayout(); 43 | // 44 | // button1 45 | // 46 | this.button1.Location = new System.Drawing.Point(183, 12); 47 | this.button1.Name = "button1"; 48 | this.button1.Size = new System.Drawing.Size(89, 23); 49 | this.button1.TabIndex = 0; 50 | this.button1.Text = "Calibrate"; 51 | this.button1.UseVisualStyleBackColor = true; 52 | this.button1.Click += new System.EventHandler(this.button1_Click); 53 | // 54 | // timer1 55 | // 56 | this.timer1.Enabled = false; 57 | this.timer1.Interval = 15; 58 | this.timer1.Tick += new System.EventHandler(this.timer1_Tick); 59 | // 60 | // label1 61 | // 62 | this.label1.AutoSize = true; 63 | this.label1.Location = new System.Drawing.Point(12, 17); 64 | this.label1.Name = "label1"; 65 | this.label1.Size = new System.Drawing.Size(34, 13); 66 | this.label1.TabIndex = 1; 67 | this.label1.Text = "X Y Z"; 68 | // 69 | // timer2 70 | // 71 | this.timer2.Enabled = false; 72 | this.timer2.Interval = 500; 73 | this.timer2.Tick += new System.EventHandler(this.timer2_Tick); 74 | // 75 | // label2 76 | // 77 | this.label2.AutoSize = true; 78 | this.label2.Location = new System.Drawing.Point(12, 58); 79 | this.label2.Name = "label2"; 80 | this.label2.Size = new System.Drawing.Size(54, 13); 81 | this.label2.TabIndex = 4; 82 | this.label2.Text = "Threshold"; 83 | // 84 | // cb_threshold 85 | // 86 | this.cb_threshold.FormattingEnabled = true; 87 | this.cb_threshold.Items.AddRange(new object[] { 88 | "2", 89 | "5", 90 | "10", 91 | "15", 92 | "20", 93 | "25"}); 94 | this.cb_threshold.Location = new System.Drawing.Point(72, 58); 95 | this.cb_threshold.Name = "cb_threshold"; 96 | this.cb_threshold.Size = new System.Drawing.Size(53, 21); 97 | this.cb_threshold.TabIndex = 5; 98 | this.cb_threshold.Text = "5"; 99 | this.cb_threshold.SelectedIndexChanged += new System.EventHandler(this.cb_threshold_SelectedIndexChanged); 100 | // 101 | // label3 102 | // 103 | this.label3.AutoSize = true; 104 | this.label3.Location = new System.Drawing.Point(12, 157); 105 | this.label3.Name = "label3"; 106 | this.label3.Size = new System.Drawing.Size(220, 13); 107 | this.label3.TabIndex = 6; 108 | this.label3.Text = "Help : bouton 1 to zoom bouton 2 to translate"; 109 | // 110 | // tb_sensivity 111 | // 112 | this.tb_sensivity.Location = new System.Drawing.Point(15, 98); 113 | this.tb_sensivity.Maximum = 50; 114 | this.tb_sensivity.Minimum = 5; 115 | this.tb_sensivity.Name = "tb_sensivity"; 116 | this.tb_sensivity.Size = new System.Drawing.Size(257, 45); 117 | this.tb_sensivity.TabIndex = 7; 118 | this.tb_sensivity.Value = 12; 119 | this.tb_sensivity.Scroll += new System.EventHandler(this.tb_sensivity_Scroll); 120 | // 121 | // label4 122 | // 123 | this.label4.AutoSize = true; 124 | this.label4.Location = new System.Drawing.Point(17, 82); 125 | this.label4.Name = "label4"; 126 | this.label4.Size = new System.Drawing.Size(49, 13); 127 | this.label4.TabIndex = 8; 128 | this.label4.Text = "Sensivity"; 129 | // 130 | // Form1 131 | // 132 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 133 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 134 | this.ClientSize = new System.Drawing.Size(284, 179); 135 | this.Controls.Add(this.label4); 136 | this.Controls.Add(this.tb_sensivity); 137 | this.Controls.Add(this.label3); 138 | this.Controls.Add(this.cb_threshold); 139 | this.Controls.Add(this.label2); 140 | this.Controls.Add(this.label1); 141 | this.Controls.Add(this.button1); 142 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 143 | this.MaximizeBox = false; 144 | this.Name = "Form1"; 145 | this.Text = "SWControl"; 146 | this.Load += new System.EventHandler(this.Form1_Load); 147 | ((System.ComponentModel.ISupportInitialize)(this.tb_sensivity)).EndInit(); 148 | this.ResumeLayout(false); 149 | this.PerformLayout(); 150 | 151 | } 152 | 153 | #endregion 154 | 155 | private System.Windows.Forms.Button button1; 156 | private System.Windows.Forms.Timer timer1; 157 | private System.Windows.Forms.Label label1; 158 | private System.Windows.Forms.Timer timer2; 159 | private System.Windows.Forms.Label label2; 160 | private System.Windows.Forms.ComboBox cb_threshold; 161 | private System.Windows.Forms.Label label3; 162 | private System.Windows.Forms.TrackBar tb_sensivity; 163 | private System.Windows.Forms.Label label4; 164 | } 165 | } 166 | 167 | -------------------------------------------------------------------------------- /Windows/3DMouseTranslator/3DMouseTranslator/Form1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using SolidWorks.Interop.sldworks; 10 | using SlimDX.DirectInput; 11 | 12 | namespace _3DMouseTranslator 13 | { 14 | public partial class Form1 : Form 15 | { 16 | public Form1() 17 | { 18 | InitializeComponent(); 19 | } 20 | private Type swType; 21 | private SldWorks app; 22 | private ModelView modelView; 23 | private ModelDoc2 swModel; 24 | 25 | private SimpleJoystick sJoy; 26 | private JoystickState jState; 27 | 28 | private double factor = 0.0012; 29 | private int calY = 0, calX = 0, calZ = 0; 30 | private int threshold = 5; 31 | 32 | private void Form1_Load(object sender, EventArgs e) 33 | { 34 | try 35 | { 36 | sJoy = new SimpleJoystick(); 37 | } 38 | catch (Exception error_init) 39 | { 40 | MessageBox.Show(null, error_init.ToString(), "Init error"); 41 | Application.Exit(); 42 | } 43 | swType = Type.GetTypeFromProgID("SldWorks.Application"); //SldWorks.Application.21 pour le 2013 44 | app = (SldWorks)Activator.CreateInstance(swType); 45 | if (app != null) 46 | { 47 | app.Visible = true; 48 | timer2.Enabled = true; 49 | } 50 | else 51 | { 52 | MessageBox.Show(null, "No SolidWork detected", "Init error"); 53 | Application.Exit(); 54 | } 55 | } 56 | 57 | private void button1_Click(object sender, EventArgs e) 58 | { 59 | jState = sJoy.State; 60 | calX = jState.X; 61 | calY = jState.Y; 62 | calZ = jState.Z; 63 | } 64 | 65 | private void timer1_Tick(object sender, EventArgs e) 66 | { 67 | jState = sJoy.State; 68 | double angX = 0; 69 | double angY = 0; 70 | double angZ = 0; 71 | bool[] Jbuttons = jState.GetButtons(); 72 | 73 | if (Math.Abs(jState.X-calX) > threshold) 74 | { 75 | angX = ((int)(jState.X - calX - (Math.Sign(jState.X)*5))) * (Math.PI / 6) * factor; 76 | } 77 | if (Math.Abs(jState.Y-calY) > threshold) 78 | { 79 | angY = ((int)(jState.Y - calY - (Math.Sign(jState.X)*5))) * (Math.PI / 6) * factor; 80 | } 81 | if (Math.Abs(jState.Z - calZ) > threshold) 82 | { 83 | angZ = ((int)(jState.Z - calZ - (Math.Sign(jState.Z) * 5))) * (Math.PI / 6) * factor; 84 | } 85 | if ((Math.Abs(jState.X-calX) > threshold) || (Math.Abs(jState.Y-calY) > threshold) || (Math.Abs(jState.Z-calZ) > threshold)) 86 | { 87 | label1.Text = "X=" + Math.Round(180 * angX / Math.PI, 3).ToString() + "°"; 88 | label1.Text += " Y=" + Math.Round(180 * angY / Math.PI, 3).ToString() + "°"; 89 | label1.Text += " Z=" + Math.Round(1 - angZ/4 ,3).ToString(); 90 | if ((angX != 0) || (angY != 0) || (angZ != 0)) 91 | { 92 | if (Jbuttons[1]) //translate 93 | { 94 | modelView.TranslateBy(angX / 40, -angY / 40); 95 | } 96 | else if (Jbuttons[0]) //zoom 97 | { 98 | modelView.ZoomByFactor(1 - angY / 4); 99 | } 100 | else 101 | { 102 | modelView.RotateAboutCenter(angY, angX); 103 | modelView.RollBy(-angZ); 104 | } 105 | } 106 | } 107 | 108 | } 109 | 110 | private void timer2_Tick(object sender, EventArgs e) 111 | { 112 | try 113 | { 114 | swModel = ((ModelDoc2)(app.ActiveDoc)); 115 | modelView = (ModelView)swModel.ActiveView; 116 | } 117 | catch 118 | { 119 | timer1.Enabled = false; 120 | timer1.Stop(); 121 | label1.Text = "No Solidwork document open"; 122 | modelView = null; 123 | } 124 | if (modelView != null) 125 | { 126 | timer1.Enabled = true; 127 | } 128 | 129 | } 130 | 131 | private void cb_threshold_SelectedIndexChanged(object sender, EventArgs e) 132 | { 133 | threshold = int.Parse(cb_threshold.Text); 134 | } 135 | 136 | private void tb_sensivity_Scroll(object sender, EventArgs e) 137 | { 138 | factor = tb_sensivity.Value; 139 | factor = factor / 10000; 140 | } 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /Windows/3DMouseTranslator/3DMouseTranslator/Form1.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | 104, 17 125 | 126 | -------------------------------------------------------------------------------- /Windows/3DMouseTranslator/3DMouseTranslator/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | 6 | namespace _3DMouseTranslator 7 | { 8 | static class Program 9 | { 10 | /// 11 | /// Der Haupteinstiegspunkt für die Anwendung. 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | Application.EnableVisualStyles(); 17 | Application.SetCompatibleTextRenderingDefault(false); 18 | Application.Run(new Form1()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Windows/3DMouseTranslator/3DMouseTranslator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Allgemeine Informationen über eine Assembly werden über die folgenden 6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 7 | // die mit einer Assembly verknüpft sind. 8 | [assembly: AssemblyTitle("3DMouseTranslator")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("3DMouseTranslator")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar 18 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von 19 | // COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. 20 | [assembly: ComVisible(false)] 21 | 22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 23 | [assembly: Guid("cd5b986a-0203-45f3-8fdc-d527adfec886")] 24 | 25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 26 | // 27 | // Hauptversion 28 | // Nebenversion 29 | // Buildnummer 30 | // Revision 31 | // 32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern 33 | // übernehmen, indem Sie "*" eingeben: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Windows/3DMouseTranslator/3DMouseTranslator/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Dieser Code wurde von einem Tool generiert. 4 | // Laufzeitversion:4.0.30319.34011 5 | // 6 | // Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn 7 | // der Code neu generiert wird. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace _3DMouseTranslator.Properties 12 | { 13 | 14 | 15 | /// 16 | /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. 17 | /// 18 | // Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse 19 | // über ein Tool wie ResGen oder Visual Studio automatisch generiert. 20 | // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen 21 | // mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("_3DMouseTranslator.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle 56 | /// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Windows/3DMouseTranslator/3DMouseTranslator/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Windows/3DMouseTranslator/3DMouseTranslator/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34011 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace _3DMouseTranslator.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Windows/3DMouseTranslator/3DMouseTranslator/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Windows/3DMouseTranslator/3DMouseTranslator/SimpleJoystick.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using SlimDX.DirectInput; 3 | 4 | namespace _3DMouseTranslator 5 | { 6 | class SimpleJoystick 7 | { 8 | /// 9 | /// Joystick handle 10 | /// 11 | private Joystick Joystick; 12 | 13 | /// 14 | /// Get the state of the joystick 15 | /// 16 | public JoystickState State 17 | { 18 | get 19 | { 20 | 21 | if (Joystick.Acquire().IsFailure) 22 | throw new Exception("Joystick failure"); 23 | 24 | if (Joystick.Poll().IsFailure) 25 | throw new Exception("Joystick failure"); 26 | 27 | return Joystick.GetCurrentState(); 28 | } 29 | } 30 | 31 | /// 32 | /// Construct, attach the joystick 33 | /// 34 | public SimpleJoystick() 35 | { 36 | DirectInput dinput = new DirectInput(); 37 | 38 | // Search for device 39 | foreach (DeviceInstance device in dinput.GetDevices(DeviceClass.GameController, DeviceEnumerationFlags.AttachedOnly)) 40 | { 41 | // Create device 42 | try 43 | { 44 | Joystick = new Joystick(dinput, device.InstanceGuid); 45 | break; 46 | } 47 | catch (DirectInputException) 48 | { 49 | } 50 | } 51 | 52 | if (Joystick == null) 53 | throw new Exception("No joystick found"); 54 | 55 | foreach (DeviceObjectInstance deviceObject in Joystick.GetObjects()) 56 | { 57 | if ((deviceObject.ObjectType & ObjectDeviceType.Axis) != 0) 58 | Joystick.GetObjectPropertiesById((int)deviceObject.ObjectType).SetRange(-100, 100); 59 | } 60 | 61 | // Acquire sdevice 62 | Joystick.Acquire(); 63 | } 64 | 65 | /// 66 | /// Release joystick 67 | /// 68 | public void Release() 69 | { 70 | if (Joystick != null) 71 | { 72 | Joystick.Unacquire(); 73 | Joystick.Dispose(); 74 | } 75 | 76 | Joystick = null; 77 | } 78 | } 79 | } -------------------------------------------------------------------------------- /Windows/3DMouseTranslator/3DMouseTranslator/bin/Release/3DMouseTranslator.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Windows/3DMouseTranslator/3DMouseTranslator/bin/Release/3DMouseTranslator.exe -------------------------------------------------------------------------------- /Windows/SlimDX Runtime .NET 4.0 x64 (January 2012).msi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/secures92/CADMouse/30190063bf56abc3c625fac666d54fe5dddbde65/Windows/SlimDX Runtime .NET 4.0 x64 (January 2012).msi -------------------------------------------------------------------------------- /Windows/how-to-build.txt: -------------------------------------------------------------------------------- 1 | install slimDX runtime 2 | add reference from solidworks dll : 3 | SolidWorks.Interop.sldworks.dll --------------------------------------------------------------------------------