From 2518500f894d0766d657bbb39bb5f296eb70d0dc Mon Sep 17 00:00:00 2001 From: "yamaguchi@google.com" Date: Fri, 19 Apr 2013 13:10:04 +0000 Subject: [PATCH] Initial upload of the Patapata input device firmware. Moving Morse key files to mozc-morse/ directory. --- mozc-flap/COPYING | 339 ++++++++++++++++ mozc-flap/Makefile | 122 ++++++ mozc-flap/Readme.txt | 106 +++++ mozc-flap/circuit.png | Bin 0 -> 19791 bytes mozc-flap/flap.c | 217 ++++++++++ mozc-flap/usb_keyboard.c | 108 +++++ mozc-flap/usb_keyboard.h | 35 ++ mozc-flap/usbconfig.h | 382 ++++++++++++++++++ COPYING => mozc-morse/COPYING | 0 Makefile => mozc-morse/Makefile | 2 +- Readme.txt => mozc-morse/Readme.txt | 0 circuit.png => mozc-morse/circuit.png | Bin dit-dah.c => mozc-morse/dit-dah.c | 2 +- .../romaji_dit-dah.txt | 0 space.c => mozc-morse/space.c | 2 +- usb_keyboard.c => mozc-morse/usb_keyboard.c | 0 usb_keyboard.h => mozc-morse/usb_keyboard.h | 0 usbconfig.h => mozc-morse/usbconfig.h | 0 18 files changed, 1312 insertions(+), 3 deletions(-) create mode 100644 mozc-flap/COPYING create mode 100644 mozc-flap/Makefile create mode 100644 mozc-flap/Readme.txt create mode 100644 mozc-flap/circuit.png create mode 100644 mozc-flap/flap.c create mode 100644 mozc-flap/usb_keyboard.c create mode 100644 mozc-flap/usb_keyboard.h create mode 100644 mozc-flap/usbconfig.h rename COPYING => mozc-morse/COPYING (100%) rename Makefile => mozc-morse/Makefile (99%) rename Readme.txt => mozc-morse/Readme.txt (100%) rename circuit.png => mozc-morse/circuit.png (100%) rename dit-dah.c => mozc-morse/dit-dah.c (98%) rename romaji_dit-dah.txt => mozc-morse/romaji_dit-dah.txt (100%) rename space.c => mozc-morse/space.c (96%) rename usb_keyboard.c => mozc-morse/usb_keyboard.c (100%) rename usb_keyboard.h => mozc-morse/usb_keyboard.h (100%) rename usbconfig.h => mozc-morse/usbconfig.h (100%) diff --git a/mozc-flap/COPYING b/mozc-flap/COPYING new file mode 100644 index 0000000..e584a02 --- /dev/null +++ b/mozc-flap/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + USB Patapata input device for Google Japanese Input + Copyright (C) 2013 Google Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/mozc-flap/Makefile b/mozc-flap/Makefile new file mode 100644 index 0000000..93f51c7 --- /dev/null +++ b/mozc-flap/Makefile @@ -0,0 +1,122 @@ +# +# Copyright 2013 Google Inc. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. +# + + +DEVICE = attiny2313 +F_CPU = 12000000 # in Hz + +AVRDUDE = avrdude -c usbasp -p $(DEVICE) # edit this line for your programmer + +USBDRV_DIR = ../third_party/usbdrv + +CFLAGS = -I$(USBDRV_DIR) -I. -DDEBUG_LEVEL=0 + + +OBJECTS = $(USBDRV_DIR)/usbdrv.o $(USBDRV_DIR)/usbdrvasm.o $(USBDRV_DIR)/oddebug.o usb_keyboard.o flap.o + +COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE) + +FUSE_L = 0xef +FUSE_H = 0xdb +# ATTiny2313 FUSE_L (Fuse low byte): +# 0xef = 1 1 1 0 1 1 1 1 +# ^ ^ \+/ \--+--/ +# | | | +------- CKSEL 3..0 (clock selection -> crystal @ 12 MHz) +# | | +--------------- SUT 1..0 (BOD enabled, fast rising power) +# | +------------------ CKOUT (clock output on CKOUT pin -> disabled) +# +-------------------- CKDIV8 (divide clock by 8 -> don't divide) +# ATTiny2313 FUSE_H (Fuse high byte): +# 0xdb = 1 1 0 1 1 0 1 1 +# ^ ^ ^ ^ \-+-/ ^ +# | | | | | +---- RSTDISBL (disable external reset -> enabled) +# | | | | +-------- BODLEVEL 2..0 (brownout trigger level -> 2.7V) +# | | | +-------------- WDTON (watchdog timer always on -> disable) +# | | +---------------- SPIEN (enable serial programming -> enabled) +# | +------------------ EESAVE (preserve EEPROM on Chip Erase -> not preserved) +# +-------------------- DWEN (debug wire enable) + + +# symbolic targets: +help: + @echo "This Makefile has no default rule. Use one of the following:" + @echo "make hex ........... to build flap.hex" + @echo "make program ....... to flash fuses and the flap firmware" + @echo "make fuse .......... to flash the fuses" + @echo "make flash ......... to flash the flap firmware" + @echo "make clean ......... to delete objects and hex file" + +hex: flap.hex + +program: flash fuse + +# rule for programming fuse bits: +fuse: + @[ "$(FUSE_H)" != "" -a "$(FUSE_L)" != "" ] || \ + { echo "*** Edit Makefile and choose values for FUSE_L and FUSE_H!"; exit 1; } + $(AVRDUDE) -U hfuse:w:$(FUSE_H):m -U lfuse:w:$(FUSE_L):m + +# rule for uploading firmware: +flash: flap.hex + $(AVRDUDE) -U flash:w:flap.hex:i + +# rule for deleting dependent files (those which can be built by Make): +clean: + rm -f flap.{hex,lst,obj,cof,list,map,eep.hex,elf,s} $(OBJECTS) $(USBDRV_DIR)/oddebug.s $(USBDRV_DIR)/usbdrv.s + +# Generic rule for compiling C files: +.c.o: + $(COMPILE) -c $< -o $@ + +$(USBDRV_DIR)/usbdrvasm.o: $(USBDRV_DIR)/usbdrvasm.S \ + $(USBDRV_DIR)/usbportability.h $(USBDRV_DIR)/usbdrv.h \ + usbconfig.h $(USBDRV_DIR)/usbdrvasm12.inc \ + $(USBDRV_DIR)/asmcommon.inc + +$(USBDRV_DIR)/oddebug.o: $(USBDRV_DIR)/oddebug.c $(USBDRV_DIR)/oddebug.h \ + $(USBDRV_DIR)/usbportability.h + +$(USBDRV_DIR)/usbdrv.o: $(USBDRV_DIR)/usbdrv.c $(USBDRV_DIR)/usbportability.h \ + $(USBDRV_DIR)/usbdrv.h usbconfig.h $(USBDRV_DIR)/oddebug.h + +usb_keyboard.o: usb_keyboard.c usb_keyboard.h $(USBDRV_DIR)/usbdrv.h \ + usbconfig.h $(USBDRV_DIR)/usbportability.h + +flap.o: flap.c usbconfig.h usb_keyboard.h + +# Generic rule for assembling Assembler source files: +.S.o: + $(COMPILE) -x assembler-with-cpp -c $< -o $@ +# "-x assembler-with-cpp" should not be necessary since this is the default +# file type for the .S (with capital S) extension. However, upper case +# characters are not always preserved on Windows. To ensure WinAVR +# compatibility define the file type manually. + +# Generic rule for compiling C to assembler, used for debugging only. +.c.s: + $(COMPILE) -S $< -o $@ + +# file targets: + +flap.elf: $(OBJECTS) + $(COMPILE) -o flap.elf $(OBJECTS) + +flap.hex: flap.elf + rm -f flap.hex flap.eep.hex + avr-objcopy -j .text -j .data -O ihex flap.elf flap.hex + avr-size flap.hex diff --git a/mozc-flap/Readme.txt b/mozc-flap/Readme.txt new file mode 100644 index 0000000..37aded9 --- /dev/null +++ b/mozc-flap/Readme.txt @@ -0,0 +1,106 @@ +Copyright 2013 Google Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +MA 02110-1301, USA. + + +===================================== + Summary +===================================== + +Circuit diagram and firmware of split-flap display input device for +Google Japanese Input. + + +===================================== + Files +===================================== + +* V-USB library files +../third_party/usbdrv/ + +The directory and files were copied from V-USB files available at +http://www.obdev.at/vusb/ + +* Documents +COPYING ...... Open Source license for this software. +Readme.txt ... The file you are currently reading. + +* Circuit diagram +circuit.png + +* Firmware source codes +Makefile +flap.c +usbconfig.h +usb_keyboard.c +usb_keyboard.h + + +===================================== + Building & Writing Firmware +===================================== + +* Building firmware binaries + +AVR-gcc is required. + +$ make hex + + +* Writing to the program memory + +Please refer documents of AVR programmer device you use. +Makefile contains "flash" rule that writes a hex file using Avrdude as an +example. + + +* Programming the fuse bits + +Fuse bits must be configured in order to run the firmware correctly. + +lower byte: 0xef +higher byte: 0xdb + +# ATTiny2313 FUSE_L (Fuse low byte): +# 0xef = 1 1 1 0 1 1 1 1 +# ^ ^ \+/ \--+--/ +# | | | +------- CKSEL 3..0 (clock selection -> crystal @ 12 MHz) +# | | +--------------- SUT 1..0 (BOD enabled, fast rising power) +# | +------------------ CKOUT (clock output on CKOUT pin -> disabled) +# +-------------------- CKDIV8 (divide clock by 8 -> don't divide) +# ATTiny2313 FUSE_H (Fuse high byte): +# 0xdb = 1 1 0 1 1 0 1 1 +# ^ ^ ^ ^ \-+-/ ^ +# | | | | | +---- RSTDISBL (disable external reset -> enabled) +# | | | | +-------- BODLEVEL 2..0 (brownout trigger level -> 2.7V) +# | | | +-------------- WDTON (watchdog timer always on -> disable) +# | | +---------------- SPIEN (enable serial programming -> enabled) +# | +------------------ EESAVE (preserve EEPROM on Chip Erase +# | -> not preserved) +# +-------------------- DWEN (debug wire enable) + +Makefile contains "fuse" rule that programs fuse bits using Avrdude as an +example. + + +================== + References +================== + +The firmware and circuit diagram has been developed based on V-USB. + +* V-USB +http://www.obdev.at/vusb/ diff --git a/mozc-flap/circuit.png b/mozc-flap/circuit.png new file mode 100644 index 0000000000000000000000000000000000000000..8a4b19656bca87dfd58594c2c038ada07cdd6a7d GIT binary patch literal 19791 zcmagG2Q*uM+&`XHRn_WJ)ap{DW>K4#mfBz1*rF|^R%}76E{dY1tu0lnO+?xnA+bkM zBlbwd-XlTm2*2z5{GRcD&iS4HIg!Zc-kW>xd%oW5M*m~1%W?YBX%Gm+q4)5<83=TO z4gwvUJarscIqMAh1biIxHPh7s6?FPBq! z;j=q0K+!y)Cx2v?;_EFh7i?lOXWI`x?%3k`ki(IZrOG!(n?ve2s6Q*fFBcyiaLP;< zI)NhosoziiyVsDYiBO|wx#bWyb|I;~# zEpdG4h-9lu4Q|hpix$vZf=YsdV;Z}>%LiLbM`Uc$nSA5vbMVXDif5Byt>qpY zyFe`kuXKNZw@nb}Lnv@;<6W|9`)PNaD^4Od!xd zH~#(j-&{Ll@+VYLKj=f?F@Q0X%>VZ-!e?KX6$C0DSY0PiP(4t0j&8L!bF;OqD9`q2 zxADm8LxI}R*3zR5clE5WT)3RW;{v%*^b6pyt4t>6soI^c0fqd=Q%B-f5%_Q zrYY-aeC@8l6f@|i5rYwl=&FXaPElkwj1P$-6CBR>n2rdy&sk!3Zj=ueexrZ5EB*S& z)=R6$C$B>QC2}USaXczHpL^`+{54aQT`NVed(_S@oA9N4=PsfW8qC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_EQ{?u zyS@!vYkHLk$e#D&ra zF-M`k@>Fk_0h9%RD^XXTe{3h9=D#j;Evy|tL2R8C+$LedEeXPYOC6(C?R?#?i>R`Ul=KB&Q)#UJ>R;zS zSON!Ft)MwG#->K1vmIePt^M1|XNCfPEHZ#RRs!}ze{fXd{iS#D@PUGd*Oh~dSPLNb zmT&{?jNRWb887SxAvjn8PE4O=zKoaqH4GWWe|8?5u|r=2yC&VEB?0kEkOl3G@Bp~? z;DG=;=TD$&jF$o|vaa!lrUo75*4TL|tI5e-JUE!M5FXQ2CoEa__db7+z!ub1Y=%fW zW&|}1!D#!v&Qg-L7+JF+?(k z|7R~XRjlBXfcDB4;`3|oEaYxU_co!aL7iSIEyiE)J>W>X=~I||P^PPc9v?a;lI*7o z?#7X3^}tT_JB@}Pg8L5TQayRl4$w82xB#~w-XH%P4fg-9d@U}JD%Ft6x$OC +#include +#include /* for _delay_ms() */ +#include "usb_keyboard.h" + +// Number of flaps that appear in one cycle. +#define LETTERS 40 + +// Number of flaps for alphabets and numerical digits. +#define ALPHANUMERICS (26 + 10) +const uchar extra_character_keycodes[LETTERS - ALPHANUMERICS] = { + KEYCODE_HYPHEN, KEYCODE_COMMA, KEYCODE_PERIOD, KEYCODE_SPACE +}; + +#define IDLE_TIMER_FREQUENCY 100 +#define DELAY_BEFORE_INPUT (1 * IDLE_TIMER_FREQUENCY) +#define MAX_SPEED 9 + +#ifdef _FULL_STEP + +#define STEPPER_PHASES 4 +/* Stepper excitation pattern. Invert the order if necessary. + * Bits 7 and 6 must be set to enable internal pullups for the switches. + */ +const uchar stepper_pattern[STEPPER_PHASES] = {0xc1, 0xc4, 0xc2, 0xc8}; +#define STEPPER_PHASE_MASK 3 +#define STEPS_PER_LETTER 5 + +#else + +/* half-step mode */ +#define STEPPER_PHASES 8 +const uchar stepper_pattern[STEPPER_PHASES] = { + 0xc1, 0xc5, 0xc4, 0xc6, 0xc2, 0xca, 0xc8, 0xc9}; +#define STEPPER_PHASE_MASK 7 +#define STEPS_PER_LETTER 10 + +#endif + +#define button_pressed() bit_is_clear(PINB, PINB7) +#define adjust_button_pressed() bit_is_clear(PINB, PINB6) + +const unsigned int intervals[MAX_SPEED + 1] = { + (unsigned int)(F_CPU / 8 / IDLE_TIMER_FREQUENCY), + (unsigned int)(F_CPU / 8 / 25), + (unsigned int)(F_CPU / 8 / 43), + (unsigned int)(F_CPU / 8 / 56), + (unsigned int)(F_CPU / 8 / 66), + (unsigned int)(F_CPU / 8 / 75), + (unsigned int)(F_CPU / 8 / 82), + (unsigned int)(F_CPU / 8 / 90), + (unsigned int)(F_CPU / 8 / 97), + (unsigned int)(F_CPU / 8 / 103) +}; + +uchar stepper_phase = 0; + +void advance_stepper_phase() { +#ifdef STEPPER_PHASE_MASK + stepper_phase = (stepper_phase + 1) & STEPPER_PHASE_MASK; +#else + stepper_phase ++; + if (stepper_phase >= STEPPER_PHASES) { + stepper_phase = 0; + } +#endif + PORTB = stepper_pattern[stepper_phase]; +} + +int __attribute__((noreturn)) main(void) +{ + DDRB = 0x3f; + PORTB = stepper_pattern[stepper_phase]; + + wdt_enable(WDTO_1S); + + initUsbKeyboard(); + + uchar key = 0; + uchar lastKey = 0; + + uchar character = 0; + uchar substep = 0; + uchar stop_count = 0; + uchar speed = 0; + enum {INIT, ACTIVE, PAUSED, ADJUST}; + uchar state = INIT; + uchar on_count = 0; + + /* sets up timer for stepper interval */ + /* timer 1 CTC mode, counts up at f[clock]/8 [Hz] */ + TCCR1B = (1 << WGM12) | (1 << CS11); + TCNT1 = 0; + OCR1A = intervals[speed]; + + while(1) { + wdt_reset(); + usbPoll(); + + if (bit_is_clear(TIFR, OCF1A)) { + continue; + } + TIFR |= _BV(OCF1A); /* clear OCF1A */ + + switch(state) { + case ADJUST: + speed = 0; + if (adjust_button_pressed()) { + } else { + state = INIT; + } + break; + case INIT: + if (button_pressed()) { + speed = 1; + on_count = 0; + state = ACTIVE; + } + if (adjust_button_pressed()) { + state = ADJUST; + advance_stepper_phase(); + continue; + } + break; + case ACTIVE: + if (button_pressed()) { + if (on_count < STEPS_PER_LETTER) { + on_count ++; + } else if (speed < MAX_SPEED) { + speed ++; + } + } else { + if (speed > 1) { + speed --; + } else if (speed == 1) { + if (substep == 0) { + speed = 0; + stop_count = 0; + state = PAUSED; + } + } + } + break; + case PAUSED: + default: + if (button_pressed()) { + speed = 1; + state = ACTIVE; + } else { + if (stop_count == DELAY_BEFORE_INPUT) { + if (character >= ALPHANUMERICS) { + key = extra_character_keycodes[character - ALPHANUMERICS]; + } else { + key = KEYCODE_A + character; + } + state = INIT; + } else { + stop_count ++; + } + } + } + + OCR1A = intervals[speed]; + if (speed > 0) { + substep ++; + if (substep >= STEPS_PER_LETTER) { + substep = 0; + character ++; + if (character >= LETTERS) { + character = 0; + } + } + advance_stepper_phase(); + } + + if (usbInterruptIsReady()) { + if (key != lastKey) { + lastKey = key; + prepareInterruptReport(key); + key = KEYCODE_NONE; + } + } + } +} diff --git a/mozc-flap/usb_keyboard.c b/mozc-flap/usb_keyboard.c new file mode 100644 index 0000000..97aaead --- /dev/null +++ b/mozc-flap/usb_keyboard.c @@ -0,0 +1,108 @@ +/* + * Copyright 2013 Google Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "usb_keyboard.h" + +#include /* for sei() */ +#include +#include /* for _delay_ms() */ + +/* USB report descriptor, size must match usbconfig.h */ +const PROGMEM char usbHidReportDescriptor[35] = { + 0x05, 0x01, // USAGE_PAGE (Generic Desktop) + 0x09, 0x06, // USAGE (Keyboard) + 0xa1, 0x01, // COLLECTION (Application) + 0x05, 0x07, // USAGE_PAGE (Keyboard) + 0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl) + 0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI) + 0x15, 0x00, // LOGICAL_MINIMUM (0) + 0x25, 0x01, // LOGICAL_MAXIMUM (1) + 0x75, 0x01, // REPORT_SIZE (1) + 0x95, 0x08, // REPORT_COUNT (8) + 0x81, 0x02, // INPUT (Data,Var,Abs) + 0x95, 0x01, // REPORT_COUNT (1) + 0x75, 0x08, // REPORT_SIZE (8) + 0x25, 0x65, // LOGICAL_MAXIMUM (101) + 0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated)) + 0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application) + 0x81, 0x00, // INPUT (Data,Ary,Abs) + 0xc0 // END_COLLECTION +}; + +static uchar reportBuffer[2]; +static uchar idleRate; /* repeat rate for keyboards */ + +#define MOD_CONTROL_LEFT (1<<0) +#define MOD_SHIFT_LEFT (1<<1) +#define MOD_ALT_LEFT (1<<2) +#define MOD_GUI_LEFT (1<<3) +#define MOD_CONTROL_RIGHT (1<<4) +#define MOD_SHIFT_RIGHT (1<<5) +#define MOD_ALT_RIGHT (1<<6) +#define MOD_GUI_RIGHT (1<<7) + +uchar keyReport[2]; + +usbMsgLen_t usbFunctionSetup(uchar data[8]) +{ + usbRequest_t *rq = (void *)data; + + /* The following requests are never used. But since they are required by + * the specification, we implement them in this example. + */ + if((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS) { + /* class request type */ + /* wValue: ReportType (highbyte), ReportID (lowbyte) */ + if(rq->bRequest == USBRQ_HID_GET_REPORT) { + /* we only have one report type, so don't look at wValue */ + usbMsgPtr = (void *)&reportBuffer; + return sizeof(reportBuffer); + } else if(rq->bRequest == USBRQ_HID_GET_IDLE) { + usbMsgPtr = &idleRate; + return 1; + } else if(rq->bRequest == USBRQ_HID_SET_IDLE) { + idleRate = rq->wValue.bytes[1]; + } + } else { + /* no vendor specific requests implemented */ + } + /* default for not implemented requests: return no data back to host */ + return 0; +} + +void initUsbKeyboard() { + usbInit(); + /* enforce re-enumeration, do this while interrupts are disabled! */ + usbDeviceDisconnect(); + uchar i; + i = 0; + while(--i) { /* fake USB disconnect for > 250 ms */ + wdt_reset(); + _delay_ms(1); + } + usbDeviceConnect(); + sei(); +} + +void prepareInterruptReport(uchar keycode) { + reportBuffer[0] = 0; /* modifier keys */ + reportBuffer[1] = keycode; + /* called after every poll of the interrupt endpoint */ + usbSetInterrupt((void *)&reportBuffer, sizeof(reportBuffer)); +} diff --git a/mozc-flap/usb_keyboard.h b/mozc-flap/usb_keyboard.h new file mode 100644 index 0000000..e583d4d --- /dev/null +++ b/mozc-flap/usb_keyboard.h @@ -0,0 +1,35 @@ +/* + * Copyright 2013 Google Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "usbdrv.h" + +usbMsgLen_t usbFunctionSetup(uchar data[8]); +void initUsbKeyboard(); +void prepareInterruptReport(uchar key); + +#define KEYCODE_NONE 0x00 +#define KEYCODE_A 0x04 +#define KEYCODE_SPACE 0x2c +#define KEYCODE_PERIOD 0x37 +#define KEYCODE_HYPHEN 0x2d +#define KEYCODE_SLASH 0x38 +#define KEYCODE_ENTER 0x28 +#define KEYCODE_SEMICOLON 0x33 +#define KEYCODE_COMMA 0x36 +#define KEYCODE_PERIOD 0x37 diff --git a/mozc-flap/usbconfig.h b/mozc-flap/usbconfig.h new file mode 100644 index 0000000..f2a0801 --- /dev/null +++ b/mozc-flap/usbconfig.h @@ -0,0 +1,382 @@ +/* + * Copyright 2013 Google Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + + +#ifndef __usbconfig_h_included__ +#define __usbconfig_h_included__ + +/* +This is a configuration file of the V-USB USB driver for USB Morse key device. + +It configures V-USB for USB D+ connected to Port D bit 2 (which is also +hardware interrupt 0 on many devices) and USB D- to Port D bit 4. + +Also see the original V-USB documents to customize. +*/ + +/* ---------------------------- Hardware Config ---------------------------- */ + +#define USB_CFG_IOPORTNAME D +/* This is the port where the USB bus is connected. When you configure it to + * "B", the registers PORTB, PINB and DDRB will be used. + */ +#define USB_CFG_DMINUS_BIT 4 +/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected. + * This may be any bit in the port. + */ +#define USB_CFG_DPLUS_BIT 3 +/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected. + * This may be any bit in the port. Please note that D+ must also be connected + * to interrupt pin INT0! [You can also use other interrupts, see section + * "Optional MCU Description" below, or you can connect D- to the interrupt, as + * it is required if you use the USB_COUNT_SOF feature. If you use D- for the + * interrupt, the USB interrupt will also be triggered at Start-Of-Frame + * markers every millisecond.] + */ +#define USB_CFG_CLOCK_KHZ (F_CPU/1000) +/* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000, + * 16500, 18000 and 20000. The 12.8 MHz and 16.5 MHz versions of the code + * require no crystal, they tolerate +/- 1% deviation from the nominal + * frequency. All other rates require a precision of 2000 ppm and thus a + * crystal! + * Since F_CPU should be defined to your actual clock rate anyway, you should + * not need to modify this setting. + */ +#define USB_CFG_CHECK_CRC 0 +/* Define this to 1 if you want that the driver checks integrity of incoming + * data packets (CRC checks). CRC checks cost quite a bit of code size and are + * currently only available for 18 MHz crystal clock. You must choose + * USB_CFG_CLOCK_KHZ = 18000 if you enable this option. + */ + +/* ----------------------- Optional Hardware Config ------------------------ */ + +#define USB_CFG_PULLUP_IOPORTNAME D +/* #define USB_CFG_PULLUP_IOPORTNAME D */ +/* If you connect the 1.5k pullup resistor from D- to a port pin instead of + * V+, you can connect and disconnect the device from firmware by calling + * the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h). + * This constant defines the port on which the pullup resistor is connected. + */ +#define USB_CFG_PULLUP_BIT 5 +/* #define USB_CFG_PULLUP_BIT 4 */ +/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined + * above) where the 1.5k pullup resistor is connected. See description + * above for details. + */ + +/* --------------------------- Functional Range ---------------------------- */ + +#define USB_CFG_HAVE_INTRIN_ENDPOINT 1 +/* Define this to 1 if you want to compile a version with two endpoints: The + * default control endpoint 0 and an interrupt-in endpoint (any other endpoint + * number). + */ +#define USB_CFG_HAVE_INTRIN_ENDPOINT3 0 +/* Define this to 1 if you want to compile a version with three endpoints: The + * default control endpoint 0, an interrupt-in endpoint 3 (or the number + * configured below) and a catch-all default interrupt-in endpoint as above. + * You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature. + */ +#define USB_CFG_EP3_NUMBER 3 +/* If the so-called endpoint 3 is used, it can now be configured to any other + * endpoint number (except 0) with this macro. Default if undefined is 3. + */ +/* #define USB_INITIAL_DATATOKEN USBPID_DATA1 */ +/* The above macro defines the startup condition for data toggling on the + * interrupt/bulk endpoints 1 and 3. Defaults to USBPID_DATA1. + * Since the token is toggled BEFORE sending any data, the first packet is + * sent with the oposite value of this configuration! + */ +#define USB_CFG_IMPLEMENT_HALT 0 +/* Define this to 1 if you also want to implement the ENDPOINT_HALT feature + * for endpoint 1 (interrupt endpoint). Although you may not need this feature, + * it is required by the standard. We have made it a config option because it + * bloats the code considerably. + */ +#define USB_CFG_SUPPRESS_INTR_CODE 0 +/* Define this to 1 if you want to declare interrupt-in endpoints, but don't + * want to send any data over them. If this macro is defined to 1, functions + * usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if + * you need the interrupt-in endpoints in order to comply to an interface + * (e.g. HID), but never want to send any data. This option saves a couple + * of bytes in flash memory and the transmit buffers in RAM. + */ +#define USB_CFG_INTR_POLL_INTERVAL 100 +/* If you compile a version with endpoint 1 (interrupt-in), this is the poll + * interval. The value is in milliseconds and must not be less than 10 ms for + * low speed devices. + */ +#define USB_CFG_IS_SELF_POWERED 0 +/* Define this to 1 if the device has its own power supply. Set it to 0 if the + * device is powered from the USB bus. + */ +#define USB_CFG_MAX_BUS_POWER 20 +/* Set this variable to the maximum USB bus power consumption of your device. + * The value is in milliamperes. [It will be divided by two since USB + * communicates power requirements in units of 2 mA.] + */ +#define USB_CFG_IMPLEMENT_FN_WRITE 0 +/* Set this to 1 if you want usbFunctionWrite() to be called for control-out + * transfers. Set it to 0 if you don't need it and want to save a couple of + * bytes. + */ +#define USB_CFG_IMPLEMENT_FN_READ 0 +/* Set this to 1 if you need to send control replies which are generated + * "on the fly" when usbFunctionRead() is called. If you only want to send + * data from a static buffer, set it to 0 and return the data from + * usbFunctionSetup(). This saves a couple of bytes. + */ +#define USB_CFG_IMPLEMENT_FN_WRITEOUT 0 +/* Define this to 1 if you want to use interrupt-out (or bulk out) endpoints. + * You must implement the function usbFunctionWriteOut() which receives all + * interrupt/bulk data sent to any endpoint other than 0. The endpoint number + * can be found in 'usbRxToken'. + */ +#define USB_CFG_HAVE_FLOWCONTROL 0 +/* Define this to 1 if you want flowcontrol over USB data. See the definition + * of the macros usbDisableAllRequests() and usbEnableAllRequests() in + * usbdrv.h. + */ +#define USB_CFG_DRIVER_FLASH_PAGE 0 +/* If the device has more than 64 kBytes of flash, define this to the 64 k page + * where the driver's constants (descriptors) are located. Or in other words: + * Define this to 1 for boot loaders on the ATMega128. + */ +#define USB_CFG_LONG_TRANSFERS 0 +/* Define this to 1 if you want to send/receive blocks of more than 254 bytes + * in a single control-in or control-out transfer. Note that the capability + * for long transfers increases the driver size. + */ +/* #define USB_RX_USER_HOOK(data, len) if(usbRxToken == (uchar)USBPID_SETUP) blinkLED(); */ +/* This macro is a hook if you want to do unconventional things. If it is + * defined, it's inserted at the beginning of received message processing. + * If you eat the received message and don't want default processing to + * proceed, do a return after doing your things. One possible application + * (besides debugging) is to flash a status LED on each packet. + */ +/* #define USB_RESET_HOOK(resetStarts) if(!resetStarts){hadUsbReset();} */ +/* This macro is a hook if you need to know when an USB RESET occurs. It has + * one parameter which distinguishes between the start of RESET state and its + * end. + */ +/* #define USB_SET_ADDRESS_HOOK() hadAddressAssigned(); */ +/* This macro (if defined) is executed when a USB SET_ADDRESS request was + * received. + */ +#define USB_COUNT_SOF 0 +/* define this macro to 1 if you need the global variable "usbSofCount" which + * counts SOF packets. This feature requires that the hardware interrupt is + * connected to D- instead of D+. + */ +/* #ifdef __ASSEMBLER__ + * macro myAssemblerMacro + * in YL, TCNT0 + * sts timer0Snapshot, YL + * endm + * #endif + * #define USB_SOF_HOOK myAssemblerMacro + * This macro (if defined) is executed in the assembler module when a + * Start Of Frame condition is detected. It is recommended to define it to + * the name of an assembler macro which is defined here as well so that more + * than one assembler instruction can be used. The macro may use the register + * YL and modify SREG. If it lasts longer than a couple of cycles, USB messages + * immediately after an SOF pulse may be lost and must be retried by the host. + * What can you do with this hook? Since the SOF signal occurs exactly every + * 1 ms (unless the host is in sleep mode), you can use it to tune OSCCAL in + * designs running on the internal RC oscillator. + * Please note that Start Of Frame detection works only if D- is wired to the + * interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES! + */ +#define USB_CFG_CHECK_DATA_TOGGLING 0 +/* define this macro to 1 if you want to filter out duplicate data packets + * sent by the host. Duplicates occur only as a consequence of communication + * errors, when the host does not receive an ACK. Please note that you need to + * implement the filtering yourself in usbFunctionWriteOut() and + * usbFunctionWrite(). Use the global usbCurrentDataToken and a static variable + * for each control- and out-endpoint to check for duplicate packets. + */ +#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0 +/* define this macro to 1 if you want the function usbMeasureFrameLength() + * compiled in. This function can be used to calibrate the AVR's RC oscillator. + */ +#define USB_USE_FAST_CRC 0 +/* The assembler module has two implementations for the CRC algorithm. One is + * faster, the other is smaller. This CRC routine is only used for transmitted + * messages where timing is not critical. The faster routine needs 31 cycles + * per byte while the smaller one needs 61 to 69 cycles. The faster routine + * may be worth the 32 bytes bigger code size if you transmit lots of data and + * run the AVR close to its limit. + */ + +/* -------------------------- Device Description --------------------------- */ + +#define USB_CFG_VENDOR_ID 0xc0, 0x16 /* = 0x16c0 = 5824 = voti.nl */ +/* USB vendor ID for the device, low byte first. If you have registered your + * own Vendor ID, define it here. Otherwise you may use one of obdev's free + * shared VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules! + */ +#define USB_CFG_DEVICE_ID 0xdb, 0x27 /* VOTI's Keyboard PID */ +/* This is the ID of the product, low byte first. It is interpreted in the + * scope of the vendor ID. If you have registered your own VID with usb.org + * or if you have licensed a PID from somebody else, define it here. Otherwise + * you may use one of obdev's free shared VID/PID pairs. See the file + * USB-IDs-for-free.txt for details! + */ +#define USB_CFG_DEVICE_VERSION 0x00, 0x01 +/* Version number of the device: Minor number first, then major number. + */ +#define USB_CFG_VENDOR_NAME 'g', 'o', 'o', 'g', 'l', 'e', '.', 'c', 'o', 'm' +#define USB_CFG_VENDOR_NAME_LEN 10 +/* These two values define the vendor name returned by the USB device. The name + * must be given as a list of characters under single quotes. The characters + * are interpreted as Unicode (UTF-16) entities. + * If you don't want a vendor name string, undefine these macros. + * ALWAYS define a vendor name containing your Internet domain name if you use + * obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for + * details. + */ +#define USB_CFG_DEVICE_NAME 'M', 'o', 'z', 'c', '-', 'p', 'a', 't', 'a', 'p', \ + 'a', 't', 'a' +#define USB_CFG_DEVICE_NAME_LEN 13 +/* Same as above for the device name. If you don't want a device name, undefine + * the macros. See the file USB-IDs-for-free.txt before you assign a name if + * you use a shared VID/PID. + */ +/*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */ +/*#define USB_CFG_SERIAL_NUMBER_LEN 0 */ +/* Same as above for the serial number. If you don't want a serial number, + * undefine the macros. + * It may be useful to provide the serial number through other means than at + * compile time. See the section about descriptor properties below for how + * to fine tune control over USB descriptors such as the string descriptor + * for the serial number. + */ +#define USB_CFG_DEVICE_CLASS 0 +#define USB_CFG_DEVICE_SUBCLASS 0 +/* See USB specification if you want to conform to an existing device class. + * Class 0xff is "vendor specific". + */ +#define USB_CFG_INTERFACE_CLASS 3 +#define USB_CFG_INTERFACE_SUBCLASS 0 +#define USB_CFG_INTERFACE_PROTOCOL 0 +/* See USB specification if you want to conform to an existing device class or + * protocol. The following classes must be set at interface level: + * HID class is 3, no subclass and protocol required (but may be useful!) + * CDC class is 2, use subclass 2 and protocol 1 for ACM + */ +#define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 35 +/* Define this to the length of the HID report descriptor, if you implement + * an HID device. Otherwise don't define it or define it to 0. + * If you use this define, you must add a PROGMEM character array named + * "usbHidReportDescriptor" to your code which contains the report descriptor. + * Don't forget to keep the array and this define in sync! + */ + +/* #define USB_PUBLIC static */ +/* Use the define above if you #include usbdrv.c instead of linking against it. + * This technique saves a couple of bytes in flash memory. + */ + +/* ------------------- Fine Control over USB Descriptors ------------------- */ +/* If you don't want to use the driver's default USB descriptors, you can + * provide our own. These can be provided as (1) fixed length static data in + * flash memory, (2) fixed length static data in RAM or (3) dynamically at + * runtime in the function usbFunctionDescriptor(). See usbdrv.h for more + * information about this function. + * Descriptor handling is configured through the descriptor's properties. If + * no properties are defined or if they are 0, the default descriptor is used. + * Possible properties are: + * + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched + * at runtime via usbFunctionDescriptor(). If the usbMsgPtr mechanism is + * used, the data is in FLASH by default. Add property USB_PROP_IS_RAM if + * you want RAM pointers. + * + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found + * in static memory is in RAM, not in flash memory. + * + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash), + * the driver must know the descriptor's length. The descriptor itself is + * found at the address of a well known identifier (see below). + * List of static descriptor names (must be declared PROGMEM if in flash): + * char usbDescriptorDevice[]; + * char usbDescriptorConfiguration[]; + * char usbDescriptorHidReport[]; + * char usbDescriptorString0[]; + * int usbDescriptorStringVendor[]; + * int usbDescriptorStringDevice[]; + * int usbDescriptorStringSerialNumber[]; + * Other descriptors can't be provided statically, they must be provided + * dynamically at runtime. + * + * Descriptor properties are or-ed or added together, e.g.: + * #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18)) + * + * The following descriptors are defined: + * USB_CFG_DESCR_PROPS_DEVICE + * USB_CFG_DESCR_PROPS_CONFIGURATION + * USB_CFG_DESCR_PROPS_STRINGS + * USB_CFG_DESCR_PROPS_STRING_0 + * USB_CFG_DESCR_PROPS_STRING_VENDOR + * USB_CFG_DESCR_PROPS_STRING_PRODUCT + * USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER + * USB_CFG_DESCR_PROPS_HID + * USB_CFG_DESCR_PROPS_HID_REPORT + * USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver) + * + * Note about string descriptors: String descriptors are not just strings, they + * are Unicode strings prefixed with a 2 byte header. Example: + * int serialNumberDescriptor[] = { + * USB_STRING_DESCRIPTOR_HEADER(6), + * 'S', 'e', 'r', 'i', 'a', 'l' + * }; + */ + +#define USB_CFG_DESCR_PROPS_DEVICE 0 +#define USB_CFG_DESCR_PROPS_CONFIGURATION 0 +#define USB_CFG_DESCR_PROPS_STRINGS 0 +#define USB_CFG_DESCR_PROPS_STRING_0 0 +#define USB_CFG_DESCR_PROPS_STRING_VENDOR 0 +#define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0 +#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0 +#define USB_CFG_DESCR_PROPS_HID 0 +#define USB_CFG_DESCR_PROPS_HID_REPORT 0 +#define USB_CFG_DESCR_PROPS_UNKNOWN 0 + +/* ----------------------- Optional MCU Description ------------------------ */ + +/* The following configurations have working defaults in usbdrv.h. You + * usually don't need to set them explicitly. Only if you want to run + * the driver on a device which is not yet supported or with a compiler + * which is not fully supported (such as IAR C) or if you use a differnt + * interrupt than INT0, you may have to define some of these. + */ +/* #define USB_INTR_CFG MCUCR */ +/* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) */ +/* #define USB_INTR_CFG_CLR 0 */ +/* #define USB_INTR_ENABLE GIMSK */ +/* #define USB_INTR_ENABLE_BIT INT0 */ +/* #define USB_INTR_PENDING GIFR */ +/* #define USB_INTR_PENDING_BIT INTF0 */ +/* #define USB_INTR_VECTOR INT0_vect */ + +#define USB_INTR_CFG_SET ((1 << ISC10) | (1 << ISC11)) /* INT1(Pos Edge only) */ +#define USB_INTR_ENABLE_BIT INT1 +#define USB_INTR_PENDING_BIT INTF1 +#define USB_INTR_VECTOR INT1_vect + +#endif /* __usbconfig_h_included__ */ diff --git a/COPYING b/mozc-morse/COPYING similarity index 100% rename from COPYING rename to mozc-morse/COPYING diff --git a/Makefile b/mozc-morse/Makefile similarity index 99% rename from Makefile rename to mozc-morse/Makefile index 14e3cb4..f65118b 100644 --- a/Makefile +++ b/mozc-morse/Makefile @@ -23,7 +23,7 @@ F_CPU = 12000000 # in Hz AVRDUDE = avrdude -c usbasp -p $(DEVICE) # edit this line for your programmer -USBDRV_DIR = third_party/usbdrv +USBDRV_DIR = ../third_party/usbdrv CFLAGS = -I$(USBDRV_DIR) -I. -DDEBUG_LEVEL=0 diff --git a/Readme.txt b/mozc-morse/Readme.txt similarity index 100% rename from Readme.txt rename to mozc-morse/Readme.txt diff --git a/circuit.png b/mozc-morse/circuit.png similarity index 100% rename from circuit.png rename to mozc-morse/circuit.png diff --git a/dit-dah.c b/mozc-morse/dit-dah.c similarity index 98% rename from dit-dah.c rename to mozc-morse/dit-dah.c index ed08563..77e1634 100644 --- a/dit-dah.c +++ b/mozc-morse/dit-dah.c @@ -68,7 +68,7 @@ int __attribute__((noreturn)) main(void) /* timer 1 CTC mode, counts up at f[clock]/8 [Hz] */ TCCR1B = (1 << WGM12) | (1 << CS11); TCNT1 = 0; - OCR1A = (unsigned int)F_CPU / 8 * 100; /* 100Hz, T=10 milliseconds */ + OCR1A = F_CPU / 8 / 100; /* 100Hz, T=10 milliseconds */ uchar key = 0; diff --git a/romaji_dit-dah.txt b/mozc-morse/romaji_dit-dah.txt similarity index 100% rename from romaji_dit-dah.txt rename to mozc-morse/romaji_dit-dah.txt diff --git a/space.c b/mozc-morse/space.c similarity index 96% rename from space.c rename to mozc-morse/space.c index 4c857fa..46a2b89 100644 --- a/space.c +++ b/mozc-morse/space.c @@ -40,7 +40,7 @@ int __attribute__((noreturn)) main(void) /* timer 1 CTC mode, counts up at f[clock]/8 [Hz] */ TCCR1B = (1 << WGM12) | (1 << CS11); TCNT1 = 0; - OCR1A = (unsigned int)F_CPU / 8 * 100; /* 100Hz, T=10 milliseconds */ + OCR1A = F_CPU / 8 / 100; /* 100Hz, T=10 milliseconds */ uchar key = 0; uchar lastKey = 0; diff --git a/usb_keyboard.c b/mozc-morse/usb_keyboard.c similarity index 100% rename from usb_keyboard.c rename to mozc-morse/usb_keyboard.c diff --git a/usb_keyboard.h b/mozc-morse/usb_keyboard.h similarity index 100% rename from usb_keyboard.h rename to mozc-morse/usb_keyboard.h diff --git a/usbconfig.h b/mozc-morse/usbconfig.h similarity index 100% rename from usbconfig.h rename to mozc-morse/usbconfig.h