Project Log : USB Stealth Twiddler
Description
Project log for development of USB Stealth Twiddler and associated code.
Inspired by Stealth USB CapsLocker but mainly an excuse for creating a "complete" project with my Arduino/AVRUSB integration and maybe having something to take to Kiwicon 2K8.
See also: Learning About Arduino and AVR-USB, ProjectLogArduinoUSB
Code
- See ProjectLogArduinoUSB currently.
Notes
- ( 19 September 2008 )
- Think I've found all the parts I need.
- I'm planning to use a bi-colour LED for feedback—just because I had some in my parts box and was looking for an excuse to use one. Thanks to the well-organised previous owner of the parts in question I know the item is a CQT24 Dome-Style Bi-Colour Red/Green LED Lamp.
- The ever helpful LED Resistor Calculator suggests matching the 2.2V forward drop with a 330 Ohm Resistor.
- Tested bi-colour LED Arduino code, it looked somewhat like this (with LED and resistor in series between digital pins 8 and 9):
void setup() { pinMode(8, INPUT); pinMode(9, INPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); // TODO: Use analogWrite for PWM. //digitalWrite(9, LOW); //digitalWrite(8, HIGH); } void loop () { digitalWrite(8, LOW); digitalWrite(9, HIGH); delay(250); digitalWrite(9, LOW); digitalWrite(8, HIGH); delay(250); }
- ( 23 September 2008 )
- Spent last few days "cutting" stripboard PCB to fit case with some success. Have also fiddled with KiCad to try and do stripboard design in pcbnew. Ended up using component side vias to stand in for jumpers. Have ended up playing by ear on actual layout though.
- Have soldered USB socket, diodes, pull-up resistor (to port) IC socket, reset pull-up and decoupling cap to stripboard. Also connected power. Tested along way. Final test was to use ATmega8 from previous experiments to test power & reset pull-up. Worked and flashed attached LED.
- No major issues noted so far. Minor issues: Neglected to remember position of secondary screw mounting holes (thus they are now inaccessible in at least one place due to jumper locations—friction seems to hold board in place currently). Neglected to allow correct placement of original ISP location—will move to new location probably. (The non-rectangular nature of the PCB restricts connector placement somewhat.)
- Next steps: solder in crystal and caps. Upload basic USB HID device demo. Eventually connect switch & LED. Consider whether it's worth connecting ISP—since we control the pull-up it may not be as big a deal to skip the bootloader.
- ( 24 September 2008 )
- Finished up hardware assembly today. Have tested ISP (via usbtinyisp with Arduino 12 IDE), push-button switch, bi-colour LED, pull-up resistor, crystal etc. Only thing not yet tested are the data lines.
- Start on software, using arduinousb alpha 001 release.
cd <path>/arduino-0012/hardware/libraries/ cp -R /<path>/arduinousb_release_001/libraries/UsbKeyboard . cd UsbKeyboard/
Patch usbconfig.h file:
--- usbconfig.h 2008-09-24 22:19:32.000000000 +1200 +++ usbconfig.h~ 2008-09-24 22:08:54.000000000 +1200 @@ -39,13 +39,13 @@ /* ----------------------- 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 6 /* */ +/* #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. @@ -138,7 +138,7 @@ * obdev's free shared VID/PID pair. See the file USBID-License.txt for * details. */ -#define USB_CFG_DEVICE_NAME 'T', 'w', 'i', 'd', 'd', 'l', 'r' +#define USB_CFG_DEVICE_NAME 'H', 'I', 'D', 'K', 'e', 'y', 's' #define USB_CFG_DEVICE_NAME_LEN 7 /* Same as above for the device name. If you don't want a device name, undefine * the macros. See the file USBID-License.txt before you assign a name.
Recompile
avr-g++ -Wall -Os -I. -DUSB_CFG_CLOCK_KHZ=16000 -mmcu=atmega168 -c usbdrvasm.S -c usbdrv.c
(I actually used this:)
/<path>/arduino-0012/hardware/tools/avr/bin/avr-g++ -Wall -Os -I. -DUSB_CFG_CLOCK_KHZ=16000 -mmcu=atmega168 -c usbdrvasm.S -c usbdrv.c
Also, got a couple of warnings...
usbdrv.c:75: warning: only initialized variables can be placed into program memory area usbdrv.c:85: warning: only initialized variables can be placed into program memory area usbdrv.c:94: warning: only initialized variables can be placed into program memory area usbdrv.c:114: warning: only initialized variables can be placed into program memory area usbdrv.c:143: warning: only initialized variables can be placed into program memory area
- ( 7 October 2008 )
- Unfortunately I couldn't get the device fully functional in time for KiwiCon but I did get enough done to have something to show & tell when I needed. Here's a large image of the Arduino/USB device.