diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..077a8ca --- /dev/null +++ b/ChangeLog @@ -0,0 +1,14 @@ +17/05/2018 + clockworkpi_keypad.ino uploaded to https://github.com/clockworkpi/Keypad. + CLOCKWORK Keypad Arduino driver + +01/08/2018 + Changelog created. + Added a debug flag to turn on/off keypress serial printing. + Intended for checking if the Keypad Board is working. + +14/04/2020 + Added a INVERT_AB flag to invert XYAB to ABXY easily. + Updated obdev v-usb lib to the latest eg. USBDRV_VERSION 20090822 to 20121206. + Ported UsbKeyboard to the latest v-usb. + Fixed the incorect not on the timer (from ! to bitwise ~) diff --git a/UsbKeyboard/Changelog.txt b/UsbKeyboard/Changelog.txt index 655a9d4..79b5215 100644 --- a/UsbKeyboard/Changelog.txt +++ b/UsbKeyboard/Changelog.txt @@ -294,3 +294,36 @@ Scroll down to the bottom to see the most recent changes. USB 1.1 (in particular bit 7, it is a must-be-set bit now). * Release 2009-08-22 + + - Moved first DBG1() after odDebugInit() in all examples. + - Use vector INT0_vect instead of SIG_INTERRUPT0 if defined. This makes + V-USB compatible with the new "p" suffix devices (e.g. ATMega328p). + - USB_CFG_CLOCK_KHZ setting is now required in usbconfig.h (no default any + more). + - New option USB_CFG_DRIVER_FLASH_PAGE allows boot loaders on devices with + more than 64 kB flash. + - Built-in configuration descriptor allows custom definition for second + endpoint now. + +* Release 2010-07-15 + + - Fixed bug in usbDriverSetup() which prevented descriptor sizes above 255 + bytes. + - Avoid a compiler warning for unused parameter in usbHandleResetHook() when + compiler option -Wextra is enabled. + - Fixed wrong hex value for some IDs in USB-IDs-for-free.txt. + - Keep a define for USBATTR_BUSPOWER, although the flag does not exist + in USB 1.1 any more. Set it to 0. This is for backward compatibility. + +* Release 2012-01-09 + + - Define a separate (defined) type for usbMsgPtr so that projects using a + tiny memory model can define it to an 8 bit type in usbconfig.h. This + change also saves a couple of bytes when using a scalar 16 bit type. + - Inserted "const" keyword for all PROGMEM declarations because new GCC + requires it. + - Fixed problem with dependence of usbportability.h on usbconfig.h. This + problem occurred with IAR CC only. + - Prepared repository for github.com. + +* Release 2012-12-06 \ No newline at end of file diff --git a/UsbKeyboard/CommercialLicense.txt b/UsbKeyboard/CommercialLicense.txt index 11d07d9..de1a2b0 100644 --- a/UsbKeyboard/CommercialLicense.txt +++ b/UsbKeyboard/CommercialLicense.txt @@ -1,5 +1,5 @@ V-USB Driver Software License Agreement -Version 2009-08-03 +Version 2012-07-09 THIS LICENSE AGREEMENT GRANTS YOU CERTAIN RIGHTS IN A SOFTWARE. YOU CAN ENTER INTO THIS AGREEMENT AND ACQUIRE THE RIGHTS OUTLINED BELOW BY PAYING @@ -37,10 +37,10 @@ Product ID(s), sent to you in e-mail. These Product IDs are reserved exclusively for you. OBJECTIVE DEVELOPMENT has obtained USB Product ID ranges under the Vendor ID 5824 from Wouter van Ooijen (Van Ooijen Technische Informatica, www.voti.nl) and under the Vendor ID 8352 from -Jason Kotzin (Clay Logic, www.claylogic.com). Both owners of the Vendor IDs -have obtained these IDs from the USB Implementers Forum, Inc. -(www.usb.org). OBJECTIVE DEVELOPMENT disclaims all liability which might -arise from the assignment of USB IDs. +Jason Kotzin (now flirc.tv, Inc.). Both owners of the Vendor IDs have +obtained these IDs from the USB Implementers Forum, Inc. (www.usb.org). +OBJECTIVE DEVELOPMENT disclaims all liability which might arise from the +assignment of USB IDs. 2.5 USB Certification. Although not part of this agreement, we want to make it clear that you cannot become USB certified when you use V-USB or a USB diff --git a/UsbKeyboard/Readme.txt b/UsbKeyboard/Readme.txt index a010d97..970dc66 100644 --- a/UsbKeyboard/Readme.txt +++ b/UsbKeyboard/Readme.txt @@ -49,8 +49,7 @@ CPU CORE CLOCK FREQUENCY ======================== We supply assembler modules for clock frequencies of 12 MHz, 12.8 MHz, 15 MHz, 16 MHz, 16.5 MHz 18 MHz and 20 MHz. Other clock rates are not supported. The -actual clock rate must be configured in usbdrv.h unless you use the default -12 MHz. +actual clock rate must be configured in usbconfig.h. 12 MHz Clock This is the traditional clock rate of V-USB because it's the lowest clock @@ -114,13 +113,28 @@ IDs. See http://www.obdev.at/vusb/ for details. DEVELOPMENT SYSTEM ================== This driver has been developed and optimized for the GNU compiler version 3 -(gcc 3). It does work well with gcc 4, but with bigger code size. We recommend -that you use the GNU compiler suite because it is freely available. V-USB -has also been ported to the IAR compiler and assembler. It has been tested -with IAR 4.10B/W32 and 4.12A/W32 on an ATmega8 with the "small" and "tiny" -memory model. Not every release is tested with IAR CC and the driver may -therefore fail to compile with IAR. Please note that gcc is more efficient for -usbdrv.c because this module has been deliberately optimized for gcc. +and 4. We recommend that you use the GNU compiler suite because it is freely +available. V-USB has also been ported to the IAR compiler and assembler. It +has been tested with IAR 4.10B/W32 and 4.12A/W32 on an ATmega8 with the +"small" and "tiny" memory model. Not every release is tested with IAR CC and +the driver may therefore fail to compile with IAR. Please note that gcc is +more efficient for usbdrv.c because this module has been deliberately +optimized for gcc. + +Gcc version 3 produces smaller code than version 4 due to new optimizing +capabilities which don't always improve things on 8 bit CPUs. The code size +generated by gcc 4 can be reduced with the compiler options +-fno-move-loop-invariants, -fno-tree-scev-cprop and +-fno-inline-small-functions in addition to -Os. On devices with more than +8k of flash memory, we also recommend the linker option --relax (written as +-Wl,--relax for gcc) to convert absolute calls into relative where possible. + +For more information about optimizing options see: + + http://www.tty1.net/blog/2008-04-29-avr-gcc-optimisations_en.html + +These optimizations are good for gcc 4.x. Version 3.x of gcc does not support +most of these options and produces good code anyway. USING V-USB FOR FREE diff --git a/UsbKeyboard/USB-ID-FAQ.txt b/UsbKeyboard/USB-ID-FAQ.txt index d1de8fb..a4a6bd6 100644 --- a/UsbKeyboard/USB-ID-FAQ.txt +++ b/UsbKeyboard/USB-ID-FAQ.txt @@ -1,4 +1,4 @@ -Version 2009-08-22 +Version 2012-07-09 ========================== WHY DO WE NEED THESE IDs? @@ -107,8 +107,8 @@ WHO IS THE OWNER OF THE VENDOR-ID? Objective Development has obtained ranges of USB Product-IDs under two Vendor-IDs: Under Vendor-ID 5824 from Wouter van Ooijen (Van Ooijen Technische Informatica, www.voti.nl) and under Vendor-ID 8352 from Jason -Kotzin (Clay Logic, www.claylogic.com). Both VID owners have received their -Vendor-ID directly from usb.org. +Kotzin (now flirc.tv, Inc.). Both VID owners have received their Vendor-ID +directly from usb.org. ========================================================================= diff --git a/UsbKeyboard/USB-IDs-for-free.txt b/UsbKeyboard/USB-IDs-for-free.txt index 2f4d59a..8f44427 100644 --- a/UsbKeyboard/USB-IDs-for-free.txt +++ b/UsbKeyboard/USB-IDs-for-free.txt @@ -86,8 +86,9 @@ If you use one of the IDs listed below, your device and host-side software must conform to these rules: (1) The USB device MUST provide a textual representation of the serial -number. The serial number string MUST be available at least in USB language -0x0409 (English/US). +number, unless ONLY the operating system's default class driver is used. +The serial number string MUST be available at least in USB language 0x0409 +(English/US). (2) The serial number MUST start with either an Internet domain name (e.g. "mycompany.com") registered and owned by you, or an e-mail address under your @@ -108,6 +109,11 @@ driver for Vendor Class devices is needed, this driver must be libusb or libusb-win32 (see http://libusb.org/ and http://libusb-win32.sourceforge.net/). +(7) If ONLY the operating system's default class driver is used, e.g. for +mice, keyboards, joysticks, CDC or MIDI devices and no discrimination by an +application is needed, the serial number may be omitted. + + Table if IDs for discrimination by serial number string: PID dec (hex) | VID dec (hex) | Description of use @@ -121,12 +127,26 @@ PID dec (hex) | VID dec (hex) | Description of use ---------------+---------------+------------------------------------------- 10203 (0x27db) | 5824 (0x16c0) | For USB Keyboards ---------------+---------------+------------------------------------------- -10204 (0x27db) | 5824 (0x16c0) | For USB Joysticks +10204 (0x27dc) | 5824 (0x16c0) | For USB Joysticks +---------------+---------------+------------------------------------------- +10205 (0x27dd) | 5824 (0x16c0) | For CDC-ACM class devices (modems) +---------------+---------------+------------------------------------------- +10206 (0x27de) | 5824 (0x16c0) | For MIDI class devices ---------------+---------------+------------------------------------------- -10205 (0x27dc) | 5824 (0x16c0) | For CDC-ACM class devices (modems) +10207 (0x27df) | 5824 (0x16c0) | For Mass Storage class devices ---------------+---------------+------------------------------------------- -10206 (0x27dd) | 5824 (0x16c0) | For MIDI class devices +10208 (0x27e0) | 5824 (0x16c0) | For Audio class devices ---------------+---------------+------------------------------------------- +10209 (0x27e1) | 5824 (0x16c0) | For CDC-ECM class devices +---------------+---------------+------------------------------------------- +10210 (0x27e2) | 5824 (0x16c0) | For MTP class devices +---------------+---------------+------------------------------------------- + +Note that the last six cannot be implemented using V-USB in a standards +compliant way because they require bulk endpoints which are forbidden for +low speed devices. We provide them nevertheless, either if you want to +implement a non-compliant device or implement it using other technology +than V-USB. ================= diff --git a/UsbKeyboard/UsbKeyboard.h b/UsbKeyboard/UsbKeyboard.h index 92be016..3dcf706 100644 --- a/UsbKeyboard/UsbKeyboard.h +++ b/UsbKeyboard/UsbKeyboard.h @@ -9,9 +9,12 @@ #include #include #include +#include // for _delay_ms() -#include "usbdrv.h" - +extern "C" +{ + #include "usbdrv.h" +}; // TODO: Work around Arduino 12 issues better. //#include //#undef int() @@ -141,7 +144,6 @@ class UsbKeyboardDevice { _delay_ms(250); usbDeviceConnect(); - usbInit(); sei(); @@ -241,11 +243,8 @@ size_t release(uint8_t k) UsbKeyboardDevice UsbKeyboard = UsbKeyboardDevice(); -#ifdef __cplusplus -extern "C"{ -#endif - // USB_PUBLIC uchar usbFunctionSetup -uchar usbFunctionSetup(uchar data[8]) + // USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]) +usbMsgLen_t usbFunctionSetup(uchar data[8]) { usbRequest_t *rq = (usbRequest_t *)((void *)data); @@ -272,9 +271,5 @@ uchar usbFunctionSetup(uchar data[8]) } return 0; } -#ifdef __cplusplus -} // extern "C" -#endif - #endif // __UsbKeyboard_h__ diff --git a/UsbKeyboard/asmcommon.inc b/UsbKeyboard/asmcommon.inc index 07d692b..d2a4f7c 100644 --- a/UsbKeyboard/asmcommon.inc +++ b/UsbKeyboard/asmcommon.inc @@ -5,7 +5,6 @@ * Tabsize: 4 * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) - * Revision: $Id$ */ /* Do not link this file! Link usbdrvasm.S instead, which includes the diff --git a/UsbKeyboard/oddebug.c b/UsbKeyboard/oddebug.c index 945457c..19bf142 100644 --- a/UsbKeyboard/oddebug.c +++ b/UsbKeyboard/oddebug.c @@ -5,7 +5,6 @@ * Tabsize: 4 * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) - * This Revision: $Id: oddebug.c 692 2008-11-07 15:07:40Z cs $ */ #include "oddebug.h" diff --git a/UsbKeyboard/oddebug.h b/UsbKeyboard/oddebug.h index d61309d..851f84d 100644 --- a/UsbKeyboard/oddebug.h +++ b/UsbKeyboard/oddebug.h @@ -5,7 +5,6 @@ * Tabsize: 4 * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) - * This Revision: $Id: oddebug.h 692 2008-11-07 15:07:40Z cs $ */ #ifndef __oddebug_h_included__ diff --git a/UsbKeyboard/usbconfig-prototype.h b/UsbKeyboard/usbconfig-prototype.h index a0fd1bf..22dd9e8 100644 --- a/UsbKeyboard/usbconfig-prototype.h +++ b/UsbKeyboard/usbconfig-prototype.h @@ -5,7 +5,6 @@ * Tabsize: 4 * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) - * This Revision: $Id: usbconfig-prototype.h 767 2009-08-22 11:39:22Z cs $ */ #ifndef __usbconfig_h_included__ @@ -45,10 +44,12 @@ section at the end of this file). */ #define USB_CFG_CLOCK_KHZ (F_CPU/1000) /* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000, - * 16500 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! - * Default if not specified: 12 MHz + * 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 @@ -144,6 +145,11 @@ section at the end of this file). * 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 @@ -349,6 +355,15 @@ section at the end of this file). #define USB_CFG_DESCR_PROPS_HID_REPORT 0 #define USB_CFG_DESCR_PROPS_UNKNOWN 0 + +//#define usbMsgPtr_t unsigned short +/* If usbMsgPtr_t is not defined, it defaults to 'uchar *'. We may define it to + * a scalar type here because gcc generates slightly shorter code for scalar + * arithmetics than for pointer arithmetics. Remove this define for backward + * type compatibility or define it to an 8 bit type if you use data in RAM only + * and all RAM is below 256 bytes (tiny memory model in IAR CC). + */ + /* ----------------------- Optional MCU Description ------------------------ */ /* The following configurations have working defaults in usbdrv.h. You @@ -364,6 +379,6 @@ section at the end of this file). /* #define USB_INTR_ENABLE_BIT INT0 */ /* #define USB_INTR_PENDING GIFR */ /* #define USB_INTR_PENDING_BIT INTF0 */ -/* #define USB_INTR_VECTOR SIG_INTERRUPT0 */ +/* #define USB_INTR_VECTOR INT0_vect */ #endif /* __usbconfig_h_included__ */ diff --git a/UsbKeyboard/usbdrv.c b/UsbKeyboard/usbdrv.c index 44fe72d..1d80ac6 100644 --- a/UsbKeyboard/usbdrv.c +++ b/UsbKeyboard/usbdrv.c @@ -5,10 +5,8 @@ * Tabsize: 4 * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) - * This Revision: $Id: usbdrv.c 763 2009-08-22 10:27:24Z cs $ */ -#include "usbportability.h" #include "usbdrv.h" #include "oddebug.h" @@ -45,11 +43,10 @@ uchar usbCurrentDataToken;/* when we check data toggling to ignore duplica #endif /* USB status registers / not shared with asm code */ -uchar *usbMsgPtr; /* data to transmit next -- ROM or RAM address */ +usbMsgPtr_t usbMsgPtr; /* data to transmit next -- ROM or RAM address */ static usbMsgLen_t usbMsgLen = USB_NO_MSG; /* remaining number of bytes */ -static uchar usbMsgFlags; /* flag values see below */ +uchar usbMsgFlags; /* flag values see USB_FLG_* */ -#define USB_FLG_MSGPTR_IS_ROM (1<<6) #define USB_FLG_USE_USER_RW (1<<7) /* @@ -151,7 +148,7 @@ PROGMEM const char usbDescriptorConfiguration[] = { /* USB configuration desc #if USB_CFG_IS_SELF_POWERED (1 << 7) | USBATTR_SELFPOWER, /* attributes */ #else - (1 << 7), /* attributes */ + (1 << 7) | USBATTR_REMOTEWAKE, /* attributes */ #endif USB_CFG_MAX_BUS_POWER/2, /* max USB current in 2mA units */ /* interface descriptor follows inline: */ @@ -171,7 +168,8 @@ PROGMEM const char usbDescriptorConfiguration[] = { /* USB configuration desc 0x00, /* target country code */ 0x01, /* number of HID Report (or other HID class) Descriptor infos to follow */ 0x22, /* descriptor type: report */ - USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH, 0, /* total length of report descriptor */ + (USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH & 0xFF), /* descriptor length (low byte) */ + ((USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH >> 8) & 0xFF), /* (high byte) */ #endif #if USB_CFG_HAVE_INTRIN_ENDPOINT /* endpoint descriptor for endpoint 1 */ 7, /* sizeof(usbDescrEndpoint) */ @@ -184,7 +182,7 @@ PROGMEM const char usbDescriptorConfiguration[] = { /* USB configuration desc #if USB_CFG_HAVE_INTRIN_ENDPOINT3 /* endpoint descriptor for endpoint 3 */ 7, /* sizeof(usbDescrEndpoint) */ USBDESCR_ENDPOINT, /* descriptor type = endpoint */ - (char)0x83, /* IN endpoint number 1 */ + (char)(0x80 | USB_CFG_EP3_NUMBER), /* IN endpoint number 3 */ 0x03, /* attrib: Interrupt endpoint */ 8, 0, /* maximum packet size */ USB_CFG_INTR_POLL_INTERVAL, /* in ms */ @@ -221,7 +219,7 @@ static inline void usbResetStall(void) static void usbGenericSetInterrupt(uchar *data, uchar len, usbTxStatus_t *txStatus) { uchar *p; -char i; +schar i; #if USB_CFG_IMPLEMENT_HALT if(usbTxLen1 == USBPID_STALL) @@ -301,7 +299,7 @@ USB_PUBLIC void usbSetInterrupt3(uchar *data, uchar len) len = usbFunctionDescriptor(rq); \ }else{ \ len = USB_PROP_LENGTH(cfgProp); \ - usbMsgPtr = (uchar *)(staticName); \ + usbMsgPtr = (usbMsgPtr_t)(staticName); \ } \ } @@ -335,6 +333,9 @@ uchar flags = USB_FLG_MSGPTR_IS_ROM; GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER, usbDescriptorStringSerialNumber) SWITCH_DEFAULT if(USB_CFG_DESCR_PROPS_UNKNOWN & USB_PROP_IS_DYNAMIC){ + if(USB_CFG_DESCR_PROPS_UNKNOWN & USB_PROP_IS_RAM){ + flags = 0; + } len = usbFunctionDescriptor(rq); } SWITCH_END @@ -347,6 +348,9 @@ uchar flags = USB_FLG_MSGPTR_IS_ROM; #endif SWITCH_DEFAULT if(USB_CFG_DESCR_PROPS_UNKNOWN & USB_PROP_IS_DYNAMIC){ + if(USB_CFG_DESCR_PROPS_UNKNOWN & USB_PROP_IS_RAM){ + flags = 0; + } len = usbFunctionDescriptor(rq); } SWITCH_END @@ -361,7 +365,8 @@ uchar flags = USB_FLG_MSGPTR_IS_ROM; */ static inline usbMsgLen_t usbDriverSetup(usbRequest_t *rq) { -uchar len = 0, *dataPtr = usbTxBuf + 9; /* there are 2 bytes free space at the end of the buffer */ +usbMsgLen_t len = 0; +uchar *dataPtr = usbTxBuf + 9; /* there are 2 bytes free space at the end of the buffer */ uchar value = rq->wValue.bytes[0]; #if USB_CFG_IMPLEMENT_HALT uchar index = rq->wIndex.bytes[0]; @@ -408,7 +413,7 @@ uchar index = rq->wIndex.bytes[0]; SWITCH_DEFAULT /* 7=SET_DESCRIPTOR, 12=SYNC_FRAME */ /* Should we add an optional hook here? */ SWITCH_END - usbMsgPtr = dataPtr; + usbMsgPtr = (usbMsgPtr_t)dataPtr; skipMsgPtrAssignment: return len; } @@ -421,7 +426,7 @@ uchar index = rq->wIndex.bytes[0]; */ static inline void usbProcessRx(uchar *data, uchar len) { - usbRequest_t *rq = (usbRequest_t *)((void *)data); +usbRequest_t *rq = (void *)data; /* usbRxToken can be: * 0x2d 00101101 (USBPID_SETUP for setup data) @@ -498,7 +503,8 @@ static uchar usbDeviceRead(uchar *data, uchar len) }else #endif { - uchar i = len, *r = usbMsgPtr; + uchar i = len; + usbMsgPtr_t r = usbMsgPtr; if(usbMsgFlags & USB_FLG_MSGPTR_IS_ROM){ /* ROM data */ do{ uchar c = USB_READ_FLASH(r); /* assign to char size variable to enforce byte ops */ @@ -507,7 +513,8 @@ static uchar usbDeviceRead(uchar *data, uchar len) }while(--i); }else{ /* RAM data */ do{ - *data++ = *r++; + *data++ = *((uchar *)r); + r++; }while(--i); } usbMsgPtr = r; @@ -557,6 +564,8 @@ uchar isReset = !notResetState; USB_RESET_HOOK(isReset); wasReset = isReset; } +#else + notResetState = notResetState; // avoid compiler warning #endif } diff --git a/UsbKeyboard/usbdrv.h b/UsbKeyboard/usbdrv.h index 751f2d4..f094120 100644 --- a/UsbKeyboard/usbdrv.h +++ b/UsbKeyboard/usbdrv.h @@ -5,13 +5,10 @@ * Tabsize: 4 * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) - * This Revision: $Id: usbdrv.h 769 2009-08-22 11:49:05Z cs $ */ #ifndef __usbdrv_h_included__ #define __usbdrv_h_included__ -#include "usbconfig.h" -#include "usbportability.h" /* Hardware Prerequisites: @@ -105,9 +102,9 @@ interrupt routine. Interrupt latency: The application must ensure that the USB interrupt is not disabled for more than 25 cycles (this is for 12 MHz, faster clocks allow longer latency). -This implies that all interrupt routines must either be declared as "INTERRUPT" -instead of "SIGNAL" (see "avr/signal.h") or that they are written in assembler -with "sei" as the first instruction. +This implies that all interrupt routines must either have the "ISR_NOBLOCK" +attribute set (see "avr/interrupt.h") or be written in assembler with "sei" +as the first instruction. Maximum interrupt duration / CPU cycle consumption: The driver handles all USB communication during the interrupt service @@ -118,11 +115,28 @@ USB messages, even if they address another (low-speed) device on the same bus. */ + +#ifdef __cplusplus +// This header should be included as C-header from C++ code. However if usbdrv.c +// is incorporated into a C++ module with an include, function names are mangled +// and this header must be parsed as C++ header, too. External modules should be +// treated as C, though, because they are compiled separately as C code. +extern "C" { +#endif + +#include "usbconfig.h" +#include "usbportability.h" + +#ifdef __cplusplus +} +#endif + + /* ------------------------------------------------------------------------- */ /* --------------------------- Module Interface ---------------------------- */ /* ------------------------------------------------------------------------- */ -#define USBDRV_VERSION 20090822 +#define USBDRV_VERSION 20121206 /* This define uniquely identifies a driver version. It is a decimal number * constructed from the driver's release date in the form YYYYMMDD. If the * driver's behavior or interface changes, you can use this constant to @@ -163,11 +177,19 @@ USB messages, even if they address another (low-speed) device on the same bus. */ #define USB_NO_MSG ((usbMsgLen_t)-1) /* constant meaning "no message" */ +#ifndef usbMsgPtr_t +#define usbMsgPtr_t uchar * +#endif +/* Making usbMsgPtr_t a define allows the user of this library to define it to + * an 8 bit type on tiny devices. This reduces code size, especially if the + * compiler supports a tiny memory model. + * The type can be a pointer or scalar type, casts are made where necessary. + * Although it's paradoxical, Gcc 4 generates slightly better code for scalar + * types than for pointers. + */ + struct usbRequest; /* forward declaration */ -#ifdef __cplusplus -extern "C"{ -#endif USB_PUBLIC void usbInit(void); /* This function must be called before interrupts are enabled and the main * loop is entered. We exepct that the PORT and DDR bits for D+ and D- have @@ -181,21 +203,21 @@ USB_PUBLIC void usbPoll(void); * Please note that debug outputs through the UART take ~ 0.5ms per byte * at 19200 bps. */ -#ifdef __cplusplus -} // extern "C" -#endif -extern uchar *usbMsgPtr; +extern usbMsgPtr_t usbMsgPtr; /* This variable may be used to pass transmit data to the driver from the * implementation of usbFunctionWrite(). It is also used internally by the * driver for standard control requests. */ -#ifdef __cplusplus -extern "C"{ -#endif + +extern uchar usbMsgFlags; /* flag values see USB_FLG_* */ +/* Can be set to `USB_FLG_MSGPTR_IS_ROM` in `usbFunctionSetup()` or + * `usbFunctionDescriptor()` if `usbMsgPtr` has been set to a flash memory + * address. + */ + +#define USB_FLG_MSGPTR_IS_ROM (1<<6) + USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]); -#ifdef __cplusplus -} // extern "C" -#endif /* This function is called when the driver receives a SETUP transaction from * the host which is not answered by the driver itself (in practice: class and * vendor requests). All control transfers start with a SETUP transaction where @@ -229,13 +251,7 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq); * data. See the documentation of usbFunctionSetup() above for more info. */ #if USB_CFG_HAVE_INTRIN_ENDPOINT -#ifdef __cplusplus -extern "C"{ -#endif USB_PUBLIC void usbSetInterrupt(uchar *data, uchar len); -#ifdef __cplusplus -} // extern "C" -#endif /* This function sets the message which will be sent during the next interrupt * IN transfer. The message is copied to an internal buffer and must not exceed * a length of 8 bytes. The message may be 0 bytes long just to indicate the @@ -332,13 +348,7 @@ extern unsigned usbCrc16(unsigned data, uchar len); * data. We enforce 16 bit calling conventions for compatibility with IAR's * tiny memory model. */ -#ifdef __cplusplus -extern "C"{ -#endif extern unsigned usbCrc16Append(unsigned data, uchar len); -#ifdef __cplusplus -} // extern "C" -#endif #define usbCrc16Append(data, len) usbCrc16Append((unsigned)(data), len) /* This function is equivalent to usbCrc16() above, except that it appends * the 2 bytes CRC (lowbyte first) in the 'data' buffer after reading 'len' @@ -414,13 +424,13 @@ extern volatile schar usbRxLen; * about the various methods to define USB descriptors. If you do nothing, * the default descriptors will be used. */ -#define USB_PROP_IS_DYNAMIC (1 << 14) +#define USB_PROP_IS_DYNAMIC (1u << 14) /* If this property is set for a descriptor, usbFunctionDescriptor() will be * used to obtain the particular descriptor. Data directly returned via * usbMsgPtr are FLASH data by default, combine (OR) with USB_PROP_IS_RAM to * return RAM data. */ -#define USB_PROP_IS_RAM (1 << 15) +#define USB_PROP_IS_RAM (1u << 15) /* If this property is set for a descriptor, the data is read from RAM * memory instead of Flash. The property is used for all methods to provide * external descriptors. @@ -743,6 +753,7 @@ typedef struct usbRequest{ #define USBDESCR_HID_PHYS 0x23 //#define USBATTR_BUSPOWER 0x80 // USB 1.1 does not define this value any more +#define USBATTR_BUSPOWER 0 #define USBATTR_SELFPOWER 0x40 #define USBATTR_REMOTEWAKE 0x20 diff --git a/UsbKeyboard/usbdrvasm.S b/UsbKeyboard/usbdrvasm.S index 80877e4..3bda63c 100644 --- a/UsbKeyboard/usbdrvasm.S +++ b/UsbKeyboard/usbdrvasm.S @@ -5,7 +5,6 @@ * Tabsize: 4 * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) - * Revision: $Id: usbdrvasm.S 761 2009-08-12 16:30:23Z cs $ */ /* @@ -57,7 +56,11 @@ the file appropriate for the given clock rate. #else /* __IAR_SYSTEMS_ASM__ */ # ifndef USB_INTR_VECTOR /* default to hardware interrupt INT0 */ -# define USB_INTR_VECTOR SIG_INTERRUPT0 +# ifdef INT0_vect +# define USB_INTR_VECTOR INT0_vect // this is the "new" define for the vector +# else +# define USB_INTR_VECTOR SIG_INTERRUPT0 // this is the "old" vector +# endif # endif .text .global USB_INTR_VECTOR @@ -142,7 +145,8 @@ RTMODEL "__rt_version", "3" #if USB_USE_FAST_CRC ; This implementation is faster, but has bigger code size -; Thanks to Slawomir Fras (BoskiDialer) for this code! +; Thanks to Slawomir Fras (BoskiDialer) for this code and to Shay Green for +; even further optimizations! ; It implements the following C pseudo-code: ; unsigned table(unsigned char x) ; { @@ -172,35 +176,29 @@ RTMODEL "__rt_version", "3" ; resCrc r24+r25 / r16+r17 ; ptr X / Z usbCrc16: - mov ptrL, argPtrL - mov ptrH, argPtrH + movw ptrL, argPtrL ldi resCrcL, 0xFF ldi resCrcH, 0xFF + clr bitCnt ; zero reg rjmp usbCrc16LoopTest usbCrc16ByteLoop: ld byte, ptr+ - eor resCrcL, byte ; resCrcL is now 'x' in table() - mov byte, resCrcL ; compute parity of 'x' + eor byte, resCrcL ; scratch is now 'x' in table() + mov scratch, byte ; compute parity of 'x' swap byte - eor byte, resCrcL - mov scratch, byte + eor byte, scratch + mov resCrcL, byte lsr byte lsr byte - eor byte, scratch + eor byte, resCrcL inc byte - lsr byte - andi byte, 1 ; byte is now parity(x) - mov scratch, resCrcL - mov resCrcL, resCrcH - eor resCrcL, byte ; low byte of if(parity(x)) value ^= 0xc001; - neg byte - andi byte, 0xc0 - mov resCrcH, byte ; high byte of if(parity(x)) value ^= 0xc001; - clr byte - lsr scratch - ror byte - eor resCrcH, scratch - eor resCrcL, byte + andi byte, 2 ; byte is now parity(x) << 1 + cp bitCnt, byte ; c = (byte != 0), then put in high bit + ror scratch ; so that after xoring, shifting, and xoring, it gives + ror byte ; the desired 0xC0 with resCrcH + mov resCrcL, byte + eor resCrcL, resCrcH + mov resCrcH, scratch lsr scratch ror byte eor resCrcH, scratch @@ -357,14 +355,18 @@ usbMFTimeout: ;---------------------------------------------------------------------------- #ifndef USB_CFG_CLOCK_KHZ -# define USB_CFG_CLOCK_KHZ 12000 +# ifdef F_CPU +# define USB_CFG_CLOCK_KHZ (F_CPU/1000) +# else +# error "USB_CFG_CLOCK_KHZ not defined in usbconfig.h and no F_CPU set!" +# endif #endif #if USB_CFG_CHECK_CRC /* separate dispatcher for CRC type modules */ # if USB_CFG_CLOCK_KHZ == 18000 # include "usbdrvasm18-crc.inc" # else -# error "USB_CFG_CLOCK_KHZ is not one of the supported crc-rates!" +# error "USB_CFG_CLOCK_KHZ is not one of the supported rates for USB_CFG_CHECK_CRC!" # endif #else /* USB_CFG_CHECK_CRC */ # if USB_CFG_CLOCK_KHZ == 12000 @@ -377,9 +379,11 @@ usbMFTimeout: # include "usbdrvasm16.inc" # elif USB_CFG_CLOCK_KHZ == 16500 # include "usbdrvasm165.inc" +# elif USB_CFG_CLOCK_KHZ == 18000 +# include "usbdrvasm18.inc" # elif USB_CFG_CLOCK_KHZ == 20000 # include "usbdrvasm20.inc" # else -# error "USB_CFG_CLOCK_KHZ is not one of the supported non-crc-rates!" +# error "USB_CFG_CLOCK_KHZ is not one of the supported rates!" # endif #endif /* USB_CFG_CHECK_CRC */ diff --git a/UsbKeyboard/usbdrvasm.asm b/UsbKeyboard/usbdrvasm.asm index 9cc4e4d..fb66934 100644 --- a/UsbKeyboard/usbdrvasm.asm +++ b/UsbKeyboard/usbdrvasm.asm @@ -5,7 +5,6 @@ * Tabsize: 4 * Copyright: (c) 2006 by OBJECTIVE DEVELOPMENT Software GmbH * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) - * This Revision: $Id$ */ /* diff --git a/UsbKeyboard/usbdrvasm12.inc b/UsbKeyboard/usbdrvasm12.inc index c116758..d3bd056 100644 --- a/UsbKeyboard/usbdrvasm12.inc +++ b/UsbKeyboard/usbdrvasm12.inc @@ -5,7 +5,6 @@ * Tabsize: 4 * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) - * This Revision: $Id: usbdrvasm12.inc 740 2009-04-13 18:23:31Z cs $ */ /* Do not link this file! Link usbdrvasm.S instead, which includes the diff --git a/UsbKeyboard/usbdrvasm128.inc b/UsbKeyboard/usbdrvasm128.inc index bcd6621..8f67bcc 100644 --- a/UsbKeyboard/usbdrvasm128.inc +++ b/UsbKeyboard/usbdrvasm128.inc @@ -5,7 +5,6 @@ * Tabsize: 4 * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) - * This Revision: $Id: usbdrvasm128.inc 758 2009-08-06 10:12:54Z cs $ */ /* Do not link this file! Link usbdrvasm.S instead, which includes the diff --git a/UsbKeyboard/usbdrvasm15.inc b/UsbKeyboard/usbdrvasm15.inc index 401b7f8..33bcf0e 100644 --- a/UsbKeyboard/usbdrvasm15.inc +++ b/UsbKeyboard/usbdrvasm15.inc @@ -5,7 +5,6 @@ * Tabsize: 4 * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) - * Revision: $Id: usbdrvasm15.inc 740 2009-04-13 18:23:31Z cs $ */ /* Do not link this file! Link usbdrvasm.S instead, which includes the diff --git a/UsbKeyboard/usbdrvasm16.inc b/UsbKeyboard/usbdrvasm16.inc index 207b6e4..25b84e6 100644 --- a/UsbKeyboard/usbdrvasm16.inc +++ b/UsbKeyboard/usbdrvasm16.inc @@ -5,7 +5,6 @@ * Tabsize: 4 * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) - * Revision: $Id: usbdrvasm16.inc 760 2009-08-09 18:59:43Z cs $ */ /* Do not link this file! Link usbdrvasm.S instead, which includes the diff --git a/UsbKeyboard/usbdrvasm165.inc b/UsbKeyboard/usbdrvasm165.inc index 79b3c61..ae91588 100644 --- a/UsbKeyboard/usbdrvasm165.inc +++ b/UsbKeyboard/usbdrvasm165.inc @@ -5,7 +5,6 @@ * Tabsize: 4 * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) - * Revision: $Id: usbdrvasm165.inc 740 2009-04-13 18:23:31Z cs $ */ /* Do not link this file! Link usbdrvasm.S instead, which includes the diff --git a/UsbKeyboard/usbdrvasm18-crc.inc b/UsbKeyboard/usbdrvasm18-crc.inc index f83347d..0ff2f42 100644 --- a/UsbKeyboard/usbdrvasm18-crc.inc +++ b/UsbKeyboard/usbdrvasm18-crc.inc @@ -5,7 +5,6 @@ * Tabsize: 4 * Copyright: (c) 2008 by Lukas Schrittwieser and OBJECTIVE DEVELOPMENT Software GmbH * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) - * Revision: $Id: usbdrvasm18-crc.inc 740 2009-04-13 18:23:31Z cs $ */ /* Do not link this file! Link usbdrvasm.S instead, which includes the diff --git a/UsbKeyboard/usbdrvasm18.inc b/UsbKeyboard/usbdrvasm18.inc new file mode 100644 index 0000000..e058bb9 --- /dev/null +++ b/UsbKeyboard/usbdrvasm18.inc @@ -0,0 +1,557 @@ +/* Name: usbdrvasm18.inc + * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers + * Author: Lukas Schrittwieser (based on 20 MHz usbdrvasm20.inc by Jeroen Benschop) + * Creation Date: 2009-01-20 + * Tabsize: 4 + * Copyright: (c) 2008 by Lukas Schrittwieser and OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + */ + +/* Do not link this file! Link usbdrvasm.S instead, which includes the + * appropriate implementation! + */ + +/* +General Description: +This file is the 18 MHz version of the asssembler part of the USB driver. It +requires a 18 MHz crystal (not a ceramic resonator and not a calibrated RC +oscillator). + +See usbdrv.h for a description of the entire driver. + +Since almost all of this code is timing critical, don't change unless you +really know what you are doing! Many parts require not only a maximum number +of CPU cycles, but even an exact number of cycles! + +Note: This version is smaller than usbdrvasm18-crc.inc because it saves the CRC +table. It's therefore suitable for boot loaders on boards @ 18 MHz. However, it +is not as small as it could be, because loops are unrolled in the same way as in +usbdrvasm18-crc.inc. There is room for optimization. +*/ + + +;max stack usage: [ret(2), YL, SREG, YH, [sofError], bitcnt(x5), shift, x1, x2, x3, x4, cnt, ZL, ZH] = 14 bytes +;nominal frequency: 18 MHz -> 12 cycles per bit +; Numbers in brackets are clocks counted from center of last sync bit +; when instruction starts +;register use in receive loop to receive the data bytes: +; shift assembles the byte currently being received +; x1 holds the D+ and D- line state +; x2 holds the previous line state +; cnt holds the number of bytes left in the receive buffer +; x4 is used as temporary register +; x3 is used for unstuffing: when unstuffing the last received bit is inverted in shift (to prevent further +; unstuffing calls. In the same time the corresponding bit in x3 is cleared to mark the bit as beening iverted +; zl lower crc value and crc table index +; zh used for crc table accesses + + + +macro POP_STANDARD ; 18 cycles + pop cnt + pop x5 + pop x3 + pop x2 + pop x1 + pop shift + pop x4 + endm +macro POP_RETI ; 7 cycles + pop YH + pop YL + out SREG, YL + pop YL + endm + +;macro CRC_CLEANUP_AND_CHECK +; ; the last byte has already been xored with the lower crc byte, we have to do the table lookup and xor +; ; x3 is the higher crc byte, zl the lower one +; ldi ZH, hi8(usbCrcTableHigh);[+1] get the new high byte from the table +; lpm x2, Z ;[+2][+3][+4] +; ldi ZH, hi8(usbCrcTableLow);[+5] get the new low xor byte from the table +; lpm ZL, Z ;[+6][+7][+8] +; eor ZL, x3 ;[+7] xor the old high byte with the value from the table, x2:ZL now holds the crc value +; cpi ZL, 0x01 ;[+8] if the crc is ok we have a fixed remainder value of 0xb001 in x2:ZL (see usb spec) +; brne ignorePacket ;[+9] detected a crc fault -> paket is ignored and retransmitted by the host +; cpi x2, 0xb0 ;[+10] +; brne ignorePacket ;[+11] detected a crc fault -> paket is ignored and retransmitted by the host +; endm + + +USB_INTR_VECTOR: +;order of registers pushed: YL, SREG, YH, [sofError], x4, shift, x1, x2, x3, x5, cnt, ZL, ZH + push YL ;[-28] push only what is necessary to sync with edge ASAP + in YL, SREG ;[-26] + push YL ;[-25] + push YH ;[-23] +;---------------------------------------------------------------------------- +; Synchronize with sync pattern: +;---------------------------------------------------------------------------- +;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] +;sync up with J to K edge during sync pattern -- use fastest possible loops +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. +waitForJ: + inc YL + sbis USBIN, USBMINUS + brne waitForJ ; just make sure we have ANY timeout +waitForK: +;The following code results in a sampling window of < 1/4 bit which meets the spec. + sbis USBIN, USBMINUS ;[-17] + rjmp foundK ;[-16] + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK +#if USB_COUNT_SOF + lds YL, usbSofCount + inc YL + sts usbSofCount, YL +#endif /* USB_COUNT_SOF */ +#ifdef USB_SOF_HOOK + USB_SOF_HOOK +#endif + rjmp sofError +foundK: ;[-15] +;{3, 5} after falling D- edge, average delay: 4 cycles +;bit0 should be at 30 (2.5 bits) for center sampling. Currently at 4 so 26 cylces till bit 0 sample +;use 1 bit time for setup purposes, then sample again. Numbers in brackets +;are cycles from center of first sync (double K) bit after the instruction + push x4 ;[-14] +; [---] ;[-13] + lds YL, usbInputBufOffset;[-12] used to toggle the two usb receive buffers +; [---] ;[-11] + clr YH ;[-10] + subi YL, lo8(-(usbRxBuf));[-9] [rx loop init] + sbci YH, hi8(-(usbRxBuf));[-8] [rx loop init] + push shift ;[-7] +; [---] ;[-6] + ldi shift, 0x80 ;[-5] the last bit is the end of byte marker for the pid receiver loop + clc ;[-4] the carry has to be clear for receipt of pid bit 0 + sbis USBIN, USBMINUS ;[-3] we want two bits K (sample 3 cycles too early) + rjmp haveTwoBitsK ;[-2] + pop shift ;[-1] undo the push from before + pop x4 ;[1] + rjmp waitForK ;[3] this was not the end of sync, retry +; The entire loop from waitForK until rjmp waitForK above must not exceed two +; bit times (= 24 cycles). + +;---------------------------------------------------------------------------- +; push more registers and initialize values while we sample the first bits: +;---------------------------------------------------------------------------- +haveTwoBitsK: + push x1 ;[0] + push x2 ;[2] + push x3 ;[4] + ldi x2, 1< jump back and store the byte + ori shift, 0x01 ;[11] invert the last received bit to prevent furhter unstuffing + in x2, USBIN ;[0] we have some free cycles so we could check for bit stuffing errors + andi x3, 0xFE ;[1] mark this bit as inverted (will be corrected before storing shift) + eor x1, x2 ;[2] x1 and x2 have to be different because the stuff bit is always a zero + andi x1, USBMASK ;[3] mask the interesting bits + breq stuffErr ;[4] if the stuff bit is a 1-bit something went wrong + mov x1, x2 ;[5] the next bit expects the last state to be in x1 + rjmp didunstuff0 ;[6] + ;[7] jump delay of rjmp didunstuffX + +unstuff1: ;[11] this is the jump delay of breq unstuffX + in x1, USBIN ;[0] we have some free cycles so we could check for bit stuffing errors + ori shift, 0x02 ;[1] invert the last received bit to prevent furhter unstuffing + andi x3, 0xFD ;[2] mark this bit as inverted (will be corrected before storing shift) + eor x2, x1 ;[3] x1 and x2 have to be different because the stuff bit is always a zero + andi x2, USBMASK ;[4] mask the interesting bits + breq stuffErr ;[5] if the stuff bit is a 1-bit something went wrong + mov x2, x1 ;[6] the next bit expects the last state to be in x2 + nop2 ;[7] + ;[8] + rjmp didunstuff1 ;[9] + ;[10] jump delay of rjmp didunstuffX + +unstuff2: ;[9] this is the jump delay of breq unstuffX + ori shift, 0x04 ;[10] invert the last received bit to prevent furhter unstuffing + andi x3, 0xFB ;[11] mark this bit as inverted (will be corrected before storing shift) + in x2, USBIN ;[0] we have some free cycles so we could check for bit stuffing errors + eor x1, x2 ;[1] x1 and x2 have to be different because the stuff bit is always a zero + andi x1, USBMASK ;[2] mask the interesting bits + breq stuffErr ;[3] if the stuff bit is a 1-bit something went wrong + mov x1, x2 ;[4] the next bit expects the last state to be in x1 + nop2 ;[5] + ;[6] + rjmp didunstuff2 ;[7] + ;[8] jump delay of rjmp didunstuffX + +unstuff3: ;[9] this is the jump delay of breq unstuffX + ori shift, 0x08 ;[10] invert the last received bit to prevent furhter unstuffing + andi x3, 0xF7 ;[11] mark this bit as inverted (will be corrected before storing shift) + in x1, USBIN ;[0] we have some free cycles so we could check for bit stuffing errors + eor x2, x1 ;[1] x1 and x2 have to be different because the stuff bit is always a zero + andi x2, USBMASK ;[2] mask the interesting bits + breq stuffErr ;[3] if the stuff bit is a 1-bit something went wrong + mov x2, x1 ;[4] the next bit expects the last state to be in x2 + nop2 ;[5] + ;[6] + rjmp didunstuff3 ;[7] + ;[8] jump delay of rjmp didunstuffX + + + +; the include has to be here due to branch distance restirctions +#include "asmcommon.inc" + + + +; USB spec says: +; idle = J +; J = (D+ = 0), (D- = 1) +; K = (D+ = 1), (D- = 0) +; Spec allows 7.5 bit times from EOP to SOP for replies +; 7.5 bit times is 90 cycles. ...there is plenty of time + + +sendNakAndReti: + ldi x3, USBPID_NAK ;[-18] + rjmp sendX3AndReti ;[-17] +sendAckAndReti: + ldi cnt, USBPID_ACK ;[-17] +sendCntAndReti: + mov x3, cnt ;[-16] +sendX3AndReti: + ldi YL, 20 ;[-15] x3==r20 address is 20 + ldi YH, 0 ;[-14] + ldi cnt, 2 ;[-13] +; rjmp usbSendAndReti fallthrough + +;usbSend: +;pointer to data in 'Y' +;number of bytes in 'cnt' -- including sync byte [range 2 ... 12] +;uses: x1...x4, btcnt, shift, cnt, Y +;Numbers in brackets are time since first bit of sync pattern is sent + +usbSendAndReti: ; 12 cycles until SOP + in x2, USBDDR ;[-12] + ori x2, USBMASK ;[-11] + sbi USBOUT, USBMINUS;[-10] prepare idle state; D+ and D- must have been 0 (no pullups) + in x1, USBOUT ;[-8] port mirror for tx loop + out USBDDR, x2 ;[-6] <- acquire bus + ldi x2, 0 ;[-6] init x2 (bitstuff history) because sync starts with 0 + ldi x4, USBMASK ;[-5] exor mask + ldi shift, 0x80 ;[-4] sync byte is first byte sent +txByteLoop: + ldi bitcnt, 0x40 ;[-3]=[9] binary 01000000 +txBitLoop: ; the loop sends the first 7 bits of the byte + sbrs shift, 0 ;[-2]=[10] if we have to send a 1 don't change the line state + eor x1, x4 ;[-1]=[11] + out USBOUT, x1 ;[0] + ror shift ;[1] + ror x2 ;[2] transfers the last sent bit to the stuffing history +didStuffN: + nop ;[3] + nop ;[4] + cpi x2, 0xfc ;[5] if we sent six consecutive ones + brcc bitstuffN ;[6] + lsr bitcnt ;[7] + brne txBitLoop ;[8] restart the loop while the 1 is still in the bitcount + +; transmit bit 7 + sbrs shift, 0 ;[9] + eor x1, x4 ;[10] +didStuff7: + ror shift ;[11] + out USBOUT, x1 ;[0] transfer bit 7 to the pins + ror x2 ;[1] move the bit into the stuffing history + cpi x2, 0xfc ;[2] + brcc bitstuff7 ;[3] + ld shift, y+ ;[4] get next byte to transmit + dec cnt ;[5] decrement byte counter + brne txByteLoop ;[7] if we have more bytes start next one + ;[8] branch delay + +;make SE0: + cbr x1, USBMASK ;[8] prepare SE0 [spec says EOP may be 25 to 30 cycles] + lds x2, usbNewDeviceAddr;[9] + lsl x2 ;[11] we compare with left shifted address + out USBOUT, x1 ;[0] <-- out SE0 -- from now 2 bits = 24 cycles until bus idle + subi YL, 20 + 2 ;[1] Only assign address on data packets, not ACK/NAK in x3 + sbci YH, 0 ;[2] +;2006-03-06: moved transfer of new address to usbDeviceAddr from C-Code to asm: +;set address only after data packet was sent, not after handshake + breq skipAddrAssign ;[3] + sts usbDeviceAddr, x2 ; if not skipped: SE0 is one cycle longer +skipAddrAssign: +;end of usbDeviceAddress transfer + ldi x2, 1< #endif -#define USB_READ_FLASH(addr) pgm_read_byte(addr) +#if USB_CFG_DRIVER_FLASH_PAGE +# define USB_READ_FLASH(addr) pgm_read_byte_far(((long)USB_CFG_DRIVER_FLASH_PAGE << 16) | (long)(addr)) +#else +# define USB_READ_FLASH(addr) pgm_read_byte(addr) +#endif #define macro .macro #define endm .endm diff --git a/clockwork_keypad_ATMEGA168PA.hex b/clockwork_keypad_ATMEGA168PA.hex index 103d291..df576b8 100644 --- a/clockwork_keypad_ATMEGA168PA.hex +++ b/clockwork_keypad_ATMEGA168PA.hex @@ -1,8 +1,8 @@ -:100000000C94AC000C9413030C94D4000C94D40006 +:100000000C94AC000C94EB020C94D4000C94D4002F :100010000C94D4000C94D4000C94D4000C94D40010 :100020000C94D4000C94D4000C94D4000C94D40000 :100030000C94D4000C94D4000C94D4000C94D400F0 -:100040000C94B0020C94D4000C947E020C945802D0 +:100040000C9430020C94D4000C94A0020C947A020C :100050000C94D4000C94D4000C94D4000C94D400D0 :100060000C94D4000C94D40000000000250028005B :100070002B0000000000240027002A0005010906CB @@ -12,365 +12,226 @@ :1000B000006100720064002003720061006E006342 :1000C00000690064006200610063006F006E002E32 :1000D0000063006F006D000403090409022200019F -:1000E0000100803209040000010300000009210121 +:1000E0000100A03209040000010300000009210101 :1000F0000100012223000705810308000A120110F4 :100100000100000008424231E1000101020001004B :100110000000002300260029000404040404040451 :1001200004020202020202030303030303010204A6 :100130000810204080010204081020010204081069 :100140002000000008000201000003040700000076 -:10015000000000000000340411241FBECFEFD4E0E3 -:10016000DEBFCDBF11E0A0E0B1E0E6E2FFE002C0FB +:100150000000000000000C0411241FBECFEFD4E00B +:10016000DEBFCDBF11E0A0E0B1E0E4E4FEE002C0FC :1001700005900D92AE36B107D9F722E0AEE6B1E0B8 -:1001800001C01D92A537B207E1F710E0CCEAD0E03C -:1001900004C02197FE010E948607CB3AD107C9F718 -:1001A0000E948C040C9491070C940000CF92DF9273 -:1001B000EF92FF920F931F93CF93DF936C017A011D -:1001C0008B01C0E0D0E0CE15DF0589F0D8016D913C -:1001D0008D01D601ED91FC910190F081E02DC601D9 -:1001E0000995892B11F47E0102C02196ECCFC7013D +:1001800001C01D92A437B207E1F710E0CCEAD0E03D +:1001900004C02197FE010E941A07CB3AD107C9F784 +:1001A0000E9462040C9420070C940000AF92BF924E +:1001B000CF92DF92EF92FF920F931F93CF93DF9333 +:1001C0006C017B018B01040F151FEB015E01AE1862 +:1001D000BF08C017D10759F06991D601ED91FC9184 +:1001E0000190F081E02DC6010995892B79F7C501B1 :1001F000DF91CF911F910F91FF90EF90DF90CF9003 -:100200000895089580E090E00895FC01538D448D99 -:10021000252F30E0842F90E0821B930B541710F0B1 -:10022000CF96089501970895FC01918D828D9817BE -:1002300061F0828DDF01A80FB11D5D968C91928DCA -:100240009F5F9F73928F90E008958FEF9FEF0895C7 -:10025000FC01918D828D981731F0828DE80FF11D90 -:10026000858D90E008958FEF9FEF0895FC01918DAB -:10027000228D892F90E0805C9F4F821B91098F73A4 -:10028000992708958AE991E00E94360121E0892B9F -:1002900009F420E0822F0895FC01848DDF01A80F6E -:1002A000B11DA35ABF4F2C91848D90E001968F739E -:1002B0009927848FA689B7892C93A089B1898C91BD -:1002C00080648C93938D848D981306C00288F38983 -:1002D000E02D80818F7D80830895EF92FF920F93B0 -:1002E0001F93CF93DF93EC0181E0888F9B8D8C8DE2 -:1002F000981305C0E889F989808185FD24C0F62E10 -:100300000B8D10E00F5F1F4F0F731127E02E8C8DA8 -:10031000E8120CC00FB607FCFACFE889F989808192 -:1003200085FFF5CFCE010E944C01F1CF8B8DFE01F0 -:10033000E80FF11DE35AFF4FF0820B8FEA89FB892A -:100340008081806207C0EE89FF896083E889F9892E -:1003500080818064808381E090E0DF91CF911F9164 -:100360000F91FF90EF900895CF93DF93EC01888D6C -:100370008823C9F0EA89FB89808185FD05C0A889A9 -:10038000B9898C9186FD0FC00FB607FCF5CF80812F -:1003900085FFF2CFA889B9898C9185FFEDCFCE0179 -:1003A0000E944C01E7CFDF91CF91089580E090E06B -:1003B000892B29F00E94420181110C9400000895BC -:1003C0008E3008F08E508770806480937C0080911E -:1003D0007A00806480937A0080917A0086FDFCCF59 -:1003E000809178002091790090E0922B08953FB79A -:1003F000F8948091730190917401A0917501B0916E -:10040000760126B5A89B05C02F3F19F00196A11DC6 -:10041000B11D3FBFBA2FA92F982F8827820F911D9A -:10042000A11DB11DBC01CD0142E0660F771F881FE1 -:10043000991F4A95D1F70895CF93C62F20914D0269 -:1004400024FF07C030914E0228E8232720934E0254 -:1004500003C02AE520934D02DC01EFE4F2E09C2F7B -:100460009E0F8D918193892F8E1B1816D4F36C2FBC -:100470008FE492E00E940F03CC5FC0934D02CF91B6 -:100480000895E8E3F2E096E09E0F882321F02081B2 -:10049000281301C0108231969E13F7CF67E087E3DF -:1004A00092E00E941C0281E090E008950E948C0777 -:1004B0001F920F920FB60F9211242F933F934F93D9 -:1004C0005F936F937F938F939F93AF93BF93EF93BC -:1004D000FF938AE991E00E944C01FF91EF91BF9157 -:1004E000AF919F918F917F916F915F914F913F91CC -:1004F0002F910F900FBE0F901F9018951F920F9283 -:100500000FB60F9211242F938F939F93EF93FF9326 -:10051000E091AA01F091AB018081E091B001F091EE -:10052000B10182FD12C090818091B3018F5F8F7302 -:100530002091B401821751F0E091B301F0E0E6564A -:10054000FE4F958F8093B30101C08081FF91EF91A1 -:100550009F918F912F910F900FBE0F901F90189524 -:100560001F920F920FB60F9211242F933F938F93E8 -:100570009F93AF93BF9380916F0190917001A09171 -:100580007101B091720130916E0123E0230F2D377C -:1005900020F40196A11DB11D05C026E8230F029687 -:1005A000A11DB11D20936E0180936F019093700186 -:1005B000A0937101B09372018091730190917401C5 -:1005C000A0917501B09176010196A11DB11D809396 -:1005D000730190937401A0937501B0937601BF915C -:1005E000AF919F918F913F912F910F900FBE0F90E0 -:1005F0001F901895A82FB92F80E090E041E050EAB5 -:10060000609530E009C02D9182279795879510F06D -:1006100084279527305EC8F36F5FA8F30895EADF5B -:100620008D939D930895CF93CFB7CF93DF93C395C9 -:100630004C9BE9F74C9B0BC04C9B09C04C9B07C0E3 -:100640004C9B05C04C9B03C04C9B01C08BC06F935F -:10065000C0915B02DD27C15ADD4F2F9365E54C9BAE -:1006600003C02F916F91E6CF0F931F934F9320E01C -:1006700040E15F9309B1047104FB27F93F9350E017 -:100680003BE039C0147140642F77012F5F5F1EC0BB -:10069000406819B114712F7752501FC0406409B1DE -:1006A0002F770471D1F15F5F00C023C0406219B1A0 -:1006B0002F77147191F15F5F00C025C0047110277E -:1006C000515012F45D5F0000115027952C3F19B175 -:1006D000C8F614710127015027952C3FC8F6422710 -:1006E000499309B1047110274F73115027952C3F7E -:1006F000A8F64695469519B1147179F00127015075 -:1007000027952C3F98F66B5A60F3315009B1B0F63B -:1007100000C011E01CBB002719C03B503195C31B22 -:10072000D04011E01CBB0881033C09F10B34F9F007 -:10073000209159021981110F1213EDCF4A81441FE4 -:10074000093651F10D3211F0013E29F700935E0296 -:100750003F915F914F911F910F912F916F91CCB36A -:10076000C0FD65CFDF91CF91CFBFCF91189520917C -:100770005E02222369F310915C02112391F534305B -:1007800092F130935C0220935A0210915B023BE09D -:10079000311B30935B0227C000915C0201300CF5E5 -:1007A0000AE54F7049F43091010134FD1DC00093FA -:1007B0000101C2E4D2E01CC030914D0234FD14C0EE -:1007C00000934D02CEE4D2E013C0052710E000C034 -:1007D00000000BB91AC0052710E0221F1DC010E051 -:1007E00021C04AE502C032ED432FC4E1D0E032E03F -:1007F0001AB114615C9A0BB11AB954E120E865E3AF -:1008000020FF05270BB9279517951C3FF0F6669535 -:10081000B8F7B1F720FF05270BB9279517951C3FAF -:10082000D0F62795179517FF052700001C3F0BB939 -:10083000B0F629913A9519F70B7E10915D02110FD0 -:10084000C651D0400BB911F01093590211E01CBBF6 -:1008500000611AB11B7E402F4B7E54E05A95F1F790 -:100860000BB91AB94BB974CFEAE9F1E013821282DD -:1008700088EE93E0A0E0B0E084839583A683B783FD -:1008800080E691E09183808385EC90E09587848772 -:1008900084EC90E09787868780EC90E0918B808B4A -:1008A00081EC90E0938B828B82EC90E0958B848B33 -:1008B00086EC90E0978B868B118E128E138E148EA1 -:1008C0001BB88AB18B6E8AB9F89455985D982FEF52 -:1008D00084E39CE0215080409040E1F700C000009C -:1008E000559A5D9AE9E6F0E0808182608083E89A1B -:1008F000EDE4F2E08BE481838AE5808378941092C2 -:100900003E0210923F02109240021092410264E0B7 -:100910008EE392E00C941C02CF93DF931F92CDB72D -:10092000DEB7789484B5826084BD84B5816084BD6F -:1009300085B5826085BD85B5816085BD80916E007D -:10094000816080936E0010928100809181008260AE -:1009500080938100809181008160809381008091EB -:1009600080008160809380008091B10084608093DA -:10097000B1008091B00081608093B00080917A00D6 -:10098000846080937A0080917A00826080937A00FC -:1009900080917A00816080937A0080917A008068EB -:1009A00080937A001092C10080916E0010926E00C8 -:1009B000AEE3B1E0ECE7CE2EE1E0DE2E20E030E069 -:1009C0004FEF50E0293031053CF58D919C91119706 -:1009D0009927FC01E35DFE4F6491FC01E75EFE4F49 -:1009E00084918823C9F090E0880F991FFC01EE588C -:1009F000FF4F05911491FC01E859FF4FE590F490E9 -:100A00009FB7F894F8018081609586238083F70171 -:100A10008081862380839FBFF601419351936F01AC -:100A20002F5F3F4F12962F30310509F0CBCFE09169 -:100A3000AA01F091AB0182E08083E091A601F091E0 -:100A4000A7011082E091A801F091A90180E18083C3 -:100A50001092B201E091AE01F091AF0186E0808387 -:100A6000E091AC01F091AD01808180618083E091E3 -:100A7000AC01F091AD01808188608083E091AC0190 -:100A8000F091AD01808180688083E091AC01F091AC -:100A9000AD0180818F7D80835CE7252E50E0352E6F -:100AA00044244A94512C88E392E026E0280F2983BD -:100AB00080915C02835087FDB6C090915B022091CB -:100AC0005A022D3209F0ADC0883009F0AAC0ECE01E -:100AD000F0E0E91BF109E15AFD4F83EC80934202FB -:100AE0008AE580930101109279018081807689F0F6 -:100AF0002EE332E030937B0120937A01803209F0BB -:100B000086C081818A3009F082C083818093770119 -:100B10007EC0928110924B028181811106C0109299 -:100B20004C022BE432E082E06DC0853019F49093E2 -:100B30005D0265C0863009F04CC08381813041F48C -:100B40008DEF90E090937B0180937A0182E13DC02C -:100B5000823041F48BED90E090937B0180937A0199 -:100B600082E233C08330F1F4911108C087ED90E048 -:100B700090937B0180937A0184E027C0913041F407 -:100B800087EB90E090937B0180937A0180E21DC017 -:100B90009230D1F48FE990E090937B0180937A01B9 -:100BA00088E113C0813241F48DEE90E090937B0197 -:100BB00080937A0189E009C0823231F430927B015E -:100BC00020927A0183E201C080E090E49093790161 -:100BD0001FC0883069F0893019F4909378010FC0F4 -:100BE0008A3049F08B3059F48BE480934E0207C071 -:100BF00028E731E002C02BE432E081E003C02BE4BF -:100C000032E080E030937B0120937A0101C080E0E4 -:100C10009781911104C09681981708F4892F8093C9 -:100C2000000110925C028091010184FF48C0809114 -:100C300000018F3F09F443C0182F893008F018E0F5 -:100C4000811B809300019091420288E8892780935C -:100C50004202112331F120917A0130917B01809180 -:100C6000790186FF0BC0A3E4B2E0F901812F820F66 -:100C700094919D9331968E13FBCF09C0D901E3E483 -:100C8000F2E0812F8E0F9D9191938E13FCCF8FEF09 -:100C9000810F90E00196820F931F90937B018093C8 -:100CA0007A01612F83E492E00E940F0364E0610FF8 -:100CB0006C3019F08FEF809300016093010184E1A3 -:100CC00099B1947131F48150D9F710925D0210926C -:100CD00059020E94F7014B015C0148EEC42E43E02B -:100CE000D42EE12CF12C0E94F701DC01CB018819F4 -:100CF0009909AA09BB09883E9340A105B10558F09E -:100D000081E0C81AD108E108F108A8EE8A0EA3E034 -:100D10009A1EA11CB11CC114D104E104F10419F7FD -:100D200090E2A92E91E0B92E22E0C22E21E0D22E2F -:100D30000EE311E03CE7832E31E0932EE12CF12C01 -:100D4000F9E0EF16F1040CF047C0D8018D919C91A9 -:100D50009927FC01EF5BFE4F3491FC01E35DFE4FF0 -:100D60002491FC01E75EFE4FE491EE2309F43FC0BD -:100D7000332339F1333091F038F43130A9F0323087 -:100D800001F584B58F7D12C0373091F03830A1F075 -:100D90003430B9F4809180008F7D03C08091800051 -:100DA0008F77809380000DC084B58F7784BD09C094 -:100DB0008091B0008F7703C08091B0008F7D8093C9 -:100DC000B000F0E0EE0FFF1FE15FFE4FA591B49180 -:100DD000EC912E2361F01DC0F80180810E94E0019A -:100DE00064EF71E00E945E076130710591F081E06F -:100DF0000E94E0018D509E4F873E9340B0F085E009 -:100E00000E94E0018D509E4F873E934008F052C0F3 -:100E10000CC0D4018D919C918F3F910579F00E9477 -:100E20004102F4015182408209C0F5016080718065 -:100E3000D4018D919C9168167906B1F4FFEFEF1AF9 -:100E4000FF0A22E0820E911C82E0A80EB11CA2E0F3 -:100E5000CA0ED11C0E5F1F4FBFE0EB16F10409F064 -:100E60006FCF0E94D60124CE8F3F910511F00E94D2 -:100E70004102262DE8E3F2E08191821791F0B981D9 -:100E8000BE13FACF80E090E0FC01E95CFD4F3181B8 -:100E9000311102C0218305C0019686309105A1F76A -:100EA00005C067E087E392E00E941C02F4017182B2 -:100EB0006082C4CFD6016D907C90BACF97FB072E8D -:100EC00016F4009407D077FD09D00E94720707FC42 -:100ED00005D03EF4909581959F4F0895709561954A -:100EE0007F4F0895AA1BBB1B51E107C0AA1FBB1F60 -:100EF000A617B70710F0A61BB70B881F991F5A95A6 -:100F0000A9F780959095BC01CD010895EE0FFF1FC4 -:100F10000590F491E02D099481E090E0F8940C9410 -:060F20009107F894FFCFD9 -:100F2600FF5A5200500051004F000C0018000D00EF -:100F36000E00280029002C000F0012001C000B00D8 -:100F46005200500051004F0012001C000B000F0011 -:100F560057002A0056004D004E004B004A00030081 -:100F660006000700080009000A000B000C000D002F -:100F76000000020003000400060007000000000055 -:0E0F86006D01D6000501B401360114012801E9 -:103800000C94341C0C94511C0C94511C0C94511CA1 -:103810000C94511C0C94511C0C94511C0C94511C74 -:103820000C94511C0C94511C0C94511C0C94511C64 -:103830000C94511C0C94511C0C94511C0C94511C54 -:103840000C94511C0C94511C0C94511C0C94511C44 -:103850000C94511C0C94511C0C94511C0C94511C34 -:103860000C94511C0C94511C11241FBECFEFD4E0BA -:10387000DEBFCDBF11E0A0E0B1E0E4EAFFE302C0AB -:1038800005900D92A230B107D9F712E0A2E0B1E0A5 -:1038900001C01D92AD30B107E1F70E94361D0C94B6 -:1038A000D01F0C94001C982F9595959595959595FE -:1038B000905D8F708A307CF0282F295A8091C0004B -:1038C00085FFFCCF9093C6008091C00085FFFCCFA0 -:1038D0002093C6000895282F205DF0CF982F809167 -:1038E000C00085FFFCCF9093C6000895EF92FF9231 -:1038F0000F931F93EE24FF2487018091C00087FD62 -:1039000017C00894E11CF11C011D111D81E4E8168B -:1039100082E4F8068FE0080780E0180770F3E09172 -:103920000401F091050109958091C00087FFE9CF5E -:103930008091C6001F910F91FF90EF9008950E9413 -:10394000761C982F8091C00085FFFCCF9093C60015 -:1039500091362CF490330CF09053892F089597559D -:10396000892F08951F930E949F1C182F0E949F1C4F -:103970001295107F810F1F910895882351F0982F81 -:1039800091508091C00087FFFCCF8091C6009923A1 -:10399000B9F708951F93182F0E94761C803249F0C2 -:1039A000809103018F5F809303018530C1F01F91E7 -:1039B00008958091C00085FFFCCF84E18093C6000C -:1039C0008091C00085FFFCCF1093C6008091C0009D -:1039D00085FFFCCF80E18093C6001F910895E091A0 -:1039E0000401F091050109951F9108950E94761C2C -:1039F000803241F0809103018F5F80930301853015 -:103A000081F008958091C00085FFFCCF84E1809310 -:103A1000C6008091C00085FFFCCF80E18093C60086 -:103A20000895E0910401F09105010995089510921F -:103A30000A028823D1F090E040E951E02D9A28EE67 -:103A400033E0FA013197F1F721503040D1F72D984A -:103A500028EE33E0FA013197F1F721503040D1F7E9 -:103A60009F5F981758F380930A0208953F924F92F0 -:103A70005F926F927F928F929F92AF92BF92CF92FE -:103A8000DF92EF92FF920F931F93CF93DF9300008B -:103A900083E38093C4001092C50088E18093C10045 -:103AA00086E08093C2005098589A259A81E00E943F -:103AB000171D44E1F42E3EE1E32E24E9D22E96E0D8 -:103AC000C92E80E1B82EAA24A39401E4902E16E515 -:103AD000812EB2E57B2EA0E26A2EF9E45F2EE3E5AB -:103AE0004E2E70E5372E0E94761C8033B1F1813363 -:103AF00009F441C0803409F479C0813409F48CC0E0 -:103B0000823471F1853409F47BC0803531F182351E -:103B100021F1813511F1853509F48DC0863509F41F -:103B20009DC0843609F4AEC0843709F41BC18537C3 -:103B300009F485C1863709F47AC0809103018F5F4B -:103B400080930301853079F6E0910401F09105013D -:103B500009950E94761C803351F60E94F61CC3CF53 -:103B600093E18091C00087FFFCCF8091C60099232C -:103B7000A1F39150F6CF0E94761C8032F1F680912D -:103B8000C00085FFFCCFF092C6008091C00085FF89 -:103B9000FCCF9092C6008091C00085FFFCCF809240 -:103BA000C6008091C00085FFFCCF7092C600809156 -:103BB000C00085FFFCCF6092C6008091C00085FFE9 -:103BC000FCCF5092C6008091C00085FFFCCF409290 -:103BD000C6008091C00085FFFCCF3092C600809166 -:103BE000C00085FFFCCFB092C6007DCF0E94761C3E -:103BF000863808F4B2CF0E94761C0E94F61C73CF60 -:103C000094E08091C00087FFFCCF8091C60099238B -:103C100009F4A3CF9150F5CF0E94761C8038D1F0E3 -:103C2000813861F1823809F499C0883979F080E0EF -:103C30000E94CA1C58CF0E94761C809306010E94E5 -:103C4000761C809307010E94F61C4DCF83E00E94F2 -:103C5000CA1C49CF82E00E94CA1C45CF0E94761C34 -:103C6000803309F486C192E08091C00087FFFCCFC9 -:103C70008091C6009923D9F29150F6CF81E00E943D -:103C8000CA1C31CF0E94761C809309020E94761CC8 -:103C90008093080280910C028E7F80930C020E9418 -:103CA000761C853429F480910C02816080930C028B -:103CB0008091080290910902892B89F000E010E0C0 -:103CC0000E94761CF801E85FFE4F80830F5F1F4F54 -:103CD00080910802909109020817190788F30E9441 -:103CE000761C803209F029CF80910C0280FFD1C070 -:103CF0004091060150910701440F551F5093070151 -:103D000040930601A0910802B09109021097C9F0F2 -:103D1000E8E0F1E09A01BD016E0F7F1FF999FECF37 -:103D200032BD21BD819180BDFA9AF99A2F5F3F4F34 -:103D3000E617F70799F74A0F5B1F50930701409367 -:103D400006018091C00085FFFCCFF092C6008091F3 -:103D5000C00085FFFCCFB092C600C5CE80E10E94B6 -:103D6000CA1CC1CE0E94761C809309020E94761C58 -:103D7000809308028091060190910701880F991F96 -:103D800090930701809306010E94761C853409F404 -:103D90007AC080910C028E7F80930C020E94761C68 -:103DA000803209F0A0CE8091C00085FFFCCFF09258 -:103DB000C600A0910802B09109021097B9F1809154 -:103DC0000C02182F1170082F0270E0910601F0917B -:103DD00007019F012F5F3F4FB90140E050E01123E1 -:103DE000B1F4002339F494918091C00085FFFCCF99 -:103DF0009093C6004F5F5F4FCB010196F9014A17C0 -:103E00005B0780F4BC012F5F3F4F112351F3F999F9 -:103E1000FECFF2BDE1BDF89A90B58091C00085FF5C -:103E2000FCCFE6CF70930701609306018091C0003C -:103E300085FDD9CE8091C00085FFF8CFD4CE0E94F9 -:103E4000761C803209F079CE8091C00085FFFCCFCE -:103E5000F092C6008091C00085FFFCCFE092C600C2 -:103E60008091C00085FFFCCFD092C6008091C00039 -:103E700085FFFCCFC092C6008091C00085FFFCCFBB -:103E8000B092C60030CE80910C02816080930C020B -:103E900085CF809107018823880F880B8A21809322 -:103EA0000B028091060190910701880F991F909352 -:103EB0000701809306018091080280FF09C080916C -:103EC00008029091090201969093090280930802DA -:103ED000F894F999FECF1127E0910601F0910701BE -:103EE000C8E0D1E08091080290910902103091F46D -:103EF0000091570001700130D9F303E0009357009F -:103F0000E8950091570001700130D9F301E1009369 -:103F10005700E89509901990009157000170013001 -:103F2000D9F301E000935700E8951395103498F009 -:103F300011270091570001700130D9F305E000937B -:103F40005700E8950091570001700130D9F301E165 -:103F500000935700E8953296029709F0C7CF1030CA -:103F600011F00296E5CF11248091C00085FFE9CEC3 -:103F7000ECCE0E94761C0E94761C182F0E94761CA4 -:103F8000112351F0113021F086E00E94CA1CABCD04 -:103F900084E90E94CA1CA7CD8EE10E94CA1CA3CD51 -:043FA000F894FFCFC3 -:023FA40080009B -:0400000300003800C1 +:10020000BF90AF900895FC01538D448D252F30E0B1 +:10021000842F90E0821B930B541710F0CF96089513 +:1002200001970895FC01918D828D981761F0A28D40 +:10023000AE0FBF2FB11D5D968C91928D9F5F9F7306 +:10024000928F90E008958FEF9FEF0895FC01918DBC +:10025000828D981731F0828DE80FF11D858D90E029 +:1002600008958FEF9FEF0895FC01918D228D892FC6 +:1002700090E0805C9F4F821B91098F7399270895AE +:1002800089E991E00E94340121E0892B09F420E002 +:10029000822F089580E090E0892B29F00E94400190 +:1002A00081110C9400000895FC01A48DA80FB92FB2 +:1002B000B11DA35ABF4F2C91848D90E001968F738E +:1002C0009927848FA689B7892C93A089B1898C91AD +:1002D000837080648C93938D848D981306C00288FC +:1002E000F389E02D80818F7D80830895EF92FF92C6 +:1002F0000F931F93CF93DF93EC0181E0888F9B8D49 +:100300008C8D98131AC0E889F989808185FF15C002 +:100310009FB7F894EE89FF896083E889F989808125 +:100320008370806480839FBF81E090E0DF91CF91F4 +:100330001F910F91FF90EF900895F62E0B8D10E016 +:100340000F5F1F4F0F731127E02E8C8D8E110CC085 +:100350000FB607FCFACFE889F989808185FFF5CFD0 +:10036000CE010E945401F1CFEB8DEC0FFD2FF11D5A +:10037000E35AFF4FF0829FB7F8940B8FEA89FB890D +:1003800080818062CFCFCF93DF93EC01888D88236B +:10039000B9F0AA89BB89E889F9898C9185FD03C0E8 +:1003A000808186FD0DC00FB607FCF7CF8C9185FFCD +:1003B000F2CF808185FFEDCFCE010E945401E9CFBD +:1003C000DF91CF9108958E3008F08E508770806451 +:1003D00080937C0080917A00806480937A00809181 +:1003E0007A0086FDFCCF8091780090917900089585 +:1003F000CF93C62F20914C0224FF19C020914D02AB +:1004000038E8232720934D022C2FFC01AEE4B2E004 +:1004100081918D9321501216DCF36C2F8EE492E0C3 +:100420000E94E702CC5FC0934C02CF9108952AE569 +:1004300020934C02E9CFE6E3F2E096E0882321F036 +:100440002181821301C01182915031969111F6CF12 +:1004500067E086E392E00E94F80181E090E0089571 +:100460001F920F920FB60F9211242F933F938F93E9 +:100470009F93AF93BF938091950190919601A09126 +:100480009701B09198013091940123E0230F2D370B +:1004900058F50196A11DB11D2093940180939501FB +:1004A00090939601A0939701B09398018091900149 +:1004B00090919101A0919201B09193010196A11D9B +:1004C000B11D8093900190939101A0939201B093FC +:1004D0009301BF91AF919F918F913F912F910F9079 +:1004E0000FBE0F901F90189526E8230F0296A11DAE +:1004F000B11DD2CF1F920F920FB60F9211242F93DE +:100500003F934F935F936F937F938F939F93AF939B +:10051000BF93EF93FF9389E991E00E945401FF910B +:10052000EF91BF91AF919F918F917F916F915F916B +:100530004F913F912F910F900FBE0F901F901895E4 +:100540001F920F920FB60F9211242F938F939F93A8 +:10055000EF93FF93E091A901F091AA018081E091CE +:10056000AF01F091B00182FD1BC090818091B2017A +:100570008F5F8F732091B301821741F0E091B20138 +:10058000F0E0E756FE4F958F8093B201FF91EF9117 +:100590009F918F912F910F900FBE0F901F901895E4 +:1005A0008081F4CFA82FB92F80E090E041E050EA9D +:1005B000609530E009C02D9182279795879510F0BE +:1005C00084279527305EC8F36F5FA8F30895EADFAC +:1005D0008D939D930895CF93CFB7CF93DF93C3951A +:1005E0004C9BE9F74C9B0BC04C9B09C04C9B07C034 +:1005F0004C9B05C04C9B03C04C9B01C08BC06F93B0 +:10060000C0915A02DD27C25ADD4F2F9365E54C9BFE +:1006100003C02F916F91E6CF0F931F934F9320E06C +:1006200040E15F9309B1047104FB27F93F9350E067 +:100630003BE039C0147140642F77012F5F5F1EC00B +:10064000406819B114712F7752501FC0406409B12E +:100650002F770471D1F15F5F00C023C0406219B1F0 +:100660002F77147191F15F5F00C025C004711027CE +:10067000515012F45D5F0000115027952C3F19B1C5 +:10068000C8F614710127015027952C3FC8F6422760 +:10069000499309B1047110274F73115027952C3FCE +:1006A000A8F64695469519B1147179F001270150C5 +:1006B00027952C3F98F66B5A60F3315009B1B0F68C +:1006C00000C011E01CBB002719C03B503195C31B73 +:1006D000D04011E01CBB0881033C09F10B34F9F058 +:1006E000209158021981110F1213EDCF4A81441F36 +:1006F000093651F10D3211F0013E29F700935D02E8 +:100700003F915F914F911F910F912F916F91CCB3BA +:10071000C0FD65CFDF91CF91CFBFCF9118952091CC +:100720005D02222369F310915B02112391F53430AD +:1007300092F130935B022093590210915A023BE0F0 +:10074000311B30935A0227C000915B0201300CF537 +:100750000AE54F7049F43091010134FD1DC000934A +:100760000101C1E4D2E01CC030914C0234FD14C040 +:1007700000934C02CDE4D2E013C0052710E000C086 +:1007800000000BB91AC0052710E0221F1DC010E0A1 +:1007900021C04AE502C032ED432FC4E1D0E032E08F +:1007A0001AB114615C9A0BB11AB954E120E865E3FF +:1007B00020FF05270BB9279517951C3FF0F6669586 +:1007C000B8F7B1F720FF05270BB9279517951C3F00 +:1007D000D0F62795179517FF052700001C3F0BB98A +:1007E000B0F629913A9519F70B7E10915C02110F22 +:1007F000C651D0400BB911F01093580211E01CBB48 +:1008000000611AB11B7E402F4B7E54E05A95F1F7E0 +:100810000BB91AB94BB974CFE9E9F1E0138212822E +:1008200088EE93E0A0E0B0E084839583A683B7834D +:1008300080E691E09183808385EC90E095878487C2 +:1008400084EC90E09787868780EC90E0918B808B9A +:1008500081EC90E0938B828B82EC90E0958B848B83 +:1008600086EC90E0978B868B118E128E138E148EF1 +:100870001BB88AB18B6E8AB9F89455985D982FEFA2 +:1008800084E39CE0215080409040E1F700C00000EC +:10089000559A5D9AE9E6F0E0808182608083E89A6B +:1008A000ECE4F2E08BE481838AE580837894EDE3E5 +:1008B000F2E084E0DF011D928A95E9F764E0CF0160 +:1008C0000C94F801789484B5826084BD84B581600D +:1008D00084BD85B5826085BD85B5816085BD80910B +:1008E0006E00816080936E00109281008091810083 +:1008F000826080938100809181008160809381007B +:10090000809180008160809380008091B10084603C +:100910008093B1008091B00081608093B00080919D +:100920007A00846080937A0080917A00826080935C +:100930007A0080917A00816080937A0080917A00B9 +:10094000806880937A001092C10080916E008E7F43 +:1009500080936E00A2E7B1E030E020E04FEF50E07E +:10096000293031055CF5F901EE0FFF1FE25CFE4F07 +:10097000808191819927FC01E35DFE4F6491875E40 +:100980009E4FFC0184918823C9F090E0880F991F45 +:10099000FC01EE58FF4FC591D491FC01E859FF4F7F +:1009A000059114919FB7F8948881E62FE0958E23E6 +:1009B0008883E8018881E823E8839FBF4D935D9396 +:1009C0002F5F3F4F2F30310509F0CACFE091A901C9 +:1009D000F091AA0182E08083E091A501F091A60147 +:1009E0001082E091A701F091A80180E1808310922C +:1009F000B101E091AD01F091AE0186E08083E0911C +:100A0000AB01F091AC01808180618083E091AB010A +:100A1000F091AC01808188608083E091AB01F0911E +:100A2000AC01808180688083E091AB01F091AC01E2 +:100A300080818F7D80837CE7672E70E0772EEDEEDE +:100A40008E2EE0E09E2E47EB242E40E0342E57ED14 +:100A5000452E50E0552E6DE3C62E62E0D62E8091D5 +:100A60005B02835087FD2AC0909159029D3221F587 +:100A7000883011F580915A02ECE0F0E0E81BF109B2 +:100A8000E25AFD4F83EC809341028AE58093010195 +:100A900010926F018081807609F48BC0D092710131 +:100AA000C092700180E09781911104C096819817DF +:100AB00008F4892F8093000110925B02809101015C +:100AC00084FF3DC0809100018F3FC9F1C82F89305C +:100AD00008F0C8E0982F9C1B909300019091410270 +:100AE00028E89227909341028823E1F080917001D9 +:100AF0009091710120916F0126FFD0C0A2E4B2E075 +:100B0000FC012C2F34913D9331962150D9F72FEFD2 +:100B10002C0F30E02F5F3F4F820F931F9093710196 +:100B2000809370016C2F82E492E00E94E702CC5F18 +:100B3000CC3019F08FEF80930001C093010184E164 +:100B400099B1947131F48150D9F710925C021092EE +:100B500058023EE3A32E31E0B32EC2E7D1E010E00D +:100B600000E0F501819191915F01093011050CF0D0 +:100B7000F5C0AC015527FA01EF5BFE4F9491FA01E5 +:100B8000E35DFE4F2491FA01E75EFE4FE491E1112F +:100B90008EC081E00E94E3018D509E4F7801EE0CE3 +:100BA000FF1C873E934008F0E4C0F701E05EFE4F73 +:100BB000ECC0228110924A02918191110AC01092D8 +:100BC0004B022AE432E082E03093710120937001FD +:100BD0006ACF953029F420935C022AE432E0F4CF06 +:100BE000963009F044C09381913059F48DEF90E034 +:100BF000909371018093700182E190E490936F0172 +:100C000052CF923041F48BED90E09093710180933C +:100C1000700182E2F2CF9330D1F4211106C05092DC +:100C200071014092700184E0E8CF213031F43092BC +:100C300071012092700180E2E0CF2230F1F68FE95D +:100C400090E0909371018093700188E1D6CF91324A +:100C500031F4909271018092700189E0CECF92328E +:100C600061F6709271016092700183E2C6CF983094 +:100C700071F0993019F420936E01AFCF9A3059F08A +:100C80009B3009F0AACF9BE490934D02A6CF2EE6AD +:100C900031E081E099CF2AE432E0FBCFDC01E2E4ED +:100CA000F2E02C2F3D9131932150E1F730CF992381 +:100CB00051F0933009F43BC080F5913009F43DC008 +:100CC000923009F43EC0F0E0EE0FFF1FE15FFE4FEF +:100CD000A591B491EC912E2309F45BCF8881998181 +:100CE0008F3F910531F00E941B028FEF90E09983B6 +:100CF00088830F5F1F4F22960F30110509F031CF07 +:100D000080E090E0892B09F4AACE0E94400188235C +:100D100009F499CE0E94000096CE9730A9F0983041 +:100D2000C9F0943081F6809180008F7D03C080915E +:100D300080008F7780938000C6CF84B58F7784BD85 +:100D4000C2CF84B58F7DFBCF8091B0008F77809329 +:100D5000B000B9CF8091B0008F7DF9CF0E94E30140 +:100D600064EF71E00E94F2066130710509F4B6CFBC +:100D700010CF85E00E94E3018D509E4FF701EE5F9A +:100D8000FE4F873E934008F410CFE080F1808881C9 +:100D900099818E159F0509F4ACCF8F3F910511F015 +:100DA0000E941B022E2DA7E3B2E0FD0181912817BE +:100DB00061F0CE16DF06D1F790E080E03D91311171 +:100DC0000AC08A5C9D4FFC01218367E086E392E0C4 +:100DD0000E94F80104C001968630910579F7F982E6 +:100DE000E88287CF97FB072E16F4009407D077FD93 +:100DF00009D00E94060707FC05D03EF49095819526 +:100E00009F4F0895709561957F4F0895AA1BBB1B56 +:100E100051E107C0AA1FBB1FA617B70710F0A61BFA +:100E2000B70B881F991F5A95A9F780959095BC011B +:100E3000CD010895EE0FFF1F0590F491E02D099468 +:040E4000F894FFCF54 +:100E4400FF5A5200500051004F000C0018000D00D2 +:100E54000E00280029002C000F0012001C000B00BB +:100E64005200500051004F0012001C000B000F00F4 +:100E740057002A0056004D004E004B004A00030064 +:100E840006000700080009000A000B000C000D0012 +:100E94000000020003000400060007000000000038 +:0E0EA4007601D6000301C301340112012601BC :00000001FF diff --git a/clockwork_keypad_ATMEGA168PA.with_bootloader.hex b/clockwork_keypad_ATMEGA168PA.with_bootloader.hex new file mode 100644 index 0000000..43b9a28 --- /dev/null +++ b/clockwork_keypad_ATMEGA168PA.with_bootloader.hex @@ -0,0 +1,362 @@ +:100000000C94AC000C94EB020C94D4000C94D4002F +:100010000C94D4000C94D4000C94D4000C94D40010 +:100020000C94D4000C94D4000C94D4000C94D40000 +:100030000C94D4000C94D4000C94D4000C94D400F0 +:100040000C9430020C94D4000C94A0020C947A020C +:100050000C94D4000C94D4000C94D4000C94D400D0 +:100060000C94D4000C94D40000000000250028005B +:100070002B0000000000240027002A0005010906CB +:10008000A101050719E029E715002501750195086B +:100090008102950675082565190029658100C0183B +:1000A000035500730062004B006500790062006F29 +:1000B000006100720064002003720061006E006342 +:1000C00000690064006200610063006F006E002E32 +:1000D0000063006F006D000403090409022200019F +:1000E0000100A03209040000010300000009210101 +:1000F0000100012223000705810308000A120110F4 +:100100000100000008424231E1000101020001004B +:100110000000002300260029000404040404040451 +:1001200004020202020202030303030303010204A6 +:100130000810204080010204081020010204081069 +:100140002000000008000201000003040700000076 +:100150000000000000000C0411241FBECFEFD4E00B +:10016000DEBFCDBF11E0A0E0B1E0E4E4FEE002C0FC +:1001700005900D92AE36B107D9F722E0AEE6B1E0B8 +:1001800001C01D92A437B207E1F710E0CCEAD0E03D +:1001900004C02197FE010E941A07CB3AD107C9F784 +:1001A0000E9462040C9420070C940000AF92BF924E +:1001B000CF92DF92EF92FF920F931F93CF93DF9333 +:1001C0006C017B018B01040F151FEB015E01AE1862 +:1001D000BF08C017D10759F06991D601ED91FC9184 +:1001E0000190F081E02DC6010995892B79F7C501B1 +:1001F000DF91CF911F910F91FF90EF90DF90CF9003 +:10020000BF90AF900895FC01538D448D252F30E0B1 +:10021000842F90E0821B930B541710F0CF96089513 +:1002200001970895FC01918D828D981761F0A28D40 +:10023000AE0FBF2FB11D5D968C91928D9F5F9F7306 +:10024000928F90E008958FEF9FEF0895FC01918DBC +:10025000828D981731F0828DE80FF11D858D90E029 +:1002600008958FEF9FEF0895FC01918D228D892FC6 +:1002700090E0805C9F4F821B91098F7399270895AE +:1002800089E991E00E94340121E0892B09F420E002 +:10029000822F089580E090E0892B29F00E94400190 +:1002A00081110C9400000895FC01A48DA80FB92FB2 +:1002B000B11DA35ABF4F2C91848D90E001968F738E +:1002C0009927848FA689B7892C93A089B1898C91AD +:1002D000837080648C93938D848D981306C00288FC +:1002E000F389E02D80818F7D80830895EF92FF92C6 +:1002F0000F931F93CF93DF93EC0181E0888F9B8D49 +:100300008C8D98131AC0E889F989808185FF15C002 +:100310009FB7F894EE89FF896083E889F989808125 +:100320008370806480839FBF81E090E0DF91CF91F4 +:100330001F910F91FF90EF900895F62E0B8D10E016 +:100340000F5F1F4F0F731127E02E8C8D8E110CC085 +:100350000FB607FCFACFE889F989808185FFF5CFD0 +:10036000CE010E945401F1CFEB8DEC0FFD2FF11D5A +:10037000E35AFF4FF0829FB7F8940B8FEA89FB890D +:1003800080818062CFCFCF93DF93EC01888D88236B +:10039000B9F0AA89BB89E889F9898C9185FD03C0E8 +:1003A000808186FD0DC00FB607FCF7CF8C9185FFCD +:1003B000F2CF808185FFEDCFCE010E945401E9CFBD +:1003C000DF91CF9108958E3008F08E508770806451 +:1003D00080937C0080917A00806480937A00809181 +:1003E0007A0086FDFCCF8091780090917900089585 +:1003F000CF93C62F20914C0224FF19C020914D02AB +:1004000038E8232720934D022C2FFC01AEE4B2E004 +:1004100081918D9321501216DCF36C2F8EE492E0C3 +:100420000E94E702CC5FC0934C02CF9108952AE569 +:1004300020934C02E9CFE6E3F2E096E0882321F036 +:100440002181821301C01182915031969111F6CF12 +:1004500067E086E392E00E94F80181E090E0089571 +:100460001F920F920FB60F9211242F933F938F93E9 +:100470009F93AF93BF938091950190919601A09126 +:100480009701B09198013091940123E0230F2D370B +:1004900058F50196A11DB11D2093940180939501FB +:1004A00090939601A0939701B09398018091900149 +:1004B00090919101A0919201B09193010196A11D9B +:1004C000B11D8093900190939101A0939201B093FC +:1004D0009301BF91AF919F918F913F912F910F9079 +:1004E0000FBE0F901F90189526E8230F0296A11DAE +:1004F000B11DD2CF1F920F920FB60F9211242F93DE +:100500003F934F935F936F937F938F939F93AF939B +:10051000BF93EF93FF9389E991E00E945401FF910B +:10052000EF91BF91AF919F918F917F916F915F916B +:100530004F913F912F910F900FBE0F901F901895E4 +:100540001F920F920FB60F9211242F938F939F93A8 +:10055000EF93FF93E091A901F091AA018081E091CE +:10056000AF01F091B00182FD1BC090818091B2017A +:100570008F5F8F732091B301821741F0E091B20138 +:10058000F0E0E756FE4F958F8093B201FF91EF9117 +:100590009F918F912F910F900FBE0F901F901895E4 +:1005A0008081F4CFA82FB92F80E090E041E050EA9D +:1005B000609530E009C02D9182279795879510F0BE +:1005C00084279527305EC8F36F5FA8F30895EADFAC +:1005D0008D939D930895CF93CFB7CF93DF93C3951A +:1005E0004C9BE9F74C9B0BC04C9B09C04C9B07C034 +:1005F0004C9B05C04C9B03C04C9B01C08BC06F93B0 +:10060000C0915A02DD27C25ADD4F2F9365E54C9BFE +:1006100003C02F916F91E6CF0F931F934F9320E06C +:1006200040E15F9309B1047104FB27F93F9350E067 +:100630003BE039C0147140642F77012F5F5F1EC00B +:10064000406819B114712F7752501FC0406409B12E +:100650002F770471D1F15F5F00C023C0406219B1F0 +:100660002F77147191F15F5F00C025C004711027CE +:10067000515012F45D5F0000115027952C3F19B1C5 +:10068000C8F614710127015027952C3FC8F6422760 +:10069000499309B1047110274F73115027952C3FCE +:1006A000A8F64695469519B1147179F001270150C5 +:1006B00027952C3F98F66B5A60F3315009B1B0F68C +:1006C00000C011E01CBB002719C03B503195C31B73 +:1006D000D04011E01CBB0881033C09F10B34F9F058 +:1006E000209158021981110F1213EDCF4A81441F36 +:1006F000093651F10D3211F0013E29F700935D02E8 +:100700003F915F914F911F910F912F916F91CCB3BA +:10071000C0FD65CFDF91CF91CFBFCF9118952091CC +:100720005D02222369F310915B02112391F53430AD +:1007300092F130935B022093590210915A023BE0F0 +:10074000311B30935A0227C000915B0201300CF537 +:100750000AE54F7049F43091010134FD1DC000934A +:100760000101C1E4D2E01CC030914C0234FD14C040 +:1007700000934C02CDE4D2E013C0052710E000C086 +:1007800000000BB91AC0052710E0221F1DC010E0A1 +:1007900021C04AE502C032ED432FC4E1D0E032E08F +:1007A0001AB114615C9A0BB11AB954E120E865E3FF +:1007B00020FF05270BB9279517951C3FF0F6669586 +:1007C000B8F7B1F720FF05270BB9279517951C3F00 +:1007D000D0F62795179517FF052700001C3F0BB98A +:1007E000B0F629913A9519F70B7E10915C02110F22 +:1007F000C651D0400BB911F01093580211E01CBB48 +:1008000000611AB11B7E402F4B7E54E05A95F1F7E0 +:100810000BB91AB94BB974CFE9E9F1E0138212822E +:1008200088EE93E0A0E0B0E084839583A683B7834D +:1008300080E691E09183808385EC90E095878487C2 +:1008400084EC90E09787868780EC90E0918B808B9A +:1008500081EC90E0938B828B82EC90E0958B848B83 +:1008600086EC90E0978B868B118E128E138E148EF1 +:100870001BB88AB18B6E8AB9F89455985D982FEFA2 +:1008800084E39CE0215080409040E1F700C00000EC +:10089000559A5D9AE9E6F0E0808182608083E89A6B +:1008A000ECE4F2E08BE481838AE580837894EDE3E5 +:1008B000F2E084E0DF011D928A95E9F764E0CF0160 +:1008C0000C94F801789484B5826084BD84B581600D +:1008D00084BD85B5826085BD85B5816085BD80910B +:1008E0006E00816080936E00109281008091810083 +:1008F000826080938100809181008160809381007B +:10090000809180008160809380008091B10084603C +:100910008093B1008091B00081608093B00080919D +:100920007A00846080937A0080917A00826080935C +:100930007A0080917A00816080937A0080917A00B9 +:10094000806880937A001092C10080916E008E7F43 +:1009500080936E00A2E7B1E030E020E04FEF50E07E +:10096000293031055CF5F901EE0FFF1FE25CFE4F07 +:10097000808191819927FC01E35DFE4F6491875E40 +:100980009E4FFC0184918823C9F090E0880F991F45 +:10099000FC01EE58FF4FC591D491FC01E859FF4F7F +:1009A000059114919FB7F8948881E62FE0958E23E6 +:1009B0008883E8018881E823E8839FBF4D935D9396 +:1009C0002F5F3F4F2F30310509F0CACFE091A901C9 +:1009D000F091AA0182E08083E091A501F091A60147 +:1009E0001082E091A701F091A80180E1808310922C +:1009F000B101E091AD01F091AE0186E08083E0911C +:100A0000AB01F091AC01808180618083E091AB010A +:100A1000F091AC01808188608083E091AB01F0911E +:100A2000AC01808180688083E091AB01F091AC01E2 +:100A300080818F7D80837CE7672E70E0772EEDEEDE +:100A40008E2EE0E09E2E47EB242E40E0342E57ED14 +:100A5000452E50E0552E6DE3C62E62E0D62E8091D5 +:100A60005B02835087FD2AC0909159029D3221F587 +:100A7000883011F580915A02ECE0F0E0E81BF109B2 +:100A8000E25AFD4F83EC809341028AE58093010195 +:100A900010926F018081807609F48BC0D092710131 +:100AA000C092700180E09781911104C096819817DF +:100AB00008F4892F8093000110925B02809101015C +:100AC00084FF3DC0809100018F3FC9F1C82F89305C +:100AD00008F0C8E0982F9C1B909300019091410270 +:100AE00028E89227909341028823E1F080917001D9 +:100AF0009091710120916F0126FFD0C0A2E4B2E075 +:100B0000FC012C2F34913D9331962150D9F72FEFD2 +:100B10002C0F30E02F5F3F4F820F931F9093710196 +:100B2000809370016C2F82E492E00E94E702CC5F18 +:100B3000CC3019F08FEF80930001C093010184E164 +:100B400099B1947131F48150D9F710925C021092EE +:100B500058023EE3A32E31E0B32EC2E7D1E010E00D +:100B600000E0F501819191915F01093011050CF0D0 +:100B7000F5C0AC015527FA01EF5BFE4F9491FA01E5 +:100B8000E35DFE4F2491FA01E75EFE4FE491E1112F +:100B90008EC081E00E94E3018D509E4F7801EE0CE3 +:100BA000FF1C873E934008F0E4C0F701E05EFE4F73 +:100BB000ECC0228110924A02918191110AC01092D8 +:100BC0004B022AE432E082E03093710120937001FD +:100BD0006ACF953029F420935C022AE432E0F4CF06 +:100BE000963009F044C09381913059F48DEF90E034 +:100BF000909371018093700182E190E490936F0172 +:100C000052CF923041F48BED90E09093710180933C +:100C1000700182E2F2CF9330D1F4211106C05092DC +:100C200071014092700184E0E8CF213031F43092BC +:100C300071012092700180E2E0CF2230F1F68FE95D +:100C400090E0909371018093700188E1D6CF91324A +:100C500031F4909271018092700189E0CECF92328E +:100C600061F6709271016092700183E2C6CF983094 +:100C700071F0993019F420936E01AFCF9A3059F08A +:100C80009B3009F0AACF9BE490934D02A6CF2EE6AD +:100C900031E081E099CF2AE432E0FBCFDC01E2E4ED +:100CA000F2E02C2F3D9131932150E1F730CF992381 +:100CB00051F0933009F43BC080F5913009F43DC008 +:100CC000923009F43EC0F0E0EE0FFF1FE15FFE4FEF +:100CD000A591B491EC912E2309F45BCF8881998181 +:100CE0008F3F910531F00E941B028FEF90E09983B6 +:100CF00088830F5F1F4F22960F30110509F031CF07 +:100D000080E090E0892B09F4AACE0E94400188235C +:100D100009F499CE0E94000096CE9730A9F0983041 +:100D2000C9F0943081F6809180008F7D03C080915E +:100D300080008F7780938000C6CF84B58F7784BD85 +:100D4000C2CF84B58F7DFBCF8091B0008F77809329 +:100D5000B000B9CF8091B0008F7DF9CF0E94E30140 +:100D600064EF71E00E94F2066130710509F4B6CFBC +:100D700010CF85E00E94E3018D509E4FF701EE5F9A +:100D8000FE4F873E934008F410CFE080F1808881C9 +:100D900099818E159F0509F4ACCF8F3F910511F015 +:100DA0000E941B022E2DA7E3B2E0FD0181912817BE +:100DB00061F0CE16DF06D1F790E080E03D91311171 +:100DC0000AC08A5C9D4FFC01218367E086E392E0C4 +:100DD0000E94F80104C001968630910579F7F982E6 +:100DE000E88287CF97FB072E16F4009407D077FD93 +:100DF00009D00E94060707FC05D03EF49095819526 +:100E00009F4F0895709561957F4F0895AA1BBB1B56 +:100E100051E107C0AA1FBB1FA617B70710F0A61BFA +:100E2000B70B881F991F5A95A9F780959095BC011B +:100E3000CD010895EE0FFF1F0590F491E02D099468 +:040E4000F894FFCF54 +:100E4400FF5A5200500051004F000C0018000D00D2 +:100E54000E00280029002C000F0012001C000B00BB +:100E64005200500051004F0012001C000B000F00F4 +:100E740057002A0056004D004E004B004A00030064 +:100E840006000700080009000A000B000C000D0012 +:100E94000000020003000400060007000000000038 +:0E0EA4007601D6000301C301340112012601BC +:103800000C94341C0C94511C0C94511C0C94511CA1 +:103810000C94511C0C94511C0C94511C0C94511C74 +:103820000C94511C0C94511C0C94511C0C94511C64 +:103830000C94511C0C94511C0C94511C0C94511C54 +:103840000C94511C0C94511C0C94511C0C94511C44 +:103850000C94511C0C94511C0C94511C0C94511C34 +:103860000C94511C0C94511C11241FBECFEFD4E0BA +:10387000DEBFCDBF11E0A0E0B1E0E4EAFFE302C0AB +:1038800005900D92A230B107D9F712E0A2E0B1E0A5 +:1038900001C01D92AD30B107E1F70E94361D0C94B6 +:1038A000D01F0C94001C982F9595959595959595FE +:1038B000905D8F708A307CF0282F295A8091C0004B +:1038C00085FFFCCF9093C6008091C00085FFFCCFA0 +:1038D0002093C6000895282F205DF0CF982F809167 +:1038E000C00085FFFCCF9093C6000895EF92FF9231 +:1038F0000F931F93EE24FF2487018091C00087FD62 +:1039000017C00894E11CF11C011D111D81E4E8168B +:1039100082E4F8068FE0080780E0180770F3E09172 +:103920000401F091050109958091C00087FFE9CF5E +:103930008091C6001F910F91FF90EF9008950E9413 +:10394000761C982F8091C00085FFFCCF9093C60015 +:1039500091362CF490330CF09053892F089597559D +:10396000892F08951F930E949F1C182F0E949F1C4F +:103970001295107F810F1F910895882351F0982F81 +:1039800091508091C00087FFFCCF8091C6009923A1 +:10399000B9F708951F93182F0E94761C803249F0C2 +:1039A000809103018F5F809303018530C1F01F91E7 +:1039B00008958091C00085FFFCCF84E18093C6000C +:1039C0008091C00085FFFCCF1093C6008091C0009D +:1039D00085FFFCCF80E18093C6001F910895E091A0 +:1039E0000401F091050109951F9108950E94761C2C +:1039F000803241F0809103018F5F80930301853015 +:103A000081F008958091C00085FFFCCF84E1809310 +:103A1000C6008091C00085FFFCCF80E18093C60086 +:103A20000895E0910401F09105010995089510921F +:103A30000A028823D1F090E040E951E02D9A28EE67 +:103A400033E0FA013197F1F721503040D1F72D984A +:103A500028EE33E0FA013197F1F721503040D1F7E9 +:103A60009F5F981758F380930A0208953F924F92F0 +:103A70005F926F927F928F929F92AF92BF92CF92FE +:103A8000DF92EF92FF920F931F93CF93DF9300008B +:103A900083E38093C4001092C50088E18093C10045 +:103AA00086E08093C2005098589A259A81E00E943F +:103AB000171D44E1F42E3EE1E32E24E9D22E96E0D8 +:103AC000C92E80E1B82EAA24A39401E4902E16E515 +:103AD000812EB2E57B2EA0E26A2EF9E45F2EE3E5AB +:103AE0004E2E70E5372E0E94761C8033B1F1813363 +:103AF00009F441C0803409F479C0813409F48CC0E0 +:103B0000823471F1853409F47BC0803531F182351E +:103B100021F1813511F1853509F48DC0863509F41F +:103B20009DC0843609F4AEC0843709F41BC18537C3 +:103B300009F485C1863709F47AC0809103018F5F4B +:103B400080930301853079F6E0910401F09105013D +:103B500009950E94761C803351F60E94F61CC3CF53 +:103B600093E18091C00087FFFCCF8091C60099232C +:103B7000A1F39150F6CF0E94761C8032F1F680912D +:103B8000C00085FFFCCFF092C6008091C00085FF89 +:103B9000FCCF9092C6008091C00085FFFCCF809240 +:103BA000C6008091C00085FFFCCF7092C600809156 +:103BB000C00085FFFCCF6092C6008091C00085FFE9 +:103BC000FCCF5092C6008091C00085FFFCCF409290 +:103BD000C6008091C00085FFFCCF3092C600809166 +:103BE000C00085FFFCCFB092C6007DCF0E94761C3E +:103BF000863808F4B2CF0E94761C0E94F61C73CF60 +:103C000094E08091C00087FFFCCF8091C60099238B +:103C100009F4A3CF9150F5CF0E94761C8038D1F0E3 +:103C2000813861F1823809F499C0883979F080E0EF +:103C30000E94CA1C58CF0E94761C809306010E94E5 +:103C4000761C809307010E94F61C4DCF83E00E94F2 +:103C5000CA1C49CF82E00E94CA1C45CF0E94761C34 +:103C6000803309F486C192E08091C00087FFFCCFC9 +:103C70008091C6009923D9F29150F6CF81E00E943D +:103C8000CA1C31CF0E94761C809309020E94761CC8 +:103C90008093080280910C028E7F80930C020E9418 +:103CA000761C853429F480910C02816080930C028B +:103CB0008091080290910902892B89F000E010E0C0 +:103CC0000E94761CF801E85FFE4F80830F5F1F4F54 +:103CD00080910802909109020817190788F30E9441 +:103CE000761C803209F029CF80910C0280FFD1C070 +:103CF0004091060150910701440F551F5093070151 +:103D000040930601A0910802B09109021097C9F0F2 +:103D1000E8E0F1E09A01BD016E0F7F1FF999FECF37 +:103D200032BD21BD819180BDFA9AF99A2F5F3F4F34 +:103D3000E617F70799F74A0F5B1F50930701409367 +:103D400006018091C00085FFFCCFF092C6008091F3 +:103D5000C00085FFFCCFB092C600C5CE80E10E94B6 +:103D6000CA1CC1CE0E94761C809309020E94761C58 +:103D7000809308028091060190910701880F991F96 +:103D800090930701809306010E94761C853409F404 +:103D90007AC080910C028E7F80930C020E94761C68 +:103DA000803209F0A0CE8091C00085FFFCCFF09258 +:103DB000C600A0910802B09109021097B9F1809154 +:103DC0000C02182F1170082F0270E0910601F0917B +:103DD00007019F012F5F3F4FB90140E050E01123E1 +:103DE000B1F4002339F494918091C00085FFFCCF99 +:103DF0009093C6004F5F5F4FCB010196F9014A17C0 +:103E00005B0780F4BC012F5F3F4F112351F3F999F9 +:103E1000FECFF2BDE1BDF89A90B58091C00085FF5C +:103E2000FCCFE6CF70930701609306018091C0003C +:103E300085FDD9CE8091C00085FFF8CFD4CE0E94F9 +:103E4000761C803209F079CE8091C00085FFFCCFCE +:103E5000F092C6008091C00085FFFCCFE092C600C2 +:103E60008091C00085FFFCCFD092C6008091C00039 +:103E700085FFFCCFC092C6008091C00085FFFCCFBB +:103E8000B092C60030CE80910C02816080930C020B +:103E900085CF809107018823880F880B8A21809322 +:103EA0000B028091060190910701880F991F909352 +:103EB0000701809306018091080280FF09C080916C +:103EC00008029091090201969093090280930802DA +:103ED000F894F999FECF1127E0910601F0910701BE +:103EE000C8E0D1E08091080290910902103091F46D +:103EF0000091570001700130D9F303E0009357009F +:103F0000E8950091570001700130D9F301E1009369 +:103F10005700E89509901990009157000170013001 +:103F2000D9F301E000935700E8951395103498F009 +:103F300011270091570001700130D9F305E000937B +:103F40005700E8950091570001700130D9F301E165 +:103F500000935700E8953296029709F0C7CF1030CA +:103F600011F00296E5CF11248091C00085FFE9CEC3 +:103F7000ECCE0E94761C0E94761C182F0E94761CA4 +:103F8000112351F0113021F086E00E94CA1CABCD04 +:103F900084E90E94CA1CA7CD8EE10E94CA1CA3CD51 +:043FA000F894FFCFC3 +:023FA40080009B +:0400000300003800C1 +:00000001FF diff --git a/clockworkpi_keypad.ino b/clockworkpi_keypad.ino index 17064a7..fc10a7a 100644 --- a/clockworkpi_keypad.ino +++ b/clockworkpi_keypad.ino @@ -1,9 +1,12 @@ // CLOCKWORK Keypad Arduino driver // For more information please visit https://forum.clockworkpi.com -// HAPPY HACKING +// HAPPY HACKING! #include "UsbKeyboard.h" +#define DEBUG 0 // 0 = Debugging mode disabled / 1 = Debbuging mode enabled +#define INVERT_AB 0 // 0 = XY/AB / 1 = AB/XY + #define KEY_ENTER 0x28 // Keyboard Return (ENTER) #define KEY_ESCAPE 0x29 // Keyboard Escape #define KEY_BACKSPACE 0x2A // Keyboard Backspace @@ -34,10 +37,19 @@ #define KEYPAD_LEFT KEY_LEFT_ARROW #define KEYPAD_DOWN KEY_DOWN_ARROW #define KEYPAD_RIGHT KEY_RIGHT_ARROW -#define KEYPAD_Y KEY_I -#define KEYPAD_X KEY_U -#define KEYPAD_A KEY_J -#define KEYPAD_B KEY_K + +#if INVERT_AB == true + #define KEYPAD_Y KEY_K + #define KEYPAD_X KEY_J + #define KEYPAD_A KEY_U + #define KEYPAD_B KEY_I +#else + #define KEYPAD_Y KEY_I + #define KEYPAD_X KEY_U + #define KEYPAD_A KEY_J + #define KEYPAD_B KEY_K +#endif + #define KEYPAD_MENU KEY_ESCAPE #define KEYPAD_SELECT KEY_SPACE #define KEYPAD_START KEY_ENTER @@ -90,7 +102,7 @@ bool shift_key_pressed() void setup() { - TIMSK0 &= !(1 << TOIE0); + TIMSK0 &= ~(1 << TOIE0); for(int i = 0; i < KEY_NUM; i++) { @@ -101,6 +113,11 @@ void setup() old_keys[i] = KEY_NULL; } Serial.begin(115200); + + #if DEBUG == true + delay( 500 ); // Give a little bit time to initialize or it prints garbage the first time + Serial.println(F("\nBoard Initialized! Listening for Key Press.")); + #endif } void loop() @@ -108,7 +125,7 @@ void loop() int on_off, key; UsbKeyboard.update(); - delay(1000); + // delay(100); for(int i = 0; i < KEY_NUM; i++) { @@ -147,6 +164,9 @@ void loop() UsbKeyboard.release(old_keys[i]); } UsbKeyboard.press(key); + #if DEBUG == true + Serial.println("Key " + String(key, DEC) + " was pressed."); + #endif old_keys[i] = key; } }