├── AUTHORS ├── COPYING ├── DSLogic.c ├── INSTALL ├── Makefile.am ├── NEWS ├── README ├── autogen.sh ├── configure.ac ├── fx2lib ├── Makefile.am ├── include │ ├── Makefile.am │ ├── autovector.h │ ├── delay.h │ ├── eputils.h │ ├── fx2ints.h │ ├── fx2macros.h │ ├── fx2regs.h │ ├── fx2types.h │ ├── gpif.h │ ├── i2c.h │ ├── lights.h │ ├── serial.h │ └── setupdat.h └── lib │ ├── Makefile.am │ ├── delay.c │ ├── eputils.c │ ├── gpif.c │ ├── i2c.c │ ├── int4av.a51 │ ├── interrupts │ ├── Makefile.am │ ├── ep0ack_isr.c │ ├── ep0in_isr.c │ ├── ep0out_isr.c │ ├── ep0ping_isr.c │ ├── ep1in_isr.c │ ├── ep1out_isr.c │ ├── ep1ping_isr.c │ ├── ep2_isr.c │ ├── ep2ef_isr.c │ ├── ep2ff_isr.c │ ├── ep2isoerr_isr.c │ ├── ep2pf_isr.c │ ├── ep2ping_isr.c │ ├── ep4_isr.c │ ├── ep4ef_isr.c │ ├── ep4ff_isr.c │ ├── ep4isoerr_isr.c │ ├── ep4pf_isr.c │ ├── ep4ping_isr.c │ ├── ep6_isr.c │ ├── ep6ef_isr.c │ ├── ep6ff_isr.c │ ├── ep6isoerr_isr.c │ ├── ep6pf_isr.c │ ├── ep6ping_isr.c │ ├── ep8_isr.c │ ├── ep8ef_isr.c │ ├── ep8ff_isr.c │ ├── ep8isoerr_isr.c │ ├── ep8pf_isr.c │ ├── ep8ping_isr.c │ ├── errlimit_isr.c │ ├── gpifdone_isr.c │ ├── gpifwf_isr.c │ ├── hispeed_isr.c │ ├── ibn_isr.c │ ├── sof_isr.c │ ├── spare_isr.c │ ├── sudav_isr.c │ ├── suspend_isr.c │ ├── sutok_isr.c │ └── usbreset_isr.c │ ├── serial.c │ ├── setupdat.c │ └── usbav.a51 ├── hw ├── Makefile.am └── dscr.a51 ├── include ├── DSLogic.h ├── Makefile.am ├── dscr.inc └── interface.h ├── interface.c └── usb.c /AUTHORS: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | AUTHORS 3 | ------------------------------------------------------------------------------- 4 | 5 | Please check the source code files and/or git history and/or ChangeLog for 6 | a list of all authors and contributors. 7 | 8 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /DSLogic.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the DSLogic-fw project. 3 | * 4 | * Copyright (C) 2012 Uwe Hermann 5 | * Copyright (C) 2012 Joel Holdsworth 6 | * Copyright (C) 2014 DreamSourceLab 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | /* ... */ 34 | #define GPIFTRIGWR 0 35 | #define GPIFTRIGRD 4 36 | 37 | /* ... */ 38 | volatile __bit recv_setup; 39 | BYTE command; 40 | BOOL cfg_enable = FALSE; 41 | BOOL set_enable = FALSE; 42 | BOOL set_init = FALSE; 43 | BOOL set_dso_ctrl = FALSE; 44 | BYTE setting_count_b0; 45 | BYTE setting_count_b1; 46 | BYTE setting_count_b2; 47 | char dsoConfig[4] = {0x00, 0xc8, 0x61, 0x55}; 48 | 49 | static void setup_endpoints(void) 50 | { 51 | /* Setup EP2 (out). */ 52 | EP2CFG = (1 << 7) | /* EP is valid/activated */ 53 | (0 << 6) | /* EP direction: OUT */ 54 | (1 << 5) | (0 << 4) | /* EP Type: bulk */ 55 | (0 << 3) | /* EP buffer size: 1024 */ 56 | (0 << 2) | /* Reserved. */ 57 | (0 << 1) | (0 << 0); /* EP buffering: double buffering */ 58 | SYNCDELAY(); 59 | 60 | /* Setup EP6 (IN). */ 61 | EP6CFG = (1 << 7) | /* EP is valid/activated */ 62 | (1 << 6) | /* EP direction: IN */ 63 | (1 << 5) | (0 << 4) | /* EP Type: bulk */ 64 | (0 << 3) | /* EP buffer size: 1024 */ 65 | (0 << 2) | /* Reserved. */ 66 | (0 << 1) | (0 << 0); /* EP buffering: double buffering */ 67 | SYNCDELAY(); 68 | 69 | 70 | /* Disable all other EPs (EP1, EP4, and EP8). */ 71 | EP1INCFG &= ~bmVALID; 72 | SYNCDELAY(); 73 | EP1OUTCFG &= ~bmVALID; 74 | SYNCDELAY(); 75 | EP4CFG &= ~bmVALID; 76 | SYNCDELAY(); 77 | EP8CFG &= ~bmVALID; 78 | SYNCDELAY(); 79 | 80 | RESETFIFOS(); 81 | 82 | /* EP2 */ 83 | EP2FIFOCFG = 0x00; // allow core to see zero to one transition of auto out bit 84 | SYNCDELAY(); 85 | EP2FIFOCFG = 0x10; // auto out mode, disable PKTEND zero length send, byte operation 86 | SYNCDELAY(); 87 | EP2GPIFFLGSEL = 0x01; // For EP2OUT, GPIF uses emtpy flag 88 | SYNCDELAY(); 89 | 90 | 91 | /* EP6 */ 92 | /* EP6: Enable AUTOIN mode. Set FIFO width to 8bits. */ 93 | EP6FIFOCFG = bmAUTOIN; 94 | SYNCDELAY(); 95 | /* EP6: Auto-commit 512 (0x200) byte packets (due to AUTOIN = 1). */ 96 | EP6AUTOINLENH = 0x02; 97 | SYNCDELAY(); 98 | EP6AUTOINLENL = 0x00; 99 | SYNCDELAY(); 100 | /* EP6: Set the GPIF flag to 'full'. */ 101 | EP6GPIFFLGSEL = (1 << 1) | (0 << 1); 102 | SYNCDELAY(); 103 | 104 | /* PA1~PA0: LED; PA2: sample enable; PA3: sample clear */ 105 | OEA = 0x0f; 106 | IOA = 0x00; 107 | } 108 | 109 | void DSLogic_init(void) 110 | { 111 | recv_setup = FALSE; 112 | command = 0; 113 | 114 | /* Renumerate. */ 115 | RENUMERATE_UNCOND(); 116 | 117 | /* Set 8051 run @48MHz */ 118 | SETCPUFREQ(CLK_48M); 119 | 120 | /* USB init */ 121 | USE_USB_INTS(); 122 | ENABLE_SOF(); 123 | ENABLE_HISPEED(); 124 | ENABLE_USBRESET(); 125 | ENABLE_SUDAV(); 126 | 127 | /* Global (8051) interrupt enable. */ 128 | EA = 1; 129 | 130 | /* Setup the endpoints. */ 131 | setup_endpoints(); 132 | 133 | /* GPIF Wavedata Init*/ 134 | setup_gpif_waveforms(); 135 | } 136 | 137 | void DSLogic_poll(void) 138 | { 139 | if (recv_setup) { 140 | handle_setupdata(); 141 | recv_setup = FALSE; 142 | } 143 | 144 | switch (command) { 145 | case CMD_START: 146 | if ((EP0CS & bmEPBUSY) != 0) 147 | break; 148 | 149 | if (EP0BCL == sizeof(struct cmd_start)) { 150 | if ((*(uint8_t *)EP0BUF) & CMD_START_FLAGS_STOP) 151 | stop_capture(); 152 | else 153 | start_capture(); 154 | } 155 | 156 | /* Acknowledge the command. */ 157 | command = 0; 158 | break; 159 | 160 | case CMD_CONFIG: 161 | if ((EP0CS & bmEPBUSY) != 0) 162 | break; 163 | 164 | if (EP0BCL == sizeof(struct cmd_cfg_count)) { 165 | init_config_intf(); 166 | FIFORESET = 0x80; // set NAKALL bit to NAK all transfers from host 167 | SYNCDELAY(); 168 | FIFORESET = 0x02; // reset EP2 FIFO 169 | SYNCDELAY(); 170 | FIFORESET = 0x06; // reset EP6 FIFO 171 | SYNCDELAY(); 172 | FIFORESET = 0x00; // clear NAKALL bit to resume normal operation 173 | SYNCDELAY(); 174 | 175 | EP2FIFOCFG = 0x00; // allow core to see zero to one transition of auto out bit 176 | SYNCDELAY(); 177 | EP2FIFOCFG = 0x10; // auto out mode, disable PKTEND zero length send, word ops 178 | SYNCDELAY(); 179 | EP6FIFOCFG = 0x08; // auto in mode, disable PKTEND zero length send, word ops 180 | SYNCDELAY(); 181 | 182 | GPIFIDLECTL &= 0xFB; //PROG_B signal low 183 | delay(1); //PROG_B signal kept asserted for 1 ms 184 | GPIFIDLECTL |= 0x04; //PROG_B signal high 185 | SYNCDELAY(); 186 | 187 | // setup transaction count 188 | GPIFTCB0 = ((const struct cmd_cfg_count *)EP0BUF)->byte0; 189 | SYNCDELAY(); 190 | GPIFTCB1 = ((const struct cmd_cfg_count *)EP0BUF)->byte1; 191 | SYNCDELAY(); 192 | GPIFTCB2 = ((const struct cmd_cfg_count *)EP0BUF)->byte2; 193 | SYNCDELAY(); 194 | 195 | cfg_enable = TRUE; 196 | } 197 | 198 | /* Acknowledge the command. */ 199 | command = 0; 200 | break; 201 | 202 | case CMD_SETTING: 203 | if ((EP0CS & bmEPBUSY) != 0) 204 | break; 205 | 206 | if (EP0BCL == sizeof(struct cmd_setting_count)) { 207 | GPIFABORT = 0xff; 208 | SYNCDELAY(); 209 | EP2FIFOCFG = 0x11; // auto out mode, disable PKTEND zero length send, word operation 210 | SYNCDELAY(); 211 | setting_count_b0 = ((const struct cmd_setting_count *)EP0BUF)->byte0; 212 | setting_count_b1 = ((const struct cmd_setting_count *)EP0BUF)->byte1; 213 | setting_count_b2 = ((const struct cmd_setting_count *)EP0BUF)->byte2; 214 | set_enable = TRUE; 215 | } 216 | 217 | /* Acknowledge the command. */ 218 | command = 0; 219 | break; 220 | 221 | case CMD_CONTROL: 222 | if ((EP0CS & bmEPBUSY) != 0) 223 | break; 224 | 225 | if (EP0BCL == sizeof(struct cmd_control)) { 226 | dsoConfig[0] = ((const struct cmd_control *)EP0BUF)->byte0; 227 | dsoConfig[1] = ((const struct cmd_control *)EP0BUF)->byte1; 228 | dsoConfig[2] = ((const struct cmd_control *)EP0BUF)->byte2; 229 | dsoConfig[3] = ((const struct cmd_control *)EP0BUF)->byte3; 230 | set_dso_ctrl = TRUE; 231 | } 232 | 233 | /* Acknowledge the command. */ 234 | command = 0; 235 | break; 236 | default: 237 | /* Unimplemented command. */ 238 | command = 0; 239 | break; 240 | } 241 | if (cfg_enable && (GPIFTRIG & 0x80)) { // if GPIF interface IDLE 242 | if ( (EP24FIFOFLGS & 0x01) && (GPIFREADYSTAT & 0x01)) { 243 | // if there's a packet in the peripheral domain for EP2 244 | // and FPGA is ready to receive the configuration bitstream 245 | IFCONFIG = 0xA6; 246 | // 7 IFCLKSRC=1 , FIFOs executes on internal clk source 247 | // 6 xMHz=0 , 30MHz internal clk rate 248 | // 5 IFCLKOE=1 , Drive IFCLK pin signal at 30MHz 249 | // 4 IFCLKPOL=0 , Don't invert IFCLK pin signal from internal clk 250 | // 3 ASYNC=0 , master samples asynchronous 251 | // 2 GSTATE=1 , Drive GPIF states out on PORTE[2:0], debug WF 252 | // 1:0 IFCFG=10, FX2 in GPIF master mode 253 | SYNCDELAY(); 254 | 255 | //delay(1); //avoid CSI_B deasserted during sync words 256 | GPIFTRIG = GPIFTRIGWR | GPIF_EP2; // launch GPIF FIFO WRITE Transaction from EP2 FIFO 257 | SYNCDELAY(); 258 | 259 | while( !( GPIFTRIG & 0x80 ) ); // poll GPIFTRIG.7 GPIF Done bit 260 | SYNCDELAY(); 261 | cfg_enable= FALSE; //end of configuration 262 | 263 | /* Put the FX2 into GPIF master mode and setup the GPIF. */ 264 | init_capture_intf(); 265 | 266 | if (GPIFREADYSTAT & 0x02) { // FPGA Configure Done 267 | IOA |= 0x01; 268 | IOA &= 0xf5; 269 | delay(1); 270 | IOA |= 0x08; 271 | } else { 272 | IOA &= 0xfc; 273 | } 274 | } 275 | } 276 | if (set_enable && (GPIFTRIG & 0x80)) { // if GPIF interface IDLE 277 | if (!(EP24FIFOFLGS & 0x02)) { 278 | SYNCDELAY(); 279 | GPIFTCB2 = setting_count_b2; 280 | SYNCDELAY(); 281 | GPIFTCB1 = setting_count_b1; // fpga setting count 282 | SYNCDELAY(); 283 | GPIFTCB0 = setting_count_b0; 284 | SYNCDELAY(); 285 | 286 | GPIFTRIG = GPIFTRIGWR | GPIF_EP2; // launch GPIF FIFO WRITE Transaction from EP2 FIFO 287 | SYNCDELAY(); 288 | 289 | while( !( GPIFTRIG & 0x80 ) ); // poll GPIFTRIG.7 GPIF Done bit 290 | SYNCDELAY(); 291 | set_enable= FALSE; //end of configuration 292 | 293 | /* Put the FX2 into GPIF master mode and setup the GPIF. */ 294 | init_capture_intf(); 295 | } 296 | } 297 | 298 | if (set_dso_ctrl) { 299 | i2c_write (0x51, 0, NULL, 4, dsoConfig); 300 | set_dso_ctrl = FALSE; 301 | } 302 | 303 | poll_intf(); 304 | } 305 | 306 | void main(void) 307 | { 308 | DSLogic_init(); 309 | while (1) 310 | DSLogic_poll(); 311 | } 312 | 313 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | INSTALL 3 | ------------------------------------------------------------------------------- 4 | 5 | Requirements 6 | ------------ 7 | 8 | - git 9 | - make 10 | - autoconf >= 2.63 11 | - automake >= 1.11 12 | - sdcc (>= 2.9.0) 13 | 14 | Notes: 15 | 16 | - In order to build DSLogic-fw you need the 'sdcc' compiler (>= 2.9.0). 17 | On Debian you can install it via: 18 | 19 | $ apt-get install sdcc 20 | 21 | 22 | Building and installing 23 | ----------------------- 24 | 25 | $ ./autogen.sh 26 | $ ./configure 27 | $ make 28 | 29 | For installing DSLogic-fw: 30 | 31 | $ make install 32 | 33 | The generated *.fw files are installed into /usr/local/share/DSLogic-fw. 34 | 35 | You can override the install location like this: 36 | 37 | $ ./configure --prefix=/usr 38 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of the DSLogic-fw project. 3 | ## 4 | ## Copyright (C) 2013 Uwe Hermann 5 | ## 6 | ## This program is free software; you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation; either version 2 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## This program is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ## You should have received a copy of the GNU General Public License 17 | ## along with this program; if not, write to the Free Software 18 | ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | ## 20 | 21 | ACLOCAL_AMFLAGS = -I autostuff 22 | 23 | SUBDIRS = include fx2lib hw 24 | 25 | EXTRA_DIST = DSLogic.c interface.c usb.c 26 | 27 | .PHONY: DSLogic 28 | DSLogic: DSLogic.rel interface.rel usb.rel 29 | 30 | .c.rel: 31 | $(AM_V_GEN)$(SDCC) -mmcs51 -I$(srcdir)/include -I${srcdir}/fx2lib/include -c $< -o $@ 32 | 33 | MAINTAINERCLEANFILES = ChangeLog 34 | 35 | .PHONY: ChangeLog 36 | ChangeLog: 37 | $(AM_V_at)git --git-dir $(top_srcdir)/.git log > ChangeLog || touch ChangeLog 38 | 39 | dist-hook: ChangeLog 40 | 41 | # Creates a convenience tarball with just the generated *.fw files, so that 42 | # the users don't have to build them manually. 43 | TARBALL=$(PACKAGE)-bin-$(VERSION) 44 | distbin: all ChangeLog 45 | $(AM_V_at)$(MKDIR_P) $(TARBALL) 46 | $(AM_V_at)$(INSTALL_DATA) hw/*.fw $(TARBALL) 47 | $(AM_V_at)$(INSTALL_DATA) README NEWS ChangeLog COPYING* $(TARBALL) 48 | $(AM_V_at)tar -c -z -f $(TARBALL).tar.gz $(TARBALL) 49 | $(AM_V_at)-rm -rf $(TARBALL) 50 | $(AM_V_at)-rm -f ChangeLog 51 | 52 | clean-local: 53 | $(AM_V_at)-rm -f *.asm *.lst *.rel *.rst *.sym 54 | 55 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | 1.0 (2014-07-07) 2 | ------------------ 3 | 4 | * Initial release. 5 | 6 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | README 3 | ------------------------------------------------------------------------------- 4 | 5 | DSLogic-fw is an Open-source firmware for DSLogic, and is built based on fx2lafw of sigrok project(www.sigrok.org). Many thanks to the original work of the sigrok guys. 6 | DSLogic project: www.dreamsourcelab.com 7 | 8 | 9 | Status 10 | ------ 11 | 12 | DSLogic-fw is in a usable state and has had official 13 | tarball releases. 14 | 15 | 16 | Copyright and license 17 | --------------------- 18 | 19 | DSLogic-fw is licensed under the terms of the GNU General Public 20 | License (GPL), version 2 or later. 21 | 22 | It uses additional helper code (fx2lib), licensed under the GNU LGPL 23 | (version 2.1 or later). 24 | 25 | 26 | Website 27 | ------- 28 | 29 | http://www.dreamsourcelab.com 30 | 31 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## 3 | ## This file is part of the DSLogic-fw project. 4 | ## 5 | ## Copyright (C) 2013 Uwe Hermann 6 | ## 7 | ## This program is free software; you can redistribute it and/or modify 8 | ## it under the terms of the GNU General Public License as published by 9 | ## the Free Software Foundation; either version 2 of the License, or 10 | ## (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | ## 21 | 22 | OS=`uname` 23 | 24 | ACLOCAL_DIR= 25 | 26 | if [ "x$OS" = "xDarwin" ]; then 27 | if [ -d /sw/share/aclocal ]; then 28 | # fink installs aclocal macros here 29 | ACLOCAL_DIR="-I /sw/share/aclocal" 30 | elif [ -d /opt/local/share/aclocal ]; then 31 | # Macports installs aclocal macros here 32 | ACLOCAL_DIR="-I /opt/local/share/aclocal" 33 | elif [ -d /usr/local/share/aclocal ]; then 34 | # Homebrew installs aclocal macros here 35 | ACLOCAL_DIR="-I /usr/local/share/aclocal" 36 | elif [ -d /usr/share/aclocal ]; then 37 | # Xcode installs aclocal macros here 38 | ACLOCAL_DIR="-I /usr/share/aclocal" 39 | fi 40 | elif [ "x$OS" = "xMINGW32_NT-5.1" ]; then 41 | # Windows XP 42 | ACLOCAL_DIR="-I /usr/local/share/aclocal" 43 | elif [ "x$OS" = "xMINGW32_NT-6.0" ]; then 44 | # Windows Vista 45 | ACLOCAL_DIR="-I /usr/local/share/aclocal" 46 | elif [ "x$OS" = "xMINGW32_NT-6.1" ]; then 47 | # Windows 7 48 | ACLOCAL_DIR="-I /usr/local/share/aclocal" 49 | fi 50 | 51 | echo "Generating build system..." 52 | mkdir -p autostuff 53 | aclocal ${ACLOCAL_DIR} || exit 1 54 | autoheader || exit 1 55 | automake --add-missing --copy || exit 1 56 | autoconf || exit 1 57 | 58 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of the DSLogic-fw project. 3 | ## 4 | ## Copyright (C) 2013 Uwe Hermann 5 | ## 6 | ## This program is free software; you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation; either version 2 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## This program is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ## You should have received a copy of the GNU General Public License 17 | ## along with this program; if not, write to the Free Software 18 | ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | ## 20 | 21 | # We require at least autoconf 2.63 (AC_INIT format changed there). 22 | AC_PREREQ([2.63]) 23 | 24 | AC_INIT([DSLogic-fw], [1.0], 25 | [support@DreamSourceLab.com], 26 | [DSLogic-fw], [http://www.DreamSourceLab.com]) 27 | AC_CONFIG_HEADER([config.h]) 28 | AC_CONFIG_MACRO_DIR([autostuff]) 29 | AC_CONFIG_AUX_DIR([autostuff]) 30 | 31 | # We require at least automake 1.11 (needed for 'silent rules'). 32 | AM_INIT_AUTOMAKE([1.11 -Wall -Werror check-news]) 33 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 34 | 35 | AC_PROG_INSTALL 36 | AC_PROG_LN_S 37 | 38 | # On Fedora, all sdcc tools have an 'sdcc-' prefix in the filename. 39 | AC_CHECK_PROGS([SDCC], [sdcc sdcc-sdcc]) 40 | if test "x$SDCC" == "x"; then 41 | AC_MSG_ERROR([cannot find sdcc.]) 42 | fi 43 | AC_CHECK_PROGS([SDCCLIB], [sdcclib sdcc-sdcclib]) 44 | if test "x$SDCCLIB" == "x"; then 45 | AC_MSG_ERROR([cannot find sdcclib.]) 46 | fi 47 | AC_CHECK_PROGS([OBJCOPY], [objcopy]) 48 | AC_CHECK_PROGS([MAKEBIN], [makebin sdcc-makebin]) 49 | if test "x$OBJCOPY" == "x" && test "x$MAKEBIN" == "x"; then 50 | AC_MSG_ERROR([cannot find objcopy or makebin.]) 51 | fi 52 | 53 | AM_CONDITIONAL([FOUND_OBJCOPY], [test "x$OBJCOPY" != "x"]) 54 | AM_CONDITIONAL([FOUND_MAKEBIN], [test "x$MAKEBIN" != "x"]) 55 | AM_COND_IF([FOUND_OBJCOPY], [AC_SUBST(FOUND_OBJCOPY, "yes")]) 56 | AM_COND_IF([FOUND_MAKEBIN], [AC_SUBST(FOUND_MAKEBIN, "yes")]) 57 | 58 | # The sdcc 8051 assembler binary has/had different names: 59 | # Newer sdcc, Debian / Ubuntu: sdas8051 60 | # Newer sdcc, Fedora: sdcc-sdas8051 61 | # Older sdcc: asx8051 62 | AC_CHECK_PROGS([SDAS8051], [sdas8051 sdcc-sdas8051 asx8051]) 63 | if test "x$SDAS8051" == "x"; then 64 | AC_MSG_ERROR([cannot find sdas8051.]) 65 | fi 66 | 67 | AC_SUBST(SDCC_FLAGS, "--code-size 0x1c00 --xram-size 0x0200 --xram-loc 0x1c00 -Wl\"-b DSCR_AREA=0x1e00\" -Wl\"-b INT2JT=0x1f00\"") 68 | AC_SUBST(FIRMWARE_DIR, "$datadir/DSLogic-fw") 69 | AC_SUBST(MAKEFLAGS, '--no-print-directory') 70 | 71 | AC_CONFIG_FILES([Makefile 72 | include/Makefile 73 | fx2lib/Makefile 74 | fx2lib/include/Makefile 75 | fx2lib/lib/Makefile 76 | fx2lib/lib/interrupts/Makefile 77 | hw/Makefile 78 | ]) 79 | 80 | AC_OUTPUT 81 | 82 | -------------------------------------------------------------------------------- /fx2lib/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of the DSLogic-fw project. 3 | ## 4 | ## Copyright (C) 2013 Uwe Hermann 5 | ## 6 | ## This program is free software; you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation; either version 2 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## This program is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ## You should have received a copy of the GNU General Public License 17 | ## along with this program; if not, write to the Free Software 18 | ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | ## 20 | 21 | SUBDIRS = include lib 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/include/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of the DSLogic-fw project. 3 | ## 4 | ## Copyright (C) 2013 Uwe Hermann 5 | ## 6 | ## This program is free software; you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation; either version 2 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## This program is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ## You should have received a copy of the GNU General Public License 17 | ## along with this program; if not, write to the Free Software 18 | ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | ## 20 | 21 | EXTRA_DIST = autovector.h delay.h eputils.h fx2ints.h fx2macros.h fx2regs.h \ 22 | fx2types.h gpif.h i2c.h lights.h serial.h setupdat.h 23 | 24 | -------------------------------------------------------------------------------- /fx2lib/include/autovector.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Ubixum, Inc. 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License, or (at your option) any later version. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | 18 | 19 | /** \file usbjt.h 20 | * 21 | * To use usbjt, you must tell the linker where to put the IN2JT. 22 | * It must lie on a page boundary or your interrupts won't work right. 23 | * 24 | * example: 25 | * -Wl"-b INT2JT = 0x1A00" 26 | * 27 | * Make sure that INT2JT doesn't overlap your other code! 28 | * 29 | * Unlike the standard fx2 interrupts (\ref fx2ints.h), the autovectored 30 | * interrupts are defined in assemply and have pre-written function names. 31 | * Be sure to override the functions defined in this header or your 32 | * interrupt handler will not be called. 33 | **/ 34 | 35 | #ifndef USBJT_H 36 | #define USBJT_H 37 | 38 | #include "fx2regs.h" 39 | 40 | 41 | 42 | // this causes usbjt to be included from the lib 43 | // not used for anything 44 | extern volatile BYTE INT2JT; 45 | extern volatile BYTE INT4JT; 46 | /** 47 | * Enable all interrupts (EA=1) separate from this macro. 48 | * This macro causes the autovector assembly for int2 interrupts 49 | * to be overlayed at 0x43. In addition, the jump table for the 50 | * interrupts will be included in the firmware. The jump table 51 | * must lie on a page boundary. This is done by passing the linker 52 | * arguments to sdcc. 53 | * 54 | * \code 55 | * sdcc -Wl"-b INT2JT = 0xaddr" 56 | * \endcode 57 | **/ 58 | #define USE_USB_INTS() {BYTE dummy=INT2JT;\ 59 | EUSB=1;\ 60 | INTSETUP|=bmAV2EN;} 61 | /** This macro causes the autovector assemby for int4 to be overlayed 62 | * at 0x53. Don't use this if you want external pin generated int4 interrupts 63 | * and want to define your own interrupt handler. It is possible to use 64 | * usb interrupts with autovectoring and not use GPIF interrupts but GPIF 65 | * interrupts require the USB jump table. (You can't USE your own usb interrupt 66 | * handler if you want to enable GPIF interrupts.) 67 | **/ 68 | #define USE_GPIF_INTS() {BYTE dummy=INT4JT;\ 69 | EIEX4=1;\ 70 | INTSETUP|=bmAV4EN|INT4IN;} 71 | 72 | 73 | 74 | #define CLEAR_USBINT() EXIF &= ~0x10 75 | #define CLEAR_GPIF() EXIF &= ~0x40 76 | 77 | #define ENABLE_SUDAV() USBIE|=bmSUDAV 78 | #define CLEAR_SUDAV() CLEAR_USBINT(); USBIRQ=bmSUDAV 79 | 80 | #define ENABLE_SUTOK() USBIE|=bmSUTOK; 81 | #define CLEAR_SUTOK() CLEAR_USBINT(); USBIRQ=bmSUTOK 82 | 83 | #define ENABLE_SOF() USBIE|=bmSOF 84 | #define CLEAR_SOF() CLEAR_USBINT(); USBIRQ=bmSOF 85 | 86 | #define ENABLE_SUSPEND() USBIE|=bmSUSP 87 | #define CLEAR_SUSPEND() CLEAR_USBINT(); USBIRQ=bmSUSP 88 | 89 | #define ENABLE_USBRESET() USBIE|= bmURES 90 | #define CLEAR_USBRESET() CLEAR_USBINT(); USBIRQ=bmURES 91 | 92 | #define ENABLE_HISPEED() USBIE|=bmHSGRANT 93 | #define CLEAR_HISPEED() CLEAR_USBINT(); USBIRQ=bmHSGRANT 94 | 95 | #define ENABLE_EP1IN() EPIE|=bmEP1IN 96 | #define CLEAR_EP1IN() CLEAR_USBINT(); EPIRQ=bmEP1IN 97 | 98 | #define ENABLE_EP2() EPIE|=bmEP2 99 | #define CLEAR_EP2() CLEAR_USBINT(); EPIRQ=bmEP2 100 | 101 | #define ENABLE_EP6() EPIE|=bmEP6 102 | #define CLEAR_EP6() CLEAR_USBINT(); EPIRQ=bmEP6 103 | 104 | #define ENABLE_EP2ISOERR() USBERRIE |= bmISOEP2 105 | #define CLEAR_EP2ISOERR() CLEAR_USBINT(); USBERRIRQ = bmISOEP2 106 | 107 | #define ENABLE_EP6PF() EP6FIFOIE |= bmBIT2 108 | #define CLEAR_EP6PF() CLEAR_GPIF(); EP6FIFOIRQ=bmBIT2 109 | 110 | #define ENABLE_EP6FF() EP6FIFOIE |= bmBIT0 111 | #define CLEAR_EP6FF() CLEAR_GPIF(); EP6FIFOIRQ=bmBIT0 112 | 113 | #define ENABLE_GPIFDONE() GPIFIE |= 0x01; 114 | #define CLEAR_GPIFDONE() CLEAR_GPIF(); GPIFIRQ = 0x01; 115 | 116 | #define ENABLE_GPIFWF() GPIFIE |= 0x02; 117 | #define CLEAR_GPIFWF() GLEAR_GPIF(); GPIFIRQ = 0x02; 118 | 119 | /** 120 | * ez-usb has 12 built in ISRs, to get 121 | * sdcc to put these USB ISRs immediately 122 | * after the other ISRs (and not waste space) 123 | * we start at 13 124 | **/ 125 | typedef enum { 126 | SUDAV_ISR=13, 127 | SOF_ISR, 128 | SUTOK_ISR, 129 | SUSPEND_ISR, 130 | USBRESET_ISR, 131 | HISPEED_ISR, 132 | EP0ACK_ISR, 133 | EP0IN_ISR, 134 | EP0OUT_ISR, 135 | EP1IN_ISR, 136 | EP1OUT_ISR, 137 | EP2_ISR, 138 | EP4_ISR, 139 | EP6_ISR, 140 | EP8_ISR, 141 | IBN_ISR, 142 | EP0PING_ISR, 143 | EP1PING_ISR, 144 | EP2PING_ISR, 145 | EP4PING_ISR, 146 | EP6PING_ISR, 147 | EP8PING_ISR, 148 | ERRLIMIT_ISR, 149 | EP2ISOERR_ISR, 150 | EP4ISOERR_ISR, 151 | EP6ISOERR_ISR, 152 | EP8ISOERR_ISR, 153 | RESERVED_ISR, 154 | EP2PF_ISR, 155 | EP4PF_ISR, 156 | EP6PF_ISR, 157 | EP8PF_ISR, 158 | EP2EF_ISR, 159 | EP4EF_ISR, 160 | EP6EF_ISR, 161 | EP8EF_ISR, 162 | EP2FF_ISR, 163 | EP4FF_ISR, 164 | EP6FF_ISR, 165 | EP8FF_ISR, 166 | GPIFDONE_ISR, 167 | GPIFWF_ISR 168 | } USB_ISR; 169 | 170 | // you must include the predef of these in the file with your main 171 | // so lets just define them here 172 | 173 | void sudav_isr() __interrupt SUDAV_ISR; 174 | void sof_isr() __interrupt SOF_ISR; 175 | void sutok_isr() __interrupt SUTOK_ISR; 176 | void suspend_isr() __interrupt SUSPEND_ISR; 177 | void usbreset_isr() __interrupt USBRESET_ISR; 178 | void hispeed_isr() __interrupt HISPEED_ISR; 179 | void ep0ack_isr() __interrupt EP0ACK_ISR; 180 | void ep0in_isr() __interrupt EP0IN_ISR; 181 | void ep0out_isr() __interrupt EP0OUT_ISR; 182 | void ep1in_isr() __interrupt EP1IN_ISR; 183 | void ep1out_isr() __interrupt EP1OUT_ISR; 184 | void ep2_isr() __interrupt EP2_ISR; 185 | void ep4_isr() __interrupt EP4_ISR; 186 | void ep6_isr() __interrupt EP6_ISR; 187 | void ep8_isr() __interrupt EP8_ISR; 188 | void ibn_isr() __interrupt IBN_ISR; 189 | void ep0ping_isr() __interrupt EP0PING_ISR; 190 | void ep1ping_isr() __interrupt EP1PING_ISR; 191 | void ep2ping_isr() __interrupt EP2PING_ISR; 192 | void ep4ping_isr() __interrupt EP4PING_ISR; 193 | void ep6ping_isr() __interrupt EP6PING_ISR; 194 | void ep8ping_isr() __interrupt EP8PING_ISR; 195 | void errlimit_isr() __interrupt ERRLIMIT_ISR; 196 | void ep2isoerr_isr() __interrupt EP2ISOERR_ISR; 197 | void ep4isoerr_isr() __interrupt EP4ISOERR_ISR; 198 | void ep6isoerr_isr() __interrupt EP6ISOERR_ISR; 199 | void ep8isoerr_isr() __interrupt EP8ISOERR_ISR; 200 | void spare_isr() __interrupt RESERVED_ISR; // not used 201 | // gpif ints 202 | void ep2pf_isr() __interrupt EP2PF_ISR; 203 | void ep4pf_isr() __interrupt EP4PF_ISR; 204 | void ep6pf_isr() __interrupt EP6PF_ISR; 205 | void ep8pf_isr() __interrupt EP8PF_ISR; 206 | void ep2ef_isr() __interrupt EP2EF_ISR; 207 | void ep4ef_isr() __interrupt EP4EF_ISR; 208 | void ep6ef_isr() __interrupt EP6EF_ISR; 209 | void ep8ef_isr() __interrupt EP8EF_ISR; 210 | void ep2ff_isr() __interrupt EP2FF_ISR; 211 | void ep4ff_isr() __interrupt EP4FF_ISR; 212 | void ep6ff_isr() __interrupt EP6FF_ISR; 213 | void ep8ff_isr() __interrupt EP8FF_ISR; 214 | void gpifdone_isr() __interrupt GPIFDONE_ISR; 215 | void gpifwf_isr() __interrupt GPIFWF_ISR; 216 | 217 | #endif 218 | 219 | -------------------------------------------------------------------------------- /fx2lib/include/delay.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009 Ubixum, Inc. 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License, or (at your option) any later version. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | /*! \file 18 | * Functions for causing delays. 19 | * */ 20 | 21 | 22 | #ifndef DELAY_H 23 | #define DELAY_H 24 | 25 | #include "fx2types.h" 26 | 27 | /** 28 | * 0-65536 millis 29 | **/ 30 | void delay(WORD millis); 31 | 32 | /** 33 | * See TRM 15-14,15-15 34 | * some registers (r/w) require syncdelay after 35 | * 36 | * up to the programmer to determine which sync is needed. 37 | * for standard 48mhz clock w/ 48mhz IFCONFIG 3 nops is sufficient. 38 | * 39 | * slower clock and faster ifclock require more delay 40 | * 41 | * min delay = roof ( 1.5 x (ifclock/clkout + 1) ) 42 | * 43 | * Minimum IFCLOCK is 5mhz but you have to use an 44 | * external clock source to go below 30mhz 45 | * 46 | * IFCLKSRC 1 = internal, 0=external 47 | * 3048mhz 0 = 30mhz, 1 = 48mzh 48 | * 49 | * Figure your own sync delay out if IFCLKSRC=0. 50 | **/ 51 | 52 | #define NOP __asm nop __endasm 53 | 54 | /** 55 | * SYNCDELAY2 can work for the following clock speeds 56 | * 57 | * ifclk/clk 58 | * \li 48/12 59 | * 60 | * ceil(1.5 * (20.8 / 83.3 + 1)) = 2 61 | * 62 | * \see NOP 63 | * 64 | **/ 65 | #define SYNCDELAY2 NOP; NOP 66 | 67 | /** 68 | * SYNCDELAY3 can work for the following clock speeds 69 | * 70 | * ifcfg/clk 71 | * \li 48/24 72 | * \li 48/48 73 | * \li 30/12 74 | * \li 30/24 75 | * 76 | * \see NOP 77 | **/ 78 | #define SYNCDELAY3 NOP; NOP; NOP 79 | 80 | /** 81 | * SYNCDELAY4 should be used for the following speeds 82 | * 83 | * ifcfg/clk 84 | * \li 30/48 85 | * 86 | * \see NOP 87 | **/ 88 | #define SYNCDELAY4 NOP; NOP; NOP; NOP 89 | 90 | #endif 91 | 92 | -------------------------------------------------------------------------------- /fx2lib/include/eputils.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009 Ubixum, Inc. 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License, or (at your option) any later version. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | /*! \file 18 | * Functions and macros for working with endpoints. 19 | * */ 20 | 21 | #ifndef EPUTILS_H 22 | #define EPUTILS_H 23 | 24 | #include "fx2types.h" 25 | 26 | /** 27 | * NOTE you can't use these unless you define SYNCDELAY 28 | * as a macro or function. The reason is that SYNCDELAY 29 | * needs to be longer or shorter depending on your IFCONFIG 30 | * settings. 31 | * See delay.h 32 | * 33 | * Example: 34 | * \code 35 | * #define SYNCDELAY() SYNCDELAY4 // SYNCDELAY4 from delay.h 36 | * \endcode 37 | * 38 | * 39 | **/ 40 | 41 | /** 42 | * Stalls EP0. 43 | **/ 44 | #define STALLEP0() EP0CS |= bmEPSTALL 45 | 46 | /** 47 | * \brief Reset the toggle on an endpoint. 48 | * To use this, the endpoint needs bit 8 to be IN=1,OUT=0 49 | **/ 50 | #define RESETTOGGLE(ep) TOGCTL = (ep&0x0F) + ((ep&0x80)>>3); TOGCTL |= bmRESETTOGGLE 51 | 52 | 53 | /** 54 | * RESETFIFO should not use 0x80|epnum for IN endpoints 55 | * Only use 0x02, 0x04, 0x06, 0x06 for ep value 56 | **/ 57 | #define RESETFIFO(ep) {FIFORESET=0x80; SYNCDELAY();\ 58 | FIFORESET=ep; SYNCDELAY();\ 59 | FIFORESET=0x00; SYNCDELAY();} 60 | /** 61 | * Quickly reset all endpoint FIFOS. 62 | **/ 63 | #define RESETFIFOS() {FIFORESET=0x80; SYNCDELAY();\ 64 | FIFORESET=0x02; SYNCDELAY();\ 65 | FIFORESET=0x04; SYNCDELAY();\ 66 | FIFORESET=0x06; SYNCDELAY();\ 67 | FIFORESET=0x08; SYNCDELAY();\ 68 | FIFORESET=0x00; SYNCDELAY();} 69 | 70 | /** 71 | * Continually read available bytes from endpoint0 into dst, wait 72 | * until more bytes are available, and loop until len bytes have 73 | * been read. 74 | **/ 75 | void readep0( BYTE* dst, WORD len ); 76 | 77 | 78 | /** 79 | * Write bytes from src to ep0, allowing host to transfer data 80 | * between 64 byte blocks. 81 | **/ 82 | void writeep0 ( BYTE* src, WORD len ); 83 | 84 | 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /fx2lib/include/fx2ints.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Ubixum, Inc. 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License, or (at your option) any later version. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | /*! \file 18 | * Define the standard fx2 interrupts. For int2 and int4 autovector 19 | * interrupts see \ref autovector.h 20 | * 21 | * To enable an interrupt, simply define an interrupt handler function 22 | * and use the appropriate ENABLE_* macro. Interrupt enable macros 23 | * do not enable interrupts globally. Use EA=1 to enable interrupts. 24 | * 25 | * \code 26 | * void main() { 27 | * ENABLE_RESUME(); 28 | * EA=1; 29 | * ... 30 | * } 31 | * 32 | * void handle_resume() interrupt RESUME_ISR { 33 | * CLEAR_RESUME(); 34 | * } 35 | * \endcode 36 | * 37 | * */ 38 | 39 | 40 | /** 41 | * \brief interrupt numbers for standard fx2 interrupts 42 | 43 | **/ 44 | typedef enum { 45 | IE0_ISR=0, ///< External interrupt 0 46 | TF0_ISR, ///< Timer 0 interrupt 47 | IE1_ISR, ///< External interrupt 1 48 | TF1_ISR, ///< Timer 1 interrupt 49 | TI_0_ISR, ///< Serial port 0 transmit or receive interrupt 50 | TF2_ISR, ///< Timer 2 interrupt 51 | RESUME_ISR, ///< Resume interrupt 52 | TI_1_ISR, ///< Serial port 1 transmit or receive interrupt 53 | USBINT_ISR, ///< Usb Interrupt. An interrupt handler for this should only be used if not using auto vectored interrupts with int2 54 | I2CINT_ISR, ///< I2C Bus interrupt 55 | IE4_ISR, ///< External interrupt 4. An interrupt handler for this should only be used if not using auto vectored interrupts with int4 56 | IE5_ISR, ///< External interrupt 5 57 | IE6_ISR, ///< External interrupt 6 58 | } FX2_ISR; 59 | 60 | 61 | /** 62 | * \brief Enable the timer 0 interrupt. 63 | * 64 | * There is not CLEAR_TIMER0 because the timer interrupt flag 65 | * is automatically cleared when the isr is called. 66 | **/ 67 | #define ENABLE_TIMER0() ET0=1 68 | 69 | /** 70 | * \brief Enable timer 1 interrupt 71 | * There is no CLEAR_TIMER1 because the timer interrupt flag 72 | * is automatically cleared when the isr is called. 73 | **/ 74 | #define ENABLE_TIMER1() ET1=1 75 | 76 | 77 | /** 78 | * \brief Enable timer 2 interrupt 79 | * 80 | * This is the same interrupt whether timer 2 overflowed or 81 | * for the external EXF2 flag. 82 | **/ 83 | #define ENABLE_TIMER2() ET2=1 84 | /** 85 | * \brief Clear timer 2 interrupt 86 | * 87 | * Clears both the TF2 AND EXF2 flag 88 | **/ 89 | #define CLEAR_TIMER2() TF2=0;EXF2=0; 90 | 91 | /** 92 | * \brief Enable the Resume Interrupt. Requires EA=1 separately. 93 | **/ 94 | #define ENABLE_RESUME() ERESI = 1 95 | 96 | /** 97 | * \brief Clear the resume interrupt. Use within the resume 98 | * interrupt handler. 99 | **/ 100 | #define CLEAR_RESUME() RESI=0 101 | 102 | 103 | #define ENABLE_INT4() 104 | 105 | /** 106 | * \brief 107 | * Enable external interupt for int5# 108 | **/ 109 | #define ENABLE_INT5() EIEX5=1 110 | 111 | /** 112 | * \brief 113 | * Clear int5# interrupt 114 | **/ 115 | #define CLEAR_INT5() EXIF &= ~0x80 116 | 117 | -------------------------------------------------------------------------------- /fx2lib/include/fx2macros.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009 Ubixum, Inc. 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License, or (at your option) any later version. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | /*! \file 18 | * Macros for simple common tasks in fx2 firmware. 19 | * */ 20 | 21 | #ifndef FX2MACROS_H 22 | #define FX2MACROS_H 23 | 24 | #include "fx2regs.h" 25 | #include "fx2types.h" 26 | 27 | #define MSB(addr) (BYTE)((addr >> 8) & 0xff) 28 | #define LSB(addr) (BYTE)(addr & 0xff) 29 | #define MAKEWORD(msb,lsb) (((WORD)msb << 8) | lsb) 30 | 31 | #define MSW(dword) (WORD)((dword >> 16) & 0xffff) 32 | #define LSW(dword) (WORD)(dword & 0xffff) 33 | #define MAKEDWORD(msw,lsw) (((DWORD)msw << 16) | lsw) 34 | 35 | // clock stuff 36 | 37 | /** 38 | * \brief Used for getting and setting the CPU clock speed. 39 | **/ 40 | typedef enum { CLK_12M =0, CLK_24M, CLK_48M} CLK_SPD; 41 | 42 | /** 43 | * \brief Evaluates to a CLK_SPD enum. 44 | **/ 45 | #define CPUFREQ (CLK_SPD)((CPUCS & bmCLKSPD) >> 3) 46 | /** 47 | * \brief Sets the cpu to operate at a specific 48 | * clock speed. 49 | **/ 50 | #define SETCPUFREQ(SPD) CPUCS = (CPUCS & ~bmCLKSPD) | (SPD << 3) 51 | 52 | /** 53 | * \brief Evaluates to a DWORD value representing 54 | * the clock speed in cycles per second. 55 | * 56 | * Speeds: 57 | * 58 | * \li 12000000L 59 | * \li 24000000L 60 | * \li 48000000L 61 | * 62 | **/ 63 | #define XTAL (CPUFREQ==CLK_12M ? 12000000L :\ 64 | CPUFREQ==CLK_24M ? 24000000L : 48000000L) 65 | 66 | 67 | /** 68 | * \brief Evaluates to the i2c bus frequency in cyles per 69 | * second. 70 | * 71 | * Speeds: 72 | * 73 | * \li 400000L 74 | * \li 100000L 75 | * 76 | **/ 77 | #define I2CFREQ ((I2CTL & bm400KHZ) ? 400000L : 100000L) 78 | 79 | 80 | #define IFFREQ (IFCONFIG & bm3048MHZ ? 48000000L : 30000000L) 81 | #define SETIF30MHZ() IFCONFIG &= ~bm3048MHZ 82 | #define SETIF48MHZ() IFCONFIG |= bm3048MHZ 83 | 84 | 85 | // eeprom stuff 86 | #define EEPROM_TWO_BYTE (I2CS & bmBIT4) 87 | 88 | /** 89 | * \brief Cause the device to disconnect and reconnect to USB. This macro 90 | * unconditionally renumerates the device no matter how the firmware is loaded. 91 | * 92 | * NOTE Windows really doesn't like this if the firmware is loaded 93 | * from an eeprom. You'll see information messages about the device not 94 | * working properly. On the other hand, if you are changing the device 95 | * descriptor, e.g., the vendor and product id, when downloading firmware to the device, 96 | * you'll need to use this macro instead of the 97 | * standard RENUMERATE macro. 98 | **/ 99 | #define RENUMERATE_UNCOND() USBCS|=bmDISCON|bmRENUM;delay(1500);USBCS&=~bmDISCON 100 | /** 101 | * \brief Cause the device to disconnect and reconnect to the USB bus. This macro 102 | * doesn't do anything if the firmware is loaded from an eeprom. 103 | **/ 104 | #define RENUMERATE() if(!(USBCS&bmRENUM)) {USBCS|=bmDISCON|bmRENUM;delay(1500);USBCS &= ~bmDISCON;} 105 | 106 | 107 | // interrupts 108 | // USB interrupts are in usbjt.h 109 | 110 | 111 | 112 | 113 | /** 114 | * \brief TRUE if the FX2 has transitioned to high speed on the USB bus.. 115 | **/ 116 | #define HISPEED (USBCS&bmHSM) 117 | 118 | 119 | 120 | 121 | /** 122 | * \brief Evaluates to TRUE if a remote wakeup event has occurred. 123 | **/ 124 | #define REMOTE_WAKEUP() (((WAKEUPCS & bmWU) && (WAKEUPCS & bmWUEN)) || ((WAKEUPCS & bmWU2) && (WAKEUPCS & bmWU2EN))) 125 | 126 | 127 | #endif 128 | -------------------------------------------------------------------------------- /fx2lib/include/fx2types.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009 Ubixum, Inc. 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License, or (at your option) any later version. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | /*! \file 18 | * define standard types of fixed widths. 19 | * */ 20 | 21 | #ifndef FXTYPES_H 22 | #define FXTYPES_H 23 | 24 | typedef unsigned int WORD; 25 | typedef unsigned char BYTE; 26 | typedef unsigned long DWORD; 27 | typedef unsigned char BOOL; 28 | typedef enum { 29 | FALSE=0, 30 | TRUE 31 | } BOOL_VALS; 32 | 33 | #ifndef NULL 34 | #define NULL (void*)0 35 | #endif 36 | 37 | /*----------------------------------------------------------------------------- 38 | Bit Masks 39 | -----------------------------------------------------------------------------*/ 40 | 41 | #define bmBIT0 1 42 | #define bmBIT1 2 43 | #define bmBIT2 4 44 | #define bmBIT3 8 45 | #define bmBIT4 16 46 | #define bmBIT5 32 47 | #define bmBIT6 64 48 | #define bmBIT7 128 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /fx2lib/include/gpif.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009 Ubixum, Inc. 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License, or (at your option) any later version. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | /*! \file 18 | * 19 | * These functions do the same thing that the Cypress gpif designer expored c file does. 20 | * Instead of including their file directly in your project, you include just the 21 | * generated waveform data. The gpif2dat script in the utils folder will export your 22 | * waveform data to a file that can be included in your project. 23 | * */ 24 | 25 | #ifndef GPIF_H 26 | #define GPIF_H 27 | 28 | #include "fx2types.h" 29 | 30 | #define GPIFDONE (GPIFTRIG&0x80) 31 | #define GPIFTC16 (MAKEWORD(GPIFTCB1,GPIFTCB0)) 32 | #define GPIFTC32 (MAKEDWORD(MAKEWORD(GPIFTCB3,GPIFTCB2),MAKEWORD(GPIFTCB1,GPIFTCB0))) 33 | 34 | 35 | /** 36 | * Gpif designer generates a c file with waveform data. 37 | * Copy the WaveData[128] array 38 | * and the InitData[7] to your code somewhere 39 | * Then this function is pretty much the reset of the generated 40 | * code but ported to sdcc. 41 | * 42 | * uses syncdelay of 4 which might not be long enough if peripheral 43 | * runs slower than 30mhz. May not affect anything. 44 | * 45 | * IFCONFIG is set with IFCFG[1:0] = 10 for GPIF master but you still 46 | * have to set the ifclk, polarity, and the rest of the bits 47 | **/ 48 | 49 | void gpif_init( BYTE* waveform, BYTE* initdata ); 50 | 51 | /** 52 | * Uses the correct bytes from your flowstates array. 53 | * This may or may not be needed depending on whether 54 | * your waveform data uses flowstates. If you don't 55 | * know if you need them or not, you probably don't. 56 | * 57 | * flowstates should have 36 elements. 58 | * bank should be 0-3 59 | **/ 60 | void gpif_setflowstate( BYTE* flowstates, BYTE bank); 61 | 62 | 63 | 64 | //! These defines/functions pretty much out of the TRM 10.4 65 | #define GPIFTRGWR 0 66 | #define GPIFTRGRD 4 67 | typedef enum { 68 | GPIF_EP2 = 0, 69 | GPIF_EP4 = 1, 70 | GPIF_EP6 = 2, 71 | GPIF_EP8 = 3 72 | } GPIF_EP_NUM; 73 | 74 | /** 75 | * \brief Simple function to help set the transaction count for gpif 76 | * transactions. 77 | * \param tc 32 bit Transaction Count 78 | **/ 79 | void gpif_set_tc32(DWORD tc); 80 | /** 81 | * \brief Simple function to set transaction count for gpif transactions. 82 | * \param tc 16 bit Transaction Count 83 | **/ 84 | void gpif_set_tc16(WORD tc); 85 | 86 | 87 | /** 88 | * Use the gpif to read a single word at a time. 89 | * Read len words and store in res 90 | * 91 | * At least one EPxFIFOCFG has to have wordwide=1 or this 92 | * functions won't transfer both bytes. 93 | **/ 94 | 95 | void gpif_single_read16( WORD* res , WORD len); 96 | 97 | /** 98 | * Use the gpif to write a single word at a time. 99 | * Write len words from data 100 | * 101 | * At leat one EPxFIFOCFG has to have wordwide=1 or this 102 | * function won't transfer both bytes. 103 | **/ 104 | void gpif_single_write16( WORD* __data, WORD len); 105 | 106 | void gpif_fifo_read ( GPIF_EP_NUM ep_num ); 107 | 108 | void gpif_fifo_write( GPIF_EP_NUM ep_num ); 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /fx2lib/include/i2c.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009 Ubixum, Inc. 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License, or (at your option) any later version. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | /** \file i2c.h 18 | * Utilities for reading and writing to i2c devices and as eeproms. 19 | **/ 20 | 21 | #ifndef I2C_H 22 | #define I2C_H 23 | 24 | #include "fx2types.h" 25 | 26 | /** 27 | * i2c_write and i2c_read set this to FALSE at the beginning of a 28 | * transaction. If for some reason, the read/write is taking too 29 | * long or not returning, firmware can set this to TRUE to cause the 30 | * routine to abort. (Usually done via an interrupt). 31 | **/ 32 | extern volatile __xdata BOOL cancel_i2c_trans; 33 | 34 | /** 35 | * \brief write data to i2c bus. 36 | * 37 | * Writes data from addr buffer 1st, then data buffer. 38 | * Either buffer can be NULL (as long as you set lenN to 0). 39 | * 40 | * Two buffers allows writing data all in one i2c write command without 41 | * having to write a hardware address and a data byte with each 42 | * i2c transaction. 43 | * 44 | * \param addr i2c address 45 | * \param len1 length of addr data 46 | * \param addr_buf addr data 47 | * \param len2 length of data 48 | * \param data_buf data bytes 49 | **/ 50 | BOOL i2c_write ( BYTE addr, WORD len1, BYTE* addr_buf, WORD len2, BYTE* data_buf ); 51 | 52 | /** 53 | * \brief read data on the i2c bus. 54 | * 55 | * \param addr i2c address 56 | * \param len number of bytes to read 57 | * \param buf buffer to store data 58 | **/ 59 | BOOL i2c_read ( BYTE addr, WORD len, BYTE* buf); 60 | 61 | /** 62 | * \brief read data from an attached eeprom. 63 | * 64 | * Writes the address of the data to read then reads len bytes into buf. 65 | * This function checks the I2CS register to determine if a one or two 66 | * byte address eepom was detected on the i2c bus. Reading from proms 67 | * at non-standard addresses my require using the i2c_read/write commands 68 | * explicitly. 69 | * 70 | * \param prom_addr eeprom i2c address 71 | * \param addr address of bytes to start reading 72 | * \param len number of bytes to read 73 | * \param buf data buffer 74 | **/ 75 | BOOL eeprom_read( BYTE prom_addr, WORD addr, WORD len, BYTE* buf); 76 | 77 | /** 78 | * \brief write data to the eeprom 79 | * 80 | * This function checks the I2CS register to determin if a one or two 81 | * two byte eeprom is detected. If the prom is not detected at boot time 82 | * or is connected to alternate addresses, the i2c_read/write commands should 83 | * be used explicitly insread of using this function. 84 | * 85 | * For each byte in buf, the address is written and then the data byte. Many 86 | * proms support writing multiple bytes at the same time. For these, it is 87 | * also better to use i2c_read/write explicitly. This function is rather slow 88 | * but is effective. 89 | * 90 | * \param prom_addr eeprom i2c address 91 | * \param addr address of bytes to start writing 92 | * \param len number of bytes to write 93 | * \param buf data buffer 94 | **/ 95 | BOOL eeprom_write( BYTE prom_addr, WORD addr, WORD len, BYTE* buf); 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /fx2lib/include/lights.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009 Ubixum, Inc. 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License, or (at your option) any later version. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | /** \file lights.h 18 | * macros for turning lights on the EZ-USB development board on and off. 19 | **/ 20 | 21 | #ifndef LIGHTS_H 22 | #define LIGHTS_H 23 | 24 | #include "fx2types.h" 25 | 26 | #ifndef FX1 27 | // FX2 Dev board lights 28 | #define D2ONH #0x88 // assembly high byte of light addr 29 | #define D2OFFH #0x80 30 | #define D3ONH #0x98 31 | #define D3OFFH #0x90 32 | #define D4ONH #0xA8 33 | #define D4OFFH #0xA0 34 | #define D5ONH #0xB8 35 | #define D5OFFH #0xB0 36 | volatile xdata at 0x8800 BYTE D2ON; 37 | volatile xdata at 0x8000 BYTE D2OFF; 38 | volatile xdata at 0x9800 BYTE D3ON; 39 | volatile xdata at 0x9000 BYTE D3OFF; 40 | volatile xdata at 0xA800 BYTE D4ON; 41 | volatile xdata at 0xA000 BYTE D4OFF; 42 | volatile xdata at 0xB800 BYTE D5ON; 43 | volatile xdata at 0xB000 BYTE D5OFF; 44 | #else 45 | // FX1 dev board lights 46 | #define D2ONH #0x80 // assembly high byte of light addr 47 | #define D2OFFH #0x81 48 | #define D3ONH #0x90 49 | #define D3OFFH #0x91 50 | #define D4ONH #0xA0 51 | #define D4OFFH #0xA1 52 | #define D5ONH #0xB0 53 | #define D5OFFH #0xB1 54 | volatile xdata at 0x8000 BYTE D2ON; 55 | volatile xdata at 0x8100 BYTE D2OFF; 56 | volatile xdata at 0x9000 BYTE D3ON; 57 | volatile xdata at 0x9100 BYTE D3OFF; 58 | volatile xdata at 0xA000 BYTE D4ON; 59 | volatile xdata at 0xA100 BYTE D4OFF; 60 | volatile xdata at 0xB000 BYTE D5ON; 61 | volatile xdata at 0xB100 BYTE D5OFF; 62 | #endif 63 | 64 | /** 65 | * Easier to use macros defined below 66 | **/ 67 | #define activate_light(LIGHT_ADDR) __asm \ 68 | mov __XPAGE, LIGHT_ADDR \ 69 | __endasm; __asm \ 70 | movx a, @r0 \ 71 | __endasm \ 72 | 73 | /** 74 | * Easy to make lights blink with these macros: 75 | * \code 76 | * WORD ct=0; 77 | * BOOL on=FALSE; 78 | * while (TRUE) { 79 | * if (!ct) { 80 | * on=!on; 81 | * if (on) d2on(); else d2off(); 82 | * } 83 | * ++ct; 84 | * } 85 | * \endcode 86 | **/ 87 | #define d2on() activate_light(D2ONH) 88 | #define d2off() activate_light(D2OFFH) 89 | #define d3on() activate_light(D3ONH) 90 | #define d3off() activate_light(D3OFFH) 91 | #define d4on() activate_light(D4ONH) 92 | #define d4off() activate_light(D4OFFH) 93 | #define d5on() activate_light(D5ONH) 94 | #define d5off() activate_light(D5OFFH) 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /fx2lib/include/serial.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009 Ubixum, Inc. 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License, or (at your option) any later version. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | /** \file serial.h 18 | * defines functions to print to a serial console with SIO0 19 | **/ 20 | 21 | #include "fx2types.h" 22 | 23 | 24 | /** 25 | * This function inits sio0 to use T2CON (timer 2) 26 | * See TRM 14.3.4.1 (Table 14-16) 27 | * Certain baud rates have too high an error rate to work. All baud rates are .16% 28 | * except: 29 | * 30 | * 12MHZ 24MHZ 31 | * \li 57600 -6.99% 32 | * \li 38400 -2.34% -2.34% 33 | * \li 19200 -2.34% 34 | * 35 | * Possible Baud rates: 36 | * \li 2400 37 | * \li 4800 38 | * \li 9600 39 | * \li 19200 40 | * \li 28800 41 | * \li 38400 42 | * \li 57600 43 | * 44 | * Any of these rates should work except 57600 at 12mhz. -2.34% is pushing 45 | * most hardware specs for working. All rates at 48mhz work at .16% 46 | **/ 47 | 48 | void sio0_init( WORD baud_rate ) __critical ; // baud_rate max should be 57600 since int=2 bytes 49 | 50 | /** 51 | putchar('\\n') or putchar('\\r') both transmit \\r\\n 52 | Just use one or the other. (This makes terminal echo easy) 53 | **/ 54 | void putchar(char c); 55 | char getchar(); 56 | -------------------------------------------------------------------------------- /fx2lib/include/setupdat.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009 Ubixum, Inc. 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License, or (at your option) any later version. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | #ifndef SETUPDAT_H 18 | #define SETUPDAT_H 19 | 20 | #include "fx2regs.h" 21 | #include "delay.h" 22 | /** \file setupdat.h 23 | Utilities for handling setup data and vendor commands. 24 | 25 | \verbatim 26 | 27 | This module needs initialized with a device descriptor. 28 | NOTE that your descriptors need to be located in code memory 29 | to use the SUDPTRH:L to auto transfer the data 30 | 31 | and vendor commands handler. You have to provide callbacks. 32 | 33 | DEVICE DESCRIPTORS 34 | 35 | // copy the dscr_asm file from the lib dir to your 36 | // own project directory, change it how 37 | // you want, and link it against your project 38 | 39 | VENDOR COMMANDS 40 | 41 | 0xA0 is handled by ez-usb firmware. (Upload/Download ram) 42 | 0xA1-0xAF is reserved for other ez-usb functions so don't use that 43 | Any other value (Above 0x0C anyway) can be used for device specific 44 | commands. 45 | 46 | If you include this file, you need to define a function for vendor 47 | commands even if you don't want to implement any vendor commands. 48 | The function should return TRUE if you handled the command and FALSE 49 | if you didn't. The handle_setup function calls 50 | EP0CS |= bmHSNAK; 51 | before returning so there is no reason to set that bit in your 52 | vendor command handler. (You do need to Set EP0 data and 53 | byte counts appropriately though.) 54 | 55 | // return TRUE if you handle the command 56 | // you can directly get SETUPDAT[0-7] for the data sent with the command 57 | BOOL handle_vendorcommand(BYTE cmd) { return FALSE; } 58 | // a note on vencor commands 59 | // this from the usb spec for requesttype 60 | D7 Data Phase Transfer Direction 61 | 0 = Host to Device 62 | 1 = Device to Host 63 | D6..5 Type 64 | 0 = Standard 65 | 1 = Class 66 | 2 = Vendor 67 | 3 = Reserved 68 | D4..0 Recipient 69 | 0 = Device 70 | 1 = Interface 71 | 2 = Endpoint 72 | 3 = Other 73 | 4..31 = Reserved 74 | // if you want libusb to send data back to the host via ep0, you need to make 75 | // sure the requesttype had 1 in bit 7. This is for libusb on linux anyway. 76 | 77 | 78 | // set *alt_ifc to the current alt interface for ifc 79 | BOOL handle_get_interface(BYTE ifc, BYTE* alt_ifc) { *ifc=0;*alt_ifc=0;} 80 | // return TRUE if you set the interface requested 81 | // NOTE this function should reconfigure and reset the endpoints 82 | // according to the interface descriptors you provided. 83 | BOOL handle_set_interface(BYTE ifc,BYTE alt_ifc) { return TRUE; } 84 | // handle getting and setting the configuration 85 | // 0 is the default. If you support more than one config 86 | // keep track of the config number and return the correct number 87 | // config numbers are set int the dscr file. 88 | BYTE handle_get_configuration() { return 1; } 89 | // return TRUE if you handle this request 90 | // NOTE changing config requires the device to reset all the endpoints 91 | BOOL handle_set_configuration(BYTE cfg) { return FALSE; } 92 | // ep num (byte 7 is dir 1=IN,0=OUT) 93 | // client needs to reset the endpoint to default state 94 | void handle_reset_ep(BYTE ep) { } 95 | 96 | \endverbatim 97 | */ 98 | 99 | 100 | #define SETUP_VALUE() MAKEWORD(SETUPDAT[3],SETUPDAT[2]) 101 | #define SETUP_INDEX() MAKEWORD(SETUPDAT[5],SETUPDAT[4]) 102 | #define SETUP_LENGTH() MAKEWORD(SETUPDAT[7],SETUPDAT[6]) 103 | #define SETUP_TYPE SETUPDAT[0] 104 | 105 | /** 106 | * self_powered is set to FALSE by default. It is 107 | * used for GET_FEATURE requests. Firmware can set it to 108 | * TRUE if the device is not powered by the USB bus. 109 | **/ 110 | extern volatile BOOL self_powered; 111 | 112 | /** 113 | * remote_wakeup_allowed defaults to FALSE but can be 114 | * set to TRUE with SET_FEATURE from the host. (firmware shouldn't 115 | * set this.) 116 | **/ 117 | extern volatile BOOL remote_wakeup_allowed; 118 | 119 | //! see TRM 2-3 120 | //! here are the usb setup data commands 121 | //! these are the usb spec pretty much 122 | 123 | typedef enum { 124 | GET_STATUS, 125 | CLEAR_FEATURE, 126 | // 0x02 is reserved 127 | SET_FEATURE=0x03, 128 | // 0x04 is reserved 129 | SET_ADDRESS=0x05, // this is handled by EZ-USB core unless RENUM=0 130 | GET_DESCRIPTOR, 131 | SET_DESCRIPTOR, 132 | GET_CONFIGURATION, 133 | SET_CONFIGURATION, 134 | GET_INTERFACE, 135 | SET_INTERFACE, 136 | SYNC_FRAME 137 | } SETUP_DATA; 138 | 139 | 140 | /** 141 | * returns the control/status register for an end point 142 | * (bit 7=1 for IN, 0 for out 143 | **/ 144 | __xdata BYTE* ep_addr(BYTE ep); 145 | 146 | /* 147 | You can call this function directly if you are polling 148 | for setup data in your main loop. 149 | You can also use the usbjt and enable the sudav isr 150 | and call the function from withing the sudav isr routine 151 | */ 152 | void handle_setupdata(); 153 | 154 | 155 | /** 156 | For devices to properly handle usb hispeed 157 | (This is if your descriptor has high speed and full speed versions 158 | and it should since the fx2lp is a high speed capable device 159 | ) 160 | enable both USBRESET and HISPEED interrupts and 161 | call this function to switch the descriptors. This function uses 162 | a __critical section to switch the descriptors and is safe to call 163 | from the hispeed or reset interrupt. See \ref fw.c 164 | 165 | \param highspeed Call the function with highspeed = TRUE if 166 | calling because the highspeed interrupt was received. 167 | If calling from usbreset, call with highspeed=false 168 | **/ 169 | void handle_hispeed( BOOL highspeed ); 170 | 171 | 172 | /* descriptor types */ 173 | #define DSCR_DEVICE_TYPE 1 174 | #define DSCR_CONFIG_TYPE 2 175 | #define DSCR_STRING_TYPE 3 176 | #define DSCR_DEVQUAL_TYPE 6 177 | #define DSCR_OTHERSPD_TYPE 7 178 | 179 | /* usb spec 2 */ 180 | #define DSCR_BCD 2 181 | 182 | 183 | /* device descriptor */ 184 | #define DSCR_DEVICE_LEN 18 185 | 186 | typedef struct { 187 | BYTE dsc_len; // descriptor length (18 for this ) 188 | BYTE dsc_type; // dscr type 189 | WORD bcd; // bcd 190 | BYTE dev_class; // device class 191 | BYTE dev_subclass; // sub class 192 | BYTE dev_protocol; // sub sub class 193 | BYTE max_pkt; // max packet size 194 | WORD vendor_id; 195 | WORD product_id; 196 | WORD dev_version; // product version id 197 | BYTE idx_manstr; // manufacturer string index 198 | BYTE idx_devstr; // product string index 199 | BYTE idx_serstr; // serial number index 200 | BYTE num_configs; // number of configurations 201 | 202 | } DEVICE_DSCR; 203 | 204 | 205 | /* config descriptor */ 206 | #define DSCR_CONFIG_LEN 9 207 | typedef struct { 208 | BYTE dsc_len; // 9 for this one 209 | BYTE dsc_type; // dscr type 210 | 211 | } CONFIG_DSCR; 212 | 213 | /* string descriptor */ 214 | typedef struct { 215 | BYTE dsc_len; 216 | BYTE dsc_type; 217 | BYTE pstr; 218 | } STRING_DSCR; 219 | 220 | 221 | 222 | 223 | #endif 224 | -------------------------------------------------------------------------------- /fx2lib/lib/Makefile.am: -------------------------------------------------------------------------------- 1 | ### 2 | ## This file is part of the DSLogic-fw project. 3 | ## 4 | ## Copyright (C) 2013 Uwe Hermann 5 | ## 6 | ## This program is free software; you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation; either version 2 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## This program is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ## You should have received a copy of the GNU General Public License 17 | ## along with this program; if not, write to the Free Software 18 | ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | ## 20 | 21 | SUBDIRS = interrupts 22 | 23 | SRC = delay.c eputils.c gpif.c i2c.c serial.c delay.c setupdat.c 24 | 25 | REL = delay.rel eputils.rel gpif.rel i2c.rel serial.rel delay.rel setupdat.rel 26 | 27 | EXTRA_DIST = $(SRC) int4av.a51 usbav.a51 28 | 29 | all: fx2.lib 30 | 31 | fx2.lib: $(REL) int4av.rel usbav.rel 32 | $(AM_V_GEN)$(SDCCLIB) fx2.lib $? 33 | 34 | usbav.rel: usbav.a51 35 | $(AM_V_at)if test "x${abs_top_srcdir}" != "x${abs_top_builddir}"; then \ 36 | $(INSTALL_DATA) ${srcdir}/usbav.a51 ${builddir}; \ 37 | fi 38 | $(AM_V_GEN)$(SDAS8051) -logs -I${top_srcdir}/include usbav.a51 39 | 40 | int4av.rel: int4av.a51 41 | $(AM_V_at)if test "x${abs_top_srcdir}" != "x${abs_top_builddir}"; then \ 42 | $(INSTALL_DATA) ${srcdir}/int4av.a51 ${builddir}; \ 43 | fi 44 | $(AM_V_GEN)$(SDAS8051) -logs -I${top_srcdir}/include int4av.a51 45 | 46 | .c.rel: 47 | $(AM_V_GEN)$(SDCC) -mmcs51 -I${top_srcdir}/fx2lib/include -c $< -o $@ 48 | 49 | clean-local: 50 | $(AM_V_at)-rm -f *.asm *.lst *.rel *.sym fx2.lib 51 | 52 | -------------------------------------------------------------------------------- /fx2lib/lib/delay.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2009 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | void delay(WORD millis) { 24 | /** 25 | * It takes 12 crystal pulses to make 1 machine cycle (8051.com) 26 | * ez-usb trm 1.13 27 | * 83.3 ns at 48mhz per instruction cycle 28 | * (assume 166.6ns at 24mhz) 29 | * (assume 333.3ns at 12mhz) 30 | * ez-usb trm 12.1 31 | * Includes the cycles for each instruction 32 | **/ 33 | WORD loop_count; 34 | volatile WORD count; // NOTE perhaps use different solutions w/ out volatile 35 | 36 | 37 | // set count to the number of times we need to 38 | // go around a loop for 1 millisecond 39 | 40 | // then do that loop millis times. (1000 us=1ms) 41 | 42 | // 48mhz: 1000 us / (17 cycles * 83.3 ns / cycle / 1000 ns/us) = 706 43 | // 24mhz: 353 44 | // 12mhz: 177 45 | // recalculate if the number of cycles changes 46 | // like if you change the loop below 47 | loop_count = CPUFREQ == CLK_12M ? 177 : 48 | CPUFREQ == CLK_24M ? 353 : 706; 49 | 50 | // sdcc generated assembly 51 | /* cycles code 52 | ; delay.c:31: do { 53 | 00101$: 54 | ; delay.c:32: } while ( --count ); 55 | 2 dec _delay_count_1_1 56 | 2 mov a,#0xff 57 | 4 cjne a,_delay_count_1_1,00121$ 58 | 2 dec (_delay_count_1_1 + 1) 59 | 00121$: 60 | 2 mov a,_delay_count_1_1 61 | 2 orl a,(_delay_count_1_1 + 1) 62 | 3 jnz 00101$ 63 | 64 | Total 17 65 | */ 66 | 67 | do { 68 | count = loop_count; 69 | do { 70 | } while ( --count ); 71 | } while ( --millis ); 72 | 73 | } 74 | -------------------------------------------------------------------------------- /fx2lib/lib/eputils.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2009 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | 20 | 21 | 22 | #include 23 | 24 | #include 25 | 26 | #ifdef DEBUG_EPUTILS 27 | #include 28 | #else 29 | #define printf(...) 30 | #endif 31 | 32 | void readep0( BYTE* dst, WORD len) { 33 | WORD read = 0; // n bytes read 34 | BYTE c,avail; 35 | while (read < len) { 36 | EP0BCH = 0; 37 | // NOTE need syncdelay? 38 | EP0BCL = 0; // re-arm ep so host can send more 39 | while (EP0CS & bmEPBUSY); 40 | avail = EP0BCL; // max size fits in one byte (64 bytes) 41 | for (c=0;c 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | #define SYNCDELAY() SYNCDELAY4 27 | 28 | void gpif_init( BYTE* wavedata, BYTE* initdata ) { 29 | 30 | BYTE i; 31 | 32 | // Registers which require a synchronization delay, see section 15.14 33 | // FIFORESET FIFOPINPOLAR 34 | // INPKTEND OUTPKTEND 35 | // EPxBCH:L REVCTL 36 | // GPIFTCB3 GPIFTCB2 37 | // GPIFTCB1 GPIFTCB0 38 | // EPxFIFOPFH:L EPxAUTOINLENH:L 39 | // EPxFIFOCFG EPxGPIFFLGSEL 40 | // PINFLAGSxx EPxFIFOIRQ 41 | // EPxFIFOIE GPIFIRQ 42 | // GPIFIE GPIFADRH:L 43 | // UDMACRCH:L EPxGPIFTRIG 44 | // GPIFTRIG 45 | 46 | // Note: The pre-REVE EPxGPIFTCH/L register are affected, as well... 47 | // ...these have been replaced by GPIFTC[B3:B0] registers 48 | 49 | // 8051 doesn't have access to waveform memories 'til 50 | // the part is in GPIF mode. 51 | 52 | // IFCLKSRC=1 , FIFOs executes on internal clk source 53 | // xMHz=1 , 48MHz internal clk rate 54 | // IFCLKOE=0 , Don't drive IFCLK pin signal at 48MHz 55 | // IFCLKPOL=0 , Don't invert IFCLK pin signal from internal clk 56 | // ASYNC=1 , master samples asynchronous 57 | // GSTATE=1 , Drive GPIF states out on PORTE[2:0], debug WF 58 | // IFCFG[1:0]=10, FX2 in GPIF master mode IFCONFIG 59 | IFCONFIG &= ~0x03; // turn off IFCFG[1:0] 60 | IFCONFIG |= 0x02; // set's IFCFG[1:0] to 10 to put in GPIF master mode. 61 | 62 | 63 | GPIFABORT = 0xFF; // abort any waveforms pending 64 | 65 | GPIFREADYCFG = initdata[ 0 ]; 66 | GPIFCTLCFG = initdata[ 1 ]; 67 | GPIFIDLECS = initdata[ 2 ]; 68 | GPIFIDLECTL = initdata[ 3 ]; 69 | GPIFWFSELECT = initdata[ 5 ]; 70 | GPIFREADYSTAT = initdata[ 6 ]; 71 | 72 | // use dual autopointer feature... 73 | AUTOPTRSETUP = 0x07; // inc both pointers, 74 | // ...warning: this introduces pdata hole(s) 75 | // ...at E67B (XAUTODAT1) and E67C (XAUTODAT2) 76 | 77 | // source 78 | AUTOPTRH1 = MSB( (WORD)wavedata ); 79 | AUTOPTRL1 = LSB( (WORD)wavedata ); 80 | 81 | // destination 82 | AUTOPTRH2 = 0xE4; 83 | AUTOPTRL2 = 0x00; 84 | 85 | // transfer 86 | for ( i = 0x00; i < 128; i++ ) 87 | { 88 | EXTAUTODAT2 = EXTAUTODAT1; 89 | } 90 | 91 | // Configure GPIF Address pins, output initial value, 92 | // these instructions don't do anything on the 93 | // smaller chips (e.g., 56 pin model only has ports a,b,d) 94 | PORTCCFG = 0xFF; // [7:0] as alt. func. GPIFADR[7:0] 95 | OEC = 0xFF; // and as outputs 96 | PORTECFG |= 0x80; // [8] as alt. func. GPIFADR[8] 97 | OEE |= 0x80; // and as output 98 | 99 | // ...OR... tri-state GPIFADR[8:0] pins 100 | // PORTCCFG = 0x00; // [7:0] as port I/O 101 | // OEC = 0x00; // and as inputs 102 | // PORTECFG &= 0x7F; // [8] as port I/O 103 | // OEE &= 0x7F; // and as input 104 | 105 | // GPIF address pins update when GPIFADRH/L written 106 | SYNCDELAY(); // 107 | GPIFADRH = 0x00; // bits[7:1] always 0 108 | SYNCDELAY(); // 109 | GPIFADRL = 0x00; // point to PERIPHERAL address 0x0000 110 | 111 | // set the initial flowstates to be all 0 in case flow states are not used 112 | 113 | FLOWSTATE = 0; 114 | FLOWLOGIC = 0; 115 | FLOWEQ0CTL = 0; 116 | FLOWEQ1CTL = 0; 117 | FLOWHOLDOFF = 0; 118 | FLOWSTB = 0; 119 | FLOWSTBEDGE = 0; 120 | FLOWSTBHPERIOD = 0; 121 | } 122 | 123 | void gpif_setflowstate( BYTE* flowstates, BYTE bank) { 124 | BYTE base = 9*bank; 125 | FLOWSTATE = flowstates[ base ]; 126 | FLOWLOGIC = flowstates[ base+1 ]; 127 | FLOWEQ0CTL = flowstates[ base+2 ]; 128 | FLOWEQ1CTL = flowstates[ base+3 ]; 129 | FLOWHOLDOFF = flowstates[ base+4 ]; 130 | FLOWSTB = flowstates[ base+5 ]; 131 | FLOWSTBEDGE = flowstates[ base+6 ]; 132 | FLOWSTBHPERIOD = flowstates[ base+7 ]; 133 | } 134 | 135 | void gpif_set_tc32(DWORD tc) { 136 | GPIFTCB3 = MSB(MSW(tc)); 137 | SYNCDELAY(); 138 | GPIFTCB2 = LSB(MSW(tc)); 139 | SYNCDELAY(); 140 | GPIFTCB1 = MSB(LSW(tc)); 141 | SYNCDELAY(); 142 | GPIFTCB0 = LSB(LSW(tc)); 143 | } 144 | void gpif_set_tc16(WORD tc) { 145 | GPIFTCB1= MSB(tc); 146 | SYNCDELAY(); 147 | GPIFTCB0= LSB(tc); 148 | } 149 | 150 | 151 | void gpif_single_read16( WORD* res, WORD len ){ 152 | BYTE c; 153 | while (!(GPIFTRIG & 0x80)); // wait done 154 | // dummy read to trigger real read 155 | res[0] = XGPIFSGLDATLX; 156 | for (c=0;c // NOTE this needs deleted 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | //#define DEBUG_I2C 1 28 | 29 | #ifdef DEBUG_I2C 30 | #define i2c_printf(...) printf(__VA_ARGS__) 31 | #else 32 | #define i2c_printf(...) 33 | #endif 34 | 35 | 36 | volatile __xdata BOOL cancel_i2c_trans; 37 | #define CHECK_I2C_CANCEL() if (cancel_i2c_trans) return FALSE 38 | 39 | /** 40 | * 41 | 1. Set START=1. If BERR=1, start timer*. 42 | 2. Write the 7-bit peripheral address and the direction bit (0 for a write) to I2DAT. 43 | 3. Wait for DONE=1 or for timer to expire*. If BERR=1, go to step 1. 44 | 4. If ACK=0, go to step 9. 45 | 5. Load I2DAT with a data byte. 46 | 6. Wait for DONE=1*. If BERR=1, go to step 1. 47 | 7. If ACK=0, go to step 9. 48 | 8. Repeat steps 5-7 for each byte until all bytes have been transferred. 49 | 9. Set STOP=1. Wait for STOP = 0 before initiating another transfer. 50 | **/ 51 | BOOL i2c_write ( BYTE addr, WORD len, BYTE *addr_buf, WORD len2, BYTE* data_buf ) { 52 | 53 | WORD cur_byte; 54 | WORD total_bytes = len+len2; // NOTE overflow error? 55 | BYTE retry_count=2; // two tries to write address/read ack 56 | cancel_i2c_trans=FALSE; 57 | //BOOL wait=FALSE; // use timer if needed 58 | 59 | // 1. Set START=1. If BERR=1, start timer*. 60 | step1: 61 | CHECK_I2C_CANCEL(); 62 | cur_byte=0; 63 | I2CS |= bmSTART; 64 | if ( I2CS & bmBERR ) { 65 | i2c_printf ( "Woops.. need to do the timer\n" ); 66 | delay(10); // way too long probably 67 | goto step1; 68 | } 69 | 70 | 71 | // 2. Write the 7-bit peripheral address and the direction bit (0 for a write) to I2DAT. 72 | I2DAT = addr << 1; 73 | 74 | // 3. Wait for DONE=1 or for timer to expire*. If BERR=1, go to step 1. 75 | while ( !(I2CS & bmDONE) && !cancel_i2c_trans); 76 | CHECK_I2C_CANCEL(); 77 | if (I2CS&bmBERR) { 78 | i2c_printf ( "bmBERR, going to step 1\n" ); 79 | goto step1; 80 | } 81 | 82 | 83 | // 4. If ACK=0, go to step 9. 84 | if ( !(I2CS & bmACK) ) { 85 | I2CS |= bmSTOP; 86 | while ( (I2CS & bmSTOP) && !cancel_i2c_trans); 87 | CHECK_I2C_CANCEL(); 88 | --retry_count; 89 | if (!retry_count){ 90 | i2c_printf ( "No ack after writing address.! Fail\n"); 91 | return FALSE; 92 | } 93 | delay(10); 94 | goto step1; 95 | } 96 | 97 | // 8. Repeat steps 5-7 for each byte until all bytes have been transferred. 98 | while ( cur_byte < total_bytes ) { 99 | // 5. Load I2DAT with a data byte. 100 | I2DAT = cur_byte < len ? addr_buf[cur_byte] : data_buf[cur_byte-len]; 101 | ++cur_byte; 102 | // 6. Wait for DONE=1*. If BERR=1, go to step 1. 103 | while (!(I2CS&bmDONE) && !cancel_i2c_trans); CHECK_I2C_CANCEL(); 104 | if ( I2CS&bmBERR ) { 105 | i2c_printf ( "bmBERR on byte %d. Going to step 1\n" , cur_byte-1 ); 106 | goto step1; 107 | //return FALSE; 108 | } 109 | // 7. If ACK=0, go to step 9. 110 | if ( !(I2CS & bmACK) ) { 111 | I2CS |= bmSTOP; 112 | while ( (I2CS&bmSTOP) && !cancel_i2c_trans); 113 | i2c_printf ( "No Ack after byte %d. Fail\n", cur_byte-1 ); 114 | return FALSE; 115 | } 116 | } 117 | 118 | 119 | // 9. Set STOP=1. Wait for STOP = 0 before initiating another transfer. 120 | //real step 9 121 | I2CS |= bmSTOP; 122 | while ( (I2CS & bmSTOP) && !cancel_i2c_trans); 123 | CHECK_I2C_CANCEL(); 124 | 125 | return TRUE; 126 | 127 | } 128 | 129 | /* 130 | trm 13.4.4 131 | 132 | 1. Set START=1. If BERR = 1, start timer*. 133 | 2. Write the 7-bit peripheral address and the direction bit (1 for a read) to I2DAT. 134 | 3. Wait for DONE=1 or for timer to expire*. If BERR=1, go to step 1. 135 | 4. If ACK=0, set STOP=1 and go to step 15. 136 | 5. Read I2DAT to initiate the first burst of nine SCL pulses to clock in the first byte from the slave. 137 | Discard the value that was read from I2DAT. 138 | 6. Wait for DONE=1. If BERR=1, go to step 1. 139 | 7. Read the just-received byte of data from I2DAT. This read also initiates the next read transfer. 140 | 8. Repeat steps 6 and 7 for each byte until ready to read the second-to-last byte. 141 | 9. Wait for DONE=1. If BERR=1, go to step 1. 142 | 10. Before reading the second-to-last I2DAT byte, set LASTRD=1. 143 | 11. Read the second-to-last byte from I2DAT. With LASTRD=1, this initiates the final byte read on 144 | the bus. 145 | 12. Wait for DONE=1. If BERR=1, go to step 1. 146 | 13. Set STOP=1. 147 | 14. Read the final byte from I2DAT immediately (the next instruction) after setting the STOP bit. By 148 | reading I2DAT while the "stop" condition is being generated, the just-received data byte will be 149 | retrieved without initiating an extra read transaction (nine more SCL pulses) on the I²Cbus. 150 | 15. Wait for STOP = 0 before initiating another transfer 151 | */ 152 | 153 | /* 154 | * timer should be at least as long as longest start-stop interval on the bus 155 | serial clock for i2c bus runs at 100khz by default and can run at 400khz for devices that support it 156 | start-stop interval is about 9 serial clock cycles 157 | 400KHZ bit 0=100khz, 1=400khz 158 | 159 | how many cycles at XTAL cycles/second = 9 cycles at 400k (or 100k) cycles/second 160 | 161 | timeout = n i2c cycles / I2C cycles/sec = timeout seconds 162 | timeout seconds * XTAL cycles/sec = XTAL cycles 163 | 9 / 400 (or 100) * (XTAL) 164 | 165 | */ 166 | BOOL i2c_read( BYTE addr, WORD len, BYTE* buf) { 167 | 168 | 169 | BYTE tmp; 170 | WORD cur_byte; 171 | cancel_i2c_trans=FALSE; 172 | //WORD timeout_cycles = (WORD)(9.0 * XTAL / I2CFREQ ); 173 | 174 | // 1. Set START=1. If BERR = 1, start timer*. 175 | start: 176 | CHECK_I2C_CANCEL(); 177 | cur_byte=0; 178 | 179 | I2CS |= bmSTART; 180 | if ( I2CS & bmBERR ) { 181 | i2c_printf ( "Woops, step1 BERR, need to do timeout\n"); 182 | delay(10); // NOTE way too long 183 | goto start; 184 | } 185 | 186 | // 2. Write the 7-bit peripheral address and the direction bit (1 for a read) to I2DAT. 187 | I2DAT = (addr << 1) | 1; // last 1 for read 188 | 189 | // 3. Wait for DONE=1 or for timer to expire*. If BERR=1, go to step 1. 190 | 191 | while ( !(I2CS & bmDONE) && !cancel_i2c_trans ); CHECK_I2C_CANCEL(); 192 | if ( I2CS & bmBERR ) 193 | goto start; 194 | 195 | // 4. If ACK=0, set STOP=1 and go to step 15. 196 | if (!(I2CS&bmACK) ) { 197 | I2CS |= bmSTOP; 198 | while ( (I2CS&bmSTOP) && !cancel_i2c_trans ); 199 | return FALSE; 200 | } 201 | 202 | // with only one byte to read, this needs set here. 203 | // (In this case, the tmp read is the 2nd to last read) 204 | if ( len==1 ) I2CS |= bmLASTRD; 205 | 206 | // 5. Read I2DAT to initiate the first burst of nine SCL pulses to clock in the first byte from the slave. 207 | // Discard the value that was read from I2DAT. 208 | tmp = I2DAT; // discard read 209 | 210 | while (len>cur_byte+1) { // reserve last byte read for after the loop 211 | 212 | // 6. Wait for DONE=1. If BERR=1, go to step 1. 213 | // 9. Wait for DONE=1. If BERR=1, go to step 1. 214 | while (!(I2CS&bmDONE) && !cancel_i2c_trans); CHECK_I2C_CANCEL(); 215 | if ( I2CS&bmBERR ) goto start; 216 | 217 | // 10. Before reading the second-to-last I2DAT byte, set LASTRD=1. 218 | if (len==cur_byte+2) // 2nd to last byte 219 | I2CS |= bmLASTRD; 220 | 221 | // 7. Read the just-received byte of data from I2DAT. This read also initiates the next read transfer. 222 | // 11. Read the second-to-last byte from I2DAT. With LASTRD=1, this initiates the final byte read on 223 | // the bus. 224 | buf[cur_byte++] = I2DAT; 225 | 226 | // 8. Repeat steps 6 and 7 for each byte until ready to read the second-to-last byte. 227 | } 228 | 229 | //12. Wait for DONE=1. If BERR=1, go to step 1. 230 | while (!(I2CS&bmDONE) && !cancel_i2c_trans); CHECK_I2C_CANCEL(); 231 | if ( I2CS&bmBERR ) goto start; 232 | // 13. Set STOP=1. 233 | I2CS |= bmSTOP; 234 | // 14. Read the final byte from I2DAT immediately (the next instruction) after setting the STOP bit. By 235 | // reading I2DAT while the "stop" condition is being generated, the just-received data byte will be 236 | // retrieved without initiating an extra read transaction (nine more SCL pulses) on the I²Cbus. 237 | buf[cur_byte] = I2DAT; // use instead of buffer addressing so next instruction reads I2DAT 238 | 239 | while ( (I2CS&bmSTOP) && !cancel_i2c_trans); CHECK_I2C_CANCEL(); 240 | 241 | return TRUE; 242 | } 243 | 244 | 245 | 246 | BOOL eeprom_write(BYTE prom_addr, WORD addr, WORD length, BYTE* buf) { 247 | BYTE addr_len=0; 248 | // 1st bytes of buffer are address and next byte is value 249 | BYTE data_buffer[3]; 250 | WORD cur_byte=0; 251 | 252 | #ifdef DEBUG_I2C 253 | if ( EEPROM_TWO_BYTE ) { 254 | i2c_printf ( "Two Byte EEProm Address detected.\n" ); 255 | } else { 256 | i2c_printf ( "Single Byte EEProm address detected.\n" ); 257 | } 258 | #endif 259 | 260 | while ( cur_byte 5 | ## 6 | ## This program is free software; you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation; either version 2 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## This program is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ## You should have received a copy of the GNU General Public License 17 | ## along with this program; if not, write to the Free Software 18 | ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | ## 20 | 21 | SRC = ep0ack_isr.c ep0in_isr.c ep0out_isr.c ep0ping_isr.c ep1in_isr.c \ 22 | ep1out_isr.c ep1ping_isr.c ep2ef_isr.c ep2ff_isr.c ep2isoerr_isr.c \ 23 | ep2_isr.c ep2pf_isr.c ep2ping_isr.c ep4ef_isr.c ep4ff_isr.c \ 24 | ep4isoerr_isr.c ep4_isr.c ep4pf_isr.c ep4ping_isr.c ep6ef_isr.c \ 25 | ep6ff_isr.c ep6isoerr_isr.c ep6_isr.c ep6pf_isr.c ep6ping_isr.c \ 26 | ep8ef_isr.c ep8ff_isr.c ep8isoerr_isr.c ep8_isr.c ep8pf_isr.c \ 27 | ep8ping_isr.c errlimit_isr.c gpifdone_isr.c gpifwf_isr.c hispeed_isr.c \ 28 | ibn_isr.c sof_isr.c spare_isr.c sudav_isr.c suspend_isr.c sutok_isr.c \ 29 | usbreset_isr.c 30 | 31 | REL = ep0ack_isr.rel ep0in_isr.rel ep0out_isr.rel ep0ping_isr.rel \ 32 | ep1in_isr.rel ep1out_isr.rel ep1ping_isr.rel ep2ef_isr.rel \ 33 | ep2ff_isr.rel ep2isoerr_isr.rel ep2_isr.rel ep2pf_isr.rel \ 34 | ep2ping_isr.rel ep4ef_isr.rel ep4ff_isr.rel ep4isoerr_isr.rel \ 35 | ep4_isr.rel ep4pf_isr.rel ep4ping_isr.rel ep6ef_isr.rel ep6ff_isr.rel \ 36 | ep6isoerr_isr.rel ep6_isr.rel ep6pf_isr.rel ep6ping_isr.rel \ 37 | ep8ef_isr.rel ep8ff_isr.rel ep8isoerr_isr.rel ep8_isr.rel ep8pf_isr.rel \ 38 | ep8ping_isr.rel errlimit_isr.rel gpifdone_isr.rel gpifwf_isr.rel \ 39 | hispeed_isr.rel ibn_isr.rel sof_isr.rel spare_isr.rel sudav_isr.rel \ 40 | suspend_isr.rel sutok_isr.rel usbreset_isr.rel 41 | 42 | EXTRA_DIST = $(SRC) 43 | 44 | all-local: ints.lib 45 | 46 | ints.lib: $(REL) 47 | $(AM_V_GEN)$(SDCCLIB) ints.lib $? 48 | 49 | .c.rel: 50 | $(AM_V_GEN)$(SDCC) -mmcs51 -I${top_srcdir}/fx2lib/include -c $< -o $@ 51 | 52 | clean-local: 53 | $(AM_V_at)-rm -f *.asm *.lst *.rel *.sym ints.lib 54 | 55 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep0ack_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep0ack_isr() __interrupt EP0ACK_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep0in_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep0in_isr() __interrupt EP0IN_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep0out_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep0out_isr() __interrupt EP0OUT_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep0ping_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep0ping_isr() __interrupt EP0PING_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep1in_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep1in_isr() __interrupt EP1IN_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep1out_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep1out_isr() __interrupt EP1OUT_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep1ping_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep1ping_isr() __interrupt EP1PING_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep2_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep2_isr() __interrupt EP2_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep2ef_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep2ef_isr() __interrupt EP2EF_ISR{} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep2ff_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep2ff_isr() __interrupt EP2FF_ISR{} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep2isoerr_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep2isoerr_isr() __interrupt EP2ISOERR_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep2pf_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep2pf_isr() __interrupt EP2PF_ISR{} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep2ping_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep2ping_isr() __interrupt EP2PING_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep4_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep4_isr() __interrupt EP4_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep4ef_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep4ef_isr() __interrupt EP4EF_ISR{} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep4ff_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep4ff_isr() __interrupt EP4FF_ISR{} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep4isoerr_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep4isoerr_isr() __interrupt EP4ISOERR_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep4pf_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep4pf_isr() __interrupt EP4PF_ISR{} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep4ping_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep4ping_isr() __interrupt EP4PING_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep6_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep6_isr() __interrupt EP6_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep6ef_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep6ef_isr() __interrupt EP6EF_ISR{} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep6ff_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep6ff_isr() __interrupt EP6FF_ISR{} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep6isoerr_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep6isoerr_isr() __interrupt EP6ISOERR_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep6pf_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep6pf_isr() __interrupt EP6PF_ISR{} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep6ping_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep6ping_isr() __interrupt EP6PING_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep8_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep8_isr() __interrupt EP8_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep8ef_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep8ef_isr() __interrupt EP8EF_ISR{} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep8ff_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep8ff_isr() __interrupt EP8FF_ISR{} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep8isoerr_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep8isoerr_isr() __interrupt EP8ISOERR_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep8pf_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep8pf_isr() __interrupt EP8PF_ISR{} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ep8ping_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ep8ping_isr() __interrupt EP8PING_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/errlimit_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void errlimit_isr() __interrupt ERRLIMIT_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/gpifdone_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void gpifdone_isr() __interrupt GPIFDONE_ISR{} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/gpifwf_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void gpifwf_isr() __interrupt GPIFWF_ISR{} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/hispeed_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void hispeed_isr() __interrupt HISPEED_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/ibn_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void ibn_isr() __interrupt IBN_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/sof_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void sof_isr() __interrupt SOF_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/spare_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void spare_isr() __interrupt RESERVED_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/sudav_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void sudav_isr() __interrupt SUDAV_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/suspend_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void suspend_isr() __interrupt SUSPEND_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/sutok_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void sutok_isr() __interrupt SUTOK_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/interrupts/usbreset_isr.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2010 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | #include 20 | 21 | void usbreset_isr() __interrupt USBRESET_ISR {} 22 | 23 | -------------------------------------------------------------------------------- /fx2lib/lib/serial.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2009 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | 25 | /** 26 | * using the comp port implies that timer 2 will be used as 27 | * a baud rate generator. (Don't use timer 2) 28 | **/ 29 | void sio0_init( WORD baud_rate ) __critical { // baud_rate max should be 57600 since int=2 bytes 30 | 31 | WORD hl; // hl value for reload 32 | BYTE mult; // multiplier for clock speed 33 | DWORD tmp; // scratch for mult/divide 34 | 35 | // 0 = 12mhz, 1=24mhz, 2=48mhz 36 | mult = CPUFREQ == CLK_12M ? 1 : 37 | CPUFREQ == CLK_24M ? 2 : 4; // since only 3 clock speeds, fast switch instead of doing 2^clock speed pow(2,clkspd) 38 | 39 | // set the clock rate 40 | // use clock 2 41 | RCLK=1;TCLK=1; 42 | 43 | // RCAP2H:L = 0xFFFF - CLKOUT / 32 x baud_rate 44 | 45 | // in order to round to nearest value.. 46 | // tmp * 2 // double 47 | // tmp / rate // do the divide 48 | // tmp + 1 // add one (which is like adding 1/2) 49 | // tmp / 2 // back to original rounded 50 | tmp = mult * 375000L * 2 ; 51 | tmp /= baud_rate; 52 | tmp += 1; 53 | tmp /= 2; 54 | 55 | hl = 0xFFFF - (WORD)tmp; 56 | 57 | RCAP2H= MSB(hl); 58 | // seems that the 24/48mhz calculations are always one less than suggested values 59 | // trm table 14-16 60 | RCAP2L= LSB(hl) + (mult>0?1:0); 61 | TR2=1; // start the timer 62 | 63 | // set up the serial port 64 | SM0 = 0; SM1=1;// serial mode 1 (asyncronous) 65 | SM2 = 0 ; // has to do with receiving 66 | REN = 1 ; // to enable receiving 67 | PCON |= 0x80; // SET SMOD0, baud rate doubler 68 | TI = 1; // we send initial byte 69 | 70 | } 71 | 72 | char getchar() { 73 | char c; 74 | while (!RI) 75 | ; 76 | c=SBUF0; 77 | RI=0; 78 | return c; 79 | } 80 | 81 | void _transchar(char c) { 82 | while ( !TI ); // wait for TI=1 83 | TI=0; 84 | SBUF0=c; 85 | } 86 | 87 | void putchar (char c) { 88 | if (c=='\n') _transchar('\r'); // transmit \r\n 89 | _transchar(c); 90 | if (c == '\r' ) _transchar('\n'); // transmit \r\n 91 | } 92 | 93 | -------------------------------------------------------------------------------- /fx2lib/lib/setupdat.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2009 Ubixum, Inc. 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | **/ 18 | 19 | //#define DEBUG_SETUPDAT 20 | 21 | #ifdef DEBUG_SETUPDAT 22 | #include // NOTE this needs deleted 23 | #else 24 | #define printf(...) 25 | #define NULL (void*)0; 26 | #endif 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | 34 | extern BOOL handle_vendorcommand(BYTE cmd); 35 | extern BOOL handle_set_configuration(BYTE cfg); 36 | extern BOOL handle_get_interface(BYTE ifc, BYTE* alt_ifc); 37 | extern BOOL handle_set_interface(BYTE ifc,BYTE alt_ifc); 38 | extern BYTE handle_get_configuration(); 39 | extern BOOL handle_set_configuration(BYTE cfg); 40 | extern void handle_reset_ep(BYTE ep); 41 | 42 | /** 43 | * Predefs for handlers 44 | **/ 45 | 46 | 47 | // GET_STATUS, 48 | BOOL handle_get_status(); 49 | // CLEAR_FEATURE, 50 | BOOL handle_clear_feature(); 51 | // 0x02 is reserved 52 | // SET_FEATURE=0x03, 53 | BOOL handle_set_feature(); 54 | // 0x04 is reserved 55 | // SET_ADDRESS=0x05, // this is handled by EZ-USB core unless RENUM=0 56 | // GET_DESCRIPTOR, 57 | void handle_get_descriptor(); 58 | // SET_DESCRIPTOR, 59 | // GET_CONFIGURATION, // handled by callback 60 | // SET_CONFIGURATION, // handled by callback 61 | // GET_INTERFACE, // handled by callback 62 | // SET_INTERFACE, // handled by callback 63 | // SYNC_FRAME // not yet implemented 64 | 65 | /* 66 | TRM 2.2 67 | Setup Token -> 68 | data transfer -> 69 | handshake 70 | */ 71 | 72 | void handle_setupdata() { 73 | //printf ( "Handle setupdat: %02x\n", SETUPDAT[1] ); 74 | 75 | switch ( SETUPDAT[1] ) { 76 | 77 | case GET_STATUS: 78 | if (!handle_get_status()) 79 | STALLEP0(); 80 | break; 81 | case CLEAR_FEATURE: 82 | if (!handle_clear_feature()) { 83 | STALLEP0(); 84 | } 85 | break; 86 | case SET_FEATURE: 87 | if (!handle_set_feature()) { 88 | STALLEP0(); 89 | } 90 | break; 91 | case GET_DESCRIPTOR: 92 | handle_get_descriptor(); 93 | break; 94 | case GET_CONFIGURATION: 95 | EP0BUF[0] = handle_get_configuration(); 96 | EP0BCH=0; 97 | EP0BCL=1; 98 | break; 99 | case SET_CONFIGURATION: 100 | // user callback 101 | if( !handle_set_configuration(SETUPDAT[2])) { 102 | STALLEP0(); 103 | } 104 | break; 105 | case GET_INTERFACE: 106 | { 107 | BYTE alt_ifc; 108 | if (!handle_get_interface(SETUPDAT[4],&alt_ifc)) { 109 | STALLEP0(); 110 | } else { 111 | EP0BUF[0] = alt_ifc; 112 | EP0BCH=0; 113 | EP0BCL=1; 114 | } 115 | } 116 | break; 117 | case SET_INTERFACE: 118 | // user callback 119 | if ( !handle_set_interface(SETUPDAT[4],SETUPDAT[2])) { 120 | STALLEP0(); 121 | } 122 | break; 123 | default: 124 | if (!handle_vendorcommand(SETUPDAT[1])) { 125 | printf ( "Unhandled Vendor Command: %02x\n" , SETUPDAT[1] ); 126 | STALLEP0(); 127 | } 128 | 129 | 130 | } 131 | 132 | // do the handshake 133 | EP0CS |= bmHSNAK; 134 | 135 | } 136 | 137 | __xdata BYTE* ep_addr(BYTE ep) { // bit 8 of ep_num is the direction 138 | BYTE ep_num = ep&~0x80; // mask the direction 139 | switch (ep_num) { 140 | case 0: return &EP0CS; 141 | case 1: return ep&0x80? &EP1INCS : &EP1OUTCS; 142 | case 2: return &EP2CS; 143 | case 4: return &EP4CS; 144 | case 6: return &EP6CS; 145 | case 8: return &EP8CS; 146 | default: return NULL; 147 | } 148 | } 149 | 150 | 151 | // Get status has three request types 152 | #define GS_DEVICE 0x80 153 | #define GS_INTERFACE 0x81 154 | #define GS_ENDPOINT 0x82 155 | 156 | 157 | volatile BOOL self_powered=FALSE; 158 | volatile BOOL remote_wakeup_allowed=FALSE; 159 | 160 | BOOL handle_get_status() { 161 | 162 | switch ( SETUPDAT[0] ) { 163 | 164 | // case 0: // sometimes we get a 0 status too 165 | case GS_INTERFACE: 166 | EP0BUF[0] = 0; 167 | EP0BUF[1] = 0; 168 | EP0BCH=0; 169 | EP0BCL=2; 170 | break; 171 | case GS_DEVICE: 172 | 173 | // two byte response 174 | // byte 0 bit 0 = self powered bit 1 = remote wakeup 175 | EP0BUF[0] = (remote_wakeup_allowed << 1) | self_powered; 176 | // byte 1 = 0 177 | EP0BUF[1] = 0; 178 | EP0BCH = 0; 179 | EP0BCL = 2; 180 | break; 181 | case GS_ENDPOINT: 182 | { 183 | __xdata BYTE* pep=ep_addr(SETUPDAT[4]); 184 | if ( !pep ) return FALSE; 185 | // byte 0 bit 0 = stall bit 186 | EP0BUF[0] = *pep & bmEPSTALL ? 1 : 0; 187 | EP0BUF[1] = 0; 188 | EP0BCH=0; 189 | EP0BCL=2; 190 | } 191 | break; 192 | default: 193 | printf ( "Unexpected Get Status: %02x\n", SETUPDAT[0] ); 194 | return FALSE; 195 | 196 | 197 | } 198 | return TRUE; 199 | } 200 | 201 | 202 | #define GF_DEVICE 0 203 | #define GF_ENDPOINT 2 204 | 205 | BOOL handle_clear_feature() { 206 | //printf ( "Clear Feature\n" ); 207 | switch ( SETUPDAT[0] ) { 208 | case GF_DEVICE: 209 | if (SETUPDAT[2] == 1) { 210 | remote_wakeup_allowed=FALSE; 211 | break; 212 | } 213 | return FALSE; 214 | case GF_ENDPOINT: 215 | if (SETUPDAT[2] == 0) { // ep stall feature 216 | __xdata BYTE* pep=ep_addr(SETUPDAT[4]); 217 | printf ( "unstall endpoint %02X\n" , SETUPDAT[4] ); 218 | *pep &= ~bmEPSTALL; 219 | } else { 220 | printf ( "unsupported ep feature %02x", SETUPDAT[2] ); 221 | return FALSE; 222 | } 223 | 224 | break; 225 | default: 226 | return handle_vendorcommand(SETUPDAT[1]); 227 | } 228 | return TRUE; 229 | } 230 | 231 | BOOL handle_set_feature() { 232 | printf ( "Set Feature %02x\n", SETUPDAT[0] ); 233 | switch ( SETUPDAT[0] ) { 234 | case GF_DEVICE: 235 | if (SETUPDAT[2] == 2) break; // this is TEST_MODE and we simply need to return the handshake 236 | if (SETUPDAT[2] == 1) { 237 | remote_wakeup_allowed=TRUE; 238 | break; 239 | } 240 | return FALSE; 241 | case GF_ENDPOINT: 242 | if ( SETUPDAT[2] == 0 ) { // ep stall feature 243 | // set TRM 2.3.2 244 | // stall and endpoint 245 | __xdata BYTE* pep = ep_addr(SETUPDAT[4]); 246 | printf ( "Stall ep %d\n", SETUPDAT[4] ); 247 | if (!pep) { 248 | return FALSE; 249 | } 250 | 251 | *pep |= bmEPSTALL; 252 | // should now reset data toggles 253 | // write ep+dir to TOGCTL 254 | RESETTOGGLE(SETUPDAT[4]); 255 | // restore stalled ep to default condition 256 | // NOTE 257 | //handle_reset_ep(SETUPDAT[4]); 258 | 259 | } else { 260 | printf ( "unsupported ep feature %02x\n", SETUPDAT[2] ); 261 | return FALSE; 262 | } 263 | break; 264 | default: 265 | return handle_vendorcommand(SETUPDAT[1]); 266 | } 267 | return TRUE; 268 | } 269 | 270 | /* these are devined in dscr.asm 271 | and need to be customized then 272 | linked in by the firmware manually */ 273 | extern __code WORD dev_dscr; 274 | extern __code WORD dev_qual_dscr; 275 | extern __code WORD highspd_dscr; 276 | extern __code WORD fullspd_dscr; 277 | extern __code WORD dev_strings; 278 | 279 | WORD pDevConfig = (WORD)&fullspd_dscr; 280 | WORD pOtherConfig = (WORD)&highspd_dscr; 281 | 282 | void handle_hispeed(BOOL highspeed) { 283 | __critical { 284 | printf ( "Hi Speed or reset Interrupt\n" ); 285 | if (highspeed) { 286 | pDevConfig=(WORD)&highspd_dscr; 287 | pOtherConfig=(WORD)&fullspd_dscr; 288 | } else { 289 | pDevConfig=(WORD)&fullspd_dscr; 290 | pOtherConfig=(WORD)&highspd_dscr; 291 | } 292 | } 293 | } 294 | 295 | /** 296 | * Handle: 297 | * Device Descriptor 298 | * Device Qualifier 299 | * Configuration 300 | * String 301 | * Other-Speed 302 | **/ 303 | void handle_get_descriptor() { 304 | //printf ( "Get Descriptor\n" ); 305 | 306 | switch ( SETUPDAT[3] ) { 307 | case DSCR_DEVICE_TYPE: 308 | printf ( "Get Device Config\n" ); 309 | SUDPTRH = MSB((WORD)&dev_dscr); 310 | SUDPTRL = LSB((WORD)&dev_dscr); 311 | break; 312 | case DSCR_CONFIG_TYPE: 313 | // get the config descriptor 314 | printf ( "Get Config Descriptor\n"); 315 | SUDPTRH = MSB(pDevConfig); 316 | SUDPTRL = LSB(pDevConfig); 317 | break; 318 | case DSCR_STRING_TYPE: 319 | //printf ( "Get String Descriptor idx: %d\n", SETUPDAT[2] ); 320 | { 321 | STRING_DSCR* pStr = (STRING_DSCR*)&dev_strings; 322 | // pStr points to string 0 323 | BYTE idx = SETUPDAT[2]; 324 | BYTE cur=0; // current check 325 | do { 326 | if (idx==cur++) break; 327 | //printf ( "Length of pStr: %d\n", pStr->dsc_len ); 328 | //printf ( "pstr: %04x to ", pStr ); 329 | pStr = (STRING_DSCR*)((BYTE*)pStr + pStr->dsc_len); 330 | //printf ( "%04x\n" , pStr ); 331 | if (pStr->dsc_type != DSCR_STRING_TYPE) pStr=NULL; 332 | } while ( pStr && cur<=idx); 333 | 334 | if (pStr) { 335 | /* BYTE i; 336 | //printf ( "found str: '"); 337 | for (i=0;idsc_len-2;++i) { 338 | printf ( i%2==0?"%c":"%02x", *((BYTE*)(&pStr->pstr)+i)); 339 | } printf ( "\n"); */ 340 | 341 | SUDPTRH = MSB((WORD)pStr); 342 | SUDPTRL = LSB((WORD)pStr); 343 | //SUDPTRH = MSB((WORD)&dev_strings); 344 | //SUDPTRL = LSB((WORD)&dev_strings); 345 | } else {STALLEP0();} 346 | 347 | } 348 | 349 | break; 350 | case DSCR_DEVQUAL_TYPE: 351 | printf ( "Get Device Qualifier Descriptor\n"); 352 | // assumes this is a high speed capable device 353 | SUDPTRH = MSB((WORD)&dev_qual_dscr); 354 | SUDPTRL = LSB((WORD)&dev_qual_dscr); 355 | break; 356 | case DSCR_OTHERSPD_TYPE: 357 | printf ( "Other Speed Descriptor\n"); 358 | SUDPTRH = MSB(pOtherConfig); 359 | SUDPTRL = LSB(pOtherConfig); 360 | break; 361 | default: 362 | printf ( "Unhandled Get Descriptor: %02x\n", SETUPDAT[3]); 363 | STALLEP0(); 364 | } 365 | 366 | } 367 | 368 | -------------------------------------------------------------------------------- /fx2lib/lib/usbav.a51: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2010 Ubixum, Inc. 2 | ; 3 | ; This library is free software; you can redistribute it and/or 4 | ; modify it under the terms of the GNU Lesser General Public 5 | ; License as published by the Free Software Foundation; either 6 | ; version 2.1 of the License, or (at your option) any later version. 7 | ; 8 | ; This library is distributed in the hope that it will be useful, 9 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | ; Lesser General Public License for more details. 12 | ; 13 | ; You should have received a copy of the GNU Lesser General Public 14 | ; License along with this library; if not, write to the Free Software 15 | ; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | .module INT2AV ; jump table for usb auto vector 18 | 19 | .globl _INT2JT ; defined as global so this assembly gets included in project 20 | 21 | .area INT2AV (ABS,OVR) 22 | .org 0x43 ; this is where USBINT ( interrupt 8 ) jumps to 23 | _INT2AV = #. + 2 ; two bytes for ljmp (auto set by INT2IVEC) 24 | ljmp _INT2JT 25 | 26 | ; INT2 Jump Table 27 | 28 | .area INT2JT ( CODE ) 29 | ;.org 0x1A00 ; needs to be on a page boundary 30 | 31 | _INT2JT: 32 | ljmp _sudav_isr 33 | .db 0 34 | ljmp _sof_isr 35 | .db 0 36 | ljmp _sutok_isr 37 | .db 0 38 | ljmp _suspend_isr 39 | .db 0 40 | ljmp _usbreset_isr 41 | .db 0 42 | ljmp _hispeed_isr 43 | .db 0 44 | ljmp _ep0ack_isr 45 | .db 0 46 | ljmp _spare_isr 47 | .db 0 48 | ljmp _ep0in_isr 49 | .db 0 50 | ljmp _ep0out_isr 51 | .db 0 52 | ljmp _ep1in_isr 53 | .db 0 54 | ljmp _ep1out_isr 55 | .db 0 56 | ljmp _ep2_isr 57 | .db 0 58 | ljmp _ep4_isr 59 | .db 0 60 | ljmp _ep6_isr 61 | .db 0 62 | ljmp _ep8_isr 63 | .db 0 64 | ljmp _ibn_isr 65 | .db 0 66 | ljmp _spare_isr 67 | .db 0 68 | ljmp _ep0ping_isr 69 | .db 0 70 | ljmp _ep1ping_isr 71 | .db 0 72 | ljmp _ep2ping_isr 73 | .db 0 74 | ljmp _ep4ping_isr 75 | .db 0 76 | ljmp _ep6ping_isr 77 | .db 0 78 | ljmp _ep8ping_isr 79 | .db 0 80 | ljmp _errlimit_isr 81 | .db 0 82 | ljmp _spare_isr 83 | .db 0 84 | ljmp _spare_isr 85 | .db 0 86 | ljmp _spare_isr 87 | .db 0 88 | ljmp _ep2isoerr_isr 89 | .db 0 90 | ljmp _ep4isoerr_isr 91 | .db 0 92 | ljmp _ep6isoerr_isr 93 | .db 0 94 | ljmp _ep8isoerr_isr 95 | .db 0 96 | ; INT4JT 97 | ljmp _ep2pf_isr 98 | .db 0 99 | ljmp _ep4pf_isr 100 | .db 0 101 | ljmp _ep6pf_isr 102 | .db 0 103 | ljmp _ep8pf_isr 104 | .db 0 105 | ljmp _ep2ef_isr 106 | .db 0 107 | ljmp _ep4ef_isr 108 | .db 0 109 | ljmp _ep6ef_isr 110 | .db 0 111 | ljmp _ep8ef_isr 112 | .db 0 113 | ljmp _ep2ff_isr 114 | .db 0 115 | ljmp _ep4ff_isr 116 | .db 0 117 | ljmp _ep6ff_isr 118 | .db 0 119 | ljmp _ep8ff_isr 120 | .db 0 121 | ljmp _gpifdone_isr 122 | .db 0 123 | ljmp _gpifwf_isr 124 | .db 0 125 | 126 | -------------------------------------------------------------------------------- /hw/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of the DSLogic-fw project. 3 | ## 4 | ## Copyright (C) 2013 Uwe Hermann 5 | ## 6 | ## This program is free software; you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation; either version 2 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## This program is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ## You should have received a copy of the GNU General Public License 17 | ## along with this program; if not, write to the Free Software 18 | ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | ## 20 | 21 | BASENAME = DSLogic 22 | 23 | all-local: $(BASENAME).fw 24 | 25 | EXTRA_DIST = dscr.a51 26 | 27 | DSLogic: 28 | $(AM_V_at)cd ${top_builddir} && $(MAKE) DSLogic 29 | 30 | if FOUND_OBJCOPY 31 | $(BASENAME).fw: $(BASENAME).ihx 32 | $(AM_V_GEN)$(OBJCOPY) -Iihex $(BASENAME).ihx -Obinary $@ 33 | else 34 | if FOUND_MAKEBIN 35 | $(BASENAME).fw: $(BASENAME).ihx 36 | $(AM_V_GEN)$(MAKEBIN) -p < $(BASENAME).ihx > $@ 37 | endif 38 | endif 39 | 40 | RELS = ${top_builddir}/DSLogic.rel ${top_builddir}/interface.rel ${top_builddir}/usb.rel\ 41 | ${builddir}/dscr.rel 42 | 43 | $(RELS): DSLogic 44 | 45 | $(builddir)/dscr.rel: dscr.a51 46 | $(AM_V_at)if test "x${abs_top_srcdir}" != "x${abs_top_builddir}"; then \ 47 | $(INSTALL_DATA) ${srcdir}/dscr.a51 ${builddir}; \ 48 | fi 49 | $(AM_V_GEN)$(SDAS8051) -logs -I${top_srcdir}/include dscr.a51 50 | 51 | $(BASENAME).ihx: DSLogic $(RELS) $(top_builddir)/fx2lib/lib/fx2.lib $(top_builddir)/fx2lib/lib/interrupts/ints.lib 52 | $(AM_V_GEN)$(SDCC) -mmcs51 $(SDCC_FLAGS) -o $@ $(RELS) -L$(top_builddir)/fx2lib/lib fx2.lib interrupts/ints.lib 53 | 54 | install-data-local: $(BASENAME).fw 55 | $(AM_V_at)$(MKDIR_P) $(DESTDIR)$(FIRMWARE_DIR) 56 | $(AM_V_at)$(INSTALL_DATA) $(BASENAME).fw $(DESTDIR)$(FIRMWARE_DIR) 57 | 58 | uninstall-local: 59 | $(AM_V_at)-rm -f $(DESTDIR)$(FIRMWARE_DIR)/$(BASENAME).fw 60 | 61 | clean-local: 62 | $(AM_V_at)-rm -f *.lst *.rel *.rst *.sym *.lnk *.map *.mem *.ihx *.fw 63 | $(AM_V_at)-rm -f *.cdb *.lk *.omf 64 | -------------------------------------------------------------------------------- /hw/dscr.a51: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; This file is part of the DSLogic-fw project. 3 | ;; 4 | ;; Copyright (C) 2014 DreamSourceLab 5 | ;; 6 | ;; This program is free software; you can redistribute it and/or modify 7 | ;; it under the terms of the GNU General Public License as published by 8 | ;; the Free Software Foundation; either version 2 of the License, or 9 | ;; (at your option) any later version. 10 | ;; 11 | ;; This program is distributed in the hope that it will be useful, 12 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ;; GNU General Public License for more details. 15 | ;; 16 | ;; You should have received a copy of the GNU General Public License 17 | ;; along with this program; if not, write to the Free Software 18 | ;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | 20 | VID = 0x0E2A ; Manufacturer ID (0x2A0E) -- DreamSourceLab 21 | PID = 0x0100 ; Product ID (0x0001) -- DSLogic 22 | 23 | .include "dscr.inc" 24 | -------------------------------------------------------------------------------- /include/DSLogic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the DSLogic-fw project. 3 | * 4 | * Copyright (C) 2014 DreamSourceLab 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef DSLOGICFW_INCLUDE_DSLOGIC_H 22 | #define DSLOGICFW_INCLUDE_DSLOGIC_H 23 | 24 | #include 25 | #include 26 | 27 | #define SYNCDELAY() SYNCDELAY4 28 | 29 | /* 30 | * Major and minor DSLogic-fw version numbers. 31 | * These can be queried by the host via CMD_GET_FW_VERSION. 32 | */ 33 | #define DSLOGICFW_VER_MAJOR 1 34 | #define DSLOGICFW_VER_MINOR 0 35 | 36 | /* Protocol commands */ 37 | #define CMD_GET_FW_VERSION 0xb0 38 | #define CMD_GET_REVID_VERSION 0xb1 39 | #define CMD_START 0xb2 40 | #define CMD_CONFIG 0xb3 41 | #define CMD_SETTING 0xb4 42 | #define CMD_CONTROL 0xb5 43 | 44 | #define CMD_START_FLAGS_WIDE_POS 5 45 | #define CMD_START_FLAGS_CLK_SRC_POS 6 46 | #define CMD_START_FLAGS_STOP_POS 7 47 | 48 | #define CMD_START_FLAGS_SAMPLE_8BIT (0 << CMD_START_FLAGS_WIDE_POS) 49 | #define CMD_START_FLAGS_SAMPLE_16BIT (1 << CMD_START_FLAGS_WIDE_POS) 50 | 51 | #define CMD_START_FLAGS_CLK_30MHZ (0 << CMD_START_FLAGS_CLK_SRC_POS) 52 | #define CMD_START_FLAGS_CLK_48MHZ (1 << CMD_START_FLAGS_CLK_SRC_POS) 53 | 54 | #define CMD_START_FLAGS_STOP (1 << CMD_START_FLAGS_STOP_POS) 55 | 56 | struct cmd_start { 57 | uint8_t flags; 58 | uint8_t param0; 59 | uint8_t param1; 60 | }; 61 | 62 | struct cmd_setting_count { 63 | uint8_t byte0; 64 | uint8_t byte1; 65 | uint8_t byte2; 66 | }; 67 | 68 | struct cmd_cfg_count { 69 | uint8_t byte0; 70 | uint8_t byte1; 71 | uint8_t byte2; 72 | }; 73 | 74 | struct cmd_control { 75 | uint8_t byte0; 76 | uint8_t byte1; 77 | uint8_t byte2; 78 | uint8_t byte3; 79 | }; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /include/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## This file is part of the DSLogic-fw project. 3 | ## 4 | ## Copyright (C) 2013 Uwe Hermann 5 | ## 6 | ## This program is free software; you can redistribute it and/or modify 7 | ## it under the terms of the GNU General Public License as published by 8 | ## the Free Software Foundation; either version 2 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## This program is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ## You should have received a copy of the GNU General Public License 17 | ## along with this program; if not, write to the Free Software 18 | ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | ## 20 | 21 | EXTRA_DIST = dscr.inc DSLogic.h interface.h 22 | 23 | -------------------------------------------------------------------------------- /include/dscr.inc: -------------------------------------------------------------------------------- 1 | ;; 2 | ;; This file is part of the DSLogic-fw project. 3 | ;; 4 | ;; Copyright (C) 2011-2012 Uwe Hermann 5 | ;; Copyright (C) 2012 Joel Holdsworth 6 | ;; Copyright (C) 2014 DreamSourceLab 7 | ;; 8 | ;; This program is free software; you can redistribute it and/or modify 9 | ;; it under the terms of the GNU General Public License as published by 10 | ;; the Free Software Foundation; either version 2 of the License, or 11 | ;; (at your option) any later version. 12 | ;; 13 | ;; This program is distributed in the hope that it will be useful, 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | ;; GNU General Public License for more details. 17 | ;; 18 | ;; You should have received a copy of the GNU General Public License 19 | ;; along with this program; if not, write to the Free Software 20 | ;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | 22 | .module DEV_DSCR 23 | 24 | ; Descriptor types 25 | DSCR_DEVICE_TYPE = 1 26 | DSCR_CONFIG_TYPE = 2 27 | DSCR_STRING_TYPE = 3 28 | DSCR_INTERFACE_TYPE = 4 29 | DSCR_ENDPOINT_TYPE = 5 30 | DSCR_DEVQUAL_TYPE = 6 31 | 32 | ; Descriptor lengths 33 | DSCR_INTERFACE_LEN = 9 34 | DSCR_ENDPOINT_LEN = 7 35 | 36 | ; Endpoint types 37 | ENDPOINT_TYPE_CONTROL = 0 38 | ENDPOINT_TYPE_ISO = 1 39 | ENDPOINT_TYPE_BULK = 2 40 | ENDPOINT_TYPE_INT = 3 41 | 42 | .globl _dev_dscr, _dev_qual_dscr, _highspd_dscr, _fullspd_dscr, _dev_strings, _dev_strings_end 43 | .area DSCR_AREA (CODE) 44 | 45 | ; ----------------------------------------------------------------------------- 46 | ; Device descriptor 47 | ; ----------------------------------------------------------------------------- 48 | _dev_dscr: 49 | .db dev_dscr_end - _dev_dscr 50 | .db DSCR_DEVICE_TYPE 51 | .dw 0x0002 ; USB 2.0 52 | .db 0xff ; Class (vendor specific) 53 | .db 0xff ; Subclass (vendor specific) 54 | .db 0xff ; Protocol (vendor specific) 55 | .db 64 ; Max. EP0 packet size 56 | .dw VID ; Manufacturer ID 57 | .dw PID ; Product ID 58 | .dw 0x0100 ; Product version (0.01) 59 | .db 1 ; Manufacturer string index 60 | .db 2 ; Product string index 61 | .db 0 ; Serial number string index (none) 62 | .db 1 ; Number of configurations 63 | dev_dscr_end: 64 | 65 | ; ----------------------------------------------------------------------------- 66 | ; Device qualifier (for "other device speed") 67 | ; ----------------------------------------------------------------------------- 68 | _dev_qual_dscr: 69 | .db dev_qualdscr_end - _dev_qual_dscr 70 | .db DSCR_DEVQUAL_TYPE 71 | .dw 0x0002 ; USB 2.0 72 | .db 0xff ; Class (vendor specific) 73 | .db 0xff ; Subclass (vendor specific) 74 | .db 0xff ; Protocol (vendor specific) 75 | .db 64 ; Max. EP0 packet size 76 | .db 1 ; Number of configurations 77 | .db 0 ; Extra reserved byte 78 | dev_qualdscr_end: 79 | 80 | ; ----------------------------------------------------------------------------- 81 | ; High-Speed configuration descriptor 82 | ; ----------------------------------------------------------------------------- 83 | _highspd_dscr: 84 | .db highspd_dscr_end - _highspd_dscr 85 | .db DSCR_CONFIG_TYPE 86 | ; Total length of the configuration (1st line LSB, 2nd line MSB) 87 | .db (highspd_dscr_realend - _highspd_dscr) % 256 88 | .db (highspd_dscr_realend - _highspd_dscr) / 256 89 | .db 1 ; Number of interfaces 90 | .db 1 ; Configuration number 91 | .db 0 ; Configuration string (none) 92 | .db 0x80 ; Attributes (bus powered, no wakeup) 93 | .db 0x32 ; Max. power (100mA) 94 | highspd_dscr_end: 95 | 96 | ; Interfaces (only one in our case) 97 | .db DSCR_INTERFACE_LEN 98 | .db DSCR_INTERFACE_TYPE 99 | .db 0 ; Interface index 100 | .db 0 ; Alternate setting index 101 | .db 2 ; Number of endpoints 102 | .db 0xff ; Class (vendor specific) 103 | .db 0xff ; Subclass (vendor specific) 104 | .db 0xff ; Protocol (vendor specific) 105 | .db 0 ; String index (none) 106 | 107 | ; Endpoint 2 (out) 108 | .db DSCR_ENDPOINT_LEN 109 | .db DSCR_ENDPOINT_TYPE 110 | .db 0x02 ; EP number (2), direction (out) 111 | .db ENDPOINT_TYPE_BULK ; Endpoint type (bulk) 112 | .db 0x00 ; Max. packet size, LSB (512 bytes) 113 | .db 0x02 ; Max. packet size, MSB (512 bytes) 114 | .db 0x00 ; Polling interval 115 | 116 | ; Endpoint 6 (IN) 117 | .db DSCR_ENDPOINT_LEN 118 | .db DSCR_ENDPOINT_TYPE 119 | .db 0x86 ; EP number (6), direction (IN) 120 | .db ENDPOINT_TYPE_BULK ; Endpoint type (bulk) 121 | .db 0x00 ; Max. packet size, LSB (512 bytes) 122 | .db 0x02 ; Max. packet size, MSB (512 bytes) 123 | .db 0x00 ; Polling interval 124 | 125 | highspd_dscr_realend: 126 | 127 | .even 128 | 129 | ; ----------------------------------------------------------------------------- 130 | ; Full-Speed configuration descriptor 131 | ; ----------------------------------------------------------------------------- 132 | _fullspd_dscr: 133 | .db fullspd_dscr_end - _fullspd_dscr 134 | .db DSCR_CONFIG_TYPE 135 | ; Total length of the configuration (1st line LSB, 2nd line MSB) 136 | .db (fullspd_dscr_realend - _fullspd_dscr) % 256 137 | .db (fullspd_dscr_realend - _fullspd_dscr) / 256 138 | .db 1 ; Number of interfaces 139 | .db 1 ; Configuration number 140 | .db 0 ; Configuration string (none) 141 | .db 0x80 ; Attributes (bus powered, no wakeup) 142 | .db 0x32 ; Max. power (100mA) 143 | fullspd_dscr_end: 144 | 145 | ; Interfaces (only one in our case) 146 | .db DSCR_INTERFACE_LEN 147 | .db DSCR_INTERFACE_TYPE 148 | .db 0 ; Interface index 149 | .db 0 ; Alternate setting index 150 | .db 2 ; Number of endpoints 151 | .db 0xff ; Class (vendor specific) 152 | .db 0xff ; Subclass (vendor specific) 153 | .db 0xff ; Protocol (vendor specific) 154 | .db 0 ; String index (none) 155 | 156 | ; Endpoint 2 (out) 157 | .db DSCR_ENDPOINT_LEN 158 | .db DSCR_ENDPOINT_TYPE 159 | .db 0x02 ; EP number (2), direction (out) 160 | .db ENDPOINT_TYPE_BULK ; Endpoint type (bulk) 161 | .db 0x40 ; Max. packet size, LSB (512 bytes) 162 | .db 0x00 ; Max. packet size, MSB (512 bytes) 163 | .db 0x00 ; Polling interval 164 | 165 | ; Endpoint 6 (IN) 166 | .db DSCR_ENDPOINT_LEN 167 | .db DSCR_ENDPOINT_TYPE 168 | .db 0x86 ; EP number (6), direction (IN) 169 | .db ENDPOINT_TYPE_BULK ; Endpoint type (bulk) 170 | .db 0x40 ; Max. packet size, LSB (64 bytes) 171 | .db 0x00 ; Max. packet size, MSB (64 bytes) 172 | .db 0x00 ; Polling interval 173 | 174 | fullspd_dscr_realend: 175 | 176 | .even 177 | 178 | ; ----------------------------------------------------------------------------- 179 | ; Strings 180 | ; ----------------------------------------------------------------------------- 181 | 182 | _dev_strings: 183 | 184 | ; See http://www.usb.org/developers/docs/USB_LANGIDs.pdf for the full list. 185 | _string0: 186 | .db string0end - _string0 187 | .db DSCR_STRING_TYPE 188 | .db 0x09, 0x04 ; Language code 0x0409 (English, US) 189 | string0end: 190 | 191 | _string1: 192 | .db string1end - _string1 193 | .db DSCR_STRING_TYPE 194 | .ascii 'D' 195 | .db 0 196 | .ascii 'r' 197 | .db 0 198 | .ascii 'e' 199 | .db 0 200 | .ascii 'a' 201 | .db 0 202 | .ascii 'm' 203 | .db 0 204 | .ascii 'S' 205 | .db 0 206 | .ascii 'o' 207 | .db 0 208 | .ascii 'u' 209 | .db 0 210 | .ascii 'r' 211 | .db 0 212 | .ascii 'c' 213 | .db 0 214 | .ascii 'e' 215 | .db 0 216 | .ascii 'L' 217 | .db 0 218 | .ascii 'a' 219 | .db 0 220 | .ascii 'b' 221 | .db 0 222 | string1end: 223 | 224 | _string2: 225 | .db string2end - _string2 226 | .db DSCR_STRING_TYPE 227 | .ascii 'D' 228 | .db 0 229 | .ascii 'S' 230 | .db 0 231 | .ascii 'L' 232 | .db 0 233 | .ascii 'o' 234 | .db 0 235 | .ascii 'g' 236 | .db 0 237 | .ascii 'i' 238 | .db 0 239 | .ascii 'c' 240 | .db 0 241 | string2end: 242 | 243 | _dev_strings_end: 244 | .dw 0x0000 245 | 246 | -------------------------------------------------------------------------------- /include/interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the DSLogic-fw project. 3 | * 4 | * Copyright (C) 2014 DreamSourceLab 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef DSLOGICFW_INCLUDE_INTERFACE_H 22 | #define DSLOGICFW_INCLUDE_INTERFACE_H 23 | 24 | #include 25 | #include 26 | 27 | void setup_gpif_waveforms(void); 28 | void init_capture_intf(void); 29 | void init_config_intf(void); 30 | bool start_capture(void); 31 | bool stop_capture(); 32 | void poll_intf(void); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /interface.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the DSLogic-fw project. 3 | * 4 | * Copyright (C) 2012 Uwe Hermann 5 | * Copyright (C) 2012 Joel Holdsworth 6 | * Copyright (C) 2014 DreamSourceLab 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | /* ... */ 33 | #define MSBW(word) (BYTE)(((WORD)(word) >> 8) & 0xff) 34 | #define LSBW(word) (BYTE)((WORD)(word) & 0xff) 35 | 36 | /* ... */ 37 | __bit capturing = FALSE; 38 | 39 | const char __xdata WaveData[128] = 40 | { 41 | // Wave 0 42 | /* LenBr */ 0x08, 0x02, 0x93, 0x38, 0x01, 0x01, 0x01, 0x07, 43 | /* Opcode*/ 0x01, 0x01, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 44 | /* Output*/ 0x07, 0x07, 0x05, 0x07, 0x07, 0x07, 0x07, 0x07, 45 | /* LFun */ 0x87, 0x36, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x3F, 46 | // Wave 1 47 | ///* LenBr */ 0xF0, 0x01, 0x3F, 0x01, 0x01, 0x01, 0x00, 0x07, 48 | /* LenBr */ 0xE8, 0x01, 0x3F, 0x01, 0x01, 0x00, 0x00, 0x07, 49 | /* Opcode*/ 0x07, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 50 | /* Output*/ 0x04, 0x04, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 51 | /* LFun */ 0x6E, 0x00, 0x2D, 0x00, 0x00, 0x00, 0x00, 0x3F, 52 | // Wave 2 53 | /* LenBr */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 54 | /* Opcode*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 55 | /* Output*/ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 56 | /* LFun */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 57 | // Wave 3 58 | /* LenBr */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 59 | /* Opcode*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 60 | /* Output*/ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 61 | /* LFun */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 62 | }; 63 | 64 | void setup_gpif_waveforms(void) 65 | { 66 | int i; 67 | 68 | // use dual autopointer feature... 69 | AUTOPTRSETUP = 0x07; // inc both pointers, 70 | // ...warning: this introduces pdata hole(s) 71 | // ...at E67B (XAUTODAT1) and E67C (XAUTODAT2) 72 | // source 73 | AUTOPTRH1 = MSBW(&WaveData); 74 | AUTOPTRL1 = LSBW(&WaveData); 75 | // destination 76 | AUTOPTRH2 = 0xE4; 77 | AUTOPTRL2 = 0x00; 78 | // transfer 79 | for ( i = 0x00; i < 128; i++ ) 80 | { 81 | EXTAUTODAT2 = EXTAUTODAT1; 82 | } 83 | } 84 | 85 | void init_capture_intf(void) 86 | { 87 | IFCONFIG = 0xb6; 88 | // 7 IFCLKSRC=1 , FIFOs executes on internal clk source 89 | // 6 xMHz=0 , 30MHz internal clk rate 90 | // 5 IFCLKOE=1 , Drive IFCLK pin signal at 30MHz 91 | // 4 IFCLKPOL=1 , Invert IFCLK pin signal from internal clk 92 | // 3 ASYNC=0 , master samples synchronously 93 | // 2 GSTATE=1 , Drive GPIF states out on PORTE[2:0], debug WF 94 | // 1:0 IFCFG=10 , FX2 in GPIF master mode 95 | 96 | /* Abort currently executing GPIF waveform (if any). */ 97 | GPIFABORT = 0xff; 98 | 99 | /* Setup the GPIF registers. */ 100 | GPIFREADYCFG = 0x00; 101 | GPIFCTLCFG = 0x00; 102 | GPIFIDLECS = 0x00; 103 | /* CTL2 = 1; CTL1 = 1; CTL0 = 0*/ 104 | GPIFIDLECTL = 0x06; 105 | /* 106 | * Map index 0 in WAVEDATA to FIFORD. 107 | * Map index 1 in WAVEDATA to FIFOWR. 108 | * GPIFWFSELECT: [7:6] = SINGLEWR index, [5:4] = SINGLERD index, 109 | * [3:2] = FIFOWR index, [1:0] = FIFORD index 110 | */ 111 | GPIFWFSELECT = (0x3 << 6) | (0x2 << 4) | (0x1 << 2) | (0x0 << 0); 112 | GPIFREADYSTAT = 0x00; 113 | 114 | /* Reset the status. */ 115 | capturing = FALSE; 116 | } 117 | 118 | void init_config_intf(void) 119 | { 120 | IFCONFIG = 0xa6; 121 | // 7 IFCLKSRC=1 , FIFOs executes on internal clk source 122 | // 6 xMHz=0 , 30MHz internal clk rate 123 | // 5 IFCLKOE=1 , Drive IFCLK pin signal at 30MHz 124 | // 4 IFCLKPOL=0 , Don't invert IFCLK pin signal from internal clk 125 | // 3 ASYNC=0 , master samples synchronously 126 | // 2 GSTATE=1 , Drive GPIF states out on PORTE[2:0], debug WF 127 | // 1:0 IFCFG=10 , FX2 in GPIF master mode 128 | 129 | /* Abort currently executing GPIF waveform (if any). */ 130 | GPIFABORT = 0xff; 131 | 132 | /* Setup the GPIF registers. */ 133 | /* Internal RDY = 1; asynchronous RDY signals*/ 134 | GPIFREADYCFG = 0xE0; 135 | GPIFCTLCFG = 0x00; 136 | GPIFIDLECS = 0x00; 137 | /* CTL2 (PROG_B) = 1; CTL1 (CSI_B) = 1; CTL0(RDWR_B) = 0*/ 138 | GPIFIDLECTL = 0x06; 139 | /* 140 | * Map index 0 in WAVEDATA to FIFORD. 141 | * Map index 1 in WAVEDATA to FIFOWR. 142 | * GPIFWFSELECT: [7:6] = SINGLEWR index, [5:4] = SINGLERD index, 143 | * [3:2] = FIFOWR index, [1:0] = FIFORD index 144 | */ 145 | GPIFWFSELECT = (0x3 << 6) | (0x2 << 4) | (0x1 << 2) | (0x0 << 0); 146 | GPIFREADYSTAT = 0x00; 147 | 148 | /**/ 149 | EP2FIFOPFH = 0x40; 150 | EP2FIFOPFL = 0x01; 151 | EP2GPIFFLGSEL = 0x00; 152 | 153 | /* */ 154 | IOA &= 0xfd; 155 | IOA |= 0x02; 156 | } 157 | 158 | 159 | bool start_capture() 160 | { 161 | /* Sample clear before each acquistion */ 162 | IOA &= 0xf7; 163 | 164 | /* Abort currently executing GPIF waveform (if any). */ 165 | GPIFABORT = 0xff; 166 | 167 | /* ... */ 168 | FIFORESET = 0x80; // set NAKALL bit to NAK all transfers from host 169 | SYNCDELAY(); 170 | FIFORESET = 0x06; // reset EP6 FIFO 171 | SYNCDELAY(); 172 | FIFORESET = 0x00; // clear NAKALL bit to resume normal operation 173 | SYNCDELAY(); 174 | 175 | /* Ensure GPIF is idle before reconfiguration. */ 176 | while (!(GPIFTRIG & 0x80)); 177 | 178 | /* Clear the stop flag */ 179 | GPIFREADYCFG &= 0x7f; 180 | 181 | /* Configure the EP6 FIFO. */ 182 | EP6FIFOCFG = bmAUTOIN | bmWORDWIDE; 183 | SYNCDELAY(); 184 | 185 | /* sample clear end */ 186 | IOA |= 0x08; 187 | 188 | /* Execute the whole GPIF waveform once. */ 189 | gpif_set_tc16(1); 190 | 191 | /* Perform the initial GPIF read. */ 192 | gpif_fifo_read(GPIF_EP6); 193 | 194 | /* Update the status. */ 195 | capturing = TRUE; 196 | IOA |= 0x04; 197 | 198 | return true; 199 | } 200 | 201 | bool stop_capture() 202 | { 203 | GPIFREADYCFG |= bmBIT7; 204 | IOA &= 0xfb; 205 | return true; 206 | } 207 | 208 | void poll_intf(void) 209 | { 210 | /* Polling capture status. */ 211 | if (capturing && (GPIFTRIG & 0x80)) { 212 | /* Activate NAK-ALL to avoid race conditions. */ 213 | FIFORESET = 0x80; 214 | SYNCDELAY(); 215 | 216 | /* Switch to manual mode. */ 217 | EP6FIFOCFG = 0; 218 | SYNCDELAY(); 219 | 220 | /* Reset EP6. */ 221 | FIFORESET = 0x06; 222 | SYNCDELAY(); 223 | 224 | /* Return to auto mode. */ 225 | EP6FIFOCFG = bmAUTOIN; 226 | SYNCDELAY(); 227 | 228 | /* Release NAK-ALL. */ 229 | FIFORESET = 0x00; 230 | SYNCDELAY(); 231 | 232 | capturing = FALSE; 233 | } 234 | } 235 | -------------------------------------------------------------------------------- /usb.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the DSLogic-fw project. 3 | * 4 | * Copyright (C) 2012 Uwe Hermann 5 | * Copyright (C) 2012 Joel Holdsworth 6 | * Copyright (C) 2014 DreamSourceLab 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | /* ... */ 30 | extern volatile __bit recv_setup; 31 | extern BYTE command; 32 | 33 | BOOL handle_vendorcommand(BYTE cmd) 34 | { 35 | /* Protocol implementation */ 36 | switch (cmd) { 37 | case CMD_GET_FW_VERSION: 38 | EP0BUF[0] = DSLOGICFW_VER_MAJOR; 39 | EP0BUF[1] = DSLOGICFW_VER_MINOR; 40 | EP0BCH = 0; 41 | EP0BCL = 2; 42 | return TRUE; 43 | break; 44 | case CMD_GET_REVID_VERSION: 45 | EP0BUF[0] = REVID; 46 | EP0BCH = 0; 47 | EP0BCL = 1; 48 | return TRUE; 49 | break; 50 | case CMD_START: 51 | case CMD_SETTING: 52 | case CMD_CONTROL: 53 | command = cmd; 54 | EP0BCL = 0; 55 | return TRUE; 56 | break; 57 | case CMD_CONFIG: 58 | IOA |= 0x03; 59 | command = cmd; 60 | EP0BCL = 0; 61 | return TRUE; 62 | break; 63 | } 64 | return FALSE; 65 | } 66 | 67 | BOOL handle_get_interface(BYTE ifc, BYTE *alt_ifc) 68 | { 69 | /* We only support interface 0, alternate interface 0. */ 70 | if (ifc != 0) 71 | return FALSE; 72 | 73 | *alt_ifc = 0; 74 | return TRUE; 75 | } 76 | 77 | BOOL handle_set_interface(BYTE ifc, BYTE alt_ifc) 78 | { 79 | /* We only support interface 0, alternate interface 0. */ 80 | if (ifc != 0 || alt_ifc != 0) 81 | return FALSE; 82 | 83 | /* Perform procedure from TRM, section 2.3.7: */ 84 | 85 | /* (1) TODO. */ 86 | 87 | /* (2) Reset data toggles of the EPs in the interface. */ 88 | /* Note: RESETTOGGLE() gets the EP number WITH bit 7 set/cleared. */ 89 | RESETTOGGLE(0x86); 90 | RESETTOGGLE(0x02); 91 | 92 | /* (3) Restore EPs to their default conditions. */ 93 | /* Note: RESETFIFO() gets the EP number WITHOUT bit 7 set/cleared. */ 94 | RESETFIFO(0x06); 95 | RESETFIFO(0x02); 96 | /* TODO */ 97 | 98 | /* (4) Clear the HSNAK bit. Not needed, fx2lib does this. */ 99 | 100 | return TRUE; 101 | } 102 | 103 | BYTE handle_get_configuration(void) 104 | { 105 | /* Only support configuration 1. */ 106 | return 1; 107 | } 108 | 109 | BOOL handle_set_configuration(BYTE cfg) 110 | { 111 | /* Only support configuration 1. */ 112 | return (cfg == 1) ? TRUE : FALSE; 113 | } 114 | 115 | void sudav_isr(void) __interrupt SUDAV_ISR 116 | { 117 | recv_setup = TRUE; 118 | CLEAR_SUDAV(); 119 | } 120 | 121 | void sof_isr(void) __interrupt SOF_ISR __using 1 122 | { 123 | CLEAR_SOF(); 124 | } 125 | 126 | void usbreset_isr(void) __interrupt USBRESET_ISR 127 | { 128 | handle_hispeed(FALSE); 129 | CLEAR_USBRESET(); 130 | } 131 | 132 | void hispeed_isr(void) __interrupt HISPEED_ISR 133 | { 134 | handle_hispeed(TRUE); 135 | CLEAR_HISPEED(); 136 | } 137 | --------------------------------------------------------------------------------