From 6e2053047356d571bdf4b96e80a056befbf4ee1d Mon Sep 17 00:00:00 2001 From: Jeff Gran Date: Thu, 26 Nov 2015 00:42:42 -0700 Subject: [PATCH 001/217] enable TAPPING_TOGGLE=1 to work correctly if TAPPING_TOGGLE is 1, then tap a single time should toggle the mods on/off each tap. Previously this was broken, this fixes it. This allows the same key to either hold (momentary mod) or tap (toggle mod, like capslock). --- common/action.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common/action.c b/common/action.c index 1f15bd09..339b3ee6 100644 --- a/common/action.c +++ b/common/action.c @@ -131,10 +131,17 @@ void process_action(keyrecord_t *record) case MODS_TAP_TOGGLE: if (event.pressed) { if (tap_count <= TAPPING_TOGGLE) { - register_mods(mods); + if (mods & get_mods()) { + dprint("MODS_TAP_TOGGLE: toggle mods off\n"); + unregister_mods(mods); + } else { + dprint("MODS_TAP_TOGGLE: toggle mods on\n"); + register_mods(mods); + } } } else { if (tap_count < TAPPING_TOGGLE) { + dprint("MODS_TAP_TOGGLE: release : unregister_mods\n"); unregister_mods(mods); } } From fdc3c00d5cab5fe2fbe2d1d652b509bd58d530cf Mon Sep 17 00:00:00 2001 From: "Howard P. Logsdon" Date: Tue, 8 Dec 2015 16:46:08 -0700 Subject: [PATCH 002/217] Remove an errant comma trailing the KC_ERAS macro alias --- common/keycode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/keycode.h b/common/keycode.h index a7d837b3..9fec2904 100644 --- a/common/keycode.h +++ b/common/keycode.h @@ -85,7 +85,7 @@ along with this program. If not, see . #define KC_LCAP KC_LOCKING_CAPS #define KC_LNUM KC_LOCKING_NUM #define KC_LSCR KC_LOCKING_SCROLL -#define KC_ERAS KC_ALT_ERASE, +#define KC_ERAS KC_ALT_ERASE #define KC_CLR KC_CLEAR /* Japanese specific */ #define KC_ZKHK KC_GRAVE From f3c7bbed944aa53e0679e27680782b910d70d76c Mon Sep 17 00:00:00 2001 From: flabbergast Date: Wed, 30 Dec 2015 10:46:08 +0100 Subject: [PATCH 003/217] Chibios: add 'core/protocol' to the makefiles' search path. --- tool/chibios/chibios.mk | 2 +- tool/chibios/common.mk | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/tool/chibios/chibios.mk b/tool/chibios/chibios.mk index 0f6af53d..a67e067a 100644 --- a/tool/chibios/chibios.mk +++ b/tool/chibios/chibios.mk @@ -152,7 +152,7 @@ INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \ $(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \ $(CHIBIOS)/os/hal/lib/streams $(CHIBIOS)/os/various \ $(TMK_DIR) $(COMMON_DIR) $(TMK_DIR)/protocol/chibios \ - $(TARGET_DIR) + $(TMK_DIR)/protocol $(TARGET_DIR) # # Project, sources and paths diff --git a/tool/chibios/common.mk b/tool/chibios/common.mk index 883054a4..7e3cccc9 100644 --- a/tool/chibios/common.mk +++ b/tool/chibios/common.mk @@ -83,6 +83,3 @@ OPT_DEFS += -DVERSION=$(shell (git describe --always --dirty || echo 'unknown') ifdef BOOTLOADER_ADDRESS OPT_DEFS += -DBOOTLOADER_ADDRESS=$(BOOTLOADER_ADDRESS) endif - -# Search Path -VPATH += $(TMK_DIR)/common From ef917817ec78273c3d7b118a59ad6b240ab98b7e Mon Sep 17 00:00:00 2001 From: obones Date: Thu, 7 Jan 2016 14:40:53 +0100 Subject: [PATCH 004/217] host_driver is only used if KEYBOARD_LOCK_ENABLE is defined --- common/command.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/command.c b/common/command.c index d59bb01b..465aa21c 100644 --- a/common/command.c +++ b/common/command.c @@ -178,7 +178,9 @@ static void print_eeconfig(void) static bool command_common(uint8_t code) { +#ifdef KEYBOARD_LOCK_ENABLE static host_driver_t *host_driver = 0; +#endif switch (code) { #ifdef SLEEP_LED_ENABLE case KC_Z: From 7559ecf198cfd7e75636151ef37df842aeef2110 Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 12 Jan 2016 13:03:22 +0900 Subject: [PATCH 005/217] usb_usb: Fix for keymap editor --- common/keycode.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/keycode.h b/common/keycode.h index 9fec2904..f3402712 100644 --- a/common/keycode.h +++ b/common/keycode.h @@ -95,6 +95,9 @@ along with this program. If not, see . #define KC_JPY KC_INT3 #define KC_HENK KC_INT4 #define KC_MHEN KC_INT5 +/* Korean specific */ +#define KC_HAEN KC_LANG1 +#define KC_HANJ KC_LANG2 /* Keypad */ #define KC_P1 KC_KP_1 #define KC_P2 KC_KP_2 @@ -114,6 +117,11 @@ along with this program. If not, see . #define KC_PPLS KC_KP_PLUS #define KC_PEQL KC_KP_EQUAL #define KC_PENT KC_KP_ENTER +/* Unix function key */ +#define KC_EXEC KC_EXECUTE +#define KC_SLCT KC_SELECT +#define KC_AGIN KC_AGAIN +#define KC_PSTE KC_PASTE /* Mousekey */ #define KC_MS_U KC_MS_UP #define KC_MS_D KC_MS_DOWN From 1adcf989ec5edc59e9e95352dc8ec49d72a440b8 Mon Sep 17 00:00:00 2001 From: Shayne Holmes Date: Tue, 12 Jan 2016 10:19:58 -0800 Subject: [PATCH 006/217] Fix typo in bootmagic debug message --- common/bootmagic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/bootmagic.c b/common/bootmagic.c index b002a585..d6684b2d 100644 --- a/common/bootmagic.c +++ b/common/bootmagic.c @@ -19,7 +19,7 @@ void bootmagic(void) } /* do scans in case of bounce */ - print("boogmagic scan: ... "); + print("bootmagic scan: ... "); uint8_t scan = 100; while (scan--) { matrix_scan(); _delay_ms(10); } print("done.\n"); From d39ea9e7382f20e643936a91e05f44a88931947e Mon Sep 17 00:00:00 2001 From: duanhongyi Date: Thu, 14 Jan 2016 15:27:26 +0800 Subject: [PATCH 007/217] remove SERIAL_SOFT_DEBUG macro SERIAL_SOFT_DEBUG can be defined in the `config.h` --- protocol/serial_soft.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/protocol/serial_soft.c b/protocol/serial_soft.c index 44822b7e..569205bf 100644 --- a/protocol/serial_soft.c +++ b/protocol/serial_soft.c @@ -68,7 +68,6 @@ POSSIBILITY OF SUCH DAMAGE. #endif /* debug for signal timing, see debug pin with oscilloscope */ -#define SERIAL_SOFT_DEBUG #ifdef SERIAL_SOFT_DEBUG #define SERIAL_SOFT_DEBUG_INIT() (DDRD |= 1<<7) #define SERIAL_SOFT_DEBUG_TGL() (PORTD ^= 1<<7) @@ -176,7 +175,7 @@ void serial_send(uint8_t data) ISR(SERIAL_SOFT_RXD_VECT) { SERIAL_SOFT_DEBUG_TGL(); - SERIAL_SOFT_RXD_INT_ENTER() + SERIAL_SOFT_RXD_INT_ENTER(); uint8_t data = 0; From 2cd960006ad48e2b292bfc3271bb1e7cd81e3aa8 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 15 Jan 2016 14:12:57 +0900 Subject: [PATCH 008/217] core: Fix doc/build.md --- doc/build.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/doc/build.md b/doc/build.md index beff191b..ffcd0fbc 100644 --- a/doc/build.md +++ b/doc/build.md @@ -10,7 +10,7 @@ Download and Install 2. **Programmer** Install [dfu-programmer][dfu-prog]. GUI tool [Atmel FLIP][flip] also can be used on Windows. -3. **Driver** On Windows you start DFU bootloader on the chip first time you will see 'Found New Hardware Wizard' to install driver. If you install device driver properly you can find chip name like 'ATmega32U4' under 'LibUSB-Win32 Devices' tree on 'Device Manager'. If not you shall need to update its driver on 'Device Manager'. You will find the driver in `FLIP` install directory like: C:\Program Files (x86)\Atmel\Flip 3.4.5\usb\. In case of `dfu-programmer` use its driver. +3. **Driver** On Windows when you start DFU bootloader on the chip first time you will see **Found New Hardware Wizard** to install driver. If you install device driver properly you will find chip name like **ATmega32U4** under **LibUSB-Win32 Devices** tree on **Device Manager**. If not you shall need to update its driver on **Device Manager**. You will find the driver in `FLIP` install directory like: `C:\Program Files (x86)\Atmel\Flip 3.4.5\usb\`. In case of `dfu-programmer` install driver distributed with it. If you use PJRC Teensy you don't need step 2 and 3 above, just get [Teensy loader][teensy-loader]. @@ -20,7 +20,7 @@ You can find firmware source at github: - -If you are familiar with `Git` tools you are recommended to use it but you can also download zip archive from: +If you are familiar with `git` tools you are recommended to use it but you can also download zip archive from: - @@ -28,7 +28,7 @@ If you are familiar with `Git` tools you are recommended to use it but you can a Build firmware -------------- ### 1. Open terminal -Open terminal window to get access to commands. Use Cygwin(or MingGW) `shell terminal` in Windows or `Terminal.app` on Mac OSX. In Windows press `Windows` key and `R` then enter `cmd` in 'Run command' dialog showing up. +Open terminal window to get access to commands. Use Cygwin(or MingGW) shell terminal in Windows or `Terminal.app` on Mac OSX. ### 2. Change directory Move to project directory in the firmware source. @@ -68,33 +68,31 @@ Or to program with `dfu-programmer` run: $ make -f Makefile. dfu #### FLIP GUI tutorial -1. On menu bar click Device -> Select, then choose your chip name. -2. On menu bar click Settings -> Communication -> USB, then click 'Open' button on 'USB Port Connection' dialog. -At this point you'll see grey-outed widgets on the app get colored and ready. +1. On menu bar click **Device** -> **Select**, then choose your chip name. (In most case **ATmega32U2** or **ATmega32U4**) +2. On menu bar click **Settings** -> **Communication** -> **USB**, then click **Open** button on **USB Port Connection** dialog. At this point you'll have to plug into USB and start bootloader. -3. On menu bar click File -> Load HEX File, then select your firmware hex file on File Selector dialog. -4. On 'Operations Flow' panel click 'Run' button to load the firmware binary to the chip. Note that you should keep 'Erase', 'Blank Check', 'Program' and 'Verify' check boxes selected. -5. Re-plug USB cord or click 'Start Application' button to restart your controller. +3. On menu bar click **File** -> **Load HEX File**, then select your firmware hex file on File Selector dialog. +4. On **Operations Flow** panel click **Run** button to load the firmware binary to the chip. Note that you should keep **Erase**, **Blank Check**, **Program** and **Verify** check boxes selected. +5. Re-plug USB cord or click **Start Application** button to restart your controller. Done. -See also these instructions if you need. +See also these instructions if needed. - - -### 3. Program with Teensy Loader -If you have PJRC Teensy see instruction of `Teensy Loader`. +##### Troubleshoot +* **FLIP: AtLibUsbDfu.dll not found** +Remove current driver and re-install one FLIP provides from DeviceManager of WIndows. See -- -Or use this command if you have command line version of Teensy Loader installed. +### 3. Program with Other programmer +If you are using PJRC Teensy consult with instruction of [Teensy Loader][teensy-loader]. Or run this target with `make` after you install command line version of it. $ make -f Makefile. teensy - -### 4. Program with Other programmer -You may want to use other programmer like `avrdude` with AVRISPmkII, Arduino or USBasp. In that case you can still use make target `program` for build with configuring `PROGRAM_CMD` in Makefile. +You may want to use other programmer like [`avrdude`][avrdude]. In that case you can still use make target `program` for build with configuring `PROGRAM_CMD` in Makefile. See below. $ make -f Makefile. program @@ -106,6 +104,7 @@ You may want to use other programmer like `avrdude` with AVRISPmkII, Arduino or [flip]: http://www.atmel.com/tools/FLIP.aspx [dfu-prog]: http://dfu-programmer.sourceforge.net/ [teensy-loader]:http://www.pjrc.com/teensy/loader.html +[avrdude]: http://savannah.nongnu.org/projects/avrdude/ @@ -121,6 +120,7 @@ Set your MCU and its clock in Hz. # Boot Section Size in *bytes* # Teensy halfKay 512 + # Teensy++ halfKay 2048 # Atmel DFU loader 4096 # LUFA bootloader 4096 OPT_DEFS += -DBOOTLOADER_SIZE=4096 @@ -140,7 +140,7 @@ Optional. Note that ***comment out*** with `#` to disable them. #BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality ### 3. Programmer -Optional. Set proper command for your controller, bootloader and programmer. This command can be used with `make program`. Not needed if you use `FLIP`, `dfu-programmer` or `Teensy Loader`. +Optional. Set proper command for your controller, bootloader and programmer. This command can be used with `make program`. # avrdude with AVRISPmkII PROGRAM_CMD = avrdude -p $(MCU) -c avrispmkII -P USB -U flash:w:$(TARGET).hex From afcdb6801f1ea190cbb14ffb5c6dd6a95384fa23 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 15 Jan 2016 14:30:47 +0900 Subject: [PATCH 009/217] core: Add dfu-programmer example to doc/build.md --- doc/build.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/doc/build.md b/doc/build.md index ffcd0fbc..0585d62d 100644 --- a/doc/build.md +++ b/doc/build.md @@ -53,22 +53,28 @@ Now you have **hex** file to program on current directory. This **hex** is only How to program controller depends on controller chip and its board design. To program AVR USB chips you'll need to start it up in bootloader mode. Most of boards with the chip have a push button to let bootloader come up. Consult with your controller board manual. ### 2. Program with DFU bootloader -Stock AVR USB chips have DFU bootloader by factory default. `FLIP` is a DFU programmer on Windows offered by Atmel. Open source command line tool `dfu-programmer` also supports AVR chips, it runs on Linux, Mac OSX and even Windows. +Stock AVR USB chips have DFU bootloader by factory default. `FLIP` is a DFU programmer on Windows offered by Atmel. `FLIP` has two version of tool, GUI app and command line program. If you want GUI see tutorial below. Open source alternative `dfu-programmer` also supports AVR chips, it is command line tool and runs on Linux, Mac OSX and even Windows. -To program AVR chip with DFU bootloader use `FLIP` or `dfu-programmer`. -If you have a proper program command in `Makefile` just type this. -`FLIP` has two version of tool, GUI app and command line program. If you want GUI see tutorial below. -To use command line tool run this command. Note that you need to set PATH variable properly. +To program with command of `FLIP` run this. Note that you need to set PATH variable properly. $ make -f Makefile. flip -Or to program with `dfu-programmer` run: +With `dfu-programmer` run this. $ make -f Makefile. dfu +Or you can execute the command directly as the following. + + $ dfu-programmer erase --force + $ dfu-programmer flash + $ dfu-programmer reset + +`` part will be `atmega32u4` or `atmega32u2` in most cases. See manual of the command for the detail. + + #### FLIP GUI tutorial -1. On menu bar click **Device** -> **Select**, then choose your chip name. (In most case **ATmega32U2** or **ATmega32U4**) +1. On menu bar click **Device** -> **Select**, then choose your chip name. (In most cases **ATmega32U2** or **ATmega32U4**) 2. On menu bar click **Settings** -> **Communication** -> **USB**, then click **Open** button on **USB Port Connection** dialog. At this point you'll have to plug into USB and start bootloader. 3. On menu bar click **File** -> **Load HEX File**, then select your firmware hex file on File Selector dialog. From 6e1746c4b77b73f76d985ea6c1e093a801bdb49c Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Fri, 23 Oct 2015 20:38:50 +0200 Subject: [PATCH 010/217] Add support for storing, restoring and clearing modifiers in macros --- common/action_macro.c | 13 +++++++++++++ common/action_macro.h | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/common/action_macro.c b/common/action_macro.c index ffaf125c..34e22e57 100644 --- a/common/action_macro.c +++ b/common/action_macro.c @@ -34,6 +34,8 @@ void action_macro_play(const macro_t *macro_p) macro_t macro = END; uint8_t interval = 0; + uint8_t mod_storage; + if (!macro_p) return; while (true) { switch (MACRO_READ()) { @@ -66,6 +68,17 @@ void action_macro_play(const macro_t *macro_p) interval = MACRO_READ(); dprintf("INTERVAL(%u)\n", interval); break; + case MOD_STORE: + mod_storage = get_mods(); + break; + case MOD_RESTORE: + set_mods(mod_storage); + send_keyboard_report(); + break; + case MOD_CLEAR: + clear_mods(); + send_keyboard_report(); + break; case 0x04 ... 0x73: dprintf("DOWN(%02X)\n", macro); register_code(macro); diff --git a/common/action_macro.h b/common/action_macro.h index aedc32ec..4cf2216d 100644 --- a/common/action_macro.h +++ b/common/action_macro.h @@ -64,6 +64,9 @@ enum macro_command_id{ /* 0x74 - 0x83 */ WAIT = 0x74, INTERVAL, + MOD_STORE, + MOD_RESTORE, + MOD_CLEAR, /* 0x84 - 0xf3 (reserved for keycode up) */ @@ -82,6 +85,9 @@ enum macro_command_id{ #define TYPE(key) DOWN(key), UP(key) #define WAIT(ms) WAIT, (ms) #define INTERVAL(ms) INTERVAL, (ms) +#define STORE() MOD_STORE +#define RESTORE() MOD_RESTORE +#define CLEAR() MOD_CLEAR /* key down */ #define D(key) DOWN(KC_##key) @@ -93,6 +99,12 @@ enum macro_command_id{ #define W(ms) WAIT(ms) /* interval */ #define I(ms) INTERVAL(ms) +/* store modifier(s) */ +#define SM() STORE() +/* restore modifier(s) */ +#define RM() RESTORE() +/* clear modifier(s) */ +#define CM() CLEAR() /* for backward comaptibility */ #define MD(key) DOWN(KC_##key) From 550fca195e2c20156d52f7f6ae2b1537785f0d29 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 15 Jan 2016 16:00:56 +0900 Subject: [PATCH 011/217] core: Add macro commands SM(), RM() and CM() --- doc/keymap.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/doc/keymap.md b/doc/keymap.md index d4a129b2..566936c6 100644 --- a/doc/keymap.md +++ b/doc/keymap.md @@ -368,17 +368,37 @@ Default Layer also has bitwise operations, they are executed when key is release MACRO( I(255), T(H), T(E), T(L), T(L), W(255), T(O), END ) #### 2.3.1 Macro Commands +- **MACRO()** +- **MACRO_NONE** + - **I()** change interval of stroke. - **D()** press key - **U()** release key - **T()** type key(press and release) - **W()** wait +- **SM()** store modifier state +- **RM()** restore modifier state +- **CM()** clear modifier state - **END** end mark #### 2.3.2 Examples +***TBD*** + + const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) + { + switch (id) { + case HELLO: + return (record->event.pressed ? + MACRO( I(0), T(H), T(E), T(L), T(L), W(255), T(O), END ) : + MACRO_NONE ); + case ALT_TAB: + return (record->event.pressed ? + MACRO( D(LALT), D(TAB), END ) : + MACRO( U(TAB), END )); + } + return MACRO_NONE; + } -***TODO: sample implementation*** -See `keyboard/hhkb/keymap.c` for sample. From 37a1dd88842cbc64d22a07f3142158fc4f314d86 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 15 Jan 2016 16:24:06 +0900 Subject: [PATCH 012/217] core: Fix variable init and header include --- common/keymap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/keymap.c b/common/keymap.c index d4892380..f6a15172 100644 --- a/common/keymap.c +++ b/common/keymap.c @@ -22,6 +22,7 @@ along with this program. If not, see . #include "action_macro.h" #include "wait.h" #include "debug.h" +#include "bootloader.h" static action_t keycode_to_action(uint8_t keycode); @@ -123,7 +124,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) /* translates keycode to action */ static action_t keycode_to_action(uint8_t keycode) { - action_t action; + action_t action = {}; switch (keycode) { case KC_A ... KC_EXSEL: case KC_LCTRL ... KC_RGUI: From 8eb092376c377e8002eb2e3e81509a48ce8d99e0 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 15 Jan 2016 16:26:01 +0900 Subject: [PATCH 013/217] core: Fix variable initialize --- common/action_macro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/action_macro.c b/common/action_macro.c index 34e22e57..b2891bf4 100644 --- a/common/action_macro.c +++ b/common/action_macro.c @@ -34,7 +34,7 @@ void action_macro_play(const macro_t *macro_p) macro_t macro = END; uint8_t interval = 0; - uint8_t mod_storage; + uint8_t mod_storage = 0; if (!macro_p) return; while (true) { From 655a6d01af58dac2d972a9c0a555821e067bfb6c Mon Sep 17 00:00:00 2001 From: flabbergast Date: Fri, 15 Jan 2016 21:41:51 +0000 Subject: [PATCH 014/217] Chibios: Update to new USB API. --- protocol/chibios/usb_main.c | 131 ++++++++++++++++++++---------------- 1 file changed, 73 insertions(+), 58 deletions(-) diff --git a/protocol/chibios/usb_main.c b/protocol/chibios/usb_main.c index ee2788e5..9097d4e8 100644 --- a/protocol/chibios/usb_main.c +++ b/protocol/chibios/usb_main.c @@ -52,11 +52,12 @@ uint8_t extra_report_blank[3] = {0}; #endif /* EXTRAKEY_ENABLE */ #ifdef CONSOLE_ENABLE -/* The emission queue */ -output_queue_t console_queue; -static uint8_t console_queue_buffer[CONSOLE_QUEUE_BUFFER_SIZE]; +/* The emission buffers queue */ +output_buffers_queue_t console_buf_queue; +static uint8_t console_queue_buffer[BQ_BUFFER_SIZE(CONSOLE_QUEUE_CAPACITY, CONSOLE_EPSIZE)]; + static virtual_timer_t console_flush_timer; -void console_queue_onotify(io_queue_t *qp); +void console_queue_onotify(io_buffers_queue_t *bqp); static void console_flush_cb(void *arg); #endif /* CONSOLE_ENABLE */ @@ -1019,7 +1020,7 @@ void init_usb_driver(USBDriver *usbp) { chVTObjectInit(&keyboard_idle_timer); #ifdef CONSOLE_ENABLE - oqObjectInit(&console_queue, console_queue_buffer, sizeof(console_queue_buffer), console_queue_onotify, (void *)usbp); + obqObjectInit(&console_buf_queue, console_queue_buffer, CONSOLE_EPSIZE, CONSOLE_QUEUE_CAPACITY, console_queue_onotify, (void*)usbp); chVTObjectInit(&console_flush_timer); #endif } @@ -1093,10 +1094,7 @@ static void keyboard_idle_timer_cb(void *arg) { if(keyboard_idle) { #endif /* NKRO_ENABLE */ /* TODO: are we sure we want the KBD_ENDPOINT? */ - osalSysUnlockFromISR(); - usbPrepareTransmit(usbp, KBD_ENDPOINT, (uint8_t *)&keyboard_report_sent, sizeof(keyboard_report_sent)); - osalSysLockFromISR(); - usbStartTransmitI(usbp, KBD_ENDPOINT); + usbStartTransmitI(usbp, KBD_ENDPOINT, (uint8_t *)&keyboard_report_sent, sizeof(keyboard_report_sent)); /* rearm the timer */ chVTSetI(&keyboard_idle_timer, 4*MS2ST(keyboard_idle), keyboard_idle_timer_cb, (void *)usbp); } @@ -1121,26 +1119,28 @@ void send_keyboard(report_keyboard_t *report) { } osalSysUnlock(); - bool ep_not_ready; #ifdef NKRO_ENABLE if(keyboard_nkro) { /* NKRO protocol */ - usbPrepareTransmit(&USB_DRIVER, NKRO_ENDPOINT, (uint8_t *)report, sizeof(report_keyboard_t)); /* need to wait until the previous packet has made it through */ - do { - osalSysLock(); - ep_not_ready = usbStartTransmitI(&USB_DRIVER, NKRO_ENDPOINT); - osalSysUnlock(); - } while (ep_not_ready); + /* can rewrite this using the synchronous API, then would wait + * until *after* the packet has been transmitted. I think + * this is more efficient */ + /* busy wait, should be short and not very common */ + osalSysLock(); + while(usbGetTransmitStatusI(&USB_DRIVER, NKRO_ENDPOINT)) + ; + usbStartTransmitI(&USB_DRIVER, NKRO_ENDPOINT, (uint8_t *)report, sizeof(report_keyboard_t)); + osalSysUnlock(); } else #endif /* NKRO_ENABLE */ { /* boot protocol */ - usbPrepareTransmit(&USB_DRIVER, KBD_ENDPOINT, (uint8_t *)report, KBD_EPSIZE); /* need to wait until the previous packet has made it through */ - do { - osalSysLock(); - ep_not_ready = usbStartTransmitI(&USB_DRIVER, KBD_ENDPOINT); - osalSysUnlock(); - } while (ep_not_ready); + /* busy wait, should be short and not very common */ + osalSysLock(); + while(usbGetTransmitStatusI(&USB_DRIVER, KBD_ENDPOINT)) + ; + usbStartTransmitI(&USB_DRIVER, KBD_ENDPOINT, (uint8_t *)report, KBD_EPSIZE); + osalSysUnlock(); } keyboard_report_sent = *report; } @@ -1171,9 +1171,8 @@ void send_mouse(report_mouse_t *report) { * is this really needed? */ - usbPrepareTransmit(&USB_DRIVER, MOUSE_ENDPOINT, (uint8_t *)report, sizeof(report_mouse_t)); osalSysLock(); - usbStartTransmitI(&USB_DRIVER, MOUSE_ENDPOINT); + usbStartTransmitI(&USB_DRIVER, MOUSE_ENDPOINT, (uint8_t *)report, sizeof(report_mouse_t)); osalSysUnlock(); } @@ -1209,10 +1208,7 @@ static void send_extra_report(uint8_t report_id, uint16_t data) { .usage = data }; - osalSysUnlock(); - usbPrepareTransmit(&USB_DRIVER, EXTRA_ENDPOINT, (uint8_t *)&report, sizeof(report_extra_t)); - osalSysLock(); - usbStartTransmitI(&USB_DRIVER, EXTRA_ENDPOINT); + usbStartTransmitI(&USB_DRIVER, EXTRA_ENDPOINT, (uint8_t *)&report, sizeof(report_extra_t)); osalSysUnlock(); } @@ -1240,20 +1236,32 @@ void send_consumer(uint16_t data) { #ifdef CONSOLE_ENABLE -/* debug IN callback hander */ +/* console IN callback hander */ void console_in_cb(USBDriver *usbp, usbep_t ep) { - (void)ep; + (void)ep; /* should have ep == CONSOLE_ENDPOINT, so use that to save time/space */ + uint8_t *buf; + size_t n; + osalSysLockFromISR(); /* rearm the timer */ chVTSetI(&console_flush_timer, MS2ST(CONSOLE_FLUSH_MS), console_flush_cb, (void *)usbp); - /* Check if there is data to send left in the output queue */ - if(chOQGetFullI(&console_queue) >= CONSOLE_EPSIZE) { - osalSysUnlockFromISR(); - usbPrepareQueuedTransmit(usbp, CONSOLE_ENDPOINT, &console_queue, CONSOLE_EPSIZE); - osalSysLockFromISR(); - usbStartTransmitI(usbp, CONSOLE_ENDPOINT); + /* Freeing the buffer just transmitted, if it was not a zero size packet.*/ + if (usbp->epc[CONSOLE_ENDPOINT]->in_state->txsize > 0U) { + obqReleaseEmptyBufferI(&console_buf_queue); + } + + /* Checking if there is a buffer ready for transmission.*/ + buf = obqGetFullBufferI(&console_buf_queue, &n); + + if (buf != NULL) { + /* The endpoint cannot be busy, we are in the context of the callback, + so it is safe to transmit without a check.*/ + /* Should have n == CONSOLE_EPSIZE; check it? */ + usbStartTransmitI(usbp, CONSOLE_ENDPOINT, buf, CONSOLE_EPSIZE); + } else { + /* Nothing to transmit.*/ } osalSysUnlockFromISR(); @@ -1261,18 +1269,22 @@ void console_in_cb(USBDriver *usbp, usbep_t ep) { /* Callback when data is inserted into the output queue * Called from a locked state */ -void console_queue_onotify(io_queue_t *qp) { - USBDriver *usbp = qGetLink(qp); +void console_queue_onotify(io_buffers_queue_t *bqp) { + size_t n; + USBDriver *usbp = bqGetLinkX(bqp); if(usbGetDriverStateI(usbp) != USB_ACTIVE) return; - if(!usbGetTransmitStatusI(usbp, CONSOLE_ENDPOINT) - && (chOQGetFullI(&console_queue) >= CONSOLE_EPSIZE)) { - osalSysUnlock(); - usbPrepareQueuedTransmit(usbp, CONSOLE_ENDPOINT, &console_queue, CONSOLE_EPSIZE); - osalSysLock(); - usbStartTransmitI(usbp, CONSOLE_ENDPOINT); + /* Checking if there is already a transaction ongoing on the endpoint.*/ + if (!usbGetTransmitStatusI(usbp, CONSOLE_ENDPOINT)) { + /* Trying to get a full buffer.*/ + uint8_t *buf = obqGetFullBufferI(&console_buf_queue, &n); + if (buf != NULL) { + /* Buffer found, starting a new transaction.*/ + /* Should have n == CONSOLE_EPSIZE; check this? */ + usbStartTransmitI(usbp, CONSOLE_ENDPOINT, buf, CONSOLE_EPSIZE); + } } } @@ -1280,8 +1292,6 @@ void console_queue_onotify(io_queue_t *qp) { * callback (called from ISR, unlocked state) */ static void console_flush_cb(void *arg) { USBDriver *usbp = (USBDriver *)arg; - size_t i, n; - uint8_t buf[CONSOLE_EPSIZE]; /* TODO: a solution without extra buffer? */ osalSysLockFromISR(); /* check that the states of things are as they're supposed to */ @@ -1292,23 +1302,28 @@ static void console_flush_cb(void *arg) { return; } - /* don't do anything if the queue is empty or has enough stuff in it */ - if(((n = oqGetFullI(&console_queue)) == 0) || (n >= CONSOLE_EPSIZE)) { + /* If there is already a transaction ongoing then another one cannot be + started.*/ + if (usbGetTransmitStatusI(usbp, CONSOLE_ENDPOINT)) { /* rearm the timer */ chVTSetI(&console_flush_timer, MS2ST(CONSOLE_FLUSH_MS), console_flush_cb, (void *)usbp); osalSysUnlockFromISR(); return; } - /* there's stuff hanging in the queue - so dequeue and send */ - for(i = 0; i < n; i++) - buf[i] = (uint8_t)oqGetI(&console_queue); - for(i = n; i < CONSOLE_EPSIZE; i++) - buf[i] = 0; - osalSysUnlockFromISR(); - usbPrepareTransmit(usbp, CONSOLE_ENDPOINT, buf, CONSOLE_EPSIZE); - osalSysLockFromISR(); - (void)usbStartTransmitI(usbp, CONSOLE_ENDPOINT); + /* Checking if there only a buffer partially filled, if so then it is + enforced in the queue and transmitted.*/ + if(obqTryFlushI(&console_buf_queue)) { + size_t n,i; + uint8_t *buf = obqGetFullBufferI(&console_buf_queue, &n); + + osalDbgAssert(buf != NULL, "queue is empty"); + + /* zero the rest of the buffer (buf should point to allocated space) */ + for(i=n; i Date: Sat, 16 Jan 2016 10:05:32 +0900 Subject: [PATCH 015/217] core: Add note about sudo and git --- doc/build.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/build.md b/doc/build.md index 0585d62d..57a36ac4 100644 --- a/doc/build.md +++ b/doc/build.md @@ -20,7 +20,7 @@ You can find firmware source at github: - -If you are familiar with `git` tools you are recommended to use it but you can also download zip archive from: +If you are familiar with [`git`][git] tools you are recommended to use it but you can also download zip archive from: - @@ -70,7 +70,7 @@ Or you can execute the command directly as the following. $ dfu-programmer flash $ dfu-programmer reset -`` part will be `atmega32u4` or `atmega32u2` in most cases. See manual of the command for the detail. +`` part will be `atmega32u4` or `atmega32u2` in most cases. See manual of the command for the detail. On Linux and Mac OSX you will need proper permission to program a controller and you can use `sudo` command for this purpose probably. On Linux you also can configure `udev` rules to set permission. #### FLIP GUI tutorial @@ -111,6 +111,7 @@ You may want to use other programmer like [`avrdude`][avrdude]. In that case you [dfu-prog]: http://dfu-programmer.sourceforge.net/ [teensy-loader]:http://www.pjrc.com/teensy/loader.html [avrdude]: http://savannah.nongnu.org/projects/avrdude/ +[git]: https://git-scm.com/ From 777176c6c99ec3d1814dc26ed52a5a34d1384efc Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Fri, 22 Jan 2016 10:21:51 +0900 Subject: [PATCH 016/217] core: Speed up compilation --- common.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common.mk b/common.mk index 3b53c0a0..e165a78b 100644 --- a/common.mk +++ b/common.mk @@ -81,7 +81,8 @@ ifdef KEYMAP_SECTION_ENABLE endif # Version string -OPT_DEFS += -DVERSION=$(shell (git describe --always --dirty || echo 'unknown') 2> /dev/null) +VERSION := $(shell (git describe --always --dirty || echo 'unknown') 2> /dev/null) +OPT_DEFS += -DVERSION=$(VERSION) # Search Path From eafd2f581395e0fdea4af8a8f4e23d7a9db62a30 Mon Sep 17 00:00:00 2001 From: flabbergast Date: Fri, 22 Jan 2016 22:19:02 +0000 Subject: [PATCH 017/217] Chibios: add more guards for transmitting (fix a deadlock bug). --- protocol/chibios/usb_main.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/protocol/chibios/usb_main.c b/protocol/chibios/usb_main.c index 9097d4e8..d248b447 100644 --- a/protocol/chibios/usb_main.c +++ b/protocol/chibios/usb_main.c @@ -1094,7 +1094,9 @@ static void keyboard_idle_timer_cb(void *arg) { if(keyboard_idle) { #endif /* NKRO_ENABLE */ /* TODO: are we sure we want the KBD_ENDPOINT? */ - usbStartTransmitI(usbp, KBD_ENDPOINT, (uint8_t *)&keyboard_report_sent, sizeof(keyboard_report_sent)); + if(!usbGetTransmitStatusI(usbp, KBD_ENDPOINT)) { + usbStartTransmitI(usbp, KBD_ENDPOINT, (uint8_t *)&keyboard_report_sent, KBD_EPSIZE); + } /* rearm the timer */ chVTSetI(&keyboard_idle_timer, 4*MS2ST(keyboard_idle), keyboard_idle_timer_cb, (void *)usbp); } @@ -1127,8 +1129,13 @@ void send_keyboard(report_keyboard_t *report) { * this is more efficient */ /* busy wait, should be short and not very common */ osalSysLock(); - while(usbGetTransmitStatusI(&USB_DRIVER, NKRO_ENDPOINT)) - ; + if(usbGetTransmitStatusI(&USB_DRIVER, NKRO_ENDPOINT)) { + /* Need to either suspend, or loop and call unlock/lock during + * every iteration - otherwise the system will remain locked, + * no interrupts served, so USB not going through as well. + * Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */ + osalThreadSuspendS(&(&USB_DRIVER)->epc[NKRO_ENDPOINT]->in_state->thread); + } usbStartTransmitI(&USB_DRIVER, NKRO_ENDPOINT, (uint8_t *)report, sizeof(report_keyboard_t)); osalSysUnlock(); } else @@ -1137,8 +1144,13 @@ void send_keyboard(report_keyboard_t *report) { /* need to wait until the previous packet has made it through */ /* busy wait, should be short and not very common */ osalSysLock(); - while(usbGetTransmitStatusI(&USB_DRIVER, KBD_ENDPOINT)) - ; + if(usbGetTransmitStatusI(&USB_DRIVER, KBD_ENDPOINT)) { + /* Need to either suspend, or loop and call unlock/lock during + * every iteration - otherwise the system will remain locked, + * no interrupts served, so USB not going through as well. + * Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */ + osalThreadSuspendS(&(&USB_DRIVER)->epc[KBD_ENDPOINT]->in_state->thread); + } usbStartTransmitI(&USB_DRIVER, KBD_ENDPOINT, (uint8_t *)report, KBD_EPSIZE); osalSysUnlock(); } From ba0a1cfae26b1c818b60d5cc815316bae4ce226a Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 27 Jan 2016 08:14:44 +0900 Subject: [PATCH 018/217] core: Remove unused warning. Fix tmk_keyboard/#293 --- common/action_tapping.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/common/action_tapping.c b/common/action_tapping.c index 826c2330..a74eb106 100644 --- a/common/action_tapping.c +++ b/common/action_tapping.c @@ -30,7 +30,6 @@ static bool process_tapping(keyrecord_t *record); static bool waiting_buffer_enq(keyrecord_t record); static void waiting_buffer_clear(void); static bool waiting_buffer_typed(keyevent_t event); -static bool waiting_buffer_has_anykey_pressed(void); static void waiting_buffer_scan_tap(void); static void debug_tapping_key(void); static void debug_waiting_buffer(void); @@ -324,14 +323,6 @@ bool waiting_buffer_typed(keyevent_t event) return false; } -bool waiting_buffer_has_anykey_pressed(void) -{ - for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) { - if (waiting_buffer[i].event.pressed) return true; - } - return false; -} - /* scan buffer for tapping */ void waiting_buffer_scan_tap(void) { From 3f5afdd26a4cf3f5e24fd6eeef10099ac1e42d87 Mon Sep 17 00:00:00 2001 From: flabbergast Date: Thu, 11 Feb 2016 21:12:19 +0000 Subject: [PATCH 019/217] Chibios: Fix a HardFault bug (wait after start). --- protocol/chibios/main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/protocol/chibios/main.c b/protocol/chibios/main.c index b62cfa9c..d588e4de 100644 --- a/protocol/chibios/main.c +++ b/protocol/chibios/main.c @@ -101,6 +101,13 @@ int main(void) { while(USB_DRIVER.state != USB_ACTIVE) chThdSleepMilliseconds(50); + /* Do need to wait here! + * Otherwise the next print might start a transfer on console EP + * before the USB is completely ready, which sometimes causes + * HardFaults. + */ + chThdSleepMilliseconds(50); + print("USB configured.\n"); /* init TMK modules */ From 53a1b0c155cf717ffcd4335c39266acc122e6340 Mon Sep 17 00:00:00 2001 From: flabbergast Date: Thu, 11 Feb 2016 21:14:28 +0000 Subject: [PATCH 020/217] Chibios: cleanup usb_main code. --- protocol/chibios/usb_main.c | 8 ++++---- protocol/chibios/usb_main.h | 6 +----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/protocol/chibios/usb_main.c b/protocol/chibios/usb_main.c index d248b447..e2c9d9bf 100644 --- a/protocol/chibios/usb_main.c +++ b/protocol/chibios/usb_main.c @@ -33,9 +33,9 @@ * --------------------------------------------------------- */ -uint8_t keyboard_idle = 0; -uint8_t keyboard_protocol = 1; -uint16_t keyboard_led_stats = 0; +uint8_t keyboard_idle __attribute__((aligned(2))) = 0; +uint8_t keyboard_protocol __attribute__((aligned(2))) = 1; +uint16_t keyboard_led_stats __attribute__((aligned(2))) = 0; volatile uint16_t keyboard_idle_count = 0; static virtual_timer_t keyboard_idle_timer; static void keyboard_idle_timer_cb(void *arg); @@ -1350,7 +1350,7 @@ int8_t sendchar(uint8_t c) { return 0; } osalSysUnlock(); - /* Timeout after 5us if the queue is full. + /* Timeout after 100us if the queue is full. * Increase this timeout if too much stuff is getting * dropped (i.e. the buffer is getting full too fast * for USB/HIDRAW to dequeue). Another possibility diff --git a/protocol/chibios/usb_main.h b/protocol/chibios/usb_main.h index d8f30e95..30d8fcae 100644 --- a/protocol/chibios/usb_main.h +++ b/protocol/chibios/usb_main.h @@ -58,9 +58,6 @@ void send_remote_wakeup(USBDriver *usbp); #define NKRO_REPORT_KEYS (NKRO_EPSIZE - 1) #endif -/* this defines report_keyboard_t and computes REPORT_SIZE defines */ -// #include "report.h" - /* extern report_keyboard_t keyboard_report_sent; */ /* keyboard IN request callback handler */ @@ -122,8 +119,7 @@ typedef struct { #define CONSOLE_EPSIZE 16 /* Number of IN reports that can be stored inside the output queue */ -#define CONSOLE_QUEUE_CAPACITY 2 -#define CONSOLE_QUEUE_BUFFER_SIZE (CONSOLE_QUEUE_CAPACITY * CONSOLE_EPSIZE) +#define CONSOLE_QUEUE_CAPACITY 4 /* Console flush time */ #define CONSOLE_FLUSH_MS 50 From b1f18cba2afa1231ab87ed796a29f960a58661e3 Mon Sep 17 00:00:00 2001 From: flabbergast Date: Sat, 13 Feb 2016 10:01:16 +0000 Subject: [PATCH 021/217] Chibios: Revert common.mk change (fix AVR linking problem). --- common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.mk b/common.mk index ebaafd1d..4c943f04 100644 --- a/common.mk +++ b/common.mk @@ -1,4 +1,4 @@ -COMMON_DIR = $(TMK_DIR)/common +COMMON_DIR = common SRC += $(COMMON_DIR)/host.c \ $(COMMON_DIR)/keyboard.c \ $(COMMON_DIR)/action.c \ From a4b7dd66200095eb5e84635a5253e23c752d2898 Mon Sep 17 00:00:00 2001 From: obones Date: Wed, 10 Feb 2016 11:18:50 +0100 Subject: [PATCH 022/217] Removed duplicate debug message code and surrounded it with IFDEF as needed --- protocol/ps2_mouse.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/protocol/ps2_mouse.c b/protocol/ps2_mouse.c index c3e8b3c1..7d23cbed 100644 --- a/protocol/ps2_mouse.c +++ b/protocol/ps2_mouse.c @@ -85,23 +85,19 @@ void ps2_mouse_task(void) if (debug_mouse) print("ps2_mouse: fail to get mouse packet\n"); return; } - xprintf("%ud ", timer_read()); - print("ps2_mouse raw: ["); - phex(mouse_report.buttons); print("|"); - print_hex8((uint8_t)mouse_report.x); print(" "); - print_hex8((uint8_t)mouse_report.y); print("]\n"); + +#ifdef PS2_MOUSE_DEBUG + xprintf("%ud ", timer_read()); + print("ps2_mouse raw: ["); + phex(mouse_report.buttons); print("|"); + print_hex8((uint8_t)mouse_report.x); print(" "); + print_hex8((uint8_t)mouse_report.y); print("]\n"); +#endif /* if mouse moves or buttons state changes */ if (mouse_report.x || mouse_report.y || ((mouse_report.buttons ^ buttons_prev) & PS2_MOUSE_BTN_MASK)) { -#ifdef PS2_MOUSE_DEBUG - print("ps2_mouse raw: ["); - phex(mouse_report.buttons); print("|"); - print_hex8((uint8_t)mouse_report.x); print(" "); - print_hex8((uint8_t)mouse_report.y); print("]\n"); -#endif - buttons_prev = mouse_report.buttons; // PS/2 mouse data is '9-bit integer'(-256 to 255) which is comprised of sign-bit and 8-bit value. From 864612fb2c304c3f672890ab9ed43db6e8745257 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 17 Feb 2016 08:23:47 +0900 Subject: [PATCH 023/217] core: Fix ps2_mouse.c debug print --- protocol/ps2_mouse.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/protocol/ps2_mouse.c b/protocol/ps2_mouse.c index 7d23cbed..b0f77a83 100644 --- a/protocol/ps2_mouse.c +++ b/protocol/ps2_mouse.c @@ -85,19 +85,19 @@ void ps2_mouse_task(void) if (debug_mouse) print("ps2_mouse: fail to get mouse packet\n"); return; } - -#ifdef PS2_MOUSE_DEBUG - xprintf("%ud ", timer_read()); - print("ps2_mouse raw: ["); - phex(mouse_report.buttons); print("|"); - print_hex8((uint8_t)mouse_report.x); print(" "); - print_hex8((uint8_t)mouse_report.y); print("]\n"); -#endif /* if mouse moves or buttons state changes */ if (mouse_report.x || mouse_report.y || ((mouse_report.buttons ^ buttons_prev) & PS2_MOUSE_BTN_MASK)) { +#ifdef PS2_MOUSE_DEBUG + xprintf("%ud ", timer_read()); + print("ps2_mouse raw: ["); + phex(mouse_report.buttons); print("|"); + print_hex8((uint8_t)mouse_report.x); print(" "); + print_hex8((uint8_t)mouse_report.y); print("]\n"); +#endif + buttons_prev = mouse_report.buttons; // PS/2 mouse data is '9-bit integer'(-256 to 255) which is comprised of sign-bit and 8-bit value. From fe6249887e8cb7216c3e7be4b84ac1847b8b34c8 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 17 Feb 2016 12:36:16 +0900 Subject: [PATCH 024/217] core: Fix chibios user compile options Compile options can be defined in project Makefile such as UDEFS, UADEFS, UINCDIR, ULIBDIR and ULIBS. --- tool/chibios/chibios.mk | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tool/chibios/chibios.mk b/tool/chibios/chibios.mk index a67e067a..77689fc3 100644 --- a/tool/chibios/chibios.mk +++ b/tool/chibios/chibios.mk @@ -201,10 +201,10 @@ CPPWARN = -Wall -Wextra -Wundef # List all user C define here, like -D_DEBUG=1 ## Select which interfaces to include here! -UDEFS = $(OPT_DEFS) +UDEFS += $(OPT_DEFS) # Define ASM defines here -UADEFS = $(OPT_DEFS) +UADEFS += $(OPT_DEFS) # bootloader definitions may be used in the startup .s file ifneq ("$(wildcard $(TARGET_DIR)/bootloader_defs.h)","") UADEFS += -include $(TARGET_DIR)/bootloader_defs.h @@ -215,13 +215,13 @@ else ifneq ("$(wildcard $(TARGET_DIR)/boards/$(BOARD)/bootloader_defs.h)","") endif # List all user directories here -UINCDIR = +#UINCDIR = # List the user directory to look for the libraries here -ULIBDIR = +#ULIBDIR = # List all user libraries here -ULIBS = +#ULIBS = # # End of user defines From 211bdbb835821a879e48663f453aa1df67e50fca Mon Sep 17 00:00:00 2001 From: Ethan Apodaca Date: Tue, 1 Mar 2016 21:37:22 -0800 Subject: [PATCH 025/217] Codes appear to be detected correctly, the break codes are broken. --- protocol.mk | 7 +++ protocol/pbuff.h | 57 ++++++++++++++++++++ protocol/ps2_interrupt.c | 60 +-------------------- protocol/xt.h | 75 ++++++++++++++++++++++++++ protocol/xt_interrupt.c | 113 +++++++++++++++++++++++++++++++++++++++ protocol/xt_io.h | 7 +++ protocol/xt_io_avr.c | 34 ++++++++++++ 7 files changed, 294 insertions(+), 59 deletions(-) create mode 100644 protocol/pbuff.h create mode 100644 protocol/xt.h create mode 100644 protocol/xt_interrupt.c create mode 100644 protocol/xt_io.h create mode 100644 protocol/xt_io_avr.c diff --git a/protocol.mk b/protocol.mk index 54913329..630c42b1 100644 --- a/protocol.mk +++ b/protocol.mk @@ -26,6 +26,13 @@ ifdef PS2_USE_USART endif +ifdef XT_USE_INT + SRC += protocol/xt_interrupt.c + SRC += protocol/xt_io_avr.c + OPT_DEFS += -DXT_USE_INT +endif + + ifdef SERIAL_MOUSE_MICROSOFT_ENABLE SRC += $(PROTOCOL_DIR)/serial_mouse_microsoft.c OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MICROSOFT \ diff --git a/protocol/pbuff.h b/protocol/pbuff.h new file mode 100644 index 00000000..27373923 --- /dev/null +++ b/protocol/pbuff.h @@ -0,0 +1,57 @@ +/*-------------------------------------------------------------------- + * Ring buffer to store scan codes from keyboard + *------------------------------------------------------------------*/ + +#ifndef PBUFF_H +#define PBUFF_H + +#include "print.h" + +#define PBUF_SIZE 32 +static uint16_t pbuf[PBUF_SIZE]; +static uint16_t pbuf_head = 0; +static uint16_t pbuf_tail = 0; +static inline void pbuf_enqueue(uint16_t data) +{ + uint8_t sreg = SREG; + cli(); + uint16_t next = (pbuf_head + 1) % PBUF_SIZE; + if (next != pbuf_tail) { + pbuf[pbuf_head] = data; + pbuf_head = next; + } else { + print("pbuf: full\n"); + } + SREG = sreg; +} +static inline uint16_t pbuf_dequeue(void) +{ + uint16_t val = 0; + + uint8_t sreg = SREG; + cli(); + if (pbuf_head != pbuf_tail) { + val = pbuf[pbuf_tail]; + pbuf_tail = (pbuf_tail + 1) % PBUF_SIZE; + } + SREG = sreg; + + return val; +} +static inline bool pbuf_has_data(void) +{ + uint8_t sreg = SREG; + cli(); + bool has_data = (pbuf_head != pbuf_tail); + SREG = sreg; + return has_data; +} +static inline void pbuf_clear(void) +{ + uint8_t sreg = SREG; + cli(); + pbuf_head = pbuf_tail = 0; + SREG = sreg; +} + +#endif diff --git a/protocol/ps2_interrupt.c b/protocol/ps2_interrupt.c index 8114442b..0fd3d360 100644 --- a/protocol/ps2_interrupt.c +++ b/protocol/ps2_interrupt.c @@ -42,6 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include "pbuff.h" #include "ps2.h" #include "ps2_io.h" #include "print.h" @@ -57,13 +58,6 @@ POSSIBILITY OF SUCH DAMAGE. uint8_t ps2_error = PS2_ERR_NONE; - -static inline uint8_t pbuf_dequeue(void); -static inline void pbuf_enqueue(uint8_t data); -static inline bool pbuf_has_data(void); -static inline void pbuf_clear(void); - - void ps2_host_init(void) { idle(); @@ -225,55 +219,3 @@ void ps2_host_set_led(uint8_t led) ps2_host_send(0xED); ps2_host_send(led); } - - -/*-------------------------------------------------------------------- - * Ring buffer to store scan codes from keyboard - *------------------------------------------------------------------*/ -#define PBUF_SIZE 32 -static uint8_t pbuf[PBUF_SIZE]; -static uint8_t pbuf_head = 0; -static uint8_t pbuf_tail = 0; -static inline void pbuf_enqueue(uint8_t data) -{ - uint8_t sreg = SREG; - cli(); - uint8_t next = (pbuf_head + 1) % PBUF_SIZE; - if (next != pbuf_tail) { - pbuf[pbuf_head] = data; - pbuf_head = next; - } else { - print("pbuf: full\n"); - } - SREG = sreg; -} -static inline uint8_t pbuf_dequeue(void) -{ - uint8_t val = 0; - - uint8_t sreg = SREG; - cli(); - if (pbuf_head != pbuf_tail) { - val = pbuf[pbuf_tail]; - pbuf_tail = (pbuf_tail + 1) % PBUF_SIZE; - } - SREG = sreg; - - return val; -} -static inline bool pbuf_has_data(void) -{ - uint8_t sreg = SREG; - cli(); - bool has_data = (pbuf_head != pbuf_tail); - SREG = sreg; - return has_data; -} -static inline void pbuf_clear(void) -{ - uint8_t sreg = SREG; - cli(); - pbuf_head = pbuf_tail = 0; - SREG = sreg; -} - diff --git a/protocol/xt.h b/protocol/xt.h new file mode 100644 index 00000000..55efd75d --- /dev/null +++ b/protocol/xt.h @@ -0,0 +1,75 @@ +/* +Copyright 2010,2011,2012,2013 Jun WAKO +Copyright 2016 Ethan Apodaca + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef XT_H +#define XT_H + +#include +#include "wait.h" +#include "xt_io.h" +#include "print.h" + +void xt_host_init(void); +uint8_t xt_host_recv(void); + + +/*-------------------------------------------------------------------- + * static functions + *------------------------------------------------------------------*/ +static inline uint16_t wait_clock_lo(uint16_t us) +{ + while (clock_in() && us) { asm(""); wait_us(1); us--; } + return us; +} +static inline uint16_t wait_clock_hi(uint16_t us) +{ + while (!clock_in() && us) { asm(""); wait_us(1); us--; } + return us; +} +static inline uint16_t wait_data_lo(uint16_t us) +{ + while (data_in() && us) { asm(""); wait_us(1); us--; } + return us; +} +static inline uint16_t wait_data_hi(uint16_t us) +{ + while (!data_in() && us) { asm(""); wait_us(1); us--; } + return us; +} + +#endif diff --git a/protocol/xt_interrupt.c b/protocol/xt_interrupt.c new file mode 100644 index 00000000..2a351c5b --- /dev/null +++ b/protocol/xt_interrupt.c @@ -0,0 +1,113 @@ +/* +Copyright 2010,2011,2012,2013 Jun WAKO + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * PS/2 protocol Pin interrupt version + */ + +#include +#include +#include +#include "pbuff.h" +#include "xt.h" +#include "xt_io.h" +#include "wait.h" +#include "print.h" + +void xt_host_init(void) +{ + XT_INT_INIT(); + XT_INT_ON(); +} + +/* get data received by interrupt */ +uint8_t xt_host_recv(void) +{ + if (pbuf_has_data()) { + return pbuf_dequeue(); + } else { + return 0; + } +} + +ISR(XT_INT_VECT) +{ + static enum { + INIT, + BIT0, BIT1, BIT2, BIT3, BIT4, BIT5, BIT6, BIT7, + STOP, + } state = INIT; + static uint8_t data = 0; + // wait for clock falling edge + if(state != INIT) + wait_clock_lo(70); + + switch (state) { + case INIT: + if (data_in()) + state++; + break; + case BIT0: + case BIT1: + case BIT2: + case BIT3: + case BIT4: + case BIT5: + case BIT6: + case BIT7: + state++; + data >>= 1; + if (data_in()) { + data |= 0x80; + } + break; + case STOP: + if (!data_in()) + goto DONE; + pbuf_enqueue(data); + goto DONE; + break; + default: + goto DONE; + } + goto RETURN; +DONE: + state = INIT; + data = 0; +RETURN: + return; +} diff --git a/protocol/xt_io.h b/protocol/xt_io.h new file mode 100644 index 00000000..2e5f31b2 --- /dev/null +++ b/protocol/xt_io.h @@ -0,0 +1,7 @@ +#ifndef XT_IO_H +#define XT_IO_H + +bool clock_in(void); +bool data_in(void); + +#endif diff --git a/protocol/xt_io_avr.c b/protocol/xt_io_avr.c new file mode 100644 index 00000000..6cd153a1 --- /dev/null +++ b/protocol/xt_io_avr.c @@ -0,0 +1,34 @@ +#include +#include +#include + +/* Check port settings for clock and data line */ +#if !(defined(XT_CLOCK_PORT) && \ + defined(XT_CLOCK_PIN) && \ + defined(XT_CLOCK_DDR) && \ + defined(XT_CLOCK_BIT)) +# error "XT clock port setting is required in config.h" +#endif + +#if !(defined(XT_DATA_PORT) && \ + defined(XT_DATA_PIN) && \ + defined(XT_DATA_DDR) && \ + defined(XT_DATA_BIT)) +# error "XT data port setting is required in config.h" +#endif + +bool clock_in(void) +{ + XT_CLOCK_DDR &= ~(1< Date: Thu, 3 Mar 2016 16:18:19 +0900 Subject: [PATCH 026/217] core: Actionmap support --- common.mk | 8 +- common/action_code.h | 4 +- common/action_layer.c | 3 +- common/actionmap.c | 39 ++++ common/actionmap.h | 459 ++++++++++++++++++++++++++++++++++++++++++ common/bootmagic.c | 66 +++--- common/bootmagic.h | 2 +- common/keycode.h | 10 +- common/report.h | 68 +++---- 9 files changed, 586 insertions(+), 73 deletions(-) create mode 100644 common/actionmap.c create mode 100644 common/actionmap.h diff --git a/common.mk b/common.mk index 4c943f04..1efd5d8f 100644 --- a/common.mk +++ b/common.mk @@ -6,7 +6,6 @@ SRC += $(COMMON_DIR)/host.c \ $(COMMON_DIR)/action_macro.c \ $(COMMON_DIR)/action_layer.c \ $(COMMON_DIR)/action_util.c \ - $(COMMON_DIR)/keymap.c \ $(COMMON_DIR)/print.c \ $(COMMON_DIR)/debug.c \ $(COMMON_DIR)/util.c \ @@ -17,6 +16,13 @@ SRC += $(COMMON_DIR)/host.c \ # Option modules +ifdef ACTIONMAP_ENABLE + SRC += $(COMMON_DIR)/actionmap.c + OPT_DEFS += -DACTIONMAP_ENABLE +else + SRC += $(COMMON_DIR)/keymap.c +endif + ifdef BOOTMAGIC_ENABLE SRC += $(COMMON_DIR)/bootmagic.c SRC += $(COMMON_DIR)/avr/eeconfig.c diff --git a/common/action_code.h b/common/action_code.h index da93f77b..b39c6441 100644 --- a/common/action_code.h +++ b/common/action_code.h @@ -251,8 +251,8 @@ enum layer_pram_tap_op { OP_OFF_ON, OP_SET_CLEAR, }; -#define ACTION_LAYER_BITOP(op, part, bits, on) (ACT_LAYER<<12 | (op)<<10 | (on)<<8 | (part)<<5 | ((bits)&0x1f)) -#define ACTION_LAYER_TAP(layer, key) (ACT_LAYER_TAP<<12 | (layer)<<8 | (key)) +#define ACTION_LAYER_BITOP(op, part, bits, on) ACTION(ACT_LAYER, (op)<<10 | (on)<<8 | (part)<<5 | ((bits)&0x1f)) +#define ACTION_LAYER_TAP(layer, key) ACTION(ACT_LAYER_TAP, (layer)<<8 | (key)) /* Default Layer */ #define ACTION_DEFAULT_LAYER_SET(layer) ACTION_DEFAULT_LAYER_BIT_SET((layer)/4, 1<<((layer)%4)) #define ACTION_DEFAULT_LAYER_TOGGLE(layer) ACTION_DEFAULT_LAYER_BIT_XOR((layer)/4, 1<<((layer)%4)) diff --git a/common/action_layer.c b/common/action_layer.c index c535615f..e6db388d 100644 --- a/common/action_layer.c +++ b/common/action_layer.c @@ -114,8 +114,7 @@ void layer_debug(void) action_t layer_switch_get_action(keypos_t key) { - action_t action; - action.code = ACTION_TRANSPARENT; + action_t action = { .code = ACTION_TRANSPARENT }; #ifndef NO_ACTION_LAYER uint32_t layers = layer_state | default_layer_state; diff --git a/common/actionmap.c b/common/actionmap.c new file mode 100644 index 00000000..49d0f5ce --- /dev/null +++ b/common/actionmap.c @@ -0,0 +1,39 @@ +/* +Copyright 2015 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include +#include "action_code.h" +#include "actionmap.h" + +/* Converts key to action */ +__attribute__ ((weak)) +action_t action_for_key(uint8_t layer, keypos_t key) +{ + return (action_t)pgm_read_word(&actionmaps[(layer)][(key.row)][(key.col)]); +} + +/* Macro */ +__attribute__ ((weak)) +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + return MACRO_NONE; +} + +/* Function */ +__attribute__ ((weak)) +void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) +{ +} diff --git a/common/actionmap.h b/common/actionmap.h new file mode 100644 index 00000000..cbbcfe93 --- /dev/null +++ b/common/actionmap.h @@ -0,0 +1,459 @@ +/* +Copyright 2015 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#ifndef ACTIONMAP_H +#define ACTIONMAP_H + +#include "keyboard.h" +#include "report.h" +#include "keycode.h" +#include "action_code.h" +#include "action.h" + + +/* Keymapping with 16bit action codes */ +extern const uint16_t actionmaps[][MATRIX_ROWS][MATRIX_COLS]; + + +/* Modified key */ +#define AC_c(kc) ACTION_MODS_KEY(MOD_LCTL, KC_##kc) +#define AC_s(kc) ACTION_MODS_KEY(MOD_LSFT, KC_##kc) +#define AC_a(kc) ACTION_MODS_KEY(MOD_LALT, KC_##kc) +#define AC_g(kc) ACTION_MODS_KEY(MOD_LSFT, KC_##kc) + +/* Normal key */ +#define AC_NO ACTION_KEY(KC_NO) +#define AC_TRANSPARENT ACTION_KEY(KC_TRANSPARENT) +#define AC_ROLL_OVER ACTION_KEY(KC_ROLL_OVER) +#define AC_POST_FAIL ACTION_KEY(KC_POST_FAIL) +#define AC_UNDEFINED ACTION_KEY(KC_UNDEFINED) +#define AC_A ACTION_KEY(KC_A) +#define AC_B ACTION_KEY(KC_B) +#define AC_C ACTION_KEY(KC_C) +#define AC_D ACTION_KEY(KC_D) +#define AC_E ACTION_KEY(KC_E) +#define AC_F ACTION_KEY(KC_F) +#define AC_G ACTION_KEY(KC_G) +#define AC_H ACTION_KEY(KC_H) +#define AC_I ACTION_KEY(KC_I) +#define AC_J ACTION_KEY(KC_J) +#define AC_K ACTION_KEY(KC_K) +#define AC_L ACTION_KEY(KC_L) +#define AC_M ACTION_KEY(KC_M) +#define AC_N ACTION_KEY(KC_N) +#define AC_O ACTION_KEY(KC_O) +#define AC_P ACTION_KEY(KC_P) +#define AC_Q ACTION_KEY(KC_Q) +#define AC_R ACTION_KEY(KC_R) +#define AC_S ACTION_KEY(KC_S) +#define AC_T ACTION_KEY(KC_T) +#define AC_U ACTION_KEY(KC_U) +#define AC_V ACTION_KEY(KC_V) +#define AC_W ACTION_KEY(KC_W) +#define AC_X ACTION_KEY(KC_X) +#define AC_Y ACTION_KEY(KC_Y) +#define AC_Z ACTION_KEY(KC_Z) +#define AC_1 ACTION_KEY(KC_1) +#define AC_2 ACTION_KEY(KC_2) +#define AC_3 ACTION_KEY(KC_3) +#define AC_4 ACTION_KEY(KC_4) +#define AC_5 ACTION_KEY(KC_5) +#define AC_6 ACTION_KEY(KC_6) +#define AC_7 ACTION_KEY(KC_7) +#define AC_8 ACTION_KEY(KC_8) +#define AC_9 ACTION_KEY(KC_9) +#define AC_0 ACTION_KEY(KC_0) +#define AC_ENTER ACTION_KEY(KC_ENTER) +#define AC_ESCAPE ACTION_KEY(KC_ESCAPE) +#define AC_BSPACE ACTION_KEY(KC_BSPACE) +#define AC_TAB ACTION_KEY(KC_TAB) +#define AC_SPACE ACTION_KEY(KC_SPACE) +#define AC_MINUS ACTION_KEY(KC_MINUS) +#define AC_EQUAL ACTION_KEY(KC_EQUAL) +#define AC_LBRACKET ACTION_KEY(KC_LBRACKET) +#define AC_RBRACKET ACTION_KEY(KC_RBRACKET) +#define AC_BSLASH ACTION_KEY(KC_BSLASH) +#define AC_NONUS_HASH ACTION_KEY(KC_NONUS_HASH) +#define AC_SCOLON ACTION_KEY(KC_SCOLON) +#define AC_QUOTE ACTION_KEY(KC_QUOTE) +#define AC_GRAVE ACTION_KEY(KC_GRAVE) +#define AC_COMMA ACTION_KEY(KC_COMMA) +#define AC_DOT ACTION_KEY(KC_DOT) +#define AC_SLASH ACTION_KEY(KC_SLASH) +#define AC_CAPSLOCK ACTION_KEY(KC_CAPSLOCK) +#define AC_F1 ACTION_KEY(KC_F1) +#define AC_F2 ACTION_KEY(KC_F2) +#define AC_F3 ACTION_KEY(KC_F3) +#define AC_F4 ACTION_KEY(KC_F4) +#define AC_F5 ACTION_KEY(KC_F5) +#define AC_F6 ACTION_KEY(KC_F6) +#define AC_F7 ACTION_KEY(KC_F7) +#define AC_F8 ACTION_KEY(KC_F8) +#define AC_F9 ACTION_KEY(KC_F9) +#define AC_F10 ACTION_KEY(KC_F10) +#define AC_F11 ACTION_KEY(KC_F11) +#define AC_F12 ACTION_KEY(KC_F12) +#define AC_PSCREEN ACTION_KEY(KC_PSCREEN) +#define AC_SCROLLLOCK ACTION_KEY(KC_SCROLLLOCK) +#define AC_PAUSE ACTION_KEY(KC_PAUSE) +#define AC_INSERT ACTION_KEY(KC_INSERT) +#define AC_HOME ACTION_KEY(KC_HOME) +#define AC_PGUP ACTION_KEY(KC_PGUP) +#define AC_DELETE ACTION_KEY(KC_DELETE) +#define AC_END ACTION_KEY(KC_END) +#define AC_PGDOWN ACTION_KEY(KC_PGDOWN) +#define AC_RIGHT ACTION_KEY(KC_RIGHT) +#define AC_LEFT ACTION_KEY(KC_LEFT) +#define AC_DOWN ACTION_KEY(KC_DOWN) +#define AC_UP ACTION_KEY(KC_UP) +#define AC_NUMLOCK ACTION_KEY(KC_NUMLOCK) +#define AC_KP_SLASH ACTION_KEY(KC_KP_SLASH) +#define AC_KP_ASTERISK ACTION_KEY(KC_KP_ASTERISK) +#define AC_KP_MINUS ACTION_KEY(KC_KP_MINUS) +#define AC_KP_PLUS ACTION_KEY(KC_KP_PLUS) +#define AC_KP_ENTER ACTION_KEY(KC_KP_ENTER) +#define AC_KP_1 ACTION_KEY(KC_KP_1) +#define AC_KP_2 ACTION_KEY(KC_KP_2) +#define AC_KP_3 ACTION_KEY(KC_KP_3) +#define AC_KP_4 ACTION_KEY(KC_KP_4) +#define AC_KP_5 ACTION_KEY(KC_KP_5) +#define AC_KP_6 ACTION_KEY(KC_KP_6) +#define AC_KP_7 ACTION_KEY(KC_KP_7) +#define AC_KP_8 ACTION_KEY(KC_KP_8) +#define AC_KP_9 ACTION_KEY(KC_KP_9) +#define AC_KP_0 ACTION_KEY(KC_KP_0) +#define AC_KP_DOT ACTION_KEY(KC_KP_DOT) +#define AC_NONUS_BSLASH ACTION_KEY(KC_NONUS_BSLASH) +#define AC_APPLICATION ACTION_KEY(KC_APPLICATION) +#define AC_POWER ACTION_KEY(KC_POWER) +#define AC_KP_EQUAL ACTION_KEY(KC_KP_EQUAL) +#define AC_F13 ACTION_KEY(KC_F13) +#define AC_F14 ACTION_KEY(KC_F14) +#define AC_F15 ACTION_KEY(KC_F15) +#define AC_F16 ACTION_KEY(KC_F16) +#define AC_F17 ACTION_KEY(KC_F17) +#define AC_F18 ACTION_KEY(KC_F18) +#define AC_F19 ACTION_KEY(KC_F19) +#define AC_F20 ACTION_KEY(KC_F20) +#define AC_F21 ACTION_KEY(KC_F21) +#define AC_F22 ACTION_KEY(KC_F22) +#define AC_F23 ACTION_KEY(KC_F23) +#define AC_F24 ACTION_KEY(KC_F24) +#define AC_EXECUTE ACTION_KEY(KC_EXECUTE) +#define AC_HELP ACTION_KEY(KC_HELP) +#define AC_MENU ACTION_KEY(KC_MENU) +#define AC_SELECT ACTION_KEY(KC_SELECT) +#define AC_STOP ACTION_KEY(KC_STOP) +#define AC_AGAIN ACTION_KEY(KC_AGAIN) +#define AC_UNDO ACTION_KEY(KC_UNDO) +#define AC_CUT ACTION_KEY(KC_CUT) +#define AC_COPY ACTION_KEY(KC_COPY) +#define AC_PASTE ACTION_KEY(KC_PASTE) +#define AC_FIND ACTION_KEY(KC_FIND) +#define AC__MUTE ACTION_KEY(KC__MUTE) +#define AC__VOLUP ACTION_KEY(KC__VOLUP) +#define AC__VOLDOWN ACTION_KEY(KC__VOLDOWN) +#define AC_LOCKING_CAPS ACTION_KEY(KC_LOCKING_CAPS) +#define AC_LOCKING_NUM ACTION_KEY(KC_LOCKING_NUM) +#define AC_LOCKING_SCROLL ACTION_KEY(KC_LOCKING_SCROLL) +#define AC_KP_COMMA ACTION_KEY(KC_KP_COMMA) +#define AC_KP_EQUAL_AS400 ACTION_KEY(KC_KP_EQUAL_AS400) +#define AC_INT1 ACTION_KEY(KC_INT1) +#define AC_INT2 ACTION_KEY(KC_INT2) +#define AC_INT3 ACTION_KEY(KC_INT3) +#define AC_INT4 ACTION_KEY(KC_INT4) +#define AC_INT5 ACTION_KEY(KC_INT5) +#define AC_INT6 ACTION_KEY(KC_INT6) +#define AC_INT7 ACTION_KEY(KC_INT7) +#define AC_INT8 ACTION_KEY(KC_INT8) +#define AC_INT9 ACTION_KEY(KC_INT9) +#define AC_LANG1 ACTION_KEY(KC_LANG1) +#define AC_LANG2 ACTION_KEY(KC_LANG2) +#define AC_LANG3 ACTION_KEY(KC_LANG3) +#define AC_LANG4 ACTION_KEY(KC_LANG4) +#define AC_LANG5 ACTION_KEY(KC_LANG5) +#define AC_LANG6 ACTION_KEY(KC_LANG6) +#define AC_LANG7 ACTION_KEY(KC_LANG7) +#define AC_LANG8 ACTION_KEY(KC_LANG8) +#define AC_LANG9 ACTION_KEY(KC_LANG9) +#define AC_ALT_ERASE ACTION_KEY(KC_ALT_ERASE) +#define AC_SYSREQ ACTION_KEY(KC_SYSREQ) +#define AC_CANCEL ACTION_KEY(KC_CANCEL) +#define AC_CLEAR ACTION_KEY(KC_CLEAR) +#define AC_PRIOR ACTION_KEY(KC_PRIOR) +#define AC_RETURN ACTION_KEY(KC_RETURN) +#define AC_SEPARATOR ACTION_KEY(KC_SEPARATOR) +#define AC_OUT ACTION_KEY(KC_OUT) +#define AC_OPER ACTION_KEY(KC_OPER) +#define AC_CLEAR_AGAIN ACTION_KEY(KC_CLEAR_AGAIN) +#define AC_CRSEL ACTION_KEY(KC_CRSEL) +#define AC_EXSEL ACTION_KEY(KC_EXSEL) +#define AC_KP_00 ACTION_KEY(KC_KP_00) +#define AC_KP_000 ACTION_KEY(KC_KP_000) +#define AC_THOUSANDS_SEPARATOR ACTION_KEY(KC_THOUSANDS_SEPARATOR) +#define AC_DECIMAL_SEPARATOR ACTION_KEY(KC_DECIMAL_SEPARATOR) +#define AC_CURRENCY_UNIT ACTION_KEY(KC_CURRENCY_UNIT) +#define AC_CURRENCY_SUB_UNIT ACTION_KEY(KC_CURRENCY_SUB_UNIT) +#define AC_KP_LPAREN ACTION_KEY(KC_KP_LPAREN) +#define AC_KP_RPAREN ACTION_KEY(KC_KP_RPAREN) +#define AC_KP_LCBRACKET ACTION_KEY(KC_KP_LCBRACKET) +#define AC_KP_RCBRACKET ACTION_KEY(KC_KP_RCBRACKET) +#define AC_KP_TAB ACTION_KEY(KC_KP_TAB) +#define AC_KP_BSPACE ACTION_KEY(KC_KP_BSPACE) +#define AC_KP_A ACTION_KEY(KC_KP_A) +#define AC_KP_B ACTION_KEY(KC_KP_B) +#define AC_KP_C ACTION_KEY(KC_KP_C) +#define AC_KP_D ACTION_KEY(KC_KP_D) +#define AC_KP_E ACTION_KEY(KC_KP_E) +#define AC_KP_F ACTION_KEY(KC_KP_F) +#define AC_KP_XOR ACTION_KEY(KC_KP_XOR) +#define AC_KP_HAT ACTION_KEY(KC_KP_HAT) +#define AC_KP_PERC ACTION_KEY(KC_KP_PERC) +#define AC_KP_LT ACTION_KEY(KC_KP_LT) +#define AC_KP_GT ACTION_KEY(KC_KP_GT) +#define AC_KP_AND ACTION_KEY(KC_KP_AND) +#define AC_KP_LAZYAND ACTION_KEY(KC_KP_LAZYAND) +#define AC_KP_OR ACTION_KEY(KC_KP_OR) +#define AC_KP_LAZYOR ACTION_KEY(KC_KP_LAZYOR) +#define AC_KP_COLON ACTION_KEY(KC_KP_COLON) +#define AC_KP_HASH ACTION_KEY(KC_KP_HASH) +#define AC_KP_SPACE ACTION_KEY(KC_KP_SPACE) +#define AC_KP_ATMARK ACTION_KEY(KC_KP_ATMARK) +#define AC_KP_EXCLAMATION ACTION_KEY(KC_KP_EXCLAMATION) +#define AC_KP_MEM_STORE ACTION_KEY(KC_KP_MEM_STORE) +#define AC_KP_MEM_RECALL ACTION_KEY(KC_KP_MEM_RECALL) +#define AC_KP_MEM_CLEAR ACTION_KEY(KC_KP_MEM_CLEAR) +#define AC_KP_MEM_ADD ACTION_KEY(KC_KP_MEM_ADD) +#define AC_KP_MEM_SUB ACTION_KEY(KC_KP_MEM_SUB) +#define AC_KP_MEM_MUL ACTION_KEY(KC_KP_MEM_MUL) +#define AC_KP_MEM_DIV ACTION_KEY(KC_KP_MEM_DIV) +#define AC_KP_PLUS_MINUS ACTION_KEY(KC_KP_PLUS_MINUS) +#define AC_KP_CLEAR ACTION_KEY(KC_KP_CLEAR) +#define AC_KP_CLEAR_ENTRY ACTION_KEY(KC_KP_CLEAR_ENTRY) +#define AC_KP_BINARY ACTION_KEY(KC_KP_BINARY) +#define AC_KP_OCTAL ACTION_KEY(KC_KP_OCTAL) +#define AC_KP_DECIMAL ACTION_KEY(KC_KP_DECIMAL) +#define AC_KP_HEXADECIMAL ACTION_KEY(KC_KP_HEXADECIMAL) + +/* Modifiers */ +#define AC_LCTRL ACTION_KEY(KC_LCTRL) +#define AC_LSHIFT ACTION_KEY(KC_LSHIFT) +#define AC_LALT ACTION_KEY(KC_LALT) +#define AC_LGUI ACTION_KEY(KC_LGUI) +#define AC_RCTRL ACTION_KEY(KC_RCTRL) +#define AC_RSHIFT ACTION_KEY(KC_RSHIFT) +#define AC_RALT ACTION_KEY(KC_RALT) +#define AC_RGUI ACTION_KEY(KC_RGUI) + +/* + * TMK extensions + */ +/* Sytem Control */ +#define AC_SYSTEM_POWER ACTION_USAGE_SYSTEM(SYSTEM_POWER_DOWN) +#define AC_SYSTEM_SLEEP ACTION_USAGE_SYSTEM(SYSTEM_SLEEP) +#define AC_SYSTEM_WAKE ACTION_USAGE_SYSTEM(SYSTEM_WAKE_UP) +/* Consumer Page */ +#define AC_AUDIO_MUTE ACTION_USAGE_CONSUMER(AUDIO_MUTE) +#define AC_AUDIO_VOL_UP ACTION_USAGE_CONSUMER(AUDIO_VOL_UP) +#define AC_AUDIO_VOL_DOWN ACTION_USAGE_CONSUMER(AUDIO_VOL_DOWN) +#define AC_MEDIA_NEXT_TRACK ACTION_USAGE_CONSUMER(TRANSPORT_NEXT_TRACK) +#define AC_MEDIA_PREV_TRACK ACTION_USAGE_CONSUMER(TRANSPORT_PREV_TRACK) +#define AC_MEDIA_FAST_FORWARD ACTION_USAGE_CONSUMER(TRANSPORT_FAST_FORWARD) +#define AC_MEDIA_REWIND ACTION_USAGE_CONSUMER(TRANSPORT_REWIND) +#define AC_MEDIA_STOP ACTION_USAGE_CONSUMER(TRANSPORT_STOP) +#define AC_MEDIA_PLAY_PAUSE ACTION_USAGE_CONSUMER(TRANSPORT_PLAY_PAUSE) +#define AC_MEDIA_EJECT ACTION_USAGE_CONSUMER(TRANSPORT_STOP_EJECT) +#define AC_MEDIA_SELECT ACTION_USAGE_CONSUMER(APPLAUNCH_CC_CONFIG) +#define AC_MAIL ACTION_USAGE_CONSUMER(APPLAUNCH_EMAIL) +#define AC_CALCULATOR ACTION_USAGE_CONSUMER(APPLAUNCH_CALCULATOR) +#define AC_MY_COMPUTER ACTION_USAGE_CONSUMER(APPLAUNCH_LOCAL_BROWSER) +#define AC_WWW_SEARCH ACTION_USAGE_CONSUMER(APPCONTROL_SEARCH) +#define AC_WWW_HOME ACTION_USAGE_CONSUMER(APPCONTROL_HOME) +#define AC_WWW_BACK ACTION_USAGE_CONSUMER(APPCONTROL_BACK) +#define AC_WWW_FORWARD ACTION_USAGE_CONSUMER(APPCONTROL_FORWARD) +#define AC_WWW_STOP ACTION_USAGE_CONSUMER(APPCONTROL_STOP) +#define AC_WWW_REFRESH ACTION_USAGE_CONSUMER(APPCONTROL_REFRESH) +#define AC_WWW_FAVORITES ACTION_USAGE_CONSUMER(APPCONTROL_BOOKMARKS) +/* Jump to bootloader */ +#define AC_BOOTLOADER ACTION_KEY(KC_BOOTLOADER) +/* Fn key */ +/* +#define AC_FN0 ACTION_KEY(KC_FN0) +#define AC_FN1 ACTION_KEY(KC_FN1) +#define AC_FN2 ACTION_KEY(KC_FN2) +#define AC_FN3 ACTION_KEY(KC_FN3) +#define AC_FN4 ACTION_KEY(KC_FN4) +#define AC_FN5 ACTION_KEY(KC_FN5) +#define AC_FN6 ACTION_KEY(KC_FN6) +#define AC_FN7 ACTION_KEY(KC_FN7) +#define AC_FN8 ACTION_KEY(KC_FN8) +#define AC_FN9 ACTION_KEY(KC_FN9) +#define AC_FN10 ACTION_KEY(KC_FN10) +#define AC_FN11 ACTION_KEY(KC_FN11) +#define AC_FN12 ACTION_KEY(KC_FN12) +#define AC_FN13 ACTION_KEY(KC_FN13) +#define AC_FN14 ACTION_KEY(KC_FN14) +#define AC_FN15 ACTION_KEY(KC_FN15) +#define AC_FN16 ACTION_KEY(KC_FN16) +#define AC_FN17 ACTION_KEY(KC_FN17) +#define AC_FN18 ACTION_KEY(KC_FN18) +#define AC_FN19 ACTION_KEY(KC_FN19) +#define AC_FN20 ACTION_KEY(KC_FN20) +#define AC_FN21 ACTION_KEY(KC_FN21) +#define AC_FN22 ACTION_KEY(KC_FN22) +#define AC_FN23 ACTION_KEY(KC_FN23) +#define AC_FN24 ACTION_KEY(KC_FN24) +#define AC_FN25 ACTION_KEY(KC_FN25) +#define AC_FN26 ACTION_KEY(KC_FN26) +#define AC_FN27 ACTION_KEY(KC_FN27) +#define AC_FN28 ACTION_KEY(KC_FN28) +#define AC_FN29 ACTION_KEY(KC_FN29) +#define AC_FN30 ACTION_KEY(KC_FN30) +#define AC_FN31 ACTION_KEY(KC_FN31) +*/ +/* Mousekey */ +#define AC_MS_UP ACTION_MOUSEKEY(KC_MS_UP) +#define AC_MS_DOWN ACTION_MOUSEKEY(KC_MS_DOWN) +#define AC_MS_LEFT ACTION_MOUSEKEY(KC_MS_LEFT) +#define AC_MS_RIGHT ACTION_MOUSEKEY(KC_MS_RIGHT) +#define AC_MS_BTN1 ACTION_MOUSEKEY(KC_MS_BTN1) +#define AC_MS_BTN2 ACTION_MOUSEKEY(KC_MS_BTN2) +#define AC_MS_BTN3 ACTION_MOUSEKEY(KC_MS_BTN3) +#define AC_MS_BTN4 ACTION_MOUSEKEY(KC_MS_BTN4) +#define AC_MS_BTN5 ACTION_MOUSEKEY(KC_MS_BTN5) +#define AC_MS_WH_UP ACTION_MOUSEKEY(KC_MS_WH_UP) +#define AC_MS_WH_DOWN ACTION_MOUSEKEY(KC_MS_WH_DOWN) +#define AC_MS_WH_LEFT ACTION_MOUSEKEY(KC_MS_WH_LEFT) +#define AC_MS_WH_RIGHT ACTION_MOUSEKEY(KC_MS_WH_RIGHT) +#define AC_MS_ACCEL0 ACTION_MOUSEKEY(KC_MS_ACCEL0) +#define AC_MS_ACCEL1 ACTION_MOUSEKEY(KC_MS_ACCEL1) +#define AC_MS_ACCEL2 ACTION_MOUSEKEY(KC_MS_ACCEL2) + +/* + * Short names + */ +#define AC_LCTL ACTION_KEY(KC_LCTRL) +#define AC_RCTL ACTION_KEY(KC_RCTRL) +#define AC_LSFT ACTION_KEY(KC_LSHIFT) +#define AC_RSFT ACTION_KEY(KC_RSHIFT) +#define AC_ESC ACTION_KEY(KC_ESCAPE) +#define AC_BSPC ACTION_KEY(KC_BSPACE) +#define AC_ENT ACTION_KEY(KC_ENTER) +#define AC_DEL ACTION_KEY(KC_DELETE) +#define AC_INS ACTION_KEY(KC_INSERT) +#define AC_CAPS ACTION_KEY(KC_CAPSLOCK) +#define AC_CLCK ACTION_KEY(KC_CAPSLOCK) +#define AC_RGHT ACTION_KEY(KC_RIGHT) +#define AC_PGDN ACTION_KEY(KC_PGDOWN) +#define AC_PSCR ACTION_KEY(KC_PSCREEN) +#define AC_SLCK ACTION_KEY(KC_SCROLLLOCK) +#define AC_PAUS ACTION_KEY(KC_PAUSE) +#define AC_BRK ACTION_KEY(KC_PAUSE) +#define AC_NLCK ACTION_KEY(KC_NUMLOCK) +#define AC_SPC ACTION_KEY(KC_SPACE) +#define AC_MINS ACTION_KEY(KC_MINUS) +#define AC_EQL ACTION_KEY(KC_EQUAL) +#define AC_GRV ACTION_KEY(KC_GRAVE) +#define AC_RBRC ACTION_KEY(KC_RBRACKET) +#define AC_LBRC ACTION_KEY(KC_LBRACKET) +#define AC_COMM ACTION_KEY(KC_COMMA) +#define AC_BSLS ACTION_KEY(KC_BSLASH) +#define AC_SLSH ACTION_KEY(KC_SLASH) +#define AC_SCLN ACTION_KEY(KC_SCOLON) +#define AC_QUOT ACTION_KEY(KC_QUOTE) +#define AC_APP ACTION_KEY(KC_APPLICATION) +#define AC_NUHS ACTION_KEY(KC_NONUS_HASH) +#define AC_NUBS ACTION_KEY(KC_NONUS_BSLASH) +#define AC_LCAP ACTION_KEY(KC_LOCKING_CAPS) +#define AC_LNUM ACTION_KEY(KC_LOCKING_NUM) +#define AC_LSCR ACTION_KEY(KC_LOCKING_SCROLL) +#define AC_ERAS ACTION_KEY(KC_ALT_ERASE,) +#define AC_CLR ACTION_KEY(KC_CLEAR) +/* Japanese specific */ +#define AC_ZKHK ACTION_KEY(KC_GRAVE) +#define AC_RO ACTION_KEY(KC_INT1) +#define AC_KANA ACTION_KEY(KC_INT2) +#define AC_JYEN ACTION_KEY(KC_INT3) +#define AC_HENK ACTION_KEY(KC_INT4) +#define AC_MHEN ACTION_KEY(KC_INT5) +/* Keypad */ +#define AC_P1 ACTION_KEY(KC_KP_1) +#define AC_P2 ACTION_KEY(KC_KP_2) +#define AC_P3 ACTION_KEY(KC_KP_3) +#define AC_P4 ACTION_KEY(KC_KP_4) +#define AC_P5 ACTION_KEY(KC_KP_5) +#define AC_P6 ACTION_KEY(KC_KP_6) +#define AC_P7 ACTION_KEY(KC_KP_7) +#define AC_P8 ACTION_KEY(KC_KP_8) +#define AC_P9 ACTION_KEY(KC_KP_9) +#define AC_P0 ACTION_KEY(KC_KP_0) +#define AC_PDOT ACTION_KEY(KC_KP_DOT) +#define AC_PCMM ACTION_KEY(KC_KP_COMMA) +#define AC_PSLS ACTION_KEY(KC_KP_SLASH) +#define AC_PAST ACTION_KEY(KC_KP_ASTERISK) +#define AC_PMNS ACTION_KEY(KC_KP_MINUS) +#define AC_PPLS ACTION_KEY(KC_KP_PLUS) +#define AC_PEQL ACTION_KEY(KC_KP_EQUAL) +#define AC_PENT ACTION_KEY(KC_KP_ENTER) +/* Mousekey */ +#define AC_MS_U ACTION_MOUSEKEY(KC_MS_UP) +#define AC_MS_D ACTION_MOUSEKEY(KC_MS_DOWN) +#define AC_MS_L ACTION_MOUSEKEY(KC_MS_LEFT) +#define AC_MS_R ACTION_MOUSEKEY(KC_MS_RIGHT) +#define AC_BTN1 ACTION_MOUSEKEY(KC_MS_BTN1) +#define AC_BTN2 ACTION_MOUSEKEY(KC_MS_BTN2) +#define AC_BTN3 ACTION_MOUSEKEY(KC_MS_BTN3) +#define AC_BTN4 ACTION_MOUSEKEY(KC_MS_BTN4) +#define AC_BTN5 ACTION_MOUSEKEY(KC_MS_BTN5) +#define AC_WH_U ACTION_MOUSEKEY(KC_MS_WH_UP) +#define AC_WH_D ACTION_MOUSEKEY(KC_MS_WH_DOWN) +#define AC_WH_L ACTION_MOUSEKEY(KC_MS_WH_LEFT) +#define AC_WH_R ACTION_MOUSEKEY(KC_MS_WH_RIGHT) +#define AC_ACL0 ACTION_MOUSEKEY(KC_MS_ACCEL0) +#define AC_ACL1 ACTION_MOUSEKEY(KC_MS_ACCEL1) +#define AC_ACL2 ACTION_MOUSEKEY(KC_MS_ACCEL2) +/* Sytem Control */ +#define AC_PWR ACTION_USAGE_SYSTEM(SYSTEM_POWER_DOWN) +#define AC_SLEP ACTION_USAGE_SYSTEM(SYSTEM_SLEEP) +#define AC_WAKE ACTION_USAGE_SYSTEM(SYSTEM_WAKE_UP) +/* Consumer Page */ +#define AC_MUTE ACTION_USAGE_CONSUMER(AUDIO_MUTE) +#define AC_VOLU ACTION_USAGE_CONSUMER(AUDIO_VOL_UP) +#define AC_VOLD ACTION_USAGE_CONSUMER(AUDIO_VOL_DOWN) +#define AC_MNXT ACTION_USAGE_CONSUMER(TRANSPORT_NEXT_TRACK) +#define AC_MPRV ACTION_USAGE_CONSUMER(TRANSPORT_PREV_TRACK) +#define AC_MFFD ACTION_USAGE_CONSUMER(TRANSPORT_FAST_FORWARD) +#define AC_MRWD ACTION_USAGE_CONSUMER(TRANSPORT_REWIND) +#define AC_MSTP ACTION_USAGE_CONSUMER(TRANSPORT_STOP) +#define AC_MPLY ACTION_USAGE_CONSUMER(TRANSPORT_PLAY_PAUSE) +#define AC_EJCT ACTION_USAGE_CONSUMER(TRANSPORT_STOP_EJECT) +#define AC_MSEL ACTION_USAGE_CONSUMER(APPLAUNCH_CC_CONFIG) +#define AC_MAIL ACTION_USAGE_CONSUMER(APPLAUNCH_EMAIL) +#define AC_CALC ACTION_USAGE_CONSUMER(APPLAUNCH_CALCULATOR) +#define AC_MYCM ACTION_USAGE_CONSUMER(APPLAUNCH_LOCAL_BROWSER) +#define AC_WSCH ACTION_USAGE_CONSUMER(APPCONTROL_SEARCH) +#define AC_WHOM ACTION_USAGE_CONSUMER(APPCONTROL_HOME) +#define AC_WBAK ACTION_USAGE_CONSUMER(APPCONTROL_BACK) +#define AC_WFWD ACTION_USAGE_CONSUMER(APPCONTROL_FORWARD) +#define AC_WSTP ACTION_USAGE_CONSUMER(APPCONTROL_STOP) +#define AC_WREF ACTION_USAGE_CONSUMER(APPCONTROL_REFRESH) +#define AC_WFAV ACTION_USAGE_CONSUMER(APPCONTROL_BOOKMARKS) +/* Jump to bootloader */ +#define AC_BTLD ACTION_KEY(KC_BOOTLOADER) +/* Transparent */ +#define AC_TRNS ACTION_KEY(KC_TRANSPARENT) + +#endif diff --git a/common/bootmagic.c b/common/bootmagic.c index 08241f7d..61236bec 100644 --- a/common/bootmagic.c +++ b/common/bootmagic.c @@ -5,6 +5,7 @@ #include "bootloader.h" #include "debug.h" #include "keymap.h" +#include "actionmap.h" #include "host.h" #include "action_layer.h" #include "eeconfig.h" @@ -26,28 +27,28 @@ void bootmagic(void) print("done.\n"); /* bootmagic skip */ - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SKIP)) { + if (bootmagic_scan_key(BOOTMAGIC_KEY_SKIP)) { return; } /* eeconfig clear */ - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EEPROM_CLEAR)) { + if (bootmagic_scan_key(BOOTMAGIC_KEY_EEPROM_CLEAR)) { eeconfig_init(); } /* bootloader */ - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_BOOTLOADER)) { + if (bootmagic_scan_key(BOOTMAGIC_KEY_BOOTLOADER)) { bootloader_jump(); } /* debug enable */ debug_config.raw = eeconfig_read_debug(); - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_ENABLE)) { - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_MATRIX)) { + if (bootmagic_scan_key(BOOTMAGIC_KEY_DEBUG_ENABLE)) { + if (bootmagic_scan_key(BOOTMAGIC_KEY_DEBUG_MATRIX)) { debug_config.matrix = !debug_config.matrix; - } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_KEYBOARD)) { + } else if (bootmagic_scan_key(BOOTMAGIC_KEY_DEBUG_KEYBOARD)) { debug_config.keyboard = !debug_config.keyboard; - } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_MOUSE)) { + } else if (bootmagic_scan_key(BOOTMAGIC_KEY_DEBUG_MOUSE)) { debug_config.mouse = !debug_config.mouse; } else { debug_config.enable = !debug_config.enable; @@ -57,28 +58,28 @@ void bootmagic(void) /* keymap config */ keymap_config.raw = eeconfig_read_keymap(); - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK)) { + if (bootmagic_scan_key(BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK)) { keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock; } - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL)) { + if (bootmagic_scan_key(BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL)) { keymap_config.capslock_to_control = !keymap_config.capslock_to_control; } - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_LALT_LGUI)) { + if (bootmagic_scan_key(BOOTMAGIC_KEY_SWAP_LALT_LGUI)) { keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui; } - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_RALT_RGUI)) { + if (bootmagic_scan_key(BOOTMAGIC_KEY_SWAP_RALT_RGUI)) { keymap_config.swap_ralt_rgui = !keymap_config.swap_ralt_rgui; } - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_NO_GUI)) { + if (bootmagic_scan_key(BOOTMAGIC_KEY_NO_GUI)) { keymap_config.no_gui = !keymap_config.no_gui; } - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_GRAVE_ESC)) { + if (bootmagic_scan_key(BOOTMAGIC_KEY_SWAP_GRAVE_ESC)) { keymap_config.swap_grave_esc = !keymap_config.swap_grave_esc; } - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_BACKSLASH_BACKSPACE)) { + if (bootmagic_scan_key(BOOTMAGIC_KEY_SWAP_BACKSLASH_BACKSPACE)) { keymap_config.swap_backslash_backspace = !keymap_config.swap_backslash_backspace; } - if (bootmagic_scan_keycode(BOOTMAGIC_HOST_NKRO)) { + if (bootmagic_scan_key(BOOTMAGIC_HOST_NKRO)) { keymap_config.nkro = !keymap_config.nkro; } eeconfig_write_keymap(keymap_config.raw); @@ -89,14 +90,14 @@ void bootmagic(void) /* default layer */ uint8_t default_layer = 0; - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) { default_layer |= (1<<0); } - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_1)) { default_layer |= (1<<1); } - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_2)) { default_layer |= (1<<2); } - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_3)) { default_layer |= (1<<3); } - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_4)) { default_layer |= (1<<4); } - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_5)) { default_layer |= (1<<5); } - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_6)) { default_layer |= (1<<6); } - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) { default_layer |= (1<<7); } + if (bootmagic_scan_key(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) { default_layer |= (1<<0); } + if (bootmagic_scan_key(BOOTMAGIC_KEY_DEFAULT_LAYER_1)) { default_layer |= (1<<1); } + if (bootmagic_scan_key(BOOTMAGIC_KEY_DEFAULT_LAYER_2)) { default_layer |= (1<<2); } + if (bootmagic_scan_key(BOOTMAGIC_KEY_DEFAULT_LAYER_3)) { default_layer |= (1<<3); } + if (bootmagic_scan_key(BOOTMAGIC_KEY_DEFAULT_LAYER_4)) { default_layer |= (1<<4); } + if (bootmagic_scan_key(BOOTMAGIC_KEY_DEFAULT_LAYER_5)) { default_layer |= (1<<5); } + if (bootmagic_scan_key(BOOTMAGIC_KEY_DEFAULT_LAYER_6)) { default_layer |= (1<<6); } + if (bootmagic_scan_key(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) { default_layer |= (1<<7); } if (default_layer) { eeconfig_write_default_layer(default_layer); default_layer_set((uint32_t)default_layer); @@ -106,13 +107,22 @@ void bootmagic(void) } } -static bool scan_keycode(uint8_t keycode) +static bool scan_key(uint16_t code) { for (uint8_t r = 0; r < MATRIX_ROWS; r++) { matrix_row_t matrix_row = matrix_get_row(r); for (uint8_t c = 0; c < MATRIX_COLS; c++) { if (matrix_row & ((matrix_row_t)1<. #define KC_MRWD KC_MEDIA_REWIND #define KC_MSTP KC_MEDIA_STOP #define KC_MPLY KC_MEDIA_PLAY_PAUSE -#define KC_MSEL KC_MEDIA_SELECT #define KC_EJCT KC_MEDIA_EJECT +#define KC_MSEL KC_MEDIA_SELECT #define KC_MAIL KC_MAIL #define KC_CALC KC_CALCULATOR #define KC_MYCM KC_MY_COMPUTER @@ -420,10 +420,12 @@ enum internal_special_keycodes { KC_AUDIO_VOL_DOWN, KC_MEDIA_NEXT_TRACK, KC_MEDIA_PREV_TRACK, + KC_MEDIA_FAST_FORWARD, + KC_MEDIA_REWIND, KC_MEDIA_STOP, KC_MEDIA_PLAY_PAUSE, - KC_MEDIA_SELECT, KC_MEDIA_EJECT, + KC_MEDIA_SELECT, KC_MAIL, KC_CALCULATOR, KC_MY_COMPUTER, @@ -433,9 +435,7 @@ enum internal_special_keycodes { KC_WWW_FORWARD, KC_WWW_STOP, KC_WWW_REFRESH, - KC_WWW_FAVORITES, - KC_MEDIA_FAST_FORWARD, - KC_MEDIA_REWIND, /* 0xBC */ + KC_WWW_FAVORITES, /* 0xBC */ /* Jump to bootloader */ KC_BOOTLOADER = 0xBF, diff --git a/common/report.h b/common/report.h index 0c799eca..f21e84ee 100644 --- a/common/report.h +++ b/common/report.h @@ -46,25 +46,25 @@ along with this program. If not, see . #define TRANSPORT_STOP_EJECT 0x00CC #define TRANSPORT_PLAY_PAUSE 0x00CD /* application launch */ -#define AL_CC_CONFIG 0x0183 -#define AL_EMAIL 0x018A -#define AL_CALCULATOR 0x0192 -#define AL_LOCAL_BROWSER 0x0194 +#define APPLAUNCH_CC_CONFIG 0x0183 +#define APPLAUNCH_EMAIL 0x018A +#define APPLAUNCH_CALCULATOR 0x0192 +#define APPLAUNCH_LOCAL_BROWSER 0x0194 /* application control */ -#define AC_SEARCH 0x0221 -#define AC_HOME 0x0223 -#define AC_BACK 0x0224 -#define AC_FORWARD 0x0225 -#define AC_STOP 0x0226 -#define AC_REFRESH 0x0227 -#define AC_BOOKMARKS 0x022A +#define APPCONTROL_SEARCH 0x0221 +#define APPCONTROL_HOME 0x0223 +#define APPCONTROL_BACK 0x0224 +#define APPCONTROL_FORWARD 0x0225 +#define APPCONTROL_STOP 0x0226 +#define APPCONTROL_REFRESH 0x0227 +#define APPCONTROL_BOOKMARKS 0x022A /* supplement for Bluegiga iWRAP HID(not supported by Windows?) */ -#define AL_LOCK 0x019E +#define APPLAUNCH_LOCK 0x019E #define TRANSPORT_RECORD 0x00B2 #define TRANSPORT_FAST_FORWARD 0x00B3 #define TRANSPORT_REWIND 0x00B4 #define TRANSPORT_EJECT 0x00B8 -#define AC_MINIMIZE 0x0206 +#define APPCONTROL_MINIMIZE 0x0206 /* Generic Desktop Page(0x01) - system power control */ #define SYSTEM_POWER_DOWN 0x0081 @@ -159,27 +159,27 @@ typedef struct { /* keycode to consumer usage */ #define KEYCODE2CONSUMER(key) \ - (key == KC_AUDIO_MUTE ? AUDIO_MUTE : \ - (key == KC_AUDIO_VOL_UP ? AUDIO_VOL_UP : \ - (key == KC_AUDIO_VOL_DOWN ? AUDIO_VOL_DOWN : \ - (key == KC_MEDIA_NEXT_TRACK ? TRANSPORT_NEXT_TRACK : \ - (key == KC_MEDIA_PREV_TRACK ? TRANSPORT_PREV_TRACK : \ - (key == KC_MEDIA_FAST_FORWARD ? TRANSPORT_FAST_FORWARD : \ - (key == KC_MEDIA_REWIND ? TRANSPORT_REWIND : \ - (key == KC_MEDIA_STOP ? TRANSPORT_STOP : \ - (key == KC_MEDIA_EJECT ? TRANSPORT_STOP_EJECT : \ - (key == KC_MEDIA_PLAY_PAUSE ? TRANSPORT_PLAY_PAUSE : \ - (key == KC_MEDIA_SELECT ? AL_CC_CONFIG : \ - (key == KC_MAIL ? AL_EMAIL : \ - (key == KC_CALCULATOR ? AL_CALCULATOR : \ - (key == KC_MY_COMPUTER ? AL_LOCAL_BROWSER : \ - (key == KC_WWW_SEARCH ? AC_SEARCH : \ - (key == KC_WWW_HOME ? AC_HOME : \ - (key == KC_WWW_BACK ? AC_BACK : \ - (key == KC_WWW_FORWARD ? AC_FORWARD : \ - (key == KC_WWW_STOP ? AC_STOP : \ - (key == KC_WWW_REFRESH ? AC_REFRESH : \ - (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0))))))))))))))))))))) + (key == KC_AUDIO_MUTE ? AUDIO_MUTE : \ + (key == KC_AUDIO_VOL_UP ? AUDIO_VOL_UP : \ + (key == KC_AUDIO_VOL_DOWN ? AUDIO_VOL_DOWN : \ + (key == KC_MEDIA_NEXT_TRACK ? TRANSPORT_NEXT_TRACK : \ + (key == KC_MEDIA_PREV_TRACK ? TRANSPORT_PREV_TRACK : \ + (key == KC_MEDIA_FAST_FORWARD ? TRANSPORT_FAST_FORWARD : \ + (key == KC_MEDIA_REWIND ? TRANSPORT_REWIND : \ + (key == KC_MEDIA_STOP ? TRANSPORT_STOP : \ + (key == KC_MEDIA_EJECT ? TRANSPORT_STOP_EJECT : \ + (key == KC_MEDIA_PLAY_PAUSE ? TRANSPORT_PLAY_PAUSE : \ + (key == KC_MEDIA_SELECT ? APPLAUNCH_CC_CONFIG : \ + (key == KC_MAIL ? APPLAUNCH_EMAIL : \ + (key == KC_CALCULATOR ? APPLAUNCH_CALCULATOR : \ + (key == KC_MY_COMPUTER ? APPLAUNCH_LOCAL_BROWSER : \ + (key == KC_WWW_SEARCH ? APPCONTROL_SEARCH : \ + (key == KC_WWW_HOME ? APPCONTROL_HOME : \ + (key == KC_WWW_BACK ? APPCONTROL_BACK : \ + (key == KC_WWW_FORWARD ? APPCONTROL_FORWARD : \ + (key == KC_WWW_STOP ? APPCONTROL_STOP : \ + (key == KC_WWW_REFRESH ? APPCONTROL_REFRESH : \ + (key == KC_WWW_FAVORITES ? APPCONTROL_BOOKMARKS : 0))))))))))))))))))))) #ifdef __cplusplus } From d03a7906668ef7143030bc50bf885dd37e1ebb4f Mon Sep 17 00:00:00 2001 From: Ethan Apodaca Date: Wed, 2 Mar 2016 23:34:13 -0800 Subject: [PATCH 027/217] Mostly working. Is unstable, will emit bad codes after a while. --- protocol/xt_interrupt.c | 51 +++++++++++++---------------------------- 1 file changed, 16 insertions(+), 35 deletions(-) diff --git a/protocol/xt_interrupt.c b/protocol/xt_interrupt.c index 2a351c5b..94b47db4 100644 --- a/protocol/xt_interrupt.c +++ b/protocol/xt_interrupt.c @@ -66,47 +66,28 @@ uint8_t xt_host_recv(void) ISR(XT_INT_VECT) { - static enum { - INIT, - BIT0, BIT1, BIT2, BIT3, BIT4, BIT5, BIT6, BIT7, - STOP, - } state = INIT; + static uint8_t state = 0; static uint8_t data = 0; - // wait for clock falling edge - if(state != INIT) - wait_clock_lo(70); - switch (state) { - case INIT: - if (data_in()) - state++; - break; - case BIT0: - case BIT1: - case BIT2: - case BIT3: - case BIT4: - case BIT5: - case BIT6: - case BIT7: + if (state == 0) { + if (data_in()) state++; - data >>= 1; - if (data_in()) { - data |= 0x80; - } - break; - case STOP: - if (!data_in()) - goto DONE; - pbuf_enqueue(data); - goto DONE; - break; - default: - goto DONE; + } else if (state >= 1 && state <= 8) { + wait_clock_lo(20); + data >>= 1; + if (data_in()) + data |= 0x80; + if (state == 8) + goto END; + state++; + } else { + goto DONE; } goto RETURN; +END: + pbuf_enqueue(data); DONE: - state = INIT; + state = 0; data = 0; RETURN: return; From eac46d8344a8b420970833fc7c2340eae25e242e Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 19 Mar 2016 08:08:49 +0900 Subject: [PATCH 028/217] ps2_usb: Fix for VUSB configuration --- protocol/vusb.mk | 1 + protocol/vusb/main.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/protocol/vusb.mk b/protocol/vusb.mk index 3cba3f71..d541dd0f 100644 --- a/protocol/vusb.mk +++ b/protocol/vusb.mk @@ -10,6 +10,7 @@ SRC += $(VUSB_DIR)/main.c \ ifdef NO_UART +OPT_DEFS += -DNO_UART SRC += $(COMMON_DIR)/sendchar_null.c else SRC += $(COMMON_DIR)/sendchar_uart.c \ diff --git a/protocol/vusb/main.c b/protocol/vusb/main.c index 8e4a266e..0d809536 100644 --- a/protocol/vusb/main.c +++ b/protocol/vusb/main.c @@ -49,7 +49,7 @@ int main(void) #endif CLKPR = 0x80, CLKPR = 0; -#ifndef PS2_USE_USART +#ifndef NO_UART uart_init(UART_BAUD_RATE); #endif From b6d80e84a8932c61450a0d93167f950b84aa5910 Mon Sep 17 00:00:00 2001 From: Nick Bair Date: Sat, 26 Mar 2016 22:40:45 -0400 Subject: [PATCH 029/217] clarify layer documentation --- doc/keymap.md | 67 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/doc/keymap.md b/doc/keymap.md index 566936c6..572cf2f8 100644 --- a/doc/keymap.md +++ b/doc/keymap.md @@ -3,9 +3,9 @@ Keymap framework - how to define your keymap ***NOTE: This is not final version, may be inconsistent with source code and changed occasionally for a while.*** ## 0. Keymap and layers -**Keymap** is comprised of multiple layers of key layout, you can define **32 layers** at most. -**Layer** is an array of **keycodes** to define **actions** for each physical keys. -respective layers can be validated simultaneously. Layers are indexed with 0 to 31 and higher layer has precedence. +The **keymap** is an array composed of one or more layers. +Each **layer** is an array of **keycodes**, defining **actions** for each physical key. +Layers can be activated and deactivated independently. Multiple layers may be active at once, resulting in the currently-active **layer state**. Each layer has an index between 0-31. As active layers are stacked together, higher layers take precedence over lower layers. Keymap: 32 Layers Layer: Keycode matrix ----------------- --------------------- @@ -21,31 +21,17 @@ respective layers can be validated simultaneously. Layers are indexed with 0 to 1 /___________// | 1 `-------------------------- 0 /___________/ V low 0 `-------------------------- +**Note:** The keymap array is limited to **32 layers**. -### 0.1 Keymap status -Keymap has its state in two parameters: -**`default_layer`** indicates a base keymap layer(0-31) which is always valid and to be referred, **`keymap_stat`** is 16bit variable which has current on/off status of layers on its each bit. -Keymap layer '0' is usually `default_layer` and which is the only valid layer and other layers is initially off after boot up firmware, though, you can configured them in `config.h`. -To change `default_layer` will be useful when you switch key layout completely, say you want Colmak instead of Qwerty. +### 0.1 Layer state +The current keymap layer state is determined by two parameters: the *default layer*, and the individual *layer states*. Changing the default layer is useful for switching key layouts completely; for example, switching to Dvorak, Colemak or Workman instead of QWERTY. Individual layer states, on the other hand, can be used to overlay the base layer with other functions such as navigation keys, function keys (F1-F12), media keys or other actions. - Initial state of Keymap Change base layout - ----------------------- ------------------ - - 31 31 - 30 30 - 29 29 - : : - : : ____________ - 2 ____________ 2 / / - 1 / / ,->1 /___________/ - ,->0 /___________/ | 0 - | | - `--- default_layer = 0 `--- default_layer = 1 - layer_state = 0x00000001 layer_state = 0x00000002 +Because the default layer is really just a special case affecting the overall layer state, it is important to first understand how the layer state is determined. -On the other hand, you shall change `layer_state` to overlay base layer with some layers for feature such as navigation keys, function key(F1-F12), media keys or special actions. +#### 0.1.1 The layer state +The **layer state** indicates the current on/off status of all layers. It is defined in the firmware by a 32-bit integer, `layer_state`, which stores each layer's on/off status in a single bit: 0 for off, 1 for on. As layers are activated and deactivated, their respective bits are flipped, changing the value of `layer_state`. Overlay feature layer --------------------- bit|status @@ -62,6 +48,41 @@ On the other hand, you shall change `layer_state` to overlay base layer with som `--- default_layer = 1 | layer_state = 0x60000002 <-' +#### 0.1.2 The default layer +The **default layer** is the base keymap layer (0-31) which is always active and considered the "bottom" of the stack. When the firmware boots, the default layer is the only active layer. It is set to layer 0 by default, though this can be changed ~~in *config.h*~~ via Boot Magic settings. + + Initial state of Keymap Change base layout + ----------------------- ------------------ + + 31 31 + 30 30 + 29 29 + : : + : : ____________ + 2 ____________ 2 / / + 1 / / ,->1 /___________/ + ,->0 /___________/ | 0 + | | + `--- default_layer = 0 `--- default_layer = 1 + layer_state = 0x00000001 layer_state = 0x00000002 + +Note that the `default_layer_state` variable only determines the lowest value to which `layer_state` may be set, and that `default_layer_state` is used by the core firmware when determining the starting value of `layer_state` before applying changes. In other words, the default layer will *always* be set to *on* in `layer_state`. + +The default layer is defined in the firmware by the `default_layer_state` variable, which is identical in format to the `layer_state` variable exlpained above. The value may be changed using the following functions: + +- `default_layer_state_set(state)` sets the state to the specified 32-bit integer value. +- AND/OR/XOR functions set the state based on a boolean logic comparison between the current state and the specified 32-bit integer value: + - `default_layer_state_and(state)` + - `default_layer_state_or(state)` + - `default_layer_state_xor(state)` + +For example, to set layer 3 as the default layer: + +```C +// convert 3 to a 32-bit unsigned long value, and set the default layer +default_layer_state_set(1UL<<3); +``` + ### 0.2 Layer Precedence and Transparency From 5105d0f99423f7391694321043078981b05ada03 Mon Sep 17 00:00:00 2001 From: Nick Bair Date: Sat, 26 Mar 2016 22:51:52 -0400 Subject: [PATCH 030/217] Clarify layer precedence --- doc/keymap.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/keymap.md b/doc/keymap.md index 572cf2f8..80ea793c 100644 --- a/doc/keymap.md +++ b/doc/keymap.md @@ -86,11 +86,12 @@ default_layer_state_set(1UL<<3); ### 0.2 Layer Precedence and Transparency -Note that ***higher layer has higher priority on stack of layers***, namely firmware falls down from top layer to bottom to look up keycode. Once it spots keycode other than **`KC_TRNS`**(transparent) on a layer it stops searching and lower layers aren't referred. +Note that ***higher layers have priority in the layer stack***. The firmware starts at the topmost active layer, and works down to the bottom to find the an active keycode. Once the search encounters any keycode other than **`KC_TRNS`** (transparent) on an active layer, the search is halted and the remaining lower layers aren't examined, even if they are active. + +**Note:** a layer must be activated before it may be included in the stack search. + +`KC_TRNS` is a special placeholder which can be used on overlay layers. This allows for the creation of "partial" layers which fall back on the lower layers, eliminating a good deal of repetition in keymap files. -You can place `KC_TRNS` on overlay layer changes just part of layout to fall back on lower or base layer. -Key with `KC_TRANS` doesn't has its own keycode and refers to lower valid layers for keycode, instead. -See example below. ### 0.3 Keymap Example From 1c04b8322eb3c08f915b032647f93169a04ad807 Mon Sep 17 00:00:00 2001 From: Nick Bair Date: Sat, 26 Mar 2016 23:06:13 -0400 Subject: [PATCH 031/217] Clean up wording in keymap example --- doc/keymap.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/keymap.md b/doc/keymap.md index 80ea793c..4c9b974c 100644 --- a/doc/keymap.md +++ b/doc/keymap.md @@ -95,17 +95,17 @@ Note that ***higher layers have priority in the layer stack***. The firmware sta ### 0.3 Keymap Example -Keymap is **`keymaps[]`** C array in fact and you can define layers in it with **`KEYMAP()`** C macro and keycodes. To use complex actions you need to define `Fn` keycode in **`fn_actions[]`** array. +The keymap is defined in the **`keymaps[]`** array, a 2-dimensional array of rows and columns corresponding to positions in the keyboard matrix. But most often the layers are defined using C macros to allow for easier reading and editing of the keymap files. To use complex actions you need to define `Fn` keycodes in the **`fn_actions[]`** array. -This is a keymap example for [HHKB](http://en.wikipedia.org/wiki/Happy_Hacking_Keyboard) keyboard. -This example has three layers, 'Qwerty' as base layer, 'Cursor' and 'Mousekey'. +This is a keymap example for the [HHKB](http://en.wikipedia.org/wiki/Happy_Hacking_Keyboard) keyboard. +This example has three layers: the QWERTY base layer, and two overlay layers for cursor and mousekey control, respectively. In this example, - `Fn0` is a **momentary layer switching** key, you can use keys on Cursor layer while holding the key. + `Fn0` is a **momentary layer switching** key--you can use keys on the Cursor layer while holding the key. - `Fn1` is a momentary layer switching key with tapping feature, you can get semicolon **';'** with taping the key and switch layers while holding the key. The word **'tap'** or **'tapping'** mean to press and release a key quickly. + `Fn1` is a momentary layer switching key with tapping function--tapping the key as one would normally use it, sends the semicolon **';'** keycode, while holding the key down switches layers. - `Fn2` is a **toggle layer switch** key, you can stay switched layer after releasing the key unlike momentary switching. + `Fn2` is a **toggle layer switch** key--pressing the key toggles the layer on until you press it again. You can find other keymap definitions in file `keymap.c` located on project directories. From 42491bfc582b963eba7090fbe9a6e928d594a443 Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 29 Mar 2016 06:58:58 +0900 Subject: [PATCH 032/217] core: Fix media/consumer keys --- common/keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/keymap.c b/common/keymap.c index 134e01c2..25161748 100644 --- a/common/keymap.c +++ b/common/keymap.c @@ -142,7 +142,7 @@ static action_t keycode_to_action(uint8_t keycode) case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE: action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode)); break; - case KC_AUDIO_MUTE ... KC_MEDIA_REWIND: + case KC_AUDIO_MUTE ... KC_WWW_FAVORITES: action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode)); break; case KC_MS_UP ... KC_MS_ACCEL2: From 04c7068201e1438d1e8231961784e5cf79297dc1 Mon Sep 17 00:00:00 2001 From: esell Date: Thu, 5 May 2016 12:50:05 -0600 Subject: [PATCH 033/217] update macro names in bluefruit --- protocol/bluefruit/bluefruit.c | 38 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/protocol/bluefruit/bluefruit.c b/protocol/bluefruit/bluefruit.c index cf26b83d..7f7d0625 100644 --- a/protocol/bluefruit/bluefruit.c +++ b/protocol/bluefruit/bluefruit.c @@ -150,25 +150,25 @@ static void send_system(uint16_t data) +-------------------------------------+-------+ */ #define CONSUMER2BLUEFRUIT(usage) \ - (usage == AUDIO_MUTE ? 0x0000 : \ - (usage == AUDIO_VOL_UP ? 0x1000 : \ - (usage == AUDIO_VOL_DOWN ? 0x2000 : \ - (usage == TRANSPORT_NEXT_TRACK ? 0x0002 : \ - (usage == TRANSPORT_PREV_TRACK ? 0x0004 : \ - (usage == TRANSPORT_STOP ? 0x0010 : \ - (usage == TRANSPORT_STOP_EJECT ? 0x0000 : \ - (usage == TRANSPORT_PLAY_PAUSE ? 0x4000 : \ - (usage == AL_CC_CONFIG ? 0x0000 : \ - (usage == AL_EMAIL ? 0x0000 : \ - (usage == AL_CALCULATOR ? 0x0000 : \ - (usage == AL_LOCAL_BROWSER ? 0x0000 : \ - (usage == AC_SEARCH ? 0x0400 : \ - (usage == AC_HOME ? 0x0100 : \ - (usage == AC_BACK ? 0x0000 : \ - (usage == AC_FORWARD ? 0x0000 : \ - (usage == AC_STOP ? 0x0000 : \ - (usage == AC_REFRESH ? 0x0000 : \ - (usage == AC_BOOKMARKS ? 0x0000 : 0))))))))))))))))))) + (usage == AUDIO_MUTE ? 0x0000 : \ + (usage == AUDIO_VOL_UP ? 0x1000 : \ + (usage == AUDIO_VOL_DOWN ? 0x2000 : \ + (usage == TRANSPORT_NEXT_TRACK ? 0x0002 : \ + (usage == TRANSPORT_PREV_TRACK ? 0x0004 : \ + (usage == TRANSPORT_STOP ? 0x0010 : \ + (usage == TRANSPORT_STOP_EJECT ? 0x0000 : \ + (usage == TRANSPORT_PLAY_PAUSE ? 0x4000 : \ + (usage == APPLAUNCH_CC_CONFIG ? 0x0000 : \ + (usage == APPLAUNCH_EMAIL ? 0x0000 : \ + (usage == APPLAUNCH_CALCULATOR ? 0x0000 : \ + (usage == APPLAUNCH_LOCAL_BROWSER ? 0x0000 : \ + (usage == APPCONTROL_SEARCH ? 0x0400 : \ + (usage == APPCONTROL_HOME ? 0x0100 : \ + (usage == APPCONTROL_BACK ? 0x0000 : \ + (usage == APPCONTROL_FORWARD ? 0x0000 : \ + (usage == APPCONTROL_STOP ? 0x0000 : \ + (usage == APPCONTROL_REFRESH ? 0x0000 : \ + (usage == APPCONTROL_BOOKMARKS ? 0x0000 : 0))))))))))))))))))) static void send_consumer(uint16_t data) { From 487da43bc8cd4beef9ef4e4e0a3cdc0a75186276 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 19 May 2016 16:25:13 +0900 Subject: [PATCH 034/217] core: Add adb_host_talk() --- protocol/adb.c | 104 ++++++++++++++++++++++++------------------------- protocol/adb.h | 18 +++++++++ 2 files changed, 70 insertions(+), 52 deletions(-) diff --git a/protocol/adb.c b/protocol/adb.c index 5c6c99b4..3f4e14ba 100644 --- a/protocol/adb.c +++ b/protocol/adb.c @@ -60,7 +60,6 @@ static inline void place_bit1(void); static inline void send_byte(uint8_t data); static inline uint16_t wait_data_lo(uint16_t us); static inline uint16_t wait_data_hi(uint16_t us); -static inline uint16_t adb_host_dev_recv(uint8_t device); void adb_host_init(void) @@ -87,49 +86,9 @@ bool adb_host_psw(void) * * */ - -// ADB Bit Cells -// -// bit cell time: 70-130us -// low part of bit0: 60-70% of bit cell -// low part of bit1: 30-40% of bit cell -// -// bit cell time 70us 130us -// -------------------------------------------- -// low part of bit0 42-49 78-91 -// high part of bit0 21-28 39-52 -// low part of bit1 21-28 39-52 -// high part of bit1 42-49 78-91 -// -// -// bit0: -// 70us bit cell: -// ____________~~~~~~ -// 42-49 21-28 -// -// 130us bit cell: -// ____________~~~~~~ -// 78-91 39-52 -// -// bit1: -// 70us bit cell: -// ______~~~~~~~~~~~~ -// 21-28 42-49 -// -// 130us bit cell: -// ______~~~~~~~~~~~~ -// 39-52 78-91 -// -// [from Apple IIgs Hardware Reference Second Edition] - -enum { - ADDR_KEYB = 0x20, - ADDR_MOUSE = 0x30 -}; - uint16_t adb_host_kbd_recv(void) { - return adb_host_dev_recv(ADDR_KEYB); + return adb_host_talk(ADB_ADDR_KEYBOARD, ADB_REG_0); } #ifdef ADB_MOUSE_ENABLE @@ -139,16 +98,16 @@ void adb_mouse_init(void) { uint16_t adb_host_mouse_recv(void) { - return adb_host_dev_recv(ADDR_MOUSE); + return adb_host_talk(ADB_ADDR_MOUSE, ADB_REG_0); } #endif -static inline uint16_t adb_host_dev_recv(uint8_t device) +uint16_t adb_host_talk(uint8_t addr, uint8_t reg) { uint16_t data = 0; cli(); attention(); - send_byte(device|0x0C); // Addr:Keyboard(0010)/Mouse(0011), Cmd:Talk(11), Register0(00) + send_byte((addr<<4) | (ADB_CMD_TALK<<2) | reg); place_bit0(); // Stopbit(0) if (!wait_data_hi(500)) { // Service Request(310us Adjustable Keyboard): just ignored sei(); @@ -158,20 +117,20 @@ static inline uint16_t adb_host_dev_recv(uint8_t device) sei(); return 0; // No data to send } - + uint8_t n = 17; // start bit + 16 data bits do { uint8_t lo = (uint8_t) wait_data_hi(130); if (!lo) goto error; - + uint8_t hi = (uint8_t) wait_data_lo(lo); if (!hi) goto error; - + hi = lo - hi; lo = 130 - lo; - + data <<= 1; if (lo < hi) { data |= 1; @@ -205,7 +164,7 @@ void adb_host_listen(uint8_t cmd, uint8_t data_h, uint8_t data_l) place_bit0(); // Stopbit(0) _delay_us(200); // Tlt/Stop to Start place_bit1(); // Startbit(1) - send_byte(data_h); + send_byte(data_h); send_byte(data_l); place_bit0(); // Stopbit(0); sei(); @@ -375,7 +334,7 @@ Commands A A A A 1 1 R R Talk(read from a device) The command to read keycodes from keyboard is 0x2C which - consist of keyboard address 2 and Talk against register 0. + consist of keyboard address 2 and Talk against register 0. Address: 2: keyboard @@ -457,7 +416,7 @@ Keyboard Data(Register0) Keyboard LEDs & state of keys(Register2) This register hold current state of three LEDs and nine keys. The state of LEDs can be changed by sending Listen command. - + 1514 . . . . . . 7 6 5 . 3 2 1 0 | | | | | | | | | | | | | | | +- LED1(NumLock) | | | | | | | | | | | | | | +--- LED2(CapsLock) @@ -474,5 +433,46 @@ Keyboard LEDs & state of keys(Register2) | +----------------------------- Delete +------------------------------- Reserved +ADB Bit Cells + bit cell time: 70-130us + low part of bit0: 60-70% of bit cell + low part of bit1: 30-40% of bit cell + + bit cell time 70us 130us + -------------------------------------------- + low part of bit0 42-49 78-91 + high part of bit0 21-28 39-52 + low part of bit1 21-28 39-52 + high part of bit1 42-49 78-91 + + + bit0: + 70us bit cell: + ____________~~~~~~ + 42-49 21-28 + + 130us bit cell: + ____________~~~~~~ + 78-91 39-52 + + bit1: + 70us bit cell: + ______~~~~~~~~~~~~ + 21-28 42-49 + + 130us bit cell: + ______~~~~~~~~~~~~ + 39-52 78-91 + + [from Apple IIgs Hardware Reference Second Edition] + +Keyboard Handle ID + Apple Standard Keyboard M0116: 0x01 + Apple Extended Keyboard M0115: 0x02 + Apple Extended Keyboard II M3501: 0x02 + Apple Adjustable Keybaord: 0x10 + + http://lxr.free-electrons.com/source/drivers/macintosh/adbhid.c?v=4.4#L802 + END_OF_ADB */ diff --git a/protocol/adb.h b/protocol/adb.h index b4b3633c..d81c4a77 100644 --- a/protocol/adb.h +++ b/protocol/adb.h @@ -52,11 +52,29 @@ POSSIBILITY OF SUCH DAMAGE. #define ADB_CAPS 0x39 +/* ADB commands */ +#define ADB_ADDR_KEYBOARD 2 +#define ADB_ADDR_MOUSE 3 +#define ADB_CMD_LISTEN 2 +#define ADB_CMD_TALK 3 +#define ADB_REG_0 0 +#define ADB_REG_1 1 +#define ADB_REG_2 2 +#define ADB_REG_3 3 + +/* ADB keyboard handle id */ +#define ADB_HANDLE_M0116 0x01 +#define ADB_HANDLE_M0115 0x02 +#define ADB_HANDLE_M3501 0x02 +#define ADB_HANDLE_M1242 0x10 + + // ADB host void adb_host_init(void); bool adb_host_psw(void); uint16_t adb_host_kbd_recv(void); uint16_t adb_host_mouse_recv(void); +uint16_t adb_host_talk(uint8_t addr, uint8_t reg); void adb_host_listen(uint8_t cmd, uint8_t data_h, uint8_t data_l); void adb_host_kbd_led(uint8_t led); void adb_mouse_task(void); From a0e4eb4e26ad7a0036a7e55f82bfee45bf5578cd Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 20 May 2016 12:15:25 +0900 Subject: [PATCH 035/217] core: Add comment of register 3 of ADB --- protocol/adb.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/protocol/adb.c b/protocol/adb.c index 3f4e14ba..b9b0be98 100644 --- a/protocol/adb.c +++ b/protocol/adb.c @@ -433,6 +433,16 @@ Keyboard LEDs & state of keys(Register2) | +----------------------------- Delete +------------------------------- Reserved +Address, Handler ID and bits(Register3) + 1514131211 . . 8 7 . . . . . . 0 + | | | | | | | | | | | | | | | | + | | | | | | | | +-+-+-+-+-+-+-+- Handler ID + | | | | +-+-+-+----------------- Address + | | | +------------------------- 0 + | | +--------------------------- Service request enable(1 = enabled) + | +----------------------------- Exeptional event(alwyas 1 if not used) + +------------------------------- 0 + ADB Bit Cells bit cell time: 70-130us low part of bit0: 60-70% of bit cell From 1178192be78280a57785c2d6cdf293ca71114dca Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 4 Jun 2016 19:02:41 +0900 Subject: [PATCH 036/217] core: change API of adb.c to accept device address --- protocol/adb.c | 22 +++++++++++----------- protocol/adb.h | 26 ++++++++++++++++++-------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/protocol/adb.c b/protocol/adb.c index b9b0be98..164255ef 100644 --- a/protocol/adb.c +++ b/protocol/adb.c @@ -86,9 +86,9 @@ bool adb_host_psw(void) * * */ -uint16_t adb_host_kbd_recv(void) +uint16_t adb_host_kbd_recv(uint8_t addr) { - return adb_host_talk(ADB_ADDR_KEYBOARD, ADB_REG_0); + return adb_host_talk(addr, ADB_REG_0); } #ifdef ADB_MOUSE_ENABLE @@ -156,11 +156,11 @@ uint16_t adb_host_talk(uint8_t addr, uint8_t reg) return -n; } -void adb_host_listen(uint8_t cmd, uint8_t data_h, uint8_t data_l) +void adb_host_listen(uint8_t addr, uint8_t reg, uint8_t data_h, uint8_t data_l) { cli(); attention(); - send_byte(cmd); + send_byte((addr<<4) | (ADB_CMD_LISTEN<<2) | reg); place_bit0(); // Stopbit(0) _delay_us(200); // Tlt/Stop to Start place_bit1(); // Startbit(1) @@ -171,12 +171,12 @@ void adb_host_listen(uint8_t cmd, uint8_t data_h, uint8_t data_l) } // send state of LEDs -void adb_host_kbd_led(uint8_t led) +void adb_host_kbd_led(uint8_t addr, uint8_t led) { - // Addr:Keyboard(0010), Cmd:Listen(10), Register2(10) - // send upper byte (not used) - // send lower byte (bit2: ScrollLock, bit1: CapsLock, bit0: - adb_host_listen(0x2A,0,led&0x07); + // Listen Register2 + // upper byte: not used + // lower byte: bit2=ScrollLock, bit1=CapsLock, bit0=NumLock + adb_host_listen(addr, 2, 0, led & 0x07); } @@ -325,7 +325,7 @@ Commands bits commands ------------------------------------------------------ - - - - - 0 0 0 0 Send Request(reset all devices) + - - - - 0 0 0 0 Send Reset(reset all devices) A A A A 0 0 0 1 Flush(reset a device) - - - - 0 0 1 0 Reserved - - - - 0 0 1 1 Reserved @@ -440,7 +440,7 @@ Address, Handler ID and bits(Register3) | | | | +-+-+-+----------------- Address | | | +------------------------- 0 | | +--------------------------- Service request enable(1 = enabled) - | +----------------------------- Exeptional event(alwyas 1 if not used) + | +----------------------------- Exceptional event(alwyas 1 if not used) +------------------------------- 0 ADB Bit Cells diff --git a/protocol/adb.h b/protocol/adb.h index d81c4a77..a8b97ea5 100644 --- a/protocol/adb.h +++ b/protocol/adb.h @@ -53,30 +53,40 @@ POSSIBILITY OF SUCH DAMAGE. /* ADB commands */ +// Default Address +#define ADB_ADDR_DONGLE 1 #define ADB_ADDR_KEYBOARD 2 #define ADB_ADDR_MOUSE 3 +#define ADB_ADDR_TABLET 4 +#define ADB_ADDR_APPLIANCE 7 +// Command Type +#define ADB_CMD_RESET 0 +#define ADB_CMD_FLUSH 1 #define ADB_CMD_LISTEN 2 #define ADB_CMD_TALK 3 +// Register #define ADB_REG_0 0 #define ADB_REG_1 1 #define ADB_REG_2 2 #define ADB_REG_3 3 -/* ADB keyboard handle id */ -#define ADB_HANDLE_M0116 0x01 -#define ADB_HANDLE_M0115 0x02 -#define ADB_HANDLE_M3501 0x02 -#define ADB_HANDLE_M1242 0x10 +/* ADB keyboard handler id */ +#define ADB_HANDLER_M0116 0x01 +#define ADB_HANDLER_IIGS 0x01 +#define ADB_HANDLER_M0115 0x02 +#define ADB_HANDLER_M3501 0x02 +#define ADB_HANDLER_M1242_ANSI 0x10 +#define ADB_HANDLER_EXTENDED_PROTOCOL 0x03 // ADB host void adb_host_init(void); bool adb_host_psw(void); -uint16_t adb_host_kbd_recv(void); +uint16_t adb_host_kbd_recv(uint8_t addr); uint16_t adb_host_mouse_recv(void); uint16_t adb_host_talk(uint8_t addr, uint8_t reg); -void adb_host_listen(uint8_t cmd, uint8_t data_h, uint8_t data_l); -void adb_host_kbd_led(uint8_t led); +void adb_host_listen(uint8_t addr, uint8_t reg, uint8_t data_h, uint8_t data_l); +void adb_host_kbd_led(uint8_t addr, uint8_t led); void adb_mouse_task(void); void adb_mouse_init(void); From 66e2af12cbc458a0039408377c25183b3500d413 Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 6 Jun 2016 01:29:46 +0900 Subject: [PATCH 037/217] core: Fix LUFA report descriptor - Logical Min/Max contains signed value and needs 16 bit to indicate 255 https://github.com/jackhumbert/qmk_firmware/issues/312 --- protocol/lufa/descriptor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/protocol/lufa/descriptor.c b/protocol/lufa/descriptor.c index c13a81bd..61afb89a 100644 --- a/protocol/lufa/descriptor.c +++ b/protocol/lufa/descriptor.c @@ -73,10 +73,10 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = HID_RI_OUTPUT(8, HID_IOF_CONSTANT), HID_RI_USAGE_PAGE(8, 0x07), /* Keyboard */ - HID_RI_USAGE_MINIMUM(8, 0x00), /* Reserved (no event indicated) */ - HID_RI_USAGE_MAXIMUM(8, 0xFF), /* Keyboard Application */ + HID_RI_USAGE_MINIMUM(8, 0x00), + HID_RI_USAGE_MAXIMUM(8, 0xFF), /* Usage ID 0x00-0xFF */ HID_RI_LOGICAL_MINIMUM(8, 0x00), - HID_RI_LOGICAL_MAXIMUM(8, 0xFF), + HID_RI_LOGICAL_MAXIMUM(16, 0x00FF), /* needs 16 bit to indicate positive value */ HID_RI_REPORT_COUNT(8, 0x06), HID_RI_REPORT_SIZE(8, 0x08), HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), From 0763a414fb89ad928b0f00a3367680b47eb570f9 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 8 Jun 2016 05:17:47 +0900 Subject: [PATCH 038/217] core: Fix Logical Maximum in report descriptor --- protocol/chibios/usb_main.c | 4 ++-- protocol/lufa/descriptor.c | 4 ++-- protocol/mbed/HIDKeyboard.cpp | 2 +- protocol/pjrc/usb.c | 4 ++-- protocol/vusb/vusb.c | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/protocol/chibios/usb_main.c b/protocol/chibios/usb_main.c index 106ce087..fbf0ceba 100644 --- a/protocol/chibios/usb_main.c +++ b/protocol/chibios/usb_main.c @@ -153,7 +153,7 @@ static const uint8_t keyboard_hid_report_desc_data[] = { 0x95, KBD_REPORT_KEYS, // Report Count (), 0x75, 0x08, // Report Size (8), 0x15, 0x00, // Logical Minimum (0), - 0x25, 0xFF, // Logical Maximum(255), + 0x26, 0xFF, 0x00, // Logical Maximum(255), 0x05, 0x07, // Usage Page (Key Codes), 0x19, 0x00, // Usage Minimum (0), 0x29, 0xFF, // Usage Maximum (255), @@ -299,7 +299,7 @@ static const uint8_t extra_hid_report_desc_data[] = { 0xa1, 0x01, // COLLECTION (Application) 0x85, REPORT_ID_SYSTEM, // REPORT_ID (2) 0x15, 0x01, // LOGICAL_MINIMUM (0x1) - 0x25, 0xb7, // LOGICAL_MAXIMUM (0xb7) + 0x26, 0xb7, 0x00, // LOGICAL_MAXIMUM (0xb7) 0x19, 0x01, // USAGE_MINIMUM (0x1) 0x29, 0xb7, // USAGE_MAXIMUM (0xb7) 0x75, 0x10, // REPORT_SIZE (16) diff --git a/protocol/lufa/descriptor.c b/protocol/lufa/descriptor.c index 61afb89a..6c2cacb5 100644 --- a/protocol/lufa/descriptor.c +++ b/protocol/lufa/descriptor.c @@ -172,13 +172,13 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = HID_RI_COLLECTION(8, 0x01), /* Application */ HID_RI_USAGE(8, 0x75), /* Vendor Usage 0x75 */ HID_RI_LOGICAL_MINIMUM(8, 0x00), - HID_RI_LOGICAL_MAXIMUM(8, 0xFF), + HID_RI_LOGICAL_MAXIMUM(16, 0x00FF), HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE), HID_RI_REPORT_SIZE(8, 0x08), HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), HID_RI_USAGE(8, 0x76), /* Vendor Usage 0x76 */ HID_RI_LOGICAL_MINIMUM(8, 0x00), - HID_RI_LOGICAL_MAXIMUM(8, 0xFF), + HID_RI_LOGICAL_MAXIMUM(16, 0x00FF), HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE), HID_RI_REPORT_SIZE(8, 0x08), HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), diff --git a/protocol/mbed/HIDKeyboard.cpp b/protocol/mbed/HIDKeyboard.cpp index 947077cd..cc2250ec 100644 --- a/protocol/mbed/HIDKeyboard.cpp +++ b/protocol/mbed/HIDKeyboard.cpp @@ -97,7 +97,7 @@ uint8_t * HIDKeyboard::reportDesc() { REPORT_COUNT(1), 0x06, REPORT_SIZE(1), 0x08, LOGICAL_MINIMUM(1), 0x00, - LOGICAL_MAXIMUM(1), 0xFF, + LOGICAL_MAXIMUM(2), 0xFF, 0x00, USAGE_PAGE(1), 0x07, // Key Codes USAGE_MINIMUM(1), 0x00, USAGE_MAXIMUM(1), 0xFF, diff --git a/protocol/pjrc/usb.c b/protocol/pjrc/usb.c index 1e6ba871..9f9c4e1b 100644 --- a/protocol/pjrc/usb.c +++ b/protocol/pjrc/usb.c @@ -184,7 +184,7 @@ static const uint8_t PROGMEM keyboard_hid_report_desc[] = { 0x95, KBD_REPORT_KEYS, // Report Count (), 0x75, 0x08, // Report Size (8), 0x15, 0x00, // Logical Minimum (0), - 0x25, 0xFF, // Logical Maximum(255), + 0x26, 0xFF, 0x00, // Logical Maximum(255), 0x05, 0x07, // Usage Page (Key Codes), 0x19, 0x00, // Usage Minimum (0), 0x29, 0xFF, // Usage Maximum (255), @@ -307,7 +307,7 @@ static const uint8_t PROGMEM extra_hid_report_desc[] = { 0xa1, 0x01, // COLLECTION (Application) 0x85, REPORT_ID_SYSTEM, // REPORT_ID (2) 0x15, 0x01, // LOGICAL_MINIMUM (0x1) - 0x25, 0xb7, // LOGICAL_MAXIMUM (0xb7) + 0x26, 0xb7, 0x00, // LOGICAL_MAXIMUM (0xb7) 0x19, 0x01, // USAGE_MINIMUM (0x1) 0x29, 0xb7, // USAGE_MAXIMUM (0xb7) 0x75, 0x10, // REPORT_SIZE (16) diff --git a/protocol/vusb/vusb.c b/protocol/vusb/vusb.c index 7d0292ed..5d00165c 100644 --- a/protocol/vusb/vusb.c +++ b/protocol/vusb/vusb.c @@ -266,7 +266,7 @@ const PROGMEM uchar keyboard_hid_report[] = { 0x95, 0x06, // Report Count (6), 0x75, 0x08, // Report Size (8), 0x15, 0x00, // Logical Minimum (0), - 0x25, 0xFF, // Logical Maximum(255), + 0x26, 0xFF, 0x00, // Logical Maximum(255), 0x05, 0x07, // Usage Page (Key Codes), 0x19, 0x00, // Usage Minimum (0), 0x29, 0xFF, // Usage Maximum (255), @@ -336,7 +336,7 @@ const PROGMEM uchar mouse_hid_report[] = { 0xa1, 0x01, // COLLECTION (Application) 0x85, REPORT_ID_SYSTEM, // REPORT_ID (2) 0x15, 0x01, // LOGICAL_MINIMUM (0x1) - 0x25, 0xb7, // LOGICAL_MAXIMUM (0xb7) + 0x26, 0xb7, 0x00, // LOGICAL_MAXIMUM (0xb7) 0x19, 0x01, // USAGE_MINIMUM (0x1) 0x29, 0xb7, // USAGE_MAXIMUM (0xb7) 0x75, 0x10, // REPORT_SIZE (16) From 20ff65663670ffb0ad8d083222fc67c7fd0d6c6a Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 21 Jun 2016 13:49:06 +0900 Subject: [PATCH 039/217] usb_usb: Add multiple keyboard support it supports four keyboards and two cascaded hubs --- common/util.h | 8 ++++++++ protocol/usb_hid/parser.cpp | 24 ++++-------------------- protocol/usb_hid/parser.h | 5 ++++- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/common/util.h b/common/util.h index 7451cc08..3e01a93d 100644 --- a/common/util.h +++ b/common/util.h @@ -28,6 +28,10 @@ along with this program. If not, see . #define XSTR(s) #s +#ifdef __cplusplus +extern "C" { +#endif + uint8_t bitpop(uint8_t bits); uint8_t bitpop16(uint16_t bits); uint8_t bitpop32(uint32_t bits); @@ -40,4 +44,8 @@ uint8_t bitrev(uint8_t bits); uint16_t bitrev16(uint16_t bits); uint32_t bitrev32(uint32_t bits); +#ifdef __cplusplus +} +#endif + #endif diff --git a/protocol/usb_hid/parser.cpp b/protocol/usb_hid/parser.cpp index fe002c0d..94e747ca 100644 --- a/protocol/usb_hid/parser.cpp +++ b/protocol/usb_hid/parser.cpp @@ -4,30 +4,14 @@ #include "debug.h" -report_keyboard_t usb_hid_keyboard_report; -uint16_t usb_hid_time_stamp; - - void KBDReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) { - bool is_error = false; - report_keyboard_t *report = (report_keyboard_t *)buf; + ::memcpy(&report, buf, sizeof(report_keyboard_t)); + time_stamp = millis(); - dprintf("keyboard input: %02X %02X", report->mods, report->reserved); + dprintf("input %d: %02X %02X", hid->GetAddress(), report.mods, report.reserved); for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { - if (IS_ERROR(report->keys[i])) { - is_error = true; - } - dprintf(" %02X", report->keys[i]); + dprintf(" %02X", report.keys[i]); } dprint("\r\n"); - - // ignore error and not send report to computer - if (is_error) { - dprint("Error usage! \r\n"); - return; - } - - ::memcpy(&usb_hid_keyboard_report, buf, sizeof(report_keyboard_t)); - usb_hid_time_stamp = millis(); } diff --git a/protocol/usb_hid/parser.h b/protocol/usb_hid/parser.h index 703eb1ed..036281fa 100644 --- a/protocol/usb_hid/parser.h +++ b/protocol/usb_hid/parser.h @@ -2,11 +2,14 @@ #define PARSER_H #include "hid.h" +#include "report.h" class KBDReportParser : public HIDReportParser { public: - virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); + report_keyboard_t report; + uint16_t time_stamp; + virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); }; #endif From 2722a92c28d62b0e4561008245c28dedafe5d56a Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 15 Jun 2016 11:01:29 +0900 Subject: [PATCH 040/217] core: Fix USB remote wakeup on ATmega32U2 #361 --- protocol/lufa.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/protocol/lufa.mk b/protocol/lufa.mk index 87386be9..d239585b 100644 --- a/protocol/lufa.mk +++ b/protocol/lufa.mk @@ -37,6 +37,10 @@ LUFA_OPTS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABL #LUFA_OPTS += -DINTERRUPT_CONTROL_ENDPOINT LUFA_OPTS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 LUFA_OPTS += -DFIXED_NUM_CONFIGURATIONS=1 +# Remote wakeup fix for ATmega32U2 https://github.com/tmk/tmk_keyboard/issues/361 +ifeq ($(MCU),atmega32u2) + LUFA_OPTS += -DNO_LIMITED_CONTROLLER_CONNECT +endif OPT_DEFS += -DF_USB=$(F_USB)UL OPT_DEFS += -DARCH=ARCH_$(ARCH) From 0968fb109271207604661f9f1f30f07e58177da3 Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 31 Jul 2016 02:00:26 +0900 Subject: [PATCH 041/217] core: Fix keycode.txt --- doc/keycode.txt | 52 +++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/doc/keycode.txt b/doc/keycode.txt index 44d7e27c..1712929c 100644 --- a/doc/keycode.txt +++ b/doc/keycode.txt @@ -1,7 +1,7 @@ Keycode Symbol Table ==================== Keycodes are defined in `common/keycode.h`. -Range of 00-A4 and E0-E7 are identical with HID Usage: +Range of 00-A4 and E0-E7 are identical with HID Usage of Keyboard/Keypad Page(0x07): Virtual keycodes are defined out of above range to support special actions. @@ -186,30 +186,35 @@ KC_RGUI E7 Keyboard Right GUI(Windows/Apple/Meta key /* * Virtual keycodes */ -/* System Control */ +/* Generic Desktop Page(0x01) - System Control */ KC_SYSTEM_POWER KC_PWR System Power Down KC_SYSTEM_SLEEP KC_SLEP System Sleep KC_SYSTEM_WAKE KC_WAKE System Wake -/* Consumer Page */ -KC_AUDIO_MUTE KC_MUTE -KC_AUDIO_VOL_UP KC_VOLU -KC_AUDIO_VOL_DOWN KC_VOLD -KC_MEDIA_NEXT_TRACK KC_MNXT -KC_MEDIA_PREV_TRACK KC_MPRV -KC_MEDIA_STOP KC_MSTP -KC_MEDIA_PLAY_PAUSE KC_MPLY -KC_MEDIA_SELECT KC_MSEL -KC_MAIL KC_MAIL -KC_CALCULATOR KC_CALC -KC_MY_COMPUTER KC_MYCM -KC_WWW_SEARCH KC_WSCH -KC_WWW_HOME KC_WHOM -KC_WWW_BACK KC_WBAK -KC_WWW_FORWARD KC_WFWD -KC_WWW_STOP KC_WSTP -KC_WWW_REFRESH KC_WREF -KC_WWW_FAVORITES KC_WFAV -/* Mousekey */ + +/* Consumer Page(0x07) */ +KC_AUDIO_MUTE KC_MUTE Mute +KC_AUDIO_VOL_UP KC_VOLU Volume Increment +KC_AUDIO_VOL_DOWN KC_VOLD Volume Decrement +KC_MEDIA_NEXT_TRACK KC_MNXT Scan Next Track +KC_MEDIA_PREV_TRACK KC_MPRV Scan Previous Track +KC_MEDIA_STOP KC_MSTP Stop +KC_MEDIA_FAST_FORWARD KC_MFFD Fast Forward +KC_MEDIA_REWIND KC_MRWD Rewind +KC_MEDIA_PLAY_PAUSE KC_MPLY Play/Pause +KC_EJCT KC_MEDIA_EJECT Stop/Eject +KC_MEDIA_SELECT KC_MSEL AL Consumer Control Configuration +KC_MAIL KC_MAIL AL Email Reader +KC_CALCULATOR KC_CALC AL Calculator +KC_MY_COMPUTER KC_MYCM AL Local Machine Browser +KC_WWW_SEARCH KC_WSCH AC Search +KC_WWW_HOME KC_WHOM AC Home +KC_WWW_BACK KC_WBAK AC Back +KC_WWW_FORWARD KC_WFWD AC Forward +KC_WWW_STOP KC_WSTP AC Stop +KC_WWW_REFRESH KC_WREF AC Refresh +KC_WWW_FAVORITES KC_WFAV AC Bookmarks + +/* Mousekey - TMK specific */ KC_MS_UP KC_MS_U Mouse Cursor Up KC_MS_DOWN KC_MS_D Mouse Cursor Down KC_MS_LEFT KC_MS_L Mouse Cursor Left @@ -226,7 +231,8 @@ KC_MS_WH_RIGHT KC_WH_R Mouse Wheel Right KC_MS_ACCEL0 KC_ACL0 Mouse Acceleration 0 KC_MS_ACCEL1 KC_ACL1 Mouse Acceleration 1 KC_MS_ACCEL2 KC_ACL2 Mouse Acceleration 2 -/* Fn key */ + +/* Fn key - TMK specific */ KC_FN0 KC_FN1 KC_FN2 From 106f4bce80a84bfee23ae8bdd323523d347e4c61 Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 8 Aug 2016 13:35:11 +0900 Subject: [PATCH 042/217] core: Change chibios repo directory names --- protocol/chibios/README.md | 8 ++++---- tool/chibios/chibios.mk | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/protocol/chibios/README.md b/protocol/chibios/README.md index 63e6641f..2fadc799 100644 --- a/protocol/chibios/README.md +++ b/protocol/chibios/README.md @@ -1,16 +1,16 @@ ## TMK running on top of ChibiOS -This code can be used to run TMK keyboard logic on top of [ChibiOS], meaning that you can run TMK on whatever [ChibiOS] supports. The notable examples are ARM-based Teensies (3.x and LC) and on the boards with STM32 MCUs. +This code can be used to run TMK keyboard logic on top of [ChibiOS], meaning that you can run TMK on whatever ChibiOS supports. The notable examples are PJRC Teensies(3.x and LC) with NXP Kinetis and dev boards with ST Micro STM32 MCUs. ### Usage -- To use, [get a zip of chibios](https://github.com/ChibiOS/ChibiOS/archive/a7df9a891067621e8e1a5c2a2c0ceada82403afe.zip) and unpack/rename it to `tmk_core/tool/chibios/chibios`; or you can just clone [the repo](https://github.com/ChibiOS/ChibiOS) there. For Freescale/NXP Kinetis support (meaning ARM Teensies and the Infinity keyboard), you'll also need [a zip of chibios-contrib](https://github.com/ChibiOS/ChibiOS-Contrib/archive/e1311c4db6cd366cf760673f769e925741ac0ad3.zip), unpacked/renamed to `tmk_core/tool/chibios/chibios-contrib`. Likewise, for git-savvy people, just clone [the repo](https://github.com/ChibiOS/ChibiOS-Contrib) there. -- Note: the abovementioned directories are the defaults. You can have the two chibios repositories wherever you want, just define their location in `CHIBIOS` and `CHIBIOS_CONTRIB` variables in your `Makefile`. +- To use, get a [zip file](https://github.com/ChibiOS/ChibiOS/archive/a7df9a891067621e8e1a5c2a2c0ceada82403afe.zip) of ChibiOS and unpack/rename it to `tmk_core/tool/chibios/ChibiOS`; or you can just clone [ChibiOS repo](https://github.com/ChibiOS/ChibiOS) there. For Freescale/NXP Kinetis support (meaning Teensies 3.x/LC and the Infinity keyboard), you'll also need a [zip](https://github.com/ChibiOS/ChibiOS-Contrib/archive/e1311c4db6cd366cf760673f769e925741ac0ad3.zip) of ChibiOS-Contrib, unpacked/renamed to `tmk_core/tool/chibios/ChibiOS-Contrib`. Likewise, for git-savvy people, just clone [ChibiOS-Contrib repo](https://github.com/ChibiOS/ChibiOS-Contrib) there. +- Note: the above mentioned directories are the defaults. You can have the two ChibiOS repositories wherever you want, just define their location in `CHIBIOS` and `CHIBIOS_CONTRIB` variables in your `Makefile`. - You will also need to install an ARM toolchain, for instance from [here](https://launchpad.net/gcc-arm-embedded). On linux, this is usually also present as a package for your distribution (as `gcc-arm` or something similar). On OS X, you can use [homebrew](http://brew.sh/) with an appropriate tap. ### Notes -- Some comments about ChibiOS syntax and the most commonly used GPIO functions are, as well as an example for ARM Teensies, is [here](https://github.com/tmk/tmk_keyboard/blob/master/keyboard/teensy_lc_onekey/instructions.md). +- Some comments about ChibiOS syntax and the most commonly used GPIO functions are, as well as an example for Teensies, is [here](https://github.com/tmk/tmk_keyboard/blob/master/keyboard/teensy_lc_onekey/instructions.md). - For gcc options, inspect `tmk_core/tool/chibios/chibios.mk`. For instance, I enabled `-Wno-missing-field-initializers`, because TMK common bits generated a lot of warnings on that. - For debugging, it is sometimes useful disable gcc optimisations, you can do that by adding `-O0` to `OPT_DEFS` in your `Makefile`. - USB string descriptors are messy. I did not find a way to cleanly generate the right structures from actual strings, so the definitions in individual keyboards' `config.h` are ugly as heck. diff --git a/tool/chibios/chibios.mk b/tool/chibios/chibios.mk index f2fedd22..88ba94ae 100644 --- a/tool/chibios/chibios.mk +++ b/tool/chibios/chibios.mk @@ -83,8 +83,8 @@ endif # # Imported source files and paths -CHIBIOS ?= $(TMK_DIR)/tool/chibios/chibios -CHIBIOS_CONTRIB ?= $(TMK_DIR)/tool/chibios/chibios-contrib +CHIBIOS ?= $(TMK_DIR)/tool/chibios/ChibiOS +CHIBIOS_CONTRIB ?= $(TMK_DIR)/tool/chibios/ChibiOS-Contrib # Startup files. Try a few different locations, for compability with old versions and # for things hardware in the contrib repository STARTUP_MK = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk From c37219549c99e591250893f0449d0798fa0c8c75 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 30 Mar 2016 03:37:57 +0900 Subject: [PATCH 043/217] core: action codes are action_t struct now --- common/action_code.h | 6 +++--- common/action_layer.c | 4 ++-- common/actionmap.h | 2 +- common/keymap.c | 32 +++++++++++++++----------------- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/common/action_code.h b/common/action_code.h index b39c6441..8dad38b9 100644 --- a/common/action_code.h +++ b/common/action_code.h @@ -181,9 +181,9 @@ typedef union { /* action utility */ -#define ACTION_NO 0 -#define ACTION_TRANSPARENT 1 -#define ACTION(kind, param) ((kind)<<12 | (param)) +#define ACTION_NO { .code = 0 } +#define ACTION_TRANSPARENT { .code = 1 } +#define ACTION(kind, param) { .code = ((kind)<<12 | (param)) } /* diff --git a/common/action_layer.c b/common/action_layer.c index 95909cc2..6b5a7fd2 100644 --- a/common/action_layer.c +++ b/common/action_layer.c @@ -117,7 +117,7 @@ void layer_debug(void) action_t layer_switch_get_action(keypos_t key) { - action_t action = { .code = ACTION_TRANSPARENT }; + action_t action = ACTION_TRANSPARENT; #ifndef NO_ACTION_LAYER uint32_t layers = layer_state | default_layer_state; @@ -125,7 +125,7 @@ action_t layer_switch_get_action(keypos_t key) for (int8_t i = 31; i >= 0; i--) { if (layers & (1UL<. /* Keymapping with 16bit action codes */ -extern const uint16_t actionmaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const action_t actionmaps[][MATRIX_ROWS][MATRIX_COLS]; /* Modified key */ diff --git a/common/keymap.c b/common/keymap.c index 25161748..b37bade8 100644 --- a/common/keymap.c +++ b/common/keymap.c @@ -53,7 +53,7 @@ action_t action_for_key(uint8_t layer, keypos_t key) case KC_LALT: if (keymap_config.swap_lalt_lgui) { if (keymap_config.no_gui) { - return keycode_to_action(ACTION_NO); + return keycode_to_action(KC_NO); } return keycode_to_action(KC_LGUI); } @@ -63,13 +63,13 @@ action_t action_for_key(uint8_t layer, keypos_t key) return keycode_to_action(KC_LALT); } if (keymap_config.no_gui) { - return keycode_to_action(ACTION_NO); + return keycode_to_action(KC_NO); } return keycode_to_action(KC_LGUI); case KC_RALT: if (keymap_config.swap_ralt_rgui) { if (keymap_config.no_gui) { - return keycode_to_action(ACTION_NO); + return keycode_to_action(KC_NO); } return keycode_to_action(KC_RGUI); } @@ -79,7 +79,7 @@ action_t action_for_key(uint8_t layer, keypos_t key) return keycode_to_action(KC_RALT); } if (keymap_config.no_gui) { - return keycode_to_action(ACTION_NO); + return keycode_to_action(KC_NO); } return keycode_to_action(KC_RGUI); case KC_GRAVE: @@ -133,23 +133,22 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) /* translates keycode to action */ static action_t keycode_to_action(uint8_t keycode) { - action_t action = {}; switch (keycode) { case KC_A ... KC_EXSEL: case KC_LCTRL ... KC_RGUI: - action.code = ACTION_KEY(keycode); + return (action_t)ACTION_KEY(keycode); break; case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE: - action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode)); + return (action_t)ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode)); break; case KC_AUDIO_MUTE ... KC_WWW_FAVORITES: - action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode)); + return (action_t)ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode)); break; case KC_MS_UP ... KC_MS_ACCEL2: - action.code = ACTION_MOUSEKEY(keycode); + return (action_t)ACTION_MOUSEKEY(keycode); break; case KC_TRNS: - action.code = ACTION_TRANSPARENT; + return (action_t)ACTION_TRANSPARENT; break; case KC_BOOTLOADER: clear_keyboard(); @@ -157,10 +156,10 @@ static action_t keycode_to_action(uint8_t keycode) bootloader_jump(); // not return break; default: - action.code = ACTION_NO; + return (action_t)ACTION_NO; break; } - return action; + return (action_t)ACTION_NO; } @@ -181,21 +180,20 @@ uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) __attribute__ ((weak)) action_t keymap_fn_to_action(uint8_t keycode) { - action_t action = { .code = ACTION_NO }; switch (keycode) { case KC_FN0 ... KC_FN31: { uint8_t layer = keymap_fn_layer(FN_INDEX(keycode)); uint8_t key = keymap_fn_keycode(FN_INDEX(keycode)); if (key) { - action.code = ACTION_LAYER_TAP_KEY(layer, key); + return (action_t)ACTION_LAYER_TAP_KEY(layer, key); } else { - action.code = ACTION_LAYER_MOMENTARY(layer); + return (action_t)ACTION_LAYER_MOMENTARY(layer); } } - return action; + return (action_t)ACTION_NO; default: - return action; + return (action_t)ACTION_NO; } } #endif From 85d104830c606abeba21437ed3e9e8e9402abefb Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 25 Jun 2016 23:10:31 +0900 Subject: [PATCH 044/217] core: Add default implemenation of keymap read --- common/keymap.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/common/keymap.c b/common/keymap.c index b37bade8..01c6e642 100644 --- a/common/keymap.c +++ b/common/keymap.c @@ -1,5 +1,5 @@ /* -Copyright 2013 Jun Wako +Copyright 2013,2016 Jun Wako This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,6 +23,9 @@ along with this program. If not, see . #include "wait.h" #include "debug.h" #include "bootloader.h" +#if defined(__AVR__) +#include +#endif #ifdef BOOTMAGIC_ENABLE extern keymap_config_t keymap_config; @@ -32,6 +35,7 @@ static action_t keycode_to_action(uint8_t keycode); /* converts key to action */ +__attribute__ ((weak)) action_t action_for_key(uint8_t layer, keypos_t key) { uint8_t keycode = keymap_key_to_keycode(layer, key); @@ -169,6 +173,28 @@ static action_t keycode_to_action(uint8_t keycode) * Legacy keymap support * Consider using new keymap API instead. */ +extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const uint8_t fn_layer[]; +extern const uint8_t fn_keycode[]; + +__attribute__ ((weak)) +uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col) +{ + return pgm_read_byte(&keymaps[(layer)][(row)][(col)]); +} + +__attribute__ ((weak)) +uint8_t keymap_fn_layer(uint8_t index) +{ + return pgm_read_byte(&fn_layer[index]); +} + +__attribute__ ((weak)) +uint8_t keymap_fn_keycode(uint8_t index) +{ + return pgm_read_byte(&fn_keycode[index]); +} + __attribute__ ((weak)) uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) { @@ -196,4 +222,31 @@ action_t keymap_fn_to_action(uint8_t keycode) return (action_t)ACTION_NO; } } + +#else + +/* user keymaps should be defined somewhere */ +extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const action_t fn_actions[]; + +__attribute__ ((weak)) +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ +#if defined(__AVR__) + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); +#else + return keymaps[(layer)][(key.row)][(key.col)]; +#endif +} + +__attribute__ ((weak)) +action_t keymap_fn_to_action(uint8_t keycode) +{ +#if defined(__AVR__) + return (action_t)pgm_read_word(&fn_actions[FN_INDEX(keycode)]); +#else + return fn_actions[FN_INDEX(keycode)]; +#endif +} + #endif From a56a5808335b2b078868023e2d5fe58026111912 Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 26 Jun 2016 14:23:28 +0900 Subject: [PATCH 045/217] core: Fix doc/keymap.md for new keymap framework --- README.md | 3 +++ doc/keymap.md | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f460d0ed..c9c2eda4 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,9 @@ Source code is available here: Updates ------- +#### 2016/06/26 +Keymap framework was updated. `fn_actions[]` should be defined as `action_t` instead of `uint16_t`. And default code for keymap handling is now included in core you just need define `uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]` and `action_t fn_actions[]`. + #### 2016/02/10 flabbergast's Chibios protocol was merged from . See [protocol/chibios/README.md](protocol/chibios/README.md). Chibios protocol supports Cortex-M such as STM32 and Kinetis. diff --git a/doc/keymap.md b/doc/keymap.md index 3a196a2d..df5d6de1 100644 --- a/doc/keymap.md +++ b/doc/keymap.md @@ -95,7 +95,7 @@ Note that ***higher layers have priority in the layer stack***. The firmware sta ### 0.3 Keymap Example -The keymap is defined in the **`keymaps[]`** array, a 2-dimensional array of rows and columns corresponding to positions in the keyboard matrix. But most often the layers are defined using C macros to allow for easier reading and editing of the keymap files. To use complex actions you need to define `Fn` keycodes in the **`fn_actions[]`** array. +The keymap is defined in the **`uint8_t keymaps[]`** array, a 2-dimensional array of rows and columns corresponding to positions in the keyboard matrix. But most often the layers are defined using C macros to allow for easier reading and editing of the keymap files. To use complex actions you need to define `Fn` action in the **`action_t fn_actions[]`** array. This is a keymap example for the [HHKB](http://en.wikipedia.org/wiki/Happy_Hacking_Keyboard) keyboard. This example has three layers: the QWERTY base layer, and two overlay layers for cursor and mousekey control, respectively. @@ -109,7 +109,7 @@ In this example, You can find other keymap definitions in file `keymap.c` located on project directories. - static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* 0: Qwerty * ,-----------------------------------------------------------. * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `| @@ -167,7 +167,7 @@ You can find other keymap definitions in file `keymap.c` located on project dire LGUI,LALT, BTN1, RALT,TRNS), }; - static const uint16_t PROGMEM fn_actions[] = { + const action_t PROGMEM fn_actions[] = { ACTION_LAYER_MOMENTARY(1), // FN0 ACTION_LAYER_TAP_KEY(2, KC_SCLN), // FN1 ACTION_LAYER_TOGGLE(2), // FN2 @@ -214,7 +214,7 @@ There are 8 modifiers which has discrimination between left and right. - `KC_WSCH`, `KC_WHOM`, `KC_WBAK`, `KC_WFWD`, `KC_WSTP`, `KC_WREF`, `KC_WFAV` for web browser operation ### 1.5 Fn key -`KC_FNnn` are keycodes for `Fn` key which not given any actions at the beginning unlike most of keycodes has its own inborn action. To use these keycodes in `KEYMAP()` you need to assign action you want at first. Action of `Fn` key is defined in `fn_actions[]` and its index of the array is identical with number part of `KC_FNnn`. Thus `KC_FN0` keycode indicates the action defined in first element of the array. ***32 `Fn` keys can be defined at most.*** +`KC_FNnn` are keycodes for `Fn` key which not given any actions at the beginning unlike most of keycodes has its own inborn action. To use these keycodes in `KEYMAP()` you need to assign action you want at first. Action of `Fn` key is defined in `action_t fn_actions[]` and its index of the array is identical with number part of `KC_FNnn`. Thus `KC_FN0` keycode indicates the action defined in first element of the array. ***32 `Fn` keys can be defined at most.*** ### 1.6 Keycode Table See keycode table in [`doc/keycode.txt`](./keycode.txt) for description of keycodes. @@ -443,7 +443,7 @@ To define tappable `Function` action in keymap use this. #### 2.4.3 Implement user function `Function` actions can be defined freely with C by user in callback function: - void keymap_call_function(keyrecord_t *event, uint8_t id, uint8_t opt) + void action_function(keyrecord_t *record, uint8_t id, uint8_t opt); This C function is called every time key is operated, argument `id` selects action to be performed and `opt` can be used for option. Function `id` can be 0-255 and `opt` can be 0-15. @@ -598,13 +598,13 @@ Legacy Keymap uses two arrays `fn_layer[]` and `fn_keycode[]` to define Fn key. In following setting example, `Fn0`, `Fn1` and `Fn2` switch layer to 1, 2 and 2 respectively. `Fn2` registers `Space` key when tapping while `Fn0` and `Fn1` doesn't send any key. - static const uint8_t PROGMEM fn_layer[] = { + const uint8_t PROGMEM fn_layer[] = { 1, // Fn0 2, // Fn1 2, // Fn2 }; - static const uint8_t PROGMEM fn_keycode[] = { + const uint8_t PROGMEM fn_keycode[] = { KC_NO, // Fn0 KC_NO, // Fn1 KC_SPC, // Fn2 From b468036b2a7b7b12e9798f9cfb1a18242b8a51b5 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 29 Jun 2016 19:59:59 +0900 Subject: [PATCH 046/217] core: Add unimap support --- common.mk | 13 ++- common/actionmap.c | 5 ++ common/actionmap.h | 4 - common/unimap.c | 57 ++++++++++++ common/unimap.h | 211 +++++++++++++++++++++++++++++++++++++++++++++ doc/unimap.txt | 51 +++++++++++ 6 files changed, 333 insertions(+), 8 deletions(-) create mode 100644 common/unimap.c create mode 100644 common/unimap.h create mode 100644 doc/unimap.txt diff --git a/common.mk b/common.mk index 9cfe6d5a..4fc5398c 100644 --- a/common.mk +++ b/common.mk @@ -17,11 +17,16 @@ SRC += $(COMMON_DIR)/host.c \ # Option modules -ifdef ACTIONMAP_ENABLE - SRC += $(COMMON_DIR)/actionmap.c - OPT_DEFS += -DACTIONMAP_ENABLE +ifdef UNIMAP_ENABLE + SRC += $(COMMON_DIR)/unimap.c + OPT_DEFS += -DUNIMAP_ENABLE else - SRC += $(COMMON_DIR)/keymap.c + ifdef ACTIONMAP_ENABLE + SRC += $(COMMON_DIR)/actionmap.c + OPT_DEFS += -DACTIONMAP_ENABLE + else + SRC += $(COMMON_DIR)/keymap.c + endif endif ifdef BOOTMAGIC_ENABLE diff --git a/common/actionmap.c b/common/actionmap.c index 49d0f5ce..6b0fa8e9 100644 --- a/common/actionmap.c +++ b/common/actionmap.c @@ -18,6 +18,11 @@ along with this program. If not, see . #include "action_code.h" #include "actionmap.h" + +/* Keymapping with 16bit action codes */ +extern const action_t actionmaps[][MATRIX_ROWS][MATRIX_COLS]; + + /* Converts key to action */ __attribute__ ((weak)) action_t action_for_key(uint8_t layer, keypos_t key) diff --git a/common/actionmap.h b/common/actionmap.h index ac529975..5e00bb2e 100644 --- a/common/actionmap.h +++ b/common/actionmap.h @@ -24,10 +24,6 @@ along with this program. If not, see . #include "action.h" -/* Keymapping with 16bit action codes */ -extern const action_t actionmaps[][MATRIX_ROWS][MATRIX_COLS]; - - /* Modified key */ #define AC_c(kc) ACTION_MODS_KEY(MOD_LCTL, KC_##kc) #define AC_s(kc) ACTION_MODS_KEY(MOD_LSFT, KC_##kc) diff --git a/common/unimap.c b/common/unimap.c new file mode 100644 index 00000000..c3d6c264 --- /dev/null +++ b/common/unimap.c @@ -0,0 +1,57 @@ +#include "keyboard.h" +#include "action.h" +#include "unimap.h" +#include "print.h" +#if defined(__AVR__) +# include +#endif + + +/* Keymapping with 16bit action codes */ +extern const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS]; + +// table translates matrix to universal keymap +extern const uint8_t unimap_trans[MATRIX_ROWS][MATRIX_COLS]; + + + +// translates raw matrix to universal map +keypos_t unimap_translate(keypos_t key) +{ + uint8_t unimap_pos = +#if defined(__AVR__) + pgm_read_byte(&unimap_trans[key.row][key.col]); +#else + unimap_trans[key.row][key.col]; +#endif + return (keypos_t) { + .row = ((unimap_pos & 0x70) >> 4), + .col = (unimap_pos & 0x0F) + }; +} + +/* Converts key to action */ +__attribute__ ((weak)) +action_t action_for_key(uint8_t layer, keypos_t key) +{ + keypos_t uni = unimap_translate(key); + if ((uni.row << 4 | uni.col) == UNIMAP_NO) return (action_t)ACTION_NO; +#if defined(__AVR__) + return (action_t)pgm_read_word(&actionmaps[(layer)][(uni.row)][(uni.col)]); +#else + return actionmaps[(layer)][(uni.row)][(uni.col)]; +#endif +} + +/* Macro */ +__attribute__ ((weak)) +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + return MACRO_NONE; +} + +/* Function */ +__attribute__ ((weak)) +void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) +{ +} diff --git a/common/unimap.h b/common/unimap.h new file mode 100644 index 00000000..43be70bd --- /dev/null +++ b/common/unimap.h @@ -0,0 +1,211 @@ +/* +Copyright 2016 Jun Wako +*/ +#ifndef _UNIMAP_H_ +#define _UNIMAP_H_ + +#include +#include +#include "action.h" +#include "action_code.h" +#include "actionmap.h" + + +// Universal map table: 8x16=128key +#define UNIMAP_ROWS 8 +#define UNIMAP_COLS 16 + +/* Universal 128-key keyboard layout(8x16) + ,-----------------------------------------------. + |F13|F14|F15|F16|F17|F18|F19|F20|F21|F22|F23|F24| +,---. |-----------------------------------------------| ,-----------. ,-----------. +|Esc| |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12| |PrS|ScL|Pau| |VDn|VUp|Mut| +`---' `-----------------------------------------------' `-----------' `-----------' +,-----------------------------------------------------------. ,-----------. ,---------------. +| `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -| +|-----------------------------------------------------------| |-----------| |---------------| +|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +| +|-----------------------------------------------------------| `-----------' |---------------| +|CapsL | A| S| D| F| G| H| J| K| L| ;| '| #|Retn| | 4| 5| 6|KP,| +|-----------------------------------------------------------| ,---. |---------------| +|Shft| <| Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3|KP=| +|-----------------------------------------------------------| ,-----------. |---------------| +|Ctl|Gui|Alt|MHEN| Space |HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0 | .|Ent| +`-----------------------------------------------------------' `-----------' `---------------' +App: Windows Menu key +Gui: Windows key, Mac ⌘ key or Meta key +VDn Vup Mut: Volume control +< #: ISO keys(in UK legend) +KP=: Keypad = for Mac +KP,: Brazilian Keypad Comma +JPY: Japanese Yen(¥) +RO: Japanese ろ(Ro) or Brazilian /(Slash) +MHEN: Japanese 無変換(Non Conversion) or Korean Hanja +HENK: Japanese 変換(Conversion) or Korean Hangul/English +KANA: Japanese かな(Hiragana/Katakana) +https://en.wikipedia.org/wiki/Keyboard_layout#Japanese +https://en.wikipedia.org/wiki/Keyboard_layout#Hangul_.28for_Korean.29 +*/ +#define UNIMAP( \ + K68,K69,K6A,K6B,K6C,K6D,K6E,K6F,K70,K71,K72,K73, \ + K29, K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,K45, K46,K47,K48, K01,K02,K03, \ + K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K74,K2A, K49,K4A,K4B, K53,K54,K55,K56, \ + K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30, K31, K4C,K4D,K4E, K5F,K60,K61,K57, \ + K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34, K32,K28, K5C,K5D,K5E,K66, \ + K79,K64,K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, K75,K7D, K52, K59,K5A,K5B,K67, \ + K78,K7B,K7A,K77, K2C, K76,K00,K7E,K7F,K65,K7C, K50,K51,K4F, K62, K63,K58 \ +) { \ + { AC_##K00, AC_##K01, AC_##K02, AC_##K03, AC_##K04, AC_##K05, AC_##K06, AC_##K07, /* 00-07 */ \ + AC_##K08, AC_##K09, AC_##K0A, AC_##K0B, AC_##K0C, AC_##K0D, AC_##K0E, AC_##K0F }, /* 08-0F */ \ + { AC_##K10, AC_##K11, AC_##K12, AC_##K13, AC_##K14, AC_##K15, AC_##K16, AC_##K17, /* 10-17 */ \ + AC_##K18, AC_##K19, AC_##K1A, AC_##K1B, AC_##K1C, AC_##K1D, AC_##K1E, AC_##K1F }, /* 18-1F */ \ + { AC_##K20, AC_##K21, AC_##K22, AC_##K23, AC_##K24, AC_##K25, AC_##K26, AC_##K27, /* 20-27 */ \ + AC_##K28, AC_##K29, AC_##K2A, AC_##K2B, AC_##K2C, AC_##K2D, AC_##K2E, AC_##K2F }, /* 28-2F */ \ + { AC_##K30, AC_##K31, AC_##K32, AC_##K33, AC_##K34, AC_##K35, AC_##K36, AC_##K37, /* 30-37 */ \ + AC_##K38, AC_##K39, AC_##K3A, AC_##K3B, AC_##K3C, AC_##K3D, AC_##K3E, AC_##K3F }, /* 38-3F */ \ + { AC_##K40, AC_##K41, AC_##K42, AC_##K43, AC_##K44, AC_##K45, AC_##K46, AC_##K47, /* 40-47 */ \ + AC_##K48, AC_##K49, AC_##K4A, AC_##K4B, AC_##K4C, AC_##K4D, AC_##K4E, AC_##K4F }, /* 48-4F */ \ + { AC_##K50, AC_##K51, AC_##K52, AC_##K53, AC_##K54, AC_##K55, AC_##K56, AC_##K57, /* 50-57 */ \ + AC_##K58, AC_##K59, AC_##K5A, AC_##K5B, AC_##K5C, AC_##K5D, AC_##K5E, AC_##K5F }, /* 58-5F */ \ + { AC_##K60, AC_##K61, AC_##K62, AC_##K63, AC_##K64, AC_##K65, AC_##K66, AC_##K67, /* 60-67 */ \ + AC_##K68, AC_##K69, AC_##K6A, AC_##K6B, AC_##K6C, AC_##K6D, AC_##K6E, AC_##K6F }, /* 68-6F */ \ + { AC_##K70, AC_##K71, AC_##K72, AC_##K73, AC_##K74, AC_##K75, AC_##K76, AC_##K77, /* 70-77 */ \ + AC_##K78, AC_##K79, AC_##K7A, AC_##K7B, AC_##K7C, AC_##K7D, AC_##K7E, AC_##K7F } /* 78-7F */ \ +} + +// Universal map position codes +enum unimap_position_codes { +// logical name position(row << 4 | col) +// ------------------------------------------------ + UNIMAP_KANA, // 0x00 + UNIMAP_VOLUME_DOWN, // 0x01 + UNIMAP_VOLUME_UP, // 0x02 + UNIMAP_VOLUME_MUTE, // 0x03 + UNIMAP_A, // 0x04 + UNIMAP_B, // 0x05 + UNIMAP_C, // 0x06 + UNIMAP_D, // 0x07 + UNIMAP_E, // 0x08 + UNIMAP_F, // 0x09 + UNIMAP_G, // 0x0A + UNIMAP_H, // 0x0B + UNIMAP_I, // 0x0C + UNIMAP_J, // 0x0D + UNIMAP_K, // 0x0E + UNIMAP_L, // 0x0F + UNIMAP_M, // 0x10 + UNIMAP_N, // 0x11 + UNIMAP_O, // 0x12 + UNIMAP_P, // 0x13 + UNIMAP_Q, // 0x14 + UNIMAP_R, // 0x15 + UNIMAP_S, // 0x16 + UNIMAP_T, // 0x17 + UNIMAP_U, // 0x18 + UNIMAP_V, // 0x19 + UNIMAP_W, // 0x1A + UNIMAP_X, // 0x1B + UNIMAP_Y, // 0x1C + UNIMAP_Z, // 0x1D + UNIMAP_1, // 0x1E + UNIMAP_2, // 0x1F + UNIMAP_3, // 0x20 + UNIMAP_4, // 0x21 + UNIMAP_5, // 0x22 + UNIMAP_6, // 0x23 + UNIMAP_7, // 0x24 + UNIMAP_8, // 0x25 + UNIMAP_9, // 0x26 + UNIMAP_0, // 0x27 + UNIMAP_ENTER, // 0x28 + UNIMAP_ESCAPE, // 0x29 + UNIMAP_BSPACE, // 0x2A + UNIMAP_TAB, // 0x2B + UNIMAP_SPACE, // 0x2C + UNIMAP_MINUS, // 0x2D + UNIMAP_EQUAL, // 0x2E + UNIMAP_LBRACKET, // 0x2F + UNIMAP_RBRACKET, // 0x30 + UNIMAP_BSLASH, // 0x31 + UNIMAP_NONUS_HASH, // 0x32 ISO UK hasu + UNIMAP_SCOLON, // 0x33 + UNIMAP_QUOTE, // 0x34 + UNIMAP_GRAVE, // 0x35 + UNIMAP_COMMA, // 0x36 + UNIMAP_DOT, // 0x37 + UNIMAP_SLASH, // 0x38 + UNIMAP_CAPSLOCK, // 0x39 + UNIMAP_F1, // 0x3A + UNIMAP_F2, // 0x3B + UNIMAP_F3, // 0x3C + UNIMAP_F4, // 0x3D + UNIMAP_F5, // 0x3E + UNIMAP_F6, // 0x3F + UNIMAP_F7, // 0x40 + UNIMAP_F8, // 0x41 + UNIMAP_F9, // 0x42 + UNIMAP_F10, // 0x43 + UNIMAP_F11, // 0x44 + UNIMAP_F12, // 0x45 + UNIMAP_PSCREEN, // 0x46 + UNIMAP_SCROLLLOCK, // 0x47 + UNIMAP_PAUSE, // 0x48 + UNIMAP_INSERT, // 0x49 + UNIMAP_HOME, // 0x4A + UNIMAP_PGUP, // 0x4B + UNIMAP_DELETE, // 0x4C + UNIMAP_END, // 0x4D + UNIMAP_PGDOWN, // 0x4E + UNIMAP_RIGHT, // 0x4F + UNIMAP_LEFT, // 0x50 + UNIMAP_DOWN, // 0x51 + UNIMAP_UP, // 0x52 + UNIMAP_NUMLOCK, // 0x53 + UNIMAP_KP_SLASH, // 0x54 + UNIMAP_KP_ASTERISK, // 0x55 + UNIMAP_KP_MINUS, // 0x56 + UNIMAP_KP_PLUS, // 0x57 + UNIMAP_KP_ENTER, // 0x58 + UNIMAP_KP_1, // 0x59 + UNIMAP_KP_2, // 0x5A + UNIMAP_KP_3, // 0x5B + UNIMAP_KP_4, // 0x5C + UNIMAP_KP_5, // 0x5D + UNIMAP_KP_6, // 0x5E + UNIMAP_KP_7, // 0x5F + UNIMAP_KP_8, // 0x60 + UNIMAP_KP_9, // 0x61 + UNIMAP_KP_0, // 0x62 + UNIMAP_KP_DOT, // 0x63 + UNIMAP_NONUS_BSLASH, // 0x64 ISO UK backslash + UNIMAP_APPLICATION, // 0x65 + UNIMAP_KP_COMMA, // 0x66 + UNIMAP_KP_EQUAL, // 0x67 + UNIMAP_F13, // 0x68 + UNIMAP_F14, // 0x69 + UNIMAP_F15, // 0x6A + UNIMAP_F16, // 0x6B + UNIMAP_F17, // 0x6C + UNIMAP_F18, // 0x6D + UNIMAP_F19, // 0x6E + UNIMAP_F20, // 0x6F + UNIMAP_F21, // 0x70 + UNIMAP_F22, // 0x71 + UNIMAP_F23, // 0x72 + UNIMAP_F24, // 0x73 + UNIMAP_JYEN, // 0x74 + UNIMAP_RO, // 0x75 + UNIMAP_HENK, // 0x76 + UNIMAP_MHEN, // 0x77 + UNIMAP_LCTRL, // 0x78 + UNIMAP_LSHIFT, // 0x79 + UNIMAP_LALT, // 0x7A + UNIMAP_LGUI, // 0x7B + UNIMAP_RCTRL, // 0x7C + UNIMAP_RSHIFT, // 0x7D + UNIMAP_RALT, // 0x7E + UNIMAP_RGUI, // 0x7F + UNIMAP_NO, // 0x80 +}; + +#endif diff --git a/doc/unimap.txt b/doc/unimap.txt new file mode 100644 index 00000000..0db038e6 --- /dev/null +++ b/doc/unimap.txt @@ -0,0 +1,51 @@ +Unimap +====== +universal keymapping framework +using logical 128-key keyboard layout independent from physical keyboad matrix + +unimap is actually an actionmap whose size is row:8xcol:16. + +/* Keymapping with 16bit action codes */ +extern const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS]; + +/* Universal 128-key keyboard layout(8x16) + ,-----------------------------------------------. + |F13|F14|F15|F16|F17|F18|F19|F20|F21|F22|F23|F24| +,---. |-----------------------------------------------| ,-----------. ,-----------. +|Esc| |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12| |PrS|ScL|Pau| |VDn|VUp|Mut| +`---' `-----------------------------------------------' `-----------' `-----------' +,-----------------------------------------------------------. ,-----------. ,---------------. +| `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -| +|-----------------------------------------------------------| |-----------| |---------------| +|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +| +|-----------------------------------------------------------| `-----------' |---------------| +|CapsL | A| S| D| F| G| H| J| K| L| ;| '| #|Retn| | 4| 5| 6|KP,| +|-----------------------------------------------------------| ,---. |---------------| +|Shft| <| Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3|KP=| +|-----------------------------------------------------------| ,-----------. |---------------| +|Ctl|Gui|Alt|MHEN| Space |HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0 | .|Ent| +`-----------------------------------------------------------' `-----------' `---------------' +App: Windows Menu key +Gui: Windows key, Mac ⌘ key or Meta key +VDn Vup Mut: Volume control +< #: ISO keys(in UK legend) +KP=: Keypad = for Mac +KP,: Brazilian Keypad Comma +JPY: Japanese Yen(¥) +RO: Japanese ろ(Ro) or Brazilian /(Slash) +MHEN: Japanese 無変換(Non Conversion) or Korean Hanja +HENK: Japanese 変換(Conversion) or Korean Hangul/English +KANA: Japanese かな(Hiragana/Katakana) +https://en.wikipedia.org/wiki/Keyboard_layout#Japanese +https://en.wikipedia.org/wiki/Keyboard_layout#Hangul_.28for_Korean.29 +*/ + + +when refering to keymapping physical matrix position needed to be translated into logical one on unimap +the translation is defined in unimap array + +row and col of unimap positon is encoded as follows +position = (row << 4) | col + +// table translates matrix to universal keymap +extern const uint8_t unimap_trans[MATRIX_ROWS][MATRIX_COLS]; From 2157ca73576f0522cbde9e17020a9ac058c3a009 Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 30 Aug 2016 12:49:59 +0900 Subject: [PATCH 047/217] core: Fix unimap layout comment --- common/unimap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/unimap.h b/common/unimap.h index 43be70bd..3b6540b1 100644 --- a/common/unimap.h +++ b/common/unimap.h @@ -26,9 +26,9 @@ Copyright 2016 Jun Wako |-----------------------------------------------------------| |-----------| |---------------| |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +| |-----------------------------------------------------------| `-----------' |---------------| -|CapsL | A| S| D| F| G| H| J| K| L| ;| '| #|Retn| | 4| 5| 6|KP,| +|CapsL | A| S| D| F| G| H| J| K| L| ;| '| #|Entr| | 4| 5| 6|KP,| |-----------------------------------------------------------| ,---. |---------------| -|Shft| <| Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3|KP=| +|Shft| <| Z| X| C| V| B| N| M| ,| .| /| RO|Shift | |Up | | 1| 2| 3|KP=| |-----------------------------------------------------------| ,-----------. |---------------| |Ctl|Gui|Alt|MHEN| Space |HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0 | .|Ent| `-----------------------------------------------------------' `-----------' `---------------' From b5a3a0326ccbe5a47aa1c522ab07f9e5666cba49 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 31 Aug 2016 16:40:32 +0900 Subject: [PATCH 048/217] core: Fix common.mk for build options --- common.mk | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/common.mk b/common.mk index 4fc5398c..d91e6d6d 100644 --- a/common.mk +++ b/common.mk @@ -17,11 +17,11 @@ SRC += $(COMMON_DIR)/host.c \ # Option modules -ifdef UNIMAP_ENABLE +ifeq (yes,$(strip $(UNIMAP_ENABLE))) SRC += $(COMMON_DIR)/unimap.c OPT_DEFS += -DUNIMAP_ENABLE else - ifdef ACTIONMAP_ENABLE + ifeq (yes,$(strip $(ACTIONMAP_ENABLE))) SRC += $(COMMON_DIR)/actionmap.c OPT_DEFS += -DACTIONMAP_ENABLE else @@ -29,58 +29,58 @@ else endif endif -ifdef BOOTMAGIC_ENABLE +ifeq (yes,$(strip $(BOOTMAGIC_ENABLE))) SRC += $(COMMON_DIR)/bootmagic.c SRC += $(COMMON_DIR)/avr/eeconfig.c OPT_DEFS += -DBOOTMAGIC_ENABLE endif -ifdef MOUSEKEY_ENABLE +ifeq (yes,$(strip $(MOUSEKEY_ENABLE))) SRC += $(COMMON_DIR)/mousekey.c OPT_DEFS += -DMOUSEKEY_ENABLE OPT_DEFS += -DMOUSE_ENABLE endif -ifdef EXTRAKEY_ENABLE +ifeq (yes,$(strip $(EXTRAKEY_ENABLE))) OPT_DEFS += -DEXTRAKEY_ENABLE endif -ifdef CONSOLE_ENABLE +ifeq (yes,$(strip $(CONSOLE_ENABLE))) OPT_DEFS += -DCONSOLE_ENABLE else OPT_DEFS += -DNO_PRINT OPT_DEFS += -DNO_DEBUG endif -ifdef COMMAND_ENABLE +ifeq (yes,$(strip $(COMMAND_ENABLE))) SRC += $(COMMON_DIR)/command.c OPT_DEFS += -DCOMMAND_ENABLE endif -ifdef NKRO_ENABLE +ifeq (yes,$(strip $(NKRO_ENABLE))) OPT_DEFS += -DNKRO_ENABLE endif -ifdef USB_6KRO_ENABLE +ifeq (yes,$(strip $(USB_6KRO_ENABLE))) OPT_DEFS += -DUSB_6KRO_ENABLE endif -ifdef KEYBOARD_LOCK_ENABLE +ifeq (yes, $(strip $(KEYBOARD_LOCK_ENABLE))) OPT_DEFS += -DKEYBOARD_LOCK_ENABLE endif -ifdef SLEEP_LED_ENABLE +ifeq (yes,$(strip $(SLEEP_LED_ENABLE))) SRC += $(COMMON_DIR)/avr/sleep_led.c OPT_DEFS += -DSLEEP_LED_ENABLE OPT_DEFS += -DNO_SUSPEND_POWER_DOWN endif -ifdef BACKLIGHT_ENABLE +ifeq (yes,$(strip $(BACKLIGHT_ENABLE))) SRC += $(COMMON_DIR)/backlight.c OPT_DEFS += -DBACKLIGHT_ENABLE endif -ifdef KEYMAP_SECTION_ENABLE +ifeq (yes,$(strip $(KEYMAP_SECTION_ENABLE))) OPT_DEFS += -DKEYMAP_SECTION_ENABLE ifeq ($(strip $(MCU)),atmega32u2) From bd07b62164d7b543c7bb6e38c4710c03cfcc9b07 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 7 Sep 2016 05:50:25 +0900 Subject: [PATCH 049/217] core: Change lufa NKRO report size 16 to 32 bytes --- protocol/lufa/descriptor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/lufa/descriptor.h b/protocol/lufa/descriptor.h index 42af0791..119f4298 100644 --- a/protocol/lufa/descriptor.h +++ b/protocol/lufa/descriptor.h @@ -155,7 +155,7 @@ typedef struct #define MOUSE_EPSIZE 8 #define EXTRAKEY_EPSIZE 8 #define CONSOLE_EPSIZE 32 -#define NKRO_EPSIZE 16 +#define NKRO_EPSIZE 32 uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, From 98f50a74de6d40863dc2f88b3797a98c21c32829 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 8 Sep 2016 13:18:05 +0900 Subject: [PATCH 050/217] core: Fix unimap UNIMAP_NO case --- common/unimap.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/common/unimap.c b/common/unimap.c index c3d6c264..84109b5a 100644 --- a/common/unimap.c +++ b/common/unimap.c @@ -25,8 +25,8 @@ keypos_t unimap_translate(keypos_t key) unimap_trans[key.row][key.col]; #endif return (keypos_t) { - .row = ((unimap_pos & 0x70) >> 4), - .col = (unimap_pos & 0x0F) + .row = ((unimap_pos & 0xf0) >> 4), + .col = (unimap_pos & 0x0f) }; } @@ -35,11 +35,13 @@ __attribute__ ((weak)) action_t action_for_key(uint8_t layer, keypos_t key) { keypos_t uni = unimap_translate(key); - if ((uni.row << 4 | uni.col) == UNIMAP_NO) return (action_t)ACTION_NO; + if ((uni.row << 4 | uni.col) == UNIMAP_NO) { + return (action_t)ACTION_NO; + } #if defined(__AVR__) - return (action_t)pgm_read_word(&actionmaps[(layer)][(uni.row)][(uni.col)]); + return (action_t)pgm_read_word(&actionmaps[(layer)][(uni.row & 0x7)][(uni.col)]); #else - return actionmaps[(layer)][(uni.row)][(uni.col)]; + return actionmaps[(layer)][(uni.row & 0x7)][(uni.col)]; #endif } From 170bce2c9eacfb7d775e7fee15ed5669cce67dc9 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 8 Sep 2016 13:52:59 +0900 Subject: [PATCH 051/217] core: 'make dfu' waits for bootloader to start jackhumbert/qmk_firmware@0b8c448 --- rules.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rules.mk b/rules.mk index 0ae84d91..a0a7c3e5 100644 --- a/rules.mk +++ b/rules.mk @@ -420,6 +420,10 @@ flip: $(TARGET).hex batchisp -hardware usb -device $(MCU) -operation start reset 0 dfu: $(TARGET).hex + @until dfu-programmer atmega32u4 get bootloader-version > /dev/null 2>&1; do \ + echo -n "."; \ + sleep 1; \ + done ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1))) dfu-programmer $(MCU) erase --force else From 234be45c4d7b4d8ff133016b4289f4ecec590569 Mon Sep 17 00:00:00 2001 From: Travis La Marr Date: Fri, 15 Jul 2016 10:41:32 -0400 Subject: [PATCH 052/217] Fix OS X Recognizing keyboard as Mouse/Tablet Modified the LUFA USB HID Descriptor to change the logical/usage minimums for System Control from 0x01 (Mouse) to 0x81 (System Power Down), this fixes OS X recognizing the Planck as having a mouse and tablet, even with mousekeys off. --- protocol/lufa/descriptor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protocol/lufa/descriptor.c b/protocol/lufa/descriptor.c index 6c2cacb5..4fb5219d 100644 --- a/protocol/lufa/descriptor.c +++ b/protocol/lufa/descriptor.c @@ -140,9 +140,9 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM ExtrakeyReport[] = HID_RI_USAGE(8, 0x80), /* System Control */ HID_RI_COLLECTION(8, 0x01), /* Application */ HID_RI_REPORT_ID(8, REPORT_ID_SYSTEM), - HID_RI_LOGICAL_MINIMUM(16, 0x0001), + HID_RI_LOGICAL_MINIMUM(16, 0x0081), HID_RI_LOGICAL_MAXIMUM(16, 0x00B7), - HID_RI_USAGE_MINIMUM(16, 0x0001), /* System Power Down */ + HID_RI_USAGE_MINIMUM(16, 0x0081), /* System Power Down */ HID_RI_USAGE_MAXIMUM(16, 0x00B7), /* System Display LCD Autoscale */ HID_RI_REPORT_SIZE(8, 16), HID_RI_REPORT_COUNT(8, 1), From 5ff299ce6a501ee08ddb5aa905c4807b96cd4ebc Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 8 Sep 2016 14:43:25 +0900 Subject: [PATCH 053/217] core: Fix 'make dfu' message --- rules.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rules.mk b/rules.mk index a0a7c3e5..987b580c 100644 --- a/rules.mk +++ b/rules.mk @@ -420,10 +420,13 @@ flip: $(TARGET).hex batchisp -hardware usb -device $(MCU) -operation start reset 0 dfu: $(TARGET).hex + @echo -n dfu-programmer: waiting @until dfu-programmer atmega32u4 get bootloader-version > /dev/null 2>&1; do \ echo -n "."; \ sleep 1; \ done + @echo + ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1))) dfu-programmer $(MCU) erase --force else From 5391df8052c8b245300780a6db041163b80eea19 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 9 Sep 2016 09:27:57 +0900 Subject: [PATCH 054/217] core: Fix dfu wait in rules.mk --- rules.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules.mk b/rules.mk index 987b580c..66b4cbd8 100644 --- a/rules.mk +++ b/rules.mk @@ -421,7 +421,7 @@ flip: $(TARGET).hex dfu: $(TARGET).hex @echo -n dfu-programmer: waiting - @until dfu-programmer atmega32u4 get bootloader-version > /dev/null 2>&1; do \ + @until dfu-programmer $(MCU) get bootloader-version > /dev/null 2>&1; do \ echo -n "."; \ sleep 1; \ done From 90844eb7cf600865d83d9e7fe8f704c1c311bf5e Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 9 Sep 2016 11:21:23 +0900 Subject: [PATCH 055/217] core: Add short names in unimap --- common/unimap.h | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/common/unimap.h b/common/unimap.h index 3b6540b1..2dd5b221 100644 --- a/common/unimap.h +++ b/common/unimap.h @@ -208,4 +208,65 @@ enum unimap_position_codes { UNIMAP_NO, // 0x80 }; +/* + * Short names + */ +#define UNIMAP_LCTL UNIMAP_LCTRL +#define UNIMAP_RCTL UNIMAP_RCTRL +#define UNIMAP_LSFT UNIMAP_LSHIFT +#define UNIMAP_RSFT UNIMAP_RSHIFT +#define UNIMAP_ESC UNIMAP_ESCAPE +#define UNIMAP_BSPC UNIMAP_BSPACE +#define UNIMAP_ENT UNIMAP_ENTER +#define UNIMAP_DEL UNIMAP_DELETE +#define UNIMAP_INS UNIMAP_INSERT +#define UNIMAP_CAPS UNIMAP_CAPSLOCK +#define UNIMAP_CLCK UNIMAP_CAPSLOCK +#define UNIMAP_RGHT UNIMAP_RIGHT +#define UNIMAP_PGDN UNIMAP_PGDOWN +#define UNIMAP_PSCR UNIMAP_PSCREEN +#define UNIMAP_SLCK UNIMAP_SCROLLLOCK +#define UNIMAP_PAUS UNIMAP_PAUSE +#define UNIMAP_BRK UNIMAP_PAUSE +#define UNIMAP_NLCK UNIMAP_NUMLOCK +#define UNIMAP_SPC UNIMAP_SPACE +#define UNIMAP_MINS UNIMAP_MINUS +#define UNIMAP_EQL UNIMAP_EQUAL +#define UNIMAP_GRV UNIMAP_GRAVE +#define UNIMAP_RBRC UNIMAP_RBRACKET +#define UNIMAP_LBRC UNIMAP_LBRACKET +#define UNIMAP_COMM UNIMAP_COMMA +#define UNIMAP_BSLS UNIMAP_BSLASH +#define UNIMAP_SLSH UNIMAP_SLASH +#define UNIMAP_SCLN UNIMAP_SCOLON +#define UNIMAP_QUOT UNIMAP_QUOTE +#define UNIMAP_APP UNIMAP_APPLICATION +#define UNIMAP_NUHS UNIMAP_NONUS_HASH +#define UNIMAP_NUBS UNIMAP_NONUS_BSLASH +/* Japanese specific */ +#define UNIMAP_ZKHK UNIMAP_GRAVE +/* Keypad */ +#define UNIMAP_P1 UNIMAP_KP_1 +#define UNIMAP_P2 UNIMAP_KP_2 +#define UNIMAP_P3 UNIMAP_KP_3 +#define UNIMAP_P4 UNIMAP_KP_4 +#define UNIMAP_P5 UNIMAP_KP_5 +#define UNIMAP_P6 UNIMAP_KP_6 +#define UNIMAP_P7 UNIMAP_KP_7 +#define UNIMAP_P8 UNIMAP_KP_8 +#define UNIMAP_P9 UNIMAP_KP_9 +#define UNIMAP_P0 UNIMAP_KP_0 +#define UNIMAP_PDOT UNIMAP_KP_DOT +#define UNIMAP_PCMM UNIMAP_KP_COMMA +#define UNIMAP_PSLS UNIMAP_KP_SLASH +#define UNIMAP_PAST UNIMAP_KP_ASTERISK +#define UNIMAP_PMNS UNIMAP_KP_MINUS +#define UNIMAP_PPLS UNIMAP_KP_PLUS +#define UNIMAP_PEQL UNIMAP_KP_EQUAL +#define UNIMAP_PENT UNIMAP_KP_ENTER +/* Consumer Page */ +#define UNIMAP_MUTE UNIMAP_VOLUME_MUTE +#define UNIMAP_VOLU UNIMAP_VOLUME_UP +#define UNIMAP_VOLD UNIMAP_VOLUME_DOWN + #endif From 4e88ae73599a02f41a39cd512a5fb731bea9202e Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 16 Sep 2016 11:47:12 +0900 Subject: [PATCH 056/217] core: Fix build config in protocol.mk --- protocol.mk | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/protocol.mk b/protocol.mk index 630c42b1..2bf05742 100644 --- a/protocol.mk +++ b/protocol.mk @@ -1,59 +1,59 @@ PROTOCOL_DIR = protocol -ifdef PS2_MOUSE_ENABLE +ifeq (yes,$(strip $(PS2_MOUSE_ENABLE))) SRC += $(PROTOCOL_DIR)/ps2_mouse.c OPT_DEFS += -DPS2_MOUSE_ENABLE OPT_DEFS += -DMOUSE_ENABLE endif -ifdef PS2_USE_BUSYWAIT +ifeq (yes,$(strip $(PS2_USE_BUSYWAIT))) SRC += protocol/ps2_busywait.c SRC += protocol/ps2_io_avr.c OPT_DEFS += -DPS2_USE_BUSYWAIT endif -ifdef PS2_USE_INT +ifeq (yes,$(strip $(PS2_USE_INT))) SRC += protocol/ps2_interrupt.c SRC += protocol/ps2_io_avr.c OPT_DEFS += -DPS2_USE_INT endif -ifdef PS2_USE_USART +ifeq (yes,$(strip $(PS2_USE_USART))) SRC += protocol/ps2_usart.c SRC += protocol/ps2_io_avr.c OPT_DEFS += -DPS2_USE_USART endif -ifdef XT_USE_INT +ifeq (yes,$(strip $(XT_USE_INT))) SRC += protocol/xt_interrupt.c SRC += protocol/xt_io_avr.c OPT_DEFS += -DXT_USE_INT endif -ifdef SERIAL_MOUSE_MICROSOFT_ENABLE +ifeq (yes,$(strip $(SERIAL_MOUSE_MICROSOFT_ENABLE))) SRC += $(PROTOCOL_DIR)/serial_mouse_microsoft.c OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MICROSOFT \ -DMOUSE_ENABLE endif -ifdef SERIAL_MOUSE_MOUSESYSTEMS_ENABLE +ifeq (yes,$(strip $(SERIAL_MOUSE_MOUSESYSTEMS_ENABLE))) SRC += $(PROTOCOL_DIR)/serial_mouse_mousesystems.c OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MOUSESYSTEMS \ -DMOUSE_ENABLE endif -ifdef SERIAL_MOUSE_USE_SOFT +ifeq (yes,$(strip $(SERIAL_MOUSE_USE_SOFT))) SRC += $(PROTOCOL_DIR)/serial_soft.c endif -ifdef SERIAL_MOUSE_USE_UART +ifeq (yes,$(strip $(SERIAL_MOUSE_USE_UART))) SRC += $(PROTOCOL_DIR)/serial_uart.c endif -ifdef ADB_MOUSE_ENABLE +ifeq (yes,$(strip $(ADB_MOUSE_ENABLE))) OPT_DEFS += -DADB_MOUSE_ENABLE -DMOUSE_ENABLE endif From dd09c54ca98a9a028e3fa646b5f3cf91ae8914e1 Mon Sep 17 00:00:00 2001 From: leizzer Date: Thu, 22 Sep 2016 01:38:26 -0300 Subject: [PATCH 057/217] Change .gitignore for ChibiOS I changed the gitignore file to match the chibios.mk declaration. Also it will be easier, you just clone ChibiOS and ChibiOS-Contrib and you don't have to rename nothing. --- tool/chibios/.gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tool/chibios/.gitignore b/tool/chibios/.gitignore index 88bbafe3..6be9cf9e 100644 --- a/tool/chibios/.gitignore +++ b/tool/chibios/.gitignore @@ -1,2 +1,2 @@ -chibios -chibios-contrib +ChibiOS +ChibiOS-Contrib From 0cf470836cc577da77f48b43d348858595deb379 Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 24 Sep 2016 11:29:21 +0900 Subject: [PATCH 058/217] core: Fix OPT_DEFS for mbed build --- tool/mbed/gcc.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/tool/mbed/gcc.mk b/tool/mbed/gcc.mk index b8c7336b..596fbc8a 100644 --- a/tool/mbed/gcc.mk +++ b/tool/mbed/gcc.mk @@ -23,6 +23,7 @@ CC_FLAGS += \ -fdata-sections \ -fomit-frame-pointer CC_FLAGS += -MMD -MP +CC_FLAGS += $(OPT_DEFS) LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs #LD_FLAGS += -u _printf_float -u _scanf_float From a1ea074d87badab35f994658b71ff6fc1cef3df2 Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 26 Sep 2016 08:22:18 +0900 Subject: [PATCH 059/217] core: Fix mechanical locking supoort #390 --- common/action.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/action.c b/common/action.c index b9040f5b..3a3c4014 100644 --- a/common/action.c +++ b/common/action.c @@ -27,6 +27,7 @@ along with this program. If not, see . #include "action_util.h" #include "action.h" #include "hook.h" +#include "wait.h" #ifdef DEBUG_ACTION #include "debug.h" @@ -365,6 +366,7 @@ void register_code(uint8_t code) #endif add_key(KC_CAPSLOCK); send_keyboard_report(); + wait_ms(100); del_key(KC_CAPSLOCK); send_keyboard_report(); } @@ -375,6 +377,7 @@ void register_code(uint8_t code) #endif add_key(KC_NUMLOCK); send_keyboard_report(); + wait_ms(100); del_key(KC_NUMLOCK); send_keyboard_report(); } @@ -385,6 +388,7 @@ void register_code(uint8_t code) #endif add_key(KC_SCROLLLOCK); send_keyboard_report(); + wait_ms(100); del_key(KC_SCROLLLOCK); send_keyboard_report(); } @@ -440,6 +444,7 @@ void unregister_code(uint8_t code) #endif add_key(KC_CAPSLOCK); send_keyboard_report(); + wait_ms(100); del_key(KC_CAPSLOCK); send_keyboard_report(); } @@ -450,6 +455,7 @@ void unregister_code(uint8_t code) #endif add_key(KC_NUMLOCK); send_keyboard_report(); + wait_ms(100); del_key(KC_NUMLOCK); send_keyboard_report(); } @@ -460,6 +466,7 @@ void unregister_code(uint8_t code) #endif add_key(KC_SCROLLLOCK); send_keyboard_report(); + wait_ms(100); del_key(KC_SCROLLLOCK); send_keyboard_report(); } From 8627cb2b43164733644433fe8e2983b1d494257e Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 28 Sep 2016 16:39:41 +0900 Subject: [PATCH 060/217] core: LUFA_DEBUG_SUART for serial debug --- common/avr/suart.S | 156 +++++++++++++++++++++++++++++++++++++++++++ common/avr/suart.h | 8 +++ protocol/lufa.mk | 5 ++ protocol/lufa/lufa.c | 17 ++++- 4 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 common/avr/suart.S create mode 100644 common/avr/suart.h diff --git a/common/avr/suart.S b/common/avr/suart.S new file mode 100644 index 00000000..9fa54529 --- /dev/null +++ b/common/avr/suart.S @@ -0,0 +1,156 @@ +;---------------------------------------------------------------------------; +; Software implemented UART module ; +; (C)ChaN, 2005 (http://elm-chan.org/) ; +;---------------------------------------------------------------------------; +; Bit rate settings: +; +; 1MHz 2MHz 4MHz 6MHz 8MHz 10MHz 12MHz 16MHz 20MHz +; 2.4kbps 138 - - - - - - - - +; 4.8kbps 68 138 - - - - - - - +; 9.6kbps 33 68 138 208 - - - - - +; 19.2kbps - 33 68 102 138 173 208 - - +; 38.4kbps - - 33 50 68 85 102 138 172 +; 57.6kbps - - 21 33 44 56 68 91 114 +; 115.2kbps - - - - 21 27 33 44 56 + +.nolist +#include +.list + +#define BPS 44 /* Bit delay. (see above table) */ +#define BIDIR 0 /* 0:Separated Tx/Rx, 1:Shared Tx/Rx */ + +#define OUT_1 sbi _SFR_IO_ADDR(SUART_OUT_PORT), SUART_OUT_BIT /* Output 1 */ +#define OUT_0 cbi _SFR_IO_ADDR(SUART_OUT_PORT), SUART_OUT_BIT /* Output 0 */ +#define SKIP_IN_1 sbis _SFR_IO_ADDR(SUART_IN_PIN), SUART_IN_BIT /* Skip if 1 */ +#define SKIP_IN_0 sbic _SFR_IO_ADDR(SUART_IN_PIN), SUART_IN_BIT /* Skip if 0 */ + + + +#ifdef SPM_PAGESIZE +.macro _LPMI reg + lpm \reg, Z+ +.endm +.macro _MOVW dh,dl, sh,sl + movw \dl, \sl +.endm +#else +.macro _LPMI reg + lpm + mov \reg, r0 + adiw ZL, 1 +.endm +.macro _MOVW dh,dl, sh,sl + mov \dl, \sl + mov \dh, \sh +.endm +#endif + + + +;---------------------------------------------------------------------------; +; Transmit a byte in serial format of N81 +; +;Prototype: void xmit (uint8_t data); +;Size: 16 words + +.global xmit +.func xmit +xmit: +#if BIDIR + ldi r23, BPS-1 ;Pre-idle time for bidirectional data line +5: dec r23 ; + brne 5b ;/ +#endif + in r0, _SFR_IO_ADDR(SREG) ;Save flags + + com r24 ;C = start bit + ldi r25, 10 ;Bit counter + cli ;Start critical section + +1: ldi r23, BPS-1 ;----- Bit transferring loop +2: dec r23 ;Wait for a bit time + brne 2b ;/ + brcs 3f ;MISO = bit to be sent + OUT_1 ; +3: brcc 4f ; + OUT_0 ;/ +4: lsr r24 ;Get next bit into C + dec r25 ;All bits sent? + brne 1b ; no, coutinue + + out _SFR_IO_ADDR(SREG), r0 ;End of critical section + ret +.endfunc + + + +;---------------------------------------------------------------------------; +; Receive a byte +; +;Prototype: uint8_t rcvr (void); +;Size: 19 words + +.global rcvr +.func rcvr +rcvr: + in r0, _SFR_IO_ADDR(SREG) ;Save flags + + ldi r24, 0x80 ;Receiving shift reg + cli ;Start critical section + +1: SKIP_IN_1 ;Wait for idle + rjmp 1b +2: SKIP_IN_0 ;Wait for start bit + rjmp 2b + ldi r25, BPS/2 ;Wait for half bit time +3: dec r25 + brne 3b + +4: ldi r25, BPS ;----- Bit receiving loop +5: dec r25 ;Wait for a bit time + brne 5b ;/ + lsr r24 ;Next bit + SKIP_IN_0 ;Get a data bit into r24.7 + ori r24, 0x80 + brcc 4b ;All bits received? no, continue + + out _SFR_IO_ADDR(SREG), r0 ;End of critical section + ret +.endfunc + + +; Not wait for start bit. This should be called after detecting start bit. +.global recv +.func recv +recv: + in r0, _SFR_IO_ADDR(SREG) ;Save flags + + ldi r24, 0x80 ;Receiving shift reg + cli ;Start critical section + +;1: SKIP_IN_1 ;Wait for idle +; rjmp 1b +;2: SKIP_IN_0 ;Wait for start bit +; rjmp 2b + ldi r25, BPS/2 ;Wait for half bit time +3: dec r25 + brne 3b + +4: ldi r25, BPS ;----- Bit receiving loop +5: dec r25 ;Wait for a bit time + brne 5b ;/ + lsr r24 ;Next bit + SKIP_IN_0 ;Get a data bit into r24.7 + ori r24, 0x80 + brcc 4b ;All bits received? no, continue + + ldi r25, BPS/2 ;Wait for half bit time +6: dec r25 + brne 6b +7: SKIP_IN_1 ;Wait for stop bit + rjmp 7b + + out _SFR_IO_ADDR(SREG), r0 ;End of critical section + ret +.endfunc diff --git a/common/avr/suart.h b/common/avr/suart.h new file mode 100644 index 00000000..72725b99 --- /dev/null +++ b/common/avr/suart.h @@ -0,0 +1,8 @@ +#ifndef SUART +#define SUART + +void xmit(uint8_t); +uint8_t rcvr(void); +uint8_t recv(void); + +#endif /* SUART */ diff --git a/protocol/lufa.mk b/protocol/lufa.mk index d239585b..1b529bde 100644 --- a/protocol/lufa.mk +++ b/protocol/lufa.mk @@ -48,3 +48,8 @@ OPT_DEFS += $(LUFA_OPTS) # This indicates using LUFA stack OPT_DEFS += -DPROTOCOL_LUFA + +ifeq (yes,$(strip $(LUFA_DEBUG_SUART))) + SRC += common/avr/suart.S + LUFA_OPTS += -DLUFA_DEBUG_SUART +endif diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index beec6b2b..c16fd177 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -50,6 +50,10 @@ #include "suspend.h" #include "hook.h" +#ifdef LUFA_DEBUG_SUART +#include "avr/suart.h" +#endif + #include "descriptor.h" #include "lufa.h" @@ -217,6 +221,7 @@ void EVENT_USB_Device_StartOfFrame(void) */ void EVENT_USB_Device_ConfigurationChanged(void) { + print("[c]"); bool ConfigSuccess = true; /* Setup Keyboard HID Report Endpoints */ @@ -270,6 +275,7 @@ Other Device Required Optional Optional Optional Optional Opti */ void EVENT_USB_Device_ControlRequest(void) { + print("[r]"); uint8_t* ReportData = NULL; uint8_t ReportSize = 0; @@ -494,6 +500,9 @@ static void send_consumer(uint16_t data) #define SEND_TIMEOUT 5 int8_t sendchar(uint8_t c) { +#ifdef LUFA_DEBUG_SUART + xmit(c); +#endif // Not wait once timeouted. // Because sendchar() is called so many times, waiting each call causes big lag. static bool timeouted = false; @@ -551,6 +560,9 @@ int8_t sendchar(uint8_t c) #else int8_t sendchar(uint8_t c) { +#ifdef LUFA_DEBUG_SUART + xmit(c); +#endif return 0; } #endif @@ -578,12 +590,15 @@ static void setup_usb(void) // for Console_Task USB_Device_EnableSOFEvents(); - print_set_sendchar(sendchar); } int main(void) __attribute__ ((weak)); int main(void) { +#ifdef LUFA_DEBUG_SUART + DDRD |= (1< Date: Wed, 28 Sep 2016 16:57:24 +0900 Subject: [PATCH 061/217] core: Fix suspend/wake for converters #386 --- common/avr/suspend.c | 1 + protocol/lufa/lufa.c | 73 +++++++++++++++++++++++++++++++++++++------- 2 files changed, 63 insertions(+), 11 deletions(-) diff --git a/common/avr/suspend.c b/common/avr/suspend.c index af99f52b..580d69e4 100644 --- a/common/avr/suspend.c +++ b/common/avr/suspend.c @@ -102,6 +102,7 @@ bool suspend_wakeup_condition(void) void suspend_wakeup_init(void) { // clear keyboard state + matrix_init(); clear_keyboard(); #ifdef BACKLIGHT_ENABLE backlight_init(); diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index c16fd177..f5fc4cb7 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -1,4 +1,4 @@ -/* +/* * Copyright 2012 Jun Wako * This file is based on: * LUFA-120219/Demos/Device/Lowlevel/KeyboardMouse @@ -54,9 +54,14 @@ #include "avr/suart.h" #endif +#include "matrix.h" #include "descriptor.h" #include "lufa.h" + +//#define LUFA_DEBUG + + uint8_t keyboard_idle = 0; /* 0: Boot Protocol, 1: Report Protocol(default) */ uint8_t keyboard_protocol = 1; @@ -104,10 +109,10 @@ static void Console_Task(void) { /* Create a temporary buffer to hold the read in report from the host */ uint8_t ConsoleData[CONSOLE_EPSIZE]; - + /* Read Console Report Data */ Endpoint_Read_Stream_LE(&ConsoleData, sizeof(ConsoleData), NULL); - + /* Process Console Report Data */ //ProcessConsoleHIDReport(ConsoleData); } @@ -168,7 +173,7 @@ void EVENT_USB_Device_Disconnect(void) print("[D]"); /* For battery powered device */ USB_IsInitialized = false; -/* TODO: This doesn't work. After several plug in/outs can not be enumerated. +/* TODO: This doesn't work. After several plug in/outs can not be enumerated. if (USB_IsInitialized) { USB_Disable(); // Disable all interrupts USB_Controller_Enable(); @@ -179,18 +184,24 @@ void EVENT_USB_Device_Disconnect(void) void EVENT_USB_Device_Reset(void) { +#ifdef LUFA_DEBUG print("[R]"); +#endif } void EVENT_USB_Device_Suspend() { +#ifdef LUFA_DEBUG print("[S]"); +#endif hook_usb_suspend_entry(); } void EVENT_USB_Device_WakeUp() { +#ifdef LUFA_DEBUG print("[W]"); +#endif hook_usb_wakeup(); } @@ -221,7 +232,9 @@ void EVENT_USB_Device_StartOfFrame(void) */ void EVENT_USB_Device_ConfigurationChanged(void) { +#ifdef LUFA_DEBUG print("[c]"); +#endif bool ConfigSuccess = true; /* Setup Keyboard HID Report Endpoints */ @@ -275,7 +288,6 @@ Other Device Required Optional Optional Optional Optional Opti */ void EVENT_USB_Device_ControlRequest(void) { - print("[r]"); uint8_t* ReportData = NULL; uint8_t ReportSize = 0; @@ -299,6 +311,9 @@ void EVENT_USB_Device_ControlRequest(void) /* Write the report data to the control endpoint */ Endpoint_Write_Control_Stream_LE(ReportData, ReportSize); Endpoint_ClearOUT(); +#ifdef LUFA_DEBUG + xprintf("[r%d]", USB_ControlRequest.wIndex); +#endif } break; @@ -322,6 +337,9 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearOUT(); Endpoint_ClearStatusStage(); +#ifdef LUFA_DEBUG + xprintf("[L%d]", USB_ControlRequest.wIndex); +#endif break; } @@ -338,6 +356,9 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_Write_8(keyboard_protocol); Endpoint_ClearIN(); Endpoint_ClearStatusStage(); +#ifdef LUFA_DEBUG + print("[p]"); +#endif } } @@ -351,6 +372,9 @@ void EVENT_USB_Device_ControlRequest(void) keyboard_protocol = (USB_ControlRequest.wValue & 0xFF); clear_keyboard(); +#ifdef LUFA_DEBUG + print("[P]"); +#endif } } @@ -362,6 +386,9 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_ClearStatusStage(); keyboard_idle = ((USB_ControlRequest.wValue & 0xFF00) >> 8); +#ifdef LUFA_DEBUG + xprintf("[I%d]%d", USB_ControlRequest.wIndex, (USB_ControlRequest.wValue & 0xFF00) >> 8); +#endif } break; @@ -373,6 +400,9 @@ void EVENT_USB_Device_ControlRequest(void) Endpoint_Write_8(keyboard_idle); Endpoint_ClearIN(); Endpoint_ClearStatusStage(); +#ifdef LUFA_DEBUG + print("[i]"); +#endif } break; @@ -380,7 +410,7 @@ void EVENT_USB_Device_ControlRequest(void) } /******************************************************************************* - * Host driver + * Host driver ******************************************************************************/ static uint8_t keyboard_leds(void) { @@ -595,11 +625,15 @@ static void setup_usb(void) int main(void) __attribute__ ((weak)); int main(void) { + setup_mcu(); + #ifdef LUFA_DEBUG_SUART - DDRD |= (1< Date: Tue, 4 Oct 2016 16:05:18 +0900 Subject: [PATCH 062/217] core: Add suspend mode options --- common/avr/suspend.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/common/avr/suspend.c b/common/avr/suspend.c index 580d69e4..b9b58c15 100644 --- a/common/avr/suspend.c +++ b/common/avr/suspend.c @@ -30,16 +30,6 @@ __asm__ __volatile__ ( \ ) -void suspend_idle(uint8_t time) -{ - cli(); - set_sleep_mode(SLEEP_MODE_IDLE); - sleep_enable(); - sei(); - sleep_cpu(); - sleep_disable(); -} - /* Power down MCU with watchdog timer * wdto: watchdog timer timeout defined in * WDTO_15MS @@ -80,9 +70,39 @@ static void power_down(uint8_t wdto) wdt_disable(); } +static void standby(void) +{ + set_sleep_mode(SLEEP_MODE_STANDBY); + sleep_enable(); + sei(); + sleep_cpu(); + sleep_disable(); +} + +static void idle(void) +{ + set_sleep_mode(SLEEP_MODE_IDLE); + sleep_enable(); + sei(); + sleep_cpu(); + sleep_disable(); +} + + +void suspend_idle(uint8_t time) +{ + idle(); +} + void suspend_power_down(void) { +#ifdef SUSPEND_MODE_STANDBY + standby(); +#elif defined(SUSPEND_MODE_IDLE) + idle(); +#else power_down(WDTO_15MS); +#endif } __attribute__ ((weak)) void matrix_power_up(void) {} From 34fd2819b2a0ec46afa1c91e72e528009755ada2 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 5 Oct 2016 13:55:56 +0900 Subject: [PATCH 063/217] core: Add matrix_clear() and default impl. --- common.mk | 1 + common/avr/suspend.c | 4 +- common/keyboard.c | 1 - common/matrix.c | 97 ++++++++++++++++++++++++++++++++++++++++++++ common/matrix.h | 5 +++ protocol/lufa/lufa.c | 2 +- 6 files changed, 105 insertions(+), 5 deletions(-) create mode 100644 common/matrix.c diff --git a/common.mk b/common.mk index d91e6d6d..69be0e13 100644 --- a/common.mk +++ b/common.mk @@ -1,6 +1,7 @@ COMMON_DIR = common SRC += $(COMMON_DIR)/host.c \ $(COMMON_DIR)/keyboard.c \ + $(COMMON_DIR)/matrix.c \ $(COMMON_DIR)/action.c \ $(COMMON_DIR)/action_tapping.c \ $(COMMON_DIR)/action_macro.c \ diff --git a/common/avr/suspend.c b/common/avr/suspend.c index b9b58c15..150588ce 100644 --- a/common/avr/suspend.c +++ b/common/avr/suspend.c @@ -105,8 +105,6 @@ void suspend_power_down(void) #endif } -__attribute__ ((weak)) void matrix_power_up(void) {} -__attribute__ ((weak)) void matrix_power_down(void) {} bool suspend_wakeup_condition(void) { matrix_power_up(); @@ -122,7 +120,7 @@ bool suspend_wakeup_condition(void) void suspend_wakeup_init(void) { // clear keyboard state - matrix_init(); + matrix_clear(); clear_keyboard(); #ifdef BACKLIGHT_ENABLE backlight_init(); diff --git a/common/keyboard.c b/common/keyboard.c index 707351bc..b0319369 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -63,7 +63,6 @@ static bool has_ghost_in_row(uint8_t row) #endif -__attribute__ ((weak)) void matrix_setup(void) {} void keyboard_setup(void) { matrix_setup(); diff --git a/common/matrix.c b/common/matrix.c new file mode 100644 index 00000000..9694bd1a --- /dev/null +++ b/common/matrix.c @@ -0,0 +1,97 @@ +/* +Copyright 2016 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "print.h" +#include "matrix.h" + + +__attribute__ ((weak)) +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +__attribute__ ((weak)) +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +__attribute__ ((weak)) +void matrix_clear(void) +{ + matrix_init(); +} + +__attribute__ ((weak)) +void matrix_setup(void) {} + +__attribute__ ((weak)) +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return (matrix_get_row(row) & (1< Date: Sat, 8 Oct 2016 10:57:38 +0900 Subject: [PATCH 064/217] core: Change matrix_init and matrix_print --- common/matrix.c | 18 ++++++++---------- common/matrix.h | 4 ++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/common/matrix.c b/common/matrix.c index 9694bd1a..9939307a 100644 --- a/common/matrix.c +++ b/common/matrix.c @@ -33,7 +33,6 @@ uint8_t matrix_cols(void) __attribute__ ((weak)) void matrix_clear(void) { - matrix_init(); } __attribute__ ((weak)) @@ -55,23 +54,22 @@ void matrix_print(void) #elif (MATRIX_COLS <= 32) print("r/c 0123456789ABCDEF0123456789ABCDEF\n"); #endif + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { - xprintf("%02X:", row); #if (MATRIX_COLS <= 8) - print_bin_reverse8(matrix_get_row(row)); + xprintf("%02X: %08b%s\n", row, bitrev(matrix_get_row(row)), #elif (MATRIX_COLS <= 16) - print_bin_reverse16(matrix_get_row(row)); + xprintf("%02X: %016b%s\n", row, bitrev16(matrix_get_row(row)), #elif (MATRIX_COLS <= 32) - print_bin_reverse32(matrix_get_row(row)); + xprintf("%02X: %032b%s\n", row, bitrev32(matrix_get_row(row)), #endif - #ifdef MATRIX_HAS_GHOST - if (matrix_has_ghost_in_row(row)) { - print(" 255) +#error "MATRIX_ROWS must not exceed 255" +#endif + #define MATRIX_IS_ON(row, col) (matrix_get_row(row) && (1< Date: Wed, 12 Oct 2016 14:35:53 +0900 Subject: [PATCH 065/217] core: Fix sleep_led --- common/avr/sleep_led.c | 17 ++++++++++++----- common/avr/suspend.c | 6 +++++- common/command.c | 12 ++++++++++-- common/sleep_led.h | 14 ++------------ 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/common/avr/sleep_led.c b/common/avr/sleep_led.c index dab3eb0f..37c2cf1b 100644 --- a/common/avr/sleep_led.c +++ b/common/avr/sleep_led.c @@ -45,10 +45,17 @@ void sleep_led_disable(void) TIMSK1 &= ~_BV(OCIE1A); } -void sleep_led_toggle(void) + +__attribute__ ((weak)) +void sleep_led_on(void) { - /* Disable Compare Match Interrupt */ - TIMSK1 ^= _BV(OCIE1A); + led_set(1< Date: Tue, 18 Oct 2016 14:34:47 +0900 Subject: [PATCH 066/217] core: Debug print for system and consumer keys --- common/host.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/host.c b/common/host.c index e9b79167..e1fa52d7 100644 --- a/common/host.c +++ b/common/host.c @@ -54,7 +54,7 @@ void host_keyboard_send(report_keyboard_t *report) (*driver->send_keyboard)(report); if (debug_keyboard) { - dprint("keyboard_report: "); + dprint("keyboard: "); for (uint8_t i = 0; i < KEYBOARD_REPORT_SIZE; i++) { dprintf("%02X ", report->raw[i]); } @@ -75,6 +75,10 @@ void host_system_send(uint16_t report) if (!driver) return; (*driver->send_system)(report); + + if (debug_keyboard) { + dprintf("system: %04X\n", report); + } } void host_consumer_send(uint16_t report) @@ -84,6 +88,10 @@ void host_consumer_send(uint16_t report) if (!driver) return; (*driver->send_consumer)(report); + + if (debug_keyboard) { + dprintf("consumer: %04X\n", report); + } } uint16_t host_last_sysytem_report(void) From 05113a6bc0013990c564b2c9b91f919bff19ec32 Mon Sep 17 00:00:00 2001 From: Aldo Gunsing Date: Mon, 14 Nov 2016 23:30:06 +0100 Subject: [PATCH 067/217] core: Fix typo in definition AC_g --- common/actionmap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/actionmap.h b/common/actionmap.h index 5e00bb2e..2ebfb0d0 100644 --- a/common/actionmap.h +++ b/common/actionmap.h @@ -28,7 +28,7 @@ along with this program. If not, see . #define AC_c(kc) ACTION_MODS_KEY(MOD_LCTL, KC_##kc) #define AC_s(kc) ACTION_MODS_KEY(MOD_LSFT, KC_##kc) #define AC_a(kc) ACTION_MODS_KEY(MOD_LALT, KC_##kc) -#define AC_g(kc) ACTION_MODS_KEY(MOD_LSFT, KC_##kc) +#define AC_g(kc) ACTION_MODS_KEY(MOD_LGUI, KC_##kc) /* Normal key */ #define AC_NO ACTION_KEY(KC_NO) From e135d9de7d4ff112076d591c83aaa5ec189fd70a Mon Sep 17 00:00:00 2001 From: Luiz Ribeiro Date: Sun, 27 Nov 2016 11:38:24 -0500 Subject: [PATCH 068/217] V-USB remote wakeup --- protocol/vusb/main.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/protocol/vusb/main.c b/protocol/vusb/main.c index 0d809536..794e4000 100644 --- a/protocol/vusb/main.c +++ b/protocol/vusb/main.c @@ -20,6 +20,7 @@ #include "timer.h" #include "uart.h" #include "debug.h" +#include "suspend.h" #define UART_BAUD_RATE 115200 @@ -41,6 +42,23 @@ static void initForUsbConnectivity(void) sei(); } +void usb_remote_wakeup(void) { + cli(); + + int8_t ddr_orig = USBDDR; + USBOUT |= (1 << USBMINUS); + USBDDR = ddr_orig | USBMASK; + USBOUT ^= USBMASK; + + _delay_ms(25); + + USBOUT ^= USBMASK; + USBDDR = ddr_orig; + USBOUT &= ~(1 << USBMINUS); + + sei(); +} + int main(void) { bool suspended = false; @@ -70,19 +88,6 @@ int main(void) // Suspend when no SOF in 3ms-10ms(7.1.7.4 Suspending of USB1.1) if (timer_elapsed(last_timer) > 5) { suspended = true; -/* - uart_putchar('S'); - _delay_ms(1); - cli(); - set_sleep_mode(SLEEP_MODE_PWR_DOWN); - sleep_enable(); - sleep_bod_disable(); - sei(); - sleep_cpu(); - sleep_disable(); - _delay_ms(10); - uart_putchar('W'); -*/ } } #endif @@ -95,6 +100,8 @@ int main(void) keyboard_task(); } vusb_transfer_keyboard(); + } else if (suspend_wakeup_condition()) { + usb_remote_wakeup(); } } } From b5d469632ff28b397b2b257811473ad8d5980fdf Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 24 Oct 2016 12:50:35 +0900 Subject: [PATCH 069/217] core: Swap position of PEQL and PENT in unimap --- common/unimap.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/unimap.h b/common/unimap.h index 2dd5b221..6a78d885 100644 --- a/common/unimap.h +++ b/common/unimap.h @@ -28,9 +28,9 @@ Copyright 2016 Jun Wako |-----------------------------------------------------------| `-----------' |---------------| |CapsL | A| S| D| F| G| H| J| K| L| ;| '| #|Entr| | 4| 5| 6|KP,| |-----------------------------------------------------------| ,---. |---------------| -|Shft| <| Z| X| C| V| B| N| M| ,| .| /| RO|Shift | |Up | | 1| 2| 3|KP=| +|Shft| <| Z| X| C| V| B| N| M| ,| .| /| RO|Shift | |Up | | 1| 2| 3|Ent| |-----------------------------------------------------------| ,-----------. |---------------| -|Ctl|Gui|Alt|MHEN| Space |HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0 | .|Ent| +|Ctl|Gui|Alt|MHEN| Space |HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0 | .|KP=| `-----------------------------------------------------------' `-----------' `---------------' App: Windows Menu key Gui: Windows key, Mac ⌘ key or Meta key @@ -52,8 +52,8 @@ KANA: Japanese かな(Hiragana/Katakana) K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K74,K2A, K49,K4A,K4B, K53,K54,K55,K56, \ K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30, K31, K4C,K4D,K4E, K5F,K60,K61,K57, \ K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34, K32,K28, K5C,K5D,K5E,K66, \ - K79,K64,K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, K75,K7D, K52, K59,K5A,K5B,K67, \ - K78,K7B,K7A,K77, K2C, K76,K00,K7E,K7F,K65,K7C, K50,K51,K4F, K62, K63,K58 \ + K79,K64,K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, K75,K7D, K52, K59,K5A,K5B,K58, \ + K78,K7B,K7A,K77, K2C, K76,K00,K7E,K7F,K65,K7C, K50,K51,K4F, K62,K63,K67 \ ) { \ { AC_##K00, AC_##K01, AC_##K02, AC_##K03, AC_##K04, AC_##K05, AC_##K06, AC_##K07, /* 00-07 */ \ AC_##K08, AC_##K09, AC_##K0A, AC_##K0B, AC_##K0C, AC_##K0D, AC_##K0E, AC_##K0F }, /* 08-0F */ \ From 381eaf54aa5c56bee90480e832a80107302edfa6 Mon Sep 17 00:00:00 2001 From: Anthony Date: Sun, 4 Dec 2016 15:23:26 +1100 Subject: [PATCH 070/217] Add in basic documentation for Macro system --- doc/keymap.md | 55 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/doc/keymap.md b/doc/keymap.md index df5d6de1..30ee5f18 100644 --- a/doc/keymap.md +++ b/doc/keymap.md @@ -379,19 +379,33 @@ Default Layer also has bitwise operations, they are executed when key is release ACTION_DEFAULT_LAYER_BIT_SET(part, bits) - ### 2.3 Macro action -***TBD*** +`Macro` actions allow you to register a complex sequence of keystrokes when a key is pressed, where macros are simple sequences of keypresses. + + ACTION_MACRO(id) + ACTION_MACRO_TAP(id) + +`id` is an 8-bit user-defined value the macro getter function can use to pick the specific macro. + + +#### 2.3.1 Implementing Macro getter function +To implement `macro` functions, the macro lookup list must be implemented: + + const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt); + +The function must always return a valid macro, and default implementation of `action_get_macro` always returns `MACRO_NONE` which has no effect. + +#### 2.3.1.1 Limitations +Similar to the Function Action system, the selector functions is passed a `keyrecord_t` object, so it can inspect the key state (e.g. different macros on key press or release), and key itself. + +Unlike the Function Action system,`macros` are pre-recorded key sequences, so you can only select from a list. If you want to use dynamic macros then you should look at the more complex function action system. -`Macro` action indicates complex key strokes. - - MACRO( D(LSHIFT), D(D), END ) - MACRO( U(D), U(LSHIFT), END ) - MACRO( I(255), T(H), T(E), T(L), T(L), W(255), T(O), END ) +#### 2.3.2 Implementing/Defining Macro sequences +Macros are of the form (must be wrapped by the `MACRO` function, and end with an `END` mark) -#### 2.3.1 Macro Commands -- **MACRO()** -- **MACRO_NONE** + MACRO( ..., END ) + +Within each macro, the following commands can be used: - **I()** change interval of stroke. - **D()** press key @@ -401,19 +415,25 @@ Default Layer also has bitwise operations, they are executed when key is release - **SM()** store modifier state - **RM()** restore modifier state - **CM()** clear modifier state -- **END** end mark + +e.g.: + + MACRO( D(LSHIFT), D(D), END ) // hold down LSHIFT and D - will print 'D' + MACRO( U(D), U(LSHIFT), END ) // release U and LSHIFT keys (an event.pressed == False counterpart for the one above) + MACRO( I(255), T(H), T(E), T(L), T(L), W(255), T(O), END ) // slowly print out h-e-l-l---o #### 2.3.2 Examples -***TBD*** + +in keymap.c, define `action_get_macro` const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { switch (id) { - case HELLO: + case 0: return (record->event.pressed ? MACRO( I(0), T(H), T(E), T(L), T(L), W(255), T(O), END ) : MACRO_NONE ); - case ALT_TAB: + case 1: return (record->event.pressed ? MACRO( D(LALT), D(TAB), END ) : MACRO( U(TAB), END )); @@ -421,7 +441,12 @@ Default Layer also has bitwise operations, they are executed when key is release return MACRO_NONE; } - +in keymap.c, bind items in `fn_actions` to the macro function + + const action_t PROGMEM fn_actions[] = { + [0] = ACTION_MACRO(0), // will print 'hello' for example + [1] = ACTION_MACRO(1), + }; ### 2.4 Function action From c2b28ce99a5bedcb9a76daff76abc7404ff83bd5 Mon Sep 17 00:00:00 2001 From: Anthony Date: Sun, 4 Dec 2016 13:19:25 +1100 Subject: [PATCH 071/217] Add note for L/R side bit being ignored --- doc/keymap.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/keymap.md b/doc/keymap.md index 30ee5f18..87b72e05 100644 --- a/doc/keymap.md +++ b/doc/keymap.md @@ -569,6 +569,7 @@ This registers modifier key(s) simultaneously with layer switching. ACTION_LAYER_MODS(2, MOD_LSFT | MOD_LALT) +This function can only register left-sided modifiers. The handedness of the modifier (left/right) is an extra bit that is not able to be passed through into the layer system. See: [`common/action_code.h`](../common/action_code.h), the spec for ACT_LAYER_TAP only allows four bits for the mods, whereas the mods themselves require five bits, with the high bit being the left/right handedness. ## 4. Tapping From 9401da5eb3d5c3c819355ab8d91094e4e166fc53 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 2 Dec 2016 10:11:46 +0900 Subject: [PATCH 072/217] core: Fix for ChibiOS update #411 --- protocol/chibios/usb_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/chibios/usb_main.c b/protocol/chibios/usb_main.c index fbf0ceba..e8f103a2 100644 --- a/protocol/chibios/usb_main.c +++ b/protocol/chibios/usb_main.c @@ -1033,7 +1033,7 @@ void init_usb_driver(USBDriver *usbp) { chVTObjectInit(&keyboard_idle_timer); #ifdef CONSOLE_ENABLE - obqObjectInit(&console_buf_queue, console_queue_buffer, CONSOLE_EPSIZE, CONSOLE_QUEUE_CAPACITY, console_queue_onotify, (void*)usbp); + obqObjectInit(&console_buf_queue, true, console_queue_buffer, CONSOLE_EPSIZE, CONSOLE_QUEUE_CAPACITY, console_queue_onotify, (void*)usbp); chVTObjectInit(&console_flush_timer); #endif } From fcb2a26acf2dbc164af61ad0af84e783c5c2731e Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 4 Jan 2017 12:51:13 +0900 Subject: [PATCH 073/217] core: Modifiers can be used as tap key Fix #422 --- common.mk | 1 + common/action.c | 4 +++- common/keycode.h | 24 ++++++++++++------------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/common.mk b/common.mk index 69be0e13..14951ec8 100644 --- a/common.mk +++ b/common.mk @@ -21,6 +21,7 @@ SRC += $(COMMON_DIR)/host.c \ ifeq (yes,$(strip $(UNIMAP_ENABLE))) SRC += $(COMMON_DIR)/unimap.c OPT_DEFS += -DUNIMAP_ENABLE + OPT_DEFS += -DACTIONMAP_ENABLE else ifeq (yes,$(strip $(ACTIONMAP_ENABLE))) SRC += $(COMMON_DIR)/actionmap.c diff --git a/common/action.c b/common/action.c index 3a3c4014..83b044fe 100644 --- a/common/action.c +++ b/common/action.c @@ -535,7 +535,9 @@ bool is_tap_key(keypos_t key) case ACT_LAYER_TAP: case ACT_LAYER_TAP_EXT: switch (action.layer_tap.code) { - case 0x00 ... 0xdf: + case KC_A ... KC_EXSEL: + case KC_KP_00 ... KC_KP_HEXADECIMAL: + case KC_LCTRL ... KC_RGUI: case OP_TAP_TOGGLE: return true; } diff --git a/common/keycode.h b/common/keycode.h index 51c91950..3ac1b55b 100644 --- a/common/keycode.h +++ b/common/keycode.h @@ -24,8 +24,14 @@ along with this program. If not, see . #define IS_ERROR(code) (KC_ROLL_OVER <= (code) && (code) <= KC_UNDEFINED) -#define IS_ANY(code) (KC_A <= (code) && (code) <= 0xFF) + +#ifndef ACTIONMAP_ENABLE #define IS_KEY(code) (KC_A <= (code) && (code) <= KC_EXSEL) +#else +#define IS_KEY(code) ((KC_A <= (code) && (code) <= KC_EXSEL) || \ + (KC_KP_00 <= (code) && (code) <= KC_KP_HEXADECIMAL)) +#endif + #define IS_MOD(code) (KC_LCTRL <= (code) && (code) <= KC_RGUI) @@ -179,7 +185,7 @@ enum hid_keyboard_keypad_usage { KC_ROLL_OVER, KC_POST_FAIL, KC_UNDEFINED, - KC_A, + KC_A, /* 0x04 */ KC_B, KC_C, KC_D, @@ -341,10 +347,7 @@ enum hid_keyboard_keypad_usage { KC_CRSEL, KC_EXSEL, /* 0xA4 */ - /* NOTE: 0xA5-DF are used for internal special purpose */ - -#if 0 - /* NOTE: Following codes(0xB0-DD) are not used. Leave them for reference. */ + /* NOTE: Following code range(0xB0-DD) are shared with special codes of 8-bit keymap */ KC_KP_00 = 0xB0, KC_KP_000, KC_THOUSANDS_SEPARATOR, @@ -391,7 +394,6 @@ enum hid_keyboard_keypad_usage { KC_KP_OCTAL, KC_KP_DECIMAL, KC_KP_HEXADECIMAL, /* 0xDD */ -#endif /* Modifiers */ KC_LCTRL = 0xE0, @@ -401,13 +403,11 @@ enum hid_keyboard_keypad_usage { KC_RCTRL, KC_RSHIFT, KC_RALT, - KC_RGUI, - - /* NOTE: 0xE8-FF are used for internal special purpose */ + KC_RGUI, /* 0xE7 */ }; -/* Special keycodes */ -/* NOTE: 0xA5-DF and 0xE8-FF are used for internal special purpose */ +/* Special keycodes for 8-bit keymap + NOTE: 0xA5-DF and 0xE8-FF are used for internal special purpose */ enum internal_special_keycodes { /* System Control */ KC_SYSTEM_POWER = 0xA5, From a31bcc1349cf2c3c9d80ea93da5d4c457300c5e5 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 5 Jan 2017 21:17:29 +0900 Subject: [PATCH 074/217] core: Cancel removing IS_ANY() at c98e89f IS_ANY() is used in usb_usb --- common/keycode.h | 1 + 1 file changed, 1 insertion(+) diff --git a/common/keycode.h b/common/keycode.h index 3ac1b55b..63d52e89 100644 --- a/common/keycode.h +++ b/common/keycode.h @@ -24,6 +24,7 @@ along with this program. If not, see . #define IS_ERROR(code) (KC_ROLL_OVER <= (code) && (code) <= KC_UNDEFINED) +#define IS_ANY(code) (KC_A <= (code) && (code) <= 0xFF) #ifndef ACTIONMAP_ENABLE #define IS_KEY(code) (KC_A <= (code) && (code) <= KC_EXSEL) From 7fe55b995c1fb99f9ba96432bca3aad9062103d7 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 11 Jan 2017 10:30:47 +0900 Subject: [PATCH 075/217] core: Fix LAYER_MODS() and LAYER_TAP() - LAYER_MODS() accepts either left or right modifiers - LAYER_TAP() can use modifier as tap key, related to #422 --- common/action.c | 28 ++++++++++++++++++++-------- common/action_code.h | 21 ++++++++++++--------- doc/keymap.md | 2 +- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/common/action.c b/common/action.c index 83b044fe..ab6e9d89 100644 --- a/common/action.c +++ b/common/action.c @@ -101,7 +101,7 @@ void process_action(keyrecord_t *record) { uint8_t mods = (action.kind.id == ACT_LMODS_TAP) ? action.key.mods : action.key.mods<<4; - switch (action.layer_tap.code) { + switch (action.key.code) { #ifndef NO_ACTION_ONESHOT case MODS_ONESHOT: // Oneshot modifier @@ -247,14 +247,18 @@ void process_action(keyrecord_t *record) case ACT_LAYER_TAP: case ACT_LAYER_TAP_EXT: switch (action.layer_tap.code) { - case 0xe0 ... 0xef: - /* layer On/Off with modifiers(left only) */ + case 0xc0 ... 0xdf: + /* layer On/Off with modifiers */ if (event.pressed) { layer_on(action.layer_tap.val); - register_mods(action.layer_tap.code & 0x0f); + register_mods((action.layer_tap.code & 0x10) ? + (action.layer_tap.code & 0x0f) << 4 : + (action.layer_tap.code & 0x0f)); } else { layer_off(action.layer_tap.val); - unregister_mods(action.layer_tap.code & 0x0f); + unregister_mods((action.layer_tap.code & 0x10) ? + (action.layer_tap.code & 0x0f) << 4 : + (action.layer_tap.code & 0x0f)); } break; case OP_TAP_TOGGLE: @@ -532,12 +536,20 @@ bool is_tap_key(keypos_t key) switch (action.kind.id) { case ACT_LMODS_TAP: case ACT_RMODS_TAP: + switch (action.key.code) { + case MODS_ONESHOT: + case MODS_TAP_TOGGLE: + case KC_A ... KC_EXSEL: // tap key + case KC_LCTRL ... KC_RGUI: // tap key + return true; + } case ACT_LAYER_TAP: case ACT_LAYER_TAP_EXT: switch (action.layer_tap.code) { - case KC_A ... KC_EXSEL: - case KC_KP_00 ... KC_KP_HEXADECIMAL: - case KC_LCTRL ... KC_RGUI: + case 0xc0 ... 0xdf: // with modifiers + return false; + case KC_A ... KC_EXSEL: // tap key + case KC_LCTRL ... KC_RGUI: // tap key case OP_TAP_TOGGLE: return true; } diff --git a/common/action_code.h b/common/action_code.h index 8dad38b9..10d040ee 100644 --- a/common/action_code.h +++ b/common/action_code.h @@ -29,14 +29,15 @@ along with this program. If not, see . * 000r|0000|0000 0001 Transparent code * 000r|0000| keycode Key * 000r|mods|0000 0000 Modifiers - * 000r|mods| keycode Modifiers+Key(Modified key) + * 000r|mods| keycode Modifiers+key(Modified key) * r: Left/Right flag(Left:0, Right:1) * * ACT_MODS_TAP(001r): - * 001r|mods|0000 0000 Modifiers with OneShot - * 001r|mods|0000 0001 Modifiers with tap toggle - * 001r|mods|0000 00xx (reserved) - * 001r|mods| keycode Modifiers with Tap Key(Dual role) + * 001r|mods|0000 0000 Modifiers with OneShot[TAP] + * 001r|mods|0000 0001 Modifiers with tap toggle[TAP] + * 001r|mods|0000 00xx (reserved) (0x02-03) + * 001r|mods| keycode Modifiers with tap key(0x04-A4, E0-E7)[TAP] + * (reserved) (0xA5-DF, E8-FF) * * * Other Keys(01xx) @@ -70,13 +71,15 @@ along with this program. If not, see . * 1001|oopp|BBBB BBBB 8-bit Bitwise Operation??? * * ACT_LAYER_TAP(101x): - * 101E|LLLL| keycode On/Off with tap key (0x00-DF)[TAP] - * 101E|LLLL|1110 mods On/Off with modifiers (0xE0-EF)[NOT TAP] + * 101E|LLLL| keycode On/Off with tap key (0x04-A4, E0-E7)[TAP] + * 101E|LLLL|110r mods On/Off with modifiers (0xC0-DF)[NOT TAP] + * r: Left/Right flag(Left:0, Right:1) + * (reserved) (0xA5-BF, E8-EF) * 101E|LLLL|1111 0000 Invert with tap toggle (0xF0) [TAP] * 101E|LLLL|1111 0001 On/Off (0xF1) [NOT TAP] * 101E|LLLL|1111 0010 Off/On (0xF2) [NOT TAP] * 101E|LLLL|1111 0011 Set/Clear (0xF3) [NOT TAP] - * 101E|LLLL|1111 xxxx Reserved (0xF4-FF) + * 101E|LLLL|1111 xxxx (reserved) (0xF4-FF) * ELLLL: layer 0-31(E: extra bit for layer 16-31) * * @@ -267,7 +270,7 @@ enum layer_pram_tap_op { #define ACTION_LAYER_ON_OFF(layer) ACTION_LAYER_TAP((layer), OP_ON_OFF) #define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON) #define ACTION_LAYER_SET_CLEAR(layer) ACTION_LAYER_TAP((layer), OP_SET_CLEAR) -#define ACTION_LAYER_MODS(layer, mods) ACTION_LAYER_TAP((layer), 0xe0 | ((mods)&0x0f)) +#define ACTION_LAYER_MODS(layer, mods) ACTION_LAYER_TAP((layer), 0xc0 | ((mods)&0x1f)) /* With Tapping */ #define ACTION_LAYER_TAP_KEY(layer, key) ACTION_LAYER_TAP((layer), (key)) #define ACTION_LAYER_TAP_TOGGLE(layer) ACTION_LAYER_TAP((layer), OP_TAP_TOGGLE) diff --git a/doc/keymap.md b/doc/keymap.md index 87b72e05..1321e763 100644 --- a/doc/keymap.md +++ b/doc/keymap.md @@ -569,7 +569,7 @@ This registers modifier key(s) simultaneously with layer switching. ACTION_LAYER_MODS(2, MOD_LSFT | MOD_LALT) -This function can only register left-sided modifiers. The handedness of the modifier (left/right) is an extra bit that is not able to be passed through into the layer system. See: [`common/action_code.h`](../common/action_code.h), the spec for ACT_LAYER_TAP only allows four bits for the mods, whereas the mods themselves require five bits, with the high bit being the left/right handedness. +You can combine four modifiers at most but cannot use both left and right modifiers at a time, either left or right modiiers only can be allowed. ## 4. Tapping From 418f490eb70a4dd806babe62f1a7c5bd75c7fb67 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 3 Feb 2017 08:54:17 +0900 Subject: [PATCH 076/217] core: Add MOD_NONE to mods_bit enum --- common/action_code.h | 1 + 1 file changed, 1 insertion(+) diff --git a/common/action_code.h b/common/action_code.h index 10d040ee..4b664286 100644 --- a/common/action_code.h +++ b/common/action_code.h @@ -200,6 +200,7 @@ typedef union { * bit 4 +----- LR flag(Left:0, Right:1) */ enum mods_bit { + MOD_NONE = 0x00, MOD_LCTL = 0x01, MOD_LSFT = 0x02, MOD_LALT = 0x04, From 442d4942a968ca790d75c41575fe2119b989da34 Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 11 Apr 2017 04:36:38 +0900 Subject: [PATCH 077/217] core: Fix for missing key on fc660c --- common/keyboard.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/keyboard.c b/common/keyboard.c index b0319369..6057ea13 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -137,8 +137,10 @@ void keyboard_task(void) hook_matrix_change(e); // record a processed key matrix_prev[r] ^= ((matrix_row_t)1< Date: Tue, 11 Apr 2017 15:50:19 +0900 Subject: [PATCH 078/217] core: Change MOD_* definition to make OR(|) usable https://github.com/tmk/tmk_keyboard/issues/448#issuecomment-285066234 --- common/action_code.h | 30 +++++++++++++++--------------- doc/keymap.md | 41 +++++++++++++++++++++++++---------------- 2 files changed, 40 insertions(+), 31 deletions(-) diff --git a/common/action_code.h b/common/action_code.h index 4b664286..1eb69104 100644 --- a/common/action_code.h +++ b/common/action_code.h @@ -200,26 +200,26 @@ typedef union { * bit 4 +----- LR flag(Left:0, Right:1) */ enum mods_bit { - MOD_NONE = 0x00, - MOD_LCTL = 0x01, - MOD_LSFT = 0x02, - MOD_LALT = 0x04, - MOD_LGUI = 0x08, - MOD_RCTL = 0x11, - MOD_RSFT = 0x12, - MOD_RALT = 0x14, - MOD_RGUI = 0x18, + MOD_NONE = 0x0000, + MOD_LCTL = 0x0100, + MOD_LSFT = 0x0200, + MOD_LALT = 0x0400, + MOD_LGUI = 0x0800, + MOD_RCTL = 0x1100, + MOD_RSFT = 0x1200, + MOD_RALT = 0x1400, + MOD_RGUI = 0x1800, }; enum mods_codes { MODS_ONESHOT = 0x00, MODS_TAP_TOGGLE = 0x01, }; #define ACTION_KEY(key) ACTION(ACT_MODS, (key)) -#define ACTION_MODS(mods) ACTION(ACT_MODS, ((mods)&0x1f)<<8 | 0) -#define ACTION_MODS_KEY(mods, key) ACTION(ACT_MODS, ((mods)&0x1f)<<8 | (key)) -#define ACTION_MODS_TAP_KEY(mods, key) ACTION(ACT_MODS_TAP, ((mods)&0x1f)<<8 | (key)) -#define ACTION_MODS_ONESHOT(mods) ACTION(ACT_MODS_TAP, ((mods)&0x1f)<<8 | MODS_ONESHOT) -#define ACTION_MODS_TAP_TOGGLE(mods) ACTION(ACT_MODS_TAP, ((mods)&0x1f)<<8 | MODS_TAP_TOGGLE) +#define ACTION_MODS(mods) ACTION(ACT_MODS, ((mods)&0x1f00) | 0) +#define ACTION_MODS_KEY(mods, key) ACTION(ACT_MODS, ((mods)&0x1f00) | (key)) +#define ACTION_MODS_TAP_KEY(mods, key) ACTION(ACT_MODS_TAP, ((mods)&0x1f00) | (key)) +#define ACTION_MODS_ONESHOT(mods) ACTION(ACT_MODS_TAP, ((mods)&0x1f00) | MODS_ONESHOT) +#define ACTION_MODS_TAP_TOGGLE(mods) ACTION(ACT_MODS_TAP, ((mods)&0x1f00) | MODS_TAP_TOGGLE) /* @@ -271,7 +271,7 @@ enum layer_pram_tap_op { #define ACTION_LAYER_ON_OFF(layer) ACTION_LAYER_TAP((layer), OP_ON_OFF) #define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON) #define ACTION_LAYER_SET_CLEAR(layer) ACTION_LAYER_TAP((layer), OP_SET_CLEAR) -#define ACTION_LAYER_MODS(layer, mods) ACTION_LAYER_TAP((layer), 0xc0 | ((mods)&0x1f)) +#define ACTION_LAYER_MODS(layer, mods) ACTION_LAYER_TAP((layer), 0xc0 | ((mods>>8)&0x1f)) /* With Tapping */ #define ACTION_LAYER_TAP_KEY(layer, key) ACTION_LAYER_TAP((layer), (key)) #define ACTION_LAYER_TAP_TOGGLE(layer) ACTION_LAYER_TAP((layer), OP_TAP_TOGGLE) diff --git a/doc/keymap.md b/doc/keymap.md index 1321e763..e1dc167e 100644 --- a/doc/keymap.md +++ b/doc/keymap.md @@ -140,7 +140,7 @@ You can find other keymap definitions in file `keymap.c` located on project dire * `-----------------------------------------------------------' * |Gui |Alt |Space |Alt |Gui| * `--------------------------------------------' - */ + */ KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS,BSPC, \ LCTL,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \ @@ -158,7 +158,7 @@ You can find other keymap definitions in file `keymap.c` located on project dire * `-----------------------------------------------------------' * |Gui |Alt |Mb1 |Alt | | * `--------------------------------------------' - * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel */ KEYMAP(ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ TAB, TRNS,TRNS,TRNS,TRNS,TRNS,WH_L,WH_D,WH_U,WH_R,TRNS,TRNS,TRNS,BSPC, \ @@ -194,7 +194,7 @@ See [`common/keycode.h`](../common/keycode.h) or keycode table below for the det - `KC_P1` to `KC_P0`, `KC_PDOT`, `KC_PCMM`, `KC_PSLS`, `KC_PAST`, `KC_PMNS`, `KC_PPLS`, `KC_PEQL`, `KC_PENT` for keypad. ### 1.2 Modifier -There are 8 modifiers which has discrimination between left and right. +There are 8 modifiers which has discrimination between left and right. - `KC_LCTL` and `KC_RCTL` for Control - `KC_LSFT` and `KC_RSFT` for Shift @@ -250,21 +250,30 @@ You can define these actions on *'A'* key and *'left shift'* modifier with: ACTION_KEY(KC_LSFT) #### 2.1.2 Modified key -This action is comprised of strokes of modifiers and a key. `Macro` action is needed if you want more complex key strokes. +This action is comprised of modifiers and a key. -Say you want to assign a key to `Shift + 1` to get character *'!'* or `Alt + Tab` to switch application windows. +Modified keys can be defined as below. Say you want to assign a key to `Shift + 1` to get character *'!'* or `Alt + Tab` to switch application windows. ACTION_MODS_KEY(MOD_LSFT, KC_1) ACTION_MODS_KEY(MOD_LALT, KC_TAB) + ACTION_MODS_KEY(MOD_LALT | MOD_LSFT, KC_TAB) -Or `Alt,Shift + Tab` can be defined. `ACTION_MODS_KEY(mods, key)` requires **4-bit modifier state** and a **keycode** as arguments. See `keycode.h` for `MOD_BIT()` macro. +These are identical to examples above. - ACTION_MODS_KEY(MOD_LALT | MOD_LSFT, KC_TAB) + ACTION_KEY(MOD_LSFT | KC_1) + ACTION_KEY(MOD_LALT | KC_TAB) + ACTION_KEY(MOD_LSFT | MOD_LALT | KC_TAB) #### 2.1.3 Multiple Modifiers Registers multiple modifiers with pressing a key. To specify multiple modifiers use `|`. - ACTION_MODS(MOD_ALT | MOD_LSFT) + ACTION_MODS(MOD_LALT | MOD_LSFT) + ACTION_MODS(MOD_LALT | MOD_LSFT | MOD_LCTL) + +These are identical to examples above. + + ACTION_KEY(MOD_LALT | MOD_LSFT, KC_NO) + ACTION_KEY(MOD_LALT | MOD_LSFT | MOD_LCTL, KC_NO) #### 2.1.3 Modifier with Tap key([Dual role][dual_role]) Works as a modifier key while holding, but registers a key on tap(press and release quickly). @@ -294,7 +303,7 @@ This sets Default Layer to given parameter `layer` and activate it. ACTION_DEFAULT_LAYER_SET(layer) -#### 2.2.2 Momentary +#### 2.2.2 Momentary Turns on `layer` momentarily while holding, in other words it activates when key is pressed and deactivate when released. ACTION_LAYER_MOMENTARY(layer) @@ -389,22 +398,22 @@ Default Layer also has bitwise operations, they are executed when key is release #### 2.3.1 Implementing Macro getter function -To implement `macro` functions, the macro lookup list must be implemented: +To implement `macro` functions, the macro lookup list must be implemented: const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt); The function must always return a valid macro, and default implementation of `action_get_macro` always returns `MACRO_NONE` which has no effect. - + #### 2.3.1.1 Limitations Similar to the Function Action system, the selector functions is passed a `keyrecord_t` object, so it can inspect the key state (e.g. different macros on key press or release), and key itself. - -Unlike the Function Action system,`macros` are pre-recorded key sequences, so you can only select from a list. If you want to use dynamic macros then you should look at the more complex function action system. + +Unlike the Function Action system,`macros` are pre-recorded key sequences, so you can only select from a list. If you want to use dynamic macros then you should look at the more complex function action system. #### 2.3.2 Implementing/Defining Macro sequences Macros are of the form (must be wrapped by the `MACRO` function, and end with an `END` mark) MACRO( ..., END ) - + Within each macro, the following commands can be used: - **I()** change interval of stroke. @@ -418,7 +427,7 @@ Within each macro, the following commands can be used: e.g.: - MACRO( D(LSHIFT), D(D), END ) // hold down LSHIFT and D - will print 'D' + MACRO( D(LSHIFT), D(D), END ) // hold down LSHIFT and D - will print 'D' MACRO( U(D), U(LSHIFT), END ) // release U and LSHIFT keys (an event.pressed == False counterpart for the one above) MACRO( I(255), T(H), T(E), T(L), T(L), W(255), T(O), END ) // slowly print out h-e-l-l---o @@ -442,7 +451,7 @@ in keymap.c, define `action_get_macro` } in keymap.c, bind items in `fn_actions` to the macro function - + const action_t PROGMEM fn_actions[] = { [0] = ACTION_MACRO(0), // will print 'hello' for example [1] = ACTION_MACRO(1), From afcda998e4cb578c678f83ee4fecc88f4d638468 Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 11 Apr 2017 15:54:35 +0900 Subject: [PATCH 079/217] core: Fix typo --- common/unimap.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/common/unimap.h b/common/unimap.h index 6a78d885..cd00e1d7 100644 --- a/common/unimap.h +++ b/common/unimap.h @@ -73,6 +73,25 @@ KANA: Japanese かな(Hiragana/Katakana) AC_##K78, AC_##K79, AC_##K7A, AC_##K7B, AC_##K7C, AC_##K7D, AC_##K7E, AC_##K7F } /* 78-7F */ \ } + +/* Matrix poision for Universal 128-key keyboard + ,-----------------------------------------------. + | 68| 69| 6A| 6B| 6C| 6D| 6E| 6F| 70| 71| 72| 73| +,---. |-----------------------------------------------| ,-----------. ,-----------. +| 29| | 3A| 3B| 3C| 3D| 3E| 3F| 40| 41| 42| 43| 44| 45| | 46| 47| 48| | 01| 02| 03| +`---' `-----------------------------------------------' `-----------' `-----------' +,-----------------------------------------------------------. ,-----------. ,---------------. +| 35| 1E| 1F| 20| 21| 22| 23| 24| 25| 26| 27| 2D| 2E| 74| 2A| | 49| 4A| 4B| | 53| 54| 55| 56| +|-----------------------------------------------------------| |-----------| |---------------| +| 2B| 14| 1A| 08| 15| 17| 1C| 18| 0C| 12| 13| 2F| 30| 31| | 4C| 4D| 4E| | 5F| 60| 61| 57| +|-----------------------------------------------------------| `-----------' |---------------| +| 39| 04| 16| 07| 09| 0A| 0B| 0D| 0E| 0F| 33| 34| 32| 28| | 5C| 5D| 5E| 66| +|-----------------------------------------------------------| ,---. |---------------| +| 79| 64| 1D| 1B| 06| 19| 05| 11| 10| 36| 37| 38| 75| 7D| | 52| | 59| 5A| 5B| 58| +|-----------------------------------------------------------| ,-----------. |---------------| +| 78| 7B| 7A| 77| 2C| 76| 00| 7E| 7F| 65| 7C| | 50| 51| 4F| | 62| 63| 67| +`-----------------------------------------------------------' `-----------' `---------------' +*/ // Universal map position codes enum unimap_position_codes { // logical name position(row << 4 | col) @@ -127,7 +146,7 @@ enum unimap_position_codes { UNIMAP_LBRACKET, // 0x2F UNIMAP_RBRACKET, // 0x30 UNIMAP_BSLASH, // 0x31 - UNIMAP_NONUS_HASH, // 0x32 ISO UK hasu + UNIMAP_NONUS_HASH, // 0x32 ISO UK hash UNIMAP_SCOLON, // 0x33 UNIMAP_QUOTE, // 0x34 UNIMAP_GRAVE, // 0x35 From 9b441180cf8a81b73f54423fae23ce6adb1b8fa7 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 26 May 2017 12:03:30 +0900 Subject: [PATCH 080/217] core: Fix for stuck key problem #441 - Idea form https://github.com/qmk/qmk_firmware/pull/182 - Define NO_TRACK_KEY_PRESS to get old behaviour - This should resolve #105, #248, #397, #441 and FAQ entry: https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#modifierlayer-stuck --- README.md | 8 ++++++++ common/action.c | 6 +++--- common/action.h | 2 +- common/action_layer.c | 36 ++++++++++++++++++++++++++++++------ common/action_layer.h | 2 +- common/action_tapping.c | 10 +++++----- 6 files changed, 48 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index c9c2eda4..50456880 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,14 @@ Source code is available here: Updates ------- +#### 2017/05/30 +Fixed **Modifier/Layer key stuck** problem. See this wiki entry. If you need old keymap behaviour for some reason define `NO_TRACK_KEY_PRESS` in your `config.h`. + +This is virtually equivalent to QMK `PREVENT_STUCK_MODIFIERS`. + +#### 2017/01/11 +Changed action code for `ACTION_LAYER_MODS` and this may cause incompatibility with existent shared URL and downloaded firmwware of keymap editor. If you are using the action you just have to redefine it on keymap editor. Existent keymap code should not suffer. + #### 2016/06/26 Keymap framework was updated. `fn_actions[]` should be defined as `action_t` instead of `uint16_t`. And default code for keymap handling is now included in core you just need define `uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]` and `action_t fn_actions[]`. diff --git a/common/action.c b/common/action.c index ab6e9d89..05aa12ee 100644 --- a/common/action.c +++ b/common/action.c @@ -65,7 +65,7 @@ void process_action(keyrecord_t *record) if (IS_NOEVENT(event)) { return; } - action_t action = layer_switch_get_action(event.key); + action_t action = layer_switch_get_action(event); dprint("ACTION: "); debug_action(action); #ifndef NO_ACTION_LAYER dprint(" layer_state: "); layer_debug(); @@ -529,9 +529,9 @@ void clear_keyboard_but_mods(void) #endif } -bool is_tap_key(keypos_t key) +bool is_tap_key(keyevent_t event) { - action_t action = layer_switch_get_action(key); + action_t action = layer_switch_get_action(event); switch (action.kind.id) { case ACT_LMODS_TAP: diff --git a/common/action.h b/common/action.h index 8a4736d7..993fc463 100644 --- a/common/action.h +++ b/common/action.h @@ -68,7 +68,7 @@ void unregister_mods(uint8_t mods); void clear_keyboard(void); void clear_keyboard_but_mods(void); void layer_switch(uint8_t new_layer); -bool is_tap_key(keypos_t key); +bool is_tap_key(keyevent_t event); /* debug */ void debug_event(keyevent_t event); diff --git a/common/action_layer.c b/common/action_layer.c index 6b5a7fd2..46401eba 100644 --- a/common/action_layer.c +++ b/common/action_layer.c @@ -24,7 +24,9 @@ static void default_layer_state_set(uint32_t state) default_layer_state = state; hook_default_layer_change(default_layer_state); default_layer_debug(); debug("\n"); +#ifdef NO_TRACK_KEY_PRESS clear_keyboard_but_mods(); // To avoid stuck keys +#endif } void default_layer_debug(void) @@ -66,7 +68,9 @@ static void layer_state_set(uint32_t state) layer_state = state; hook_layer_change(layer_state); layer_debug(); dprintln(); +#ifdef NO_TRACK_KEY_PRESS clear_keyboard_but_mods(); // To avoid stuck keys +#endif } void layer_clear(void) @@ -115,7 +119,8 @@ void layer_debug(void) -action_t layer_switch_get_action(keypos_t key) +/* return layer effective for key at this time */ +static uint8_t current_layer_for_key(keypos_t key) { action_t action = ACTION_TRANSPARENT; @@ -126,15 +131,34 @@ action_t layer_switch_get_action(keypos_t key) if (layers & (1UL< 1) { debug("Tapping: Start new tap with releasing last tap(>1).\n"); // unregister key @@ -196,7 +196,7 @@ bool process_tapping(keyrecord_t *keyp) tapping_key = (keyrecord_t){}; return true; } - else if (is_tap_key(event.key) && event.pressed) { + else if (is_tap_key(event) && event.pressed) { if (tapping_key.tap.count > 1) { debug("Tapping: Start new tap with releasing last timeout tap(>1).\n"); // unregister key @@ -241,7 +241,7 @@ bool process_tapping(keyrecord_t *keyp) tapping_key = *keyp; return true; } - } else if (is_tap_key(event.key)) { + } else if (is_tap_key(event)) { // Sequential tap can be interfered with other tap key. debug("Tapping: Start with interfering other tap.\n"); tapping_key = *keyp; @@ -272,7 +272,7 @@ bool process_tapping(keyrecord_t *keyp) } // not tapping state else { - if (event.pressed && is_tap_key(event.key)) { + if (event.pressed && is_tap_key(event)) { debug("Tapping: Start(Press tap key).\n"); tapping_key = *keyp; waiting_buffer_scan_tap(); From 088d576c024a739cd4757357b0ffc77ee85565e1 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 31 May 2017 01:15:45 +0900 Subject: [PATCH 081/217] core: Fix Oneshot mods key repeat problem #474 --- protocol/lufa/lufa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index 93fe9a2f..076c8c8d 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -431,7 +431,7 @@ static void send_keyboard(report_keyboard_t *report) Endpoint_SelectEndpoint(NKRO_IN_EPNUM); /* Check if write ready for a polling interval around 1ms */ - while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(4); + while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(8); if (!Endpoint_IsReadWriteAllowed()) return; /* Write Keyboard Report Data */ From 5617648f32ce77fe0cddc3c8969abd92ce485368 Mon Sep 17 00:00:00 2001 From: X64051 Date: Sat, 24 Jun 2017 20:54:46 +0200 Subject: [PATCH 082/217] remove unused functions --- protocol/xt.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/protocol/xt.h b/protocol/xt.h index 55efd75d..ef1bbfaf 100644 --- a/protocol/xt.h +++ b/protocol/xt.h @@ -56,20 +56,5 @@ static inline uint16_t wait_clock_lo(uint16_t us) while (clock_in() && us) { asm(""); wait_us(1); us--; } return us; } -static inline uint16_t wait_clock_hi(uint16_t us) -{ - while (!clock_in() && us) { asm(""); wait_us(1); us--; } - return us; -} -static inline uint16_t wait_data_lo(uint16_t us) -{ - while (data_in() && us) { asm(""); wait_us(1); us--; } - return us; -} -static inline uint16_t wait_data_hi(uint16_t us) -{ - while (!data_in() && us) { asm(""); wait_us(1); us--; } - return us; -} #endif From 75f747e731dfcbf8bf7632145308bc5a883d4bcf Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 7 Sep 2017 09:00:57 +0900 Subject: [PATCH 083/217] core: Fix dfu-programmer version check --- rules.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rules.mk b/rules.mk index 66b4cbd8..0d0b6afb 100644 --- a/rules.mk +++ b/rules.mk @@ -427,7 +427,7 @@ dfu: $(TARGET).hex done @echo -ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1))) +ifneq (, $(findstring 0.7, $(shell dfu-programmer 2>/dev/null && dfu-programmer --version 2>&1))) dfu-programmer $(MCU) erase --force else dfu-programmer $(MCU) erase @@ -447,7 +447,7 @@ flip-ee: $(TARGET).hex $(TARGET).eep $(REMOVE) $(TARGET)eep.hex dfu-ee: $(TARGET).hex $(TARGET).eep -ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1))) +ifneq (, $(findstring 0.7, $(shell dfu-programmer 2>/dev/null && dfu-programmer --version 2>&1))) dfu-programmer $(MCU) flash --eeprom $(TARGET).eep else dfu-programmer $(MCU) flash-eeprom $(TARGET).eep From 4743ab2ce3d4cedae0d97be58ac4dfc343bd6015 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 14 Sep 2017 12:56:35 +0900 Subject: [PATCH 084/217] core: Fix for ATtiny85 --- common/avr/suspend.c | 2 ++ common/avr/timer.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/common/avr/suspend.c b/common/avr/suspend.c index 02d7e4c9..0e13eb69 100644 --- a/common/avr/suspend.c +++ b/common/avr/suspend.c @@ -72,11 +72,13 @@ static void power_down(uint8_t wdto) static void standby(void) { +#ifdef SLEEP_MODE_STANDBY set_sleep_mode(SLEEP_MODE_STANDBY); sleep_enable(); sei(); sleep_cpu(); sleep_disable(); +#endif } static void idle(void) diff --git a/common/avr/timer.c b/common/avr/timer.c index 292b41c3..1aa4a6a8 100644 --- a/common/avr/timer.c +++ b/common/avr/timer.c @@ -46,7 +46,11 @@ void timer_init(void) #endif OCR0A = TIMER_RAW_TOP; +#ifdef TIMSK0 TIMSK0 = (1< Date: Thu, 14 Sep 2017 12:58:06 +0900 Subject: [PATCH 085/217] core: Fix for build option NO_ACTION_LAYER --- common/action_layer.c | 3 +-- common/action_layer.h | 16 ---------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/common/action_layer.c b/common/action_layer.c index 46401eba..31d659b7 100644 --- a/common/action_layer.c +++ b/common/action_layer.c @@ -122,9 +122,8 @@ void layer_debug(void) /* return layer effective for key at this time */ static uint8_t current_layer_for_key(keypos_t key) { - action_t action = ACTION_TRANSPARENT; - #ifndef NO_ACTION_LAYER + action_t action = ACTION_TRANSPARENT; uint32_t layers = layer_state | default_layer_state; /* check top layer first */ for (int8_t i = 31; i >= 0; i--) { diff --git a/common/action_layer.h b/common/action_layer.h index ba8b0638..2811cd7c 100644 --- a/common/action_layer.h +++ b/common/action_layer.h @@ -34,10 +34,6 @@ void default_layer_set(uint32_t state); void default_layer_or(uint32_t state); void default_layer_and(uint32_t state); void default_layer_xor(uint32_t state); -#else -#define default_layer_or(state) -#define default_layer_and(state) -#define default_layer_xor(state) #endif @@ -56,18 +52,6 @@ void layer_invert(uint8_t layer); void layer_or(uint32_t state); void layer_and(uint32_t state); void layer_xor(uint32_t state); -#else -#define layer_state 0 -#define layer_clear() -#define layer_move(layer) -#define layer_on(layer) -#define layer_off(layer) -#define layer_invert(layer) - -#define layer_or(state) -#define layer_and(state) -#define layer_xor(state) -#define layer_debug() #endif From 9bc51e1d67ec5ead13bb53d8dd49e9ce29eb0aa7 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 14 Sep 2017 22:35:41 +0900 Subject: [PATCH 086/217] core: Remove unused file in vusb --- protocol/vusb/sendchar_usart.c | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 protocol/vusb/sendchar_usart.c diff --git a/protocol/vusb/sendchar_usart.c b/protocol/vusb/sendchar_usart.c deleted file mode 100644 index 8d24f87d..00000000 --- a/protocol/vusb/sendchar_usart.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH - * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) - */ -#include -#include "oddebug.h" -#include "sendchar.h" - - -#if DEBUG_LEVEL > 0 -/* from oddebug.c */ -int8_t sendchar(uint8_t c) -{ - while(!(ODDBG_USR & (1 << ODDBG_UDRE))); /* wait for data register empty */ - ODDBG_UDR = c; - return 1; -} -#else -int8_t sendchar(uint8_t c) -{ - return 1; -} -#endif From e80a587bdb647f412a9f867cbc08e1d03d3b08c2 Mon Sep 17 00:00:00 2001 From: lactide Date: Sun, 15 Oct 2017 10:06:32 +0200 Subject: [PATCH 087/217] Fix for ChibiOS Update tmk/tmk_keyboard#411 --- protocol/chibios/usb_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/chibios/usb_main.c b/protocol/chibios/usb_main.c index 18104ac8..23e4f37e 100644 --- a/protocol/chibios/usb_main.c +++ b/protocol/chibios/usb_main.c @@ -1033,7 +1033,7 @@ void init_usb_driver(USBDriver *usbp) { chVTObjectInit(&keyboard_idle_timer); #ifdef CONSOLE_ENABLE - obqObjectInit(&console_buf_queue, console_queue_buffer, CONSOLE_EPSIZE, CONSOLE_QUEUE_CAPACITY, console_queue_onotify, (void*)usbp); + obqObjectInit(&console_buf_queue, true, console_queue_buffer, CONSOLE_EPSIZE, CONSOLE_QUEUE_CAPACITY, console_queue_onotify, (void*)usbp); chVTObjectInit(&console_flush_timer); #endif } From 1087c1368a396f62f49aa6b651efab74a9550a80 Mon Sep 17 00:00:00 2001 From: Mark Furland Date: Sun, 15 Oct 2017 13:21:18 -0400 Subject: [PATCH 088/217] Move all ChibiOS install documentation to once place Moved to tmk_core/protocol/chibios/README.md --- protocol/chibios/README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/protocol/chibios/README.md b/protocol/chibios/README.md index 2fadc799..49b0dfd3 100644 --- a/protocol/chibios/README.md +++ b/protocol/chibios/README.md @@ -4,9 +4,15 @@ This code can be used to run TMK keyboard logic on top of [ChibiOS], meaning tha ### Usage -- To use, get a [zip file](https://github.com/ChibiOS/ChibiOS/archive/a7df9a891067621e8e1a5c2a2c0ceada82403afe.zip) of ChibiOS and unpack/rename it to `tmk_core/tool/chibios/ChibiOS`; or you can just clone [ChibiOS repo](https://github.com/ChibiOS/ChibiOS) there. For Freescale/NXP Kinetis support (meaning Teensies 3.x/LC and the Infinity keyboard), you'll also need a [zip](https://github.com/ChibiOS/ChibiOS-Contrib/archive/e1311c4db6cd366cf760673f769e925741ac0ad3.zip) of ChibiOS-Contrib, unpacked/renamed to `tmk_core/tool/chibios/ChibiOS-Contrib`. Likewise, for git-savvy people, just clone [ChibiOS-Contrib repo](https://github.com/ChibiOS/ChibiOS-Contrib) there. -- Note: the above mentioned directories are the defaults. You can have the two ChibiOS repositories wherever you want, just define their location in `CHIBIOS` and `CHIBIOS_CONTRIB` variables in your `Makefile`. -- You will also need to install an ARM toolchain, for instance from [here](https://launchpad.net/gcc-arm-embedded). On linux, this is usually also present as a package for your distribution (as `gcc-arm` or something similar). On OS X, you can use [homebrew](http://brew.sh/) with an appropriate tap. +- To use, get a [zip file](https://github.com/ChibiOS/ChibiOS/archive/stable_17.6.x.zip) of ChibiOS and unpack/rename it to `tmk_core/tool/chibios/ChibiOS`; or you can just clone [ChibiOS/ChibiOS](https://github.com/ChibiOS/ChibiOS) there. +If you use git, make sure to check out the most recent stable branch such as `stable_17.6.x` +For Freescale/NXP Kinetis support (meaning Teensies 3.x/LC and the Infinity keyboard), you'll also need a [zip](https://github.com/ChibiOS/ChibiOS-Contrib/archive/master.zip) of ChibiOS-Contrib, unpacked/renamed to `tmk_core/tool/chibios/ChibiOS-Contrib`. +Likewise, for git-savvy people, just clone [ChibiOS/ChibiOS-Contrib](https://github.com/ChibiOS/ChibiOS-Contrib) there. +- Note: the above mentioned directories are the defaults. +You can have the two ChibiOS repositories wherever you want, just define their location in `CHIBIOS` and `CHIBIOS_CONTRIB` variables in your `Makefile`. +- You will also need to install an ARM toolchain, for instance from [here](https://launchpad.net/gcc-arm-embedded). +On linux, this is usually also present as a package for your distribution (as `gcc-arm` or something similar). +On OS X, you can use [homebrew](http://brew.sh/) with an appropriate tap. ### Notes From 45d350c27e5c49112413ae3d92476c4f81aaa23f Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 22 Oct 2017 03:09:20 +0900 Subject: [PATCH 089/217] core: Fix out-of-bounds access by TICK event #487 The error is caused in layer_swtich_get_action() and fails to access layer_pressed[][] --- common/action.c | 2 ++ common/action_layer.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/common/action.c b/common/action.c index 05aa12ee..305816d4 100644 --- a/common/action.c +++ b/common/action.c @@ -531,6 +531,8 @@ void clear_keyboard_but_mods(void) bool is_tap_key(keyevent_t event) { + if (IS_NOEVENT(event)) { return false; } + action_t action = layer_switch_get_action(event); switch (action.kind.id) { diff --git a/common/action_layer.c b/common/action_layer.c index 31d659b7..be316697 100644 --- a/common/action_layer.c +++ b/common/action_layer.c @@ -148,6 +148,8 @@ static uint8_t layer_pressed[MATRIX_ROWS][MATRIX_COLS] = {}; #endif action_t layer_switch_get_action(keyevent_t event) { + if (IS_NOEVENT(event)) return (action_t)ACTION_NO; + uint8_t layer = 0; #ifndef NO_TRACK_KEY_PRESS if (event.pressed) { From c15d6a1be9138ea393c7e9d93fc749f4106e408e Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 26 Oct 2017 14:37:52 +0900 Subject: [PATCH 090/217] core: Fix doc/keymap.md for bitwise operation --- doc/keymap.md | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/doc/keymap.md b/doc/keymap.md index e1dc167e..630966fc 100644 --- a/doc/keymap.md +++ b/doc/keymap.md @@ -292,7 +292,7 @@ You can specify a **target layer** of action and **when the action is executed** + **layer**: `0`-`31` + **on**: { `ON_PRESS` | `ON_RELEASE` | `ON_BOTH` } -+ **bits**: 4-bit value and 1-bit mask bit ++ **bits**: 5-bit: 1-bit for mask and 4-bit for operand #### 2.2.1 Default Layer @@ -365,20 +365,44 @@ Turns on layer only and clear all layer on release.. #### 2.2.10 Bitwise operation - -**part** indicates which part of 32bit layer state(0-7). **bits** is 5-bit value. **on** indicates when the action is executed. +Performs bitwise operaiton(AND, OR, XOR, SET) against layer state. ACTION_LAYER_BIT_AND(part, bits, on) ACTION_LAYER_BIT_OR(part, bits, on) ACTION_LAYER_BIT_XOR(part, bits, on) ACTION_LAYER_BIT_SET(part, bits, on) -These actions works with parameters as following code. +`part` paramter indicates 0-based index(0-7) of where breaking 32-bit `layer_state` into eight nibbles(4-bit unit). - uint8_t shift = part*4; - uint32_t mask = (bits&0x10) ? ~(0xf< ((bits<) { + case BIT_AND: + layer_state = layer_state & (((bits&0xf)< (((bits&0xf)< Date: Wed, 3 Jan 2018 11:06:08 +0800 Subject: [PATCH 091/217] fix not correctly showing 32u2 warning message when Endpints are more than 4. --- protocol/lufa/descriptor.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/protocol/lufa/descriptor.h b/protocol/lufa/descriptor.h index 119f4298..4af872b7 100644 --- a/protocol/lufa/descriptor.h +++ b/protocol/lufa/descriptor.h @@ -145,9 +145,10 @@ typedef struct #ifdef NKRO_ENABLE # define NKRO_IN_EPNUM (CONSOLE_OUT_EPNUM + 1) -# if defined(__AVR_ATmega32U2__) && NKRO_IN_EPNUM > 4 -# error "Endpoints are not available enough to support all functions. Remove some in Makefile.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO)" -# endif +#endif + +#if defined(__AVR_ATmega32U2__) && NKRO_IN_EPNUM > 4 +# error "Endpoints are not available enough to support all functions. Remove some in Makefile.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO)" #endif From f38a9300b058b257f12ef1f1e5fd39a9780a809b Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 4 Jan 2018 13:12:14 +0900 Subject: [PATCH 092/217] core: LUFA: Fix checking num of endpoints for 32u2 --- protocol/lufa/descriptor.h | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/protocol/lufa/descriptor.h b/protocol/lufa/descriptor.h index 4af872b7..8aaa32c5 100644 --- a/protocol/lufa/descriptor.h +++ b/protocol/lufa/descriptor.h @@ -121,34 +121,33 @@ typedef struct // Endopoint number and size -#define KEYBOARD_IN_EPNUM 1 +#define CUR_EPNUM 1 +#define KEYBOARD_IN_EPNUM CUR_EPNUM #ifdef MOUSE_ENABLE -# define MOUSE_IN_EPNUM (KEYBOARD_IN_EPNUM + 1) -#else -# define MOUSE_IN_EPNUM KEYBOARD_IN_EPNUM +# define CUR_EPNUM (CUR_EPNUM + 1) +# define MOUSE_IN_EPNUM CUR_EPNUM #endif #ifdef EXTRAKEY_ENABLE -# define EXTRAKEY_IN_EPNUM (MOUSE_IN_EPNUM + 1) -#else -# define EXTRAKEY_IN_EPNUM MOUSE_IN_EPNUM +# define CUR_EPNUM (CUR_EPNUM + 1) +# define EXTRAKEY_IN_EPNUM CUR_EPNUM #endif #ifdef CONSOLE_ENABLE -# define CONSOLE_IN_EPNUM (EXTRAKEY_IN_EPNUM + 1) -# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 1) -//# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 2) -#else -# define CONSOLE_OUT_EPNUM EXTRAKEY_IN_EPNUM +# define CUR_EPNUM (CUR_EPNUM + 1) +# define CONSOLE_IN_EPNUM CUR_EPNUM +# define CONSOLE_OUT_EPNUM CUR_EPNUM #endif #ifdef NKRO_ENABLE -# define NKRO_IN_EPNUM (CONSOLE_OUT_EPNUM + 1) +# define CUR_EPNUM (CUR_EPNUM + 1) +# define NKRO_IN_EPNUM CUR_EPNUM #endif -#if defined(__AVR_ATmega32U2__) && NKRO_IN_EPNUM > 4 -# error "Endpoints are not available enough to support all functions. Remove some in Makefile.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO)" +/* Check number of endpoints. ATmega32u2 has only four except for control endpoint. */ +#if defined(__AVR_ATmega32U2__) && CUR_EPNUM > 4 +# error "Endpoints are not available enough to support all functions. Disable some of build options in Makefile.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO)" #endif From de78b4b30359ab6d62c110bc48e8db45da8ed608 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 4 Jan 2018 16:39:44 +0900 Subject: [PATCH 093/217] Revert "core: LUFA: Fix checking num of endpoints for 32u2" This reverts commit a567fec91c0f9020cf050ae80410b891486f2ba3. --- protocol/lufa/descriptor.h | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/protocol/lufa/descriptor.h b/protocol/lufa/descriptor.h index 8aaa32c5..4af872b7 100644 --- a/protocol/lufa/descriptor.h +++ b/protocol/lufa/descriptor.h @@ -121,33 +121,34 @@ typedef struct // Endopoint number and size -#define CUR_EPNUM 1 -#define KEYBOARD_IN_EPNUM CUR_EPNUM +#define KEYBOARD_IN_EPNUM 1 #ifdef MOUSE_ENABLE -# define CUR_EPNUM (CUR_EPNUM + 1) -# define MOUSE_IN_EPNUM CUR_EPNUM +# define MOUSE_IN_EPNUM (KEYBOARD_IN_EPNUM + 1) +#else +# define MOUSE_IN_EPNUM KEYBOARD_IN_EPNUM #endif #ifdef EXTRAKEY_ENABLE -# define CUR_EPNUM (CUR_EPNUM + 1) -# define EXTRAKEY_IN_EPNUM CUR_EPNUM +# define EXTRAKEY_IN_EPNUM (MOUSE_IN_EPNUM + 1) +#else +# define EXTRAKEY_IN_EPNUM MOUSE_IN_EPNUM #endif #ifdef CONSOLE_ENABLE -# define CUR_EPNUM (CUR_EPNUM + 1) -# define CONSOLE_IN_EPNUM CUR_EPNUM -# define CONSOLE_OUT_EPNUM CUR_EPNUM +# define CONSOLE_IN_EPNUM (EXTRAKEY_IN_EPNUM + 1) +# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 1) +//# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 2) +#else +# define CONSOLE_OUT_EPNUM EXTRAKEY_IN_EPNUM #endif #ifdef NKRO_ENABLE -# define CUR_EPNUM (CUR_EPNUM + 1) -# define NKRO_IN_EPNUM CUR_EPNUM +# define NKRO_IN_EPNUM (CONSOLE_OUT_EPNUM + 1) #endif -/* Check number of endpoints. ATmega32u2 has only four except for control endpoint. */ -#if defined(__AVR_ATmega32U2__) && CUR_EPNUM > 4 -# error "Endpoints are not available enough to support all functions. Disable some of build options in Makefile.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO)" +#if defined(__AVR_ATmega32U2__) && NKRO_IN_EPNUM > 4 +# error "Endpoints are not available enough to support all functions. Remove some in Makefile.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO)" #endif From 2fa345ba2ede0aab253f5ba16d534314c20ff6f8 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 4 Jan 2018 16:49:24 +0900 Subject: [PATCH 094/217] core: lufa: Fix checking num of endpoints for 32u2(again) --- protocol/lufa/descriptor.h | 6 ++++-- protocol/lufa/lufa.c | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/protocol/lufa/descriptor.h b/protocol/lufa/descriptor.h index 4af872b7..63491117 100644 --- a/protocol/lufa/descriptor.h +++ b/protocol/lufa/descriptor.h @@ -138,17 +138,19 @@ typedef struct #ifdef CONSOLE_ENABLE # define CONSOLE_IN_EPNUM (EXTRAKEY_IN_EPNUM + 1) # define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 1) -//# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 2) #else # define CONSOLE_OUT_EPNUM EXTRAKEY_IN_EPNUM #endif #ifdef NKRO_ENABLE # define NKRO_IN_EPNUM (CONSOLE_OUT_EPNUM + 1) +#else +# define NKRO_IN_EPNUM CONSOLE_OUT_EPNUM #endif +/* Check number of endpoints. ATmega32u2 has only four except for control endpoint. */ #if defined(__AVR_ATmega32U2__) && NKRO_IN_EPNUM > 4 -# error "Endpoints are not available enough to support all functions. Remove some in Makefile.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO)" +# error "Endpoints are not available enough to support all functions. Disable some of build options in Makefile.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO)" #endif diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index 076c8c8d..1fd6eb34 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -482,6 +482,7 @@ static void send_mouse(report_mouse_t *report) static void send_system(uint16_t data) { +#ifdef EXTRAKEY_ENABLE uint8_t timeout = 255; if (USB_DeviceState != DEVICE_STATE_Configured) @@ -499,10 +500,12 @@ static void send_system(uint16_t data) Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); Endpoint_ClearIN(); +#endif } static void send_consumer(uint16_t data) { +#ifdef EXTRAKEY_ENABLE uint8_t timeout = 255; if (USB_DeviceState != DEVICE_STATE_Configured) @@ -520,6 +523,7 @@ static void send_consumer(uint16_t data) Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); Endpoint_ClearIN(); +#endif } From 0e081557e53bb55786c089fbb4ba3a14b0c01e8d Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 14 Jan 2018 07:54:31 +0900 Subject: [PATCH 095/217] core: Fix for warning of unused label. #515 --- common/keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/keyboard.c b/common/keyboard.c index 6057ea13..864db2b2 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -148,7 +148,7 @@ void keyboard_task(void) // call with pseudo tick event when no real key event. action_exec(TICK); -MATRIX_LOOP_END: +//MATRIX_LOOP_END: hook_keyboard_loop(); From b30d2c36c7aecf503be75f8c0c4f7683efb4ebb8 Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 14 Jan 2018 08:14:16 +0900 Subject: [PATCH 096/217] core: Fix for warning of unused function standby() --- common/avr/suspend.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/avr/suspend.c b/common/avr/suspend.c index 0e13eb69..ea8099d0 100644 --- a/common/avr/suspend.c +++ b/common/avr/suspend.c @@ -70,6 +70,7 @@ static void power_down(uint8_t wdto) wdt_disable(); } +#ifdef SUSPEND_MODE_STANDBY static void standby(void) { #ifdef SLEEP_MODE_STANDBY @@ -80,6 +81,7 @@ static void standby(void) sleep_disable(); #endif } +#endif static void idle(void) { From cd0db15a26aca73294516653c7b7065ba2f49ab2 Mon Sep 17 00:00:00 2001 From: alex-ong Date: Mon, 22 Jan 2018 13:55:11 +1100 Subject: [PATCH 097/217] core: Fix for unused function when compiling without MOUSEKEY_ENABLE --- common/command.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/command.c b/common/command.c index bb471e88..688e460e 100644 --- a/common/command.c +++ b/common/command.c @@ -629,6 +629,7 @@ static bool mousekey_console(uint8_t code) /*********************************************************** * Utilities ***********************************************************/ +#if MOUSEKEY_ENABLE static uint8_t numkey2num(uint8_t code) { switch (code) { @@ -645,6 +646,7 @@ static uint8_t numkey2num(uint8_t code) } return 0; } +#endif static void switch_default_layer(uint8_t layer) { From 95e0c998c06f0b0c55001f01de4e1e4940f74eec Mon Sep 17 00:00:00 2001 From: alex-ong Date: Mon, 22 Jan 2018 14:50:38 +1100 Subject: [PATCH 098/217] core: Fix for un-defined function when compiling without MOUSEKEY_ENABLE --- common/command.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/command.c b/common/command.c index 688e460e..e08f91e5 100644 --- a/common/command.c +++ b/common/command.c @@ -57,9 +57,10 @@ static void command_console_help(void); #ifdef MOUSEKEY_ENABLE static bool mousekey_console(uint8_t code); static void mousekey_console_help(void); +static uint8_t numkey2num(uint8_t code); #endif -static uint8_t numkey2num(uint8_t code); + static void switch_default_layer(uint8_t layer); From f26b74eb38fe7fe50bfc8e72d0f6ef283ab4b50b Mon Sep 17 00:00:00 2001 From: Alex Ong Date: Tue, 23 Jan 2018 19:43:45 +1100 Subject: [PATCH 099/217] Typos (#524) * GH60: Found a typo * Typo: Another typo * Typo: More typos --- doc/keymap.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/keymap.md b/doc/keymap.md index 630966fc..dfb80797 100644 --- a/doc/keymap.md +++ b/doc/keymap.md @@ -68,7 +68,7 @@ The **default layer** is the base keymap layer (0-31) which is always active and Note that the `default_layer_state` variable only determines the lowest value to which `layer_state` may be set, and that `default_layer_state` is used by the core firmware when determining the starting value of `layer_state` before applying changes. In other words, the default layer will *always* be set to *on* in `layer_state`. -The default layer is defined in the firmware by the `default_layer_state` variable, which is identical in format to the `layer_state` variable exlpained above. The value may be changed using the following functions: +The default layer is defined in the firmware by the `default_layer_state` variable, which is identical in format to the `layer_state` variable explained above. The value may be changed using the following functions: - `default_layer_state_set(state)` sets the state to the specified 32-bit integer value. - AND/OR/XOR functions set the state based on a boolean logic comparison between the current state and the specified 32-bit integer value: @@ -86,7 +86,7 @@ default_layer_state_set(1UL<<3); ### 0.2 Layer Precedence and Transparency -Note that ***higher layers have priority in the layer stack***. The firmware starts at the topmost active layer, and works down to the bottom to find the an active keycode. Once the search encounters any keycode other than **`KC_TRNS`** (transparent) on an active layer, the search is halted and the remaining lower layers aren't examined, even if they are active. +Note that ***higher layers have priority in the layer stack***. The firmware starts at the topmost active layer, and works down to the bottom to find an active keycode. Once the search encounters any keycode other than **`KC_TRNS`** (transparent) on an active layer, the search is halted and the remaining lower layers aren't examined, even if they are active. **Note:** a layer must be activated before it may be included in the stack search. @@ -365,14 +365,14 @@ Turns on layer only and clear all layer on release.. #### 2.2.10 Bitwise operation -Performs bitwise operaiton(AND, OR, XOR, SET) against layer state. +Performs bitwise operation(AND, OR, XOR, SET) against layer state. ACTION_LAYER_BIT_AND(part, bits, on) ACTION_LAYER_BIT_OR(part, bits, on) ACTION_LAYER_BIT_XOR(part, bits, on) ACTION_LAYER_BIT_SET(part, bits, on) -`part` paramter indicates 0-based index(0-7) of where breaking 32-bit `layer_state` into eight nibbles(4-bit unit). +`part` parameter indicates 0-based index(0-7) of where breaking 32-bit `layer_state` into eight nibbles(4-bit unit). bs @@ -602,7 +602,7 @@ This registers modifier key(s) simultaneously with layer switching. ACTION_LAYER_MODS(2, MOD_LSFT | MOD_LALT) -You can combine four modifiers at most but cannot use both left and right modifiers at a time, either left or right modiiers only can be allowed. +You can combine four modifiers at most but cannot use both left and right modifiers at a time, either left or right modifiers only can be allowed. ## 4. Tapping From f0c8b994b0f22ccbeceed44c5b24f1719e1b8af8 Mon Sep 17 00:00:00 2001 From: Alex Ong Date: Wed, 24 Jan 2018 14:15:56 +1100 Subject: [PATCH 100/217] core: Saved 60~ bytes (and possible performance) by storing col_mask when iterating through columns (#522) --- common/keyboard.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/common/keyboard.c b/common/keyboard.c index 864db2b2..929b862a 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -126,17 +126,18 @@ void keyboard_task(void) matrix_ghost[r] = matrix_row; #endif if (debug_matrix) matrix_print(); - for (uint8_t c = 0; c < MATRIX_COLS; c++) { - if (matrix_change & ((matrix_row_t)1< Date: Fri, 26 Jan 2018 18:18:55 +1100 Subject: [PATCH 101/217] core: Typo (mantrix -> matrix) --- common/keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/keyboard.c b/common/keyboard.c index 929b862a..2302acb7 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -93,7 +93,7 @@ void keyboard_init(void) } /* - * Do keyboard routine jobs: scan mantrix, light LEDs, ... + * Do keyboard routine jobs: scan matrix, light LEDs, ... * This is repeatedly called as fast as possible. */ void keyboard_task(void) From d02701fad4673ac313995f8bc24e61e67e5cdd4a Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 28 Jan 2018 16:17:20 +0900 Subject: [PATCH 102/217] core: Add utility type_code() in aciton.h #528 --- common/action.c | 6 ++++++ common/action.h | 1 + 2 files changed, 7 insertions(+) diff --git a/common/action.c b/common/action.c index 305816d4..9b139d48 100644 --- a/common/action.c +++ b/common/action.c @@ -492,6 +492,12 @@ void unregister_code(uint8_t code) } } +void type_code(uint8_t code) +{ + register_code(code); + unregister_code(code); +} + void register_mods(uint8_t mods) { if (mods) { diff --git a/common/action.h b/common/action.h index 993fc463..84201897 100644 --- a/common/action.h +++ b/common/action.h @@ -62,6 +62,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt); void process_action(keyrecord_t *record); void register_code(uint8_t code); void unregister_code(uint8_t code); +void type_code(uint8_t code); void register_mods(uint8_t mods); void unregister_mods(uint8_t mods); //void set_mods(uint8_t mods); From 51d78cac72c5e24770633a9869a5121e26ae2a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98ystein=20Bech=20Gadmar?= Date: Mon, 29 Jan 2018 00:10:35 +0100 Subject: [PATCH 103/217] core: Add utility macros in action_macro.h (#532) --- common/action_macro.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/common/action_macro.h b/common/action_macro.h index 4cf2216d..73937864 100644 --- a/common/action_macro.h +++ b/common/action_macro.h @@ -105,6 +105,19 @@ enum macro_command_id{ #define RM() RESTORE() /* clear modifier(s) */ #define CM() CLEAR() +/* key shift-type */ +#define ST(key) D(LSFT), T(key), U(LSFT) +/* modifier utility macros */ +/* Example: Ctrl+Alt+[Shift+] is CTL_( ALT_( [S]T(key1), [S]T(key2) )) . */ +#define SFT_(...) D(LSFT), __VA_ARGS__, U(LSFT) +#define CTL_(...) D(LCTL), __VA_ARGS__, U(LCTL) +#define ALT_(...) D(LALT), __VA_ARGS__, U(LALT) +#define AGR_(...) D(RALT), __VA_ARGS__, U(RALT) +/* Unicode macros for XOrg/MacOs/Win. */ +/* Example: UNIW_(0,1,4,9) enters a bullet glyph on Windows using Alt+KeyPad(####). */ +#define UNIX_(d1,d2,d3,d4) CTL_(ST(U)), T(d1), T(d2), T(d3), T(d4) , T(ENT) +#define UNIM_(d1,d2,d3,d4) ALT_( T(d1), T(d2), T(d3), T(d4) ) +#define UNIW_(d1,d2,d3,d4) ALT_( T(P##d1), T(P##d2), T(P##d3), T(P##d4) ) /* for backward comaptibility */ #define MD(key) DOWN(KC_##key) From 0f44384eed1504cf77de7af63d1a36ee37ffb0e5 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 1 Mar 2018 12:36:21 +0900 Subject: [PATCH 104/217] core: lufa: Add delay for console startup --- protocol/lufa/lufa.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index 1fd6eb34..60849aea 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -651,6 +651,17 @@ int main(void) USB_USBTask(); #endif } + + /* wait for Console startup */ + // TODO: long delay often works anyhoo but proper startup would be better + uint16_t delay = 2000; + while (delay--) { +#ifndef INTERRUPT_CONTROL_ENDPOINT + USB_USBTask(); +#endif + _delay_ms(1); + } + print("USB configured.\n"); /* init modules */ From 799af8373bb492372d55fa2284ace02195a58972 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 28 Feb 2018 15:48:06 +0900 Subject: [PATCH 105/217] xt_usb: read data on falling edge soft/hard reset See https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-XT-Keyboard-Protocol - read data on falling edge of clock - add soft reset and hard reset --- protocol.mk | 7 ----- protocol/xt_interrupt.c | 64 +++++++++++++++++++++++++++-------------- protocol/xt_io.h | 3 ++ protocol/xt_io_avr.c | 12 ++++++++ 4 files changed, 58 insertions(+), 28 deletions(-) diff --git a/protocol.mk b/protocol.mk index 2bf05742..47265d80 100644 --- a/protocol.mk +++ b/protocol.mk @@ -26,13 +26,6 @@ ifeq (yes,$(strip $(PS2_USE_USART))) endif -ifeq (yes,$(strip $(XT_USE_INT))) - SRC += protocol/xt_interrupt.c - SRC += protocol/xt_io_avr.c - OPT_DEFS += -DXT_USE_INT -endif - - ifeq (yes,$(strip $(SERIAL_MOUSE_MICROSOFT_ENABLE))) SRC += $(PROTOCOL_DIR)/serial_mouse_microsoft.c OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MICROSOFT \ diff --git a/protocol/xt_interrupt.c b/protocol/xt_interrupt.c index 94b47db4..8c8408ba 100644 --- a/protocol/xt_interrupt.c +++ b/protocol/xt_interrupt.c @@ -51,6 +51,17 @@ POSSIBILITY OF SUCH DAMAGE. void xt_host_init(void) { XT_INT_INIT(); + + /* hard reset */ +#ifdef XT_RESET + XT_RESET(); +#endif + + /* soft reset: pull clock line down for 20ms */ + XT_INT_OFF(); + data_lo(); clock_lo(); + _delay_ms(20); + data_in(); clock_in(); XT_INT_ON(); } @@ -66,29 +77,40 @@ uint8_t xt_host_recv(void) ISR(XT_INT_VECT) { - static uint8_t state = 0; + /* + * XT signal format consits of 10 or 9 clocks and sends start bits and 8-bit data, + * which should be read on falling edge of clock. + * + * start(0), start(1), bit0, bit1, bit2, bit3, bit4, bit5, bit6, bit7 + * + * Original IBM XT keyboard sends start(0) bit while some of clones don't. + * Start(0) bit is read as low on data line while start(1) as high. + * + * https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-XT-Keyboard-Protocol + */ + static enum { + START, BIT0, BIT1, BIT2, BIT3, BIT4, BIT5, BIT6, BIT7, END + } state = START; static uint8_t data = 0; - if (state == 0) { - if (data_in()) - state++; - } else if (state >= 1 && state <= 8) { - wait_clock_lo(20); - data >>= 1; - if (data_in()) - data |= 0x80; - if (state == 8) - goto END; - state++; - } else { - goto DONE; + // This is needed if using PCINT which can be called on both falling and rising edge + if (clock_in()) return; + + switch (state) { + case START: + // ignore start(0) bit + if (!data_in()) return; + break; + case BIT0 ... BIT7: + data >>= 1; + if (data_in()) + data |= 0x80; + break; + } + if (++state == END) { + pbuf_enqueue(data); + state = START; + data = 0; } - goto RETURN; -END: - pbuf_enqueue(data); -DONE: - state = 0; - data = 0; -RETURN: return; } diff --git a/protocol/xt_io.h b/protocol/xt_io.h index 2e5f31b2..4198e655 100644 --- a/protocol/xt_io.h +++ b/protocol/xt_io.h @@ -4,4 +4,7 @@ bool clock_in(void); bool data_in(void); +void clock_lo(void); +void data_lo(void); + #endif diff --git a/protocol/xt_io_avr.c b/protocol/xt_io_avr.c index 6cd153a1..7775be7f 100644 --- a/protocol/xt_io_avr.c +++ b/protocol/xt_io_avr.c @@ -32,3 +32,15 @@ bool data_in(void) _delay_us(1); return XT_DATA_PIN&(1< Date: Fri, 2 Mar 2018 02:31:44 +0900 Subject: [PATCH 106/217] xt_usb: Read data earlier as possible in ISR --- protocol/xt_interrupt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/protocol/xt_interrupt.c b/protocol/xt_interrupt.c index 8c8408ba..5531464d 100644 --- a/protocol/xt_interrupt.c +++ b/protocol/xt_interrupt.c @@ -93,17 +93,18 @@ ISR(XT_INT_VECT) } state = START; static uint8_t data = 0; + uint8_t dbit = data_in(); // This is needed if using PCINT which can be called on both falling and rising edge if (clock_in()) return; switch (state) { case START: // ignore start(0) bit - if (!data_in()) return; + if (!dbit) return; break; case BIT0 ... BIT7: data >>= 1; - if (data_in()) + if (dbit) data |= 0x80; break; } From 485ccdae9f97ce8695667e0af1f06dc040d014d3 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 2 Mar 2018 09:28:03 +0900 Subject: [PATCH 107/217] xt_usb: Comment out clock check for PCINT --- protocol/xt_interrupt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/protocol/xt_interrupt.c b/protocol/xt_interrupt.c index 5531464d..05afefd3 100644 --- a/protocol/xt_interrupt.c +++ b/protocol/xt_interrupt.c @@ -94,8 +94,9 @@ ISR(XT_INT_VECT) static uint8_t data = 0; uint8_t dbit = data_in(); + // This is needed if using PCINT which can be called on both falling and rising edge - if (clock_in()) return; + //if (clock_in()) return; switch (state) { case START: From da5a4823e1059f70f48a5ab8e22358769af3ce91 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 2 Mar 2018 13:56:46 +0900 Subject: [PATCH 108/217] xt_usb: Replace functions with macros --- protocol/xt.h | 15 -------------- protocol/xt_interrupt.c | 13 ++++++++---- protocol/xt_io.h | 27 ++++++++++++++++++++---- protocol/xt_io_avr.c | 46 ----------------------------------------- 4 files changed, 32 insertions(+), 69 deletions(-) delete mode 100644 protocol/xt_io_avr.c diff --git a/protocol/xt.h b/protocol/xt.h index ef1bbfaf..e689109c 100644 --- a/protocol/xt.h +++ b/protocol/xt.h @@ -39,22 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef XT_H #define XT_H -#include -#include "wait.h" -#include "xt_io.h" -#include "print.h" - void xt_host_init(void); uint8_t xt_host_recv(void); - -/*-------------------------------------------------------------------- - * static functions - *------------------------------------------------------------------*/ -static inline uint16_t wait_clock_lo(uint16_t us) -{ - while (clock_in() && us) { asm(""); wait_us(1); us--; } - return us; -} - #endif diff --git a/protocol/xt_interrupt.c b/protocol/xt_interrupt.c index 05afefd3..97e93a5a 100644 --- a/protocol/xt_interrupt.c +++ b/protocol/xt_interrupt.c @@ -51,6 +51,7 @@ POSSIBILITY OF SUCH DAMAGE. void xt_host_init(void) { XT_INT_INIT(); + XT_INT_OFF(); /* hard reset */ #ifdef XT_RESET @@ -58,10 +59,14 @@ void xt_host_init(void) #endif /* soft reset: pull clock line down for 20ms */ - XT_INT_OFF(); - data_lo(); clock_lo(); + XT_DATA_LO(); + XT_CLOCK_LO(); _delay_ms(20); - data_in(); clock_in(); + + /* input mode with pullup */ + XT_CLOCK_IN(); + XT_DATA_IN(); + XT_INT_ON(); } @@ -93,7 +98,7 @@ ISR(XT_INT_VECT) } state = START; static uint8_t data = 0; - uint8_t dbit = data_in(); + uint8_t dbit = XT_DATA_READ(); // This is needed if using PCINT which can be called on both falling and rising edge //if (clock_in()) return; diff --git a/protocol/xt_io.h b/protocol/xt_io.h index 4198e655..8252e1cf 100644 --- a/protocol/xt_io.h +++ b/protocol/xt_io.h @@ -1,10 +1,29 @@ #ifndef XT_IO_H #define XT_IO_H -bool clock_in(void); -bool data_in(void); +#define XT_DATA_IN() do { \ + XT_DATA_DDR &= ~(1< -#include -#include - -/* Check port settings for clock and data line */ -#if !(defined(XT_CLOCK_PORT) && \ - defined(XT_CLOCK_PIN) && \ - defined(XT_CLOCK_DDR) && \ - defined(XT_CLOCK_BIT)) -# error "XT clock port setting is required in config.h" -#endif - -#if !(defined(XT_DATA_PORT) && \ - defined(XT_DATA_PIN) && \ - defined(XT_DATA_DDR) && \ - defined(XT_DATA_BIT)) -# error "XT data port setting is required in config.h" -#endif - -bool clock_in(void) -{ - XT_CLOCK_DDR &= ~(1< Date: Fri, 2 Mar 2018 14:09:09 +0900 Subject: [PATCH 109/217] xt_usb: Fix warning on switch-case --- protocol/xt_interrupt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protocol/xt_interrupt.c b/protocol/xt_interrupt.c index 97e93a5a..525dbcf2 100644 --- a/protocol/xt_interrupt.c +++ b/protocol/xt_interrupt.c @@ -94,7 +94,7 @@ ISR(XT_INT_VECT) * https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-XT-Keyboard-Protocol */ static enum { - START, BIT0, BIT1, BIT2, BIT3, BIT4, BIT5, BIT6, BIT7, END + START, BIT0, BIT1, BIT2, BIT3, BIT4, BIT5, BIT6, BIT7 } state = START; static uint8_t data = 0; @@ -114,7 +114,7 @@ ISR(XT_INT_VECT) data |= 0x80; break; } - if (++state == END) { + if (state++ == BIT7) { pbuf_enqueue(data); state = START; data = 0; From e37466193ca94700f2ab607d25578988a1f0b6ba Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 2 Mar 2018 14:40:21 +0900 Subject: [PATCH 110/217] xt_usb: Remove xt_io.h --- protocol/xt.h | 28 +++++++++++++++++++++++++++- protocol/xt_interrupt.c | 8 ++------ protocol/xt_io.h | 29 ----------------------------- 3 files changed, 29 insertions(+), 36 deletions(-) delete mode 100644 protocol/xt_io.h diff --git a/protocol/xt.h b/protocol/xt.h index e689109c..93bc5daf 100644 --- a/protocol/xt.h +++ b/protocol/xt.h @@ -1,5 +1,5 @@ /* -Copyright 2010,2011,2012,2013 Jun WAKO +Copyright 2018 Jun WAKO Copyright 2016 Ethan Apodaca This software is licensed with a Modified BSD License. @@ -39,6 +39,32 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef XT_H #define XT_H +#define XT_DATA_IN() do { \ + XT_DATA_DDR &= ~(1< +Copyright 2018 Jun WAKO +Copyright 2016 Ethan Apodaca This software is licensed with a Modified BSD License. All of this is supposed to be Free Software, Open Source, DFSG-free, @@ -35,16 +36,11 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* - * PS/2 protocol Pin interrupt version - */ - #include #include #include #include "pbuff.h" #include "xt.h" -#include "xt_io.h" #include "wait.h" #include "print.h" diff --git a/protocol/xt_io.h b/protocol/xt_io.h deleted file mode 100644 index 8252e1cf..00000000 --- a/protocol/xt_io.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef XT_IO_H -#define XT_IO_H - -#define XT_DATA_IN() do { \ - XT_DATA_DDR &= ~(1< Date: Fri, 2 Mar 2018 15:06:38 +0900 Subject: [PATCH 111/217] xt_usb: Replace function with macro --- protocol/xt_interrupt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/xt_interrupt.c b/protocol/xt_interrupt.c index 08af1b9a..a0c55e9c 100644 --- a/protocol/xt_interrupt.c +++ b/protocol/xt_interrupt.c @@ -97,7 +97,7 @@ ISR(XT_INT_VECT) uint8_t dbit = XT_DATA_READ(); // This is needed if using PCINT which can be called on both falling and rising edge - //if (clock_in()) return; + //if (XT_CLOCK_READ()) return; switch (state) { case START: From fc56db4a56c91d9213bf290bffda31baa0d51081 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 18 May 2018 08:34:39 +0900 Subject: [PATCH 112/217] tmk_core: Now expects dfu-programmer 0.7 or later --- rules.mk | 8 -------- 1 file changed, 8 deletions(-) diff --git a/rules.mk b/rules.mk index 0d0b6afb..ca933826 100644 --- a/rules.mk +++ b/rules.mk @@ -427,11 +427,7 @@ dfu: $(TARGET).hex done @echo -ifneq (, $(findstring 0.7, $(shell dfu-programmer 2>/dev/null && dfu-programmer --version 2>&1))) dfu-programmer $(MCU) erase --force -else - dfu-programmer $(MCU) erase -endif dfu-programmer $(MCU) flash $(TARGET).hex dfu-programmer $(MCU) reset @@ -447,11 +443,7 @@ flip-ee: $(TARGET).hex $(TARGET).eep $(REMOVE) $(TARGET)eep.hex dfu-ee: $(TARGET).hex $(TARGET).eep -ifneq (, $(findstring 0.7, $(shell dfu-programmer 2>/dev/null && dfu-programmer --version 2>&1))) dfu-programmer $(MCU) flash --eeprom $(TARGET).eep -else - dfu-programmer $(MCU) flash-eeprom $(TARGET).eep -endif dfu-programmer $(MCU) reset From 302c881cd8f1dcfb1f27e83c3d35f2bc5ba90e66 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 5 Jul 2018 23:18:56 +0900 Subject: [PATCH 113/217] rule.mk: Add dfu-programmer version check again - ubuntu 18.04 still uses old 0.6.1 --- rules.mk | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rules.mk b/rules.mk index ca933826..978f3c06 100644 --- a/rules.mk +++ b/rules.mk @@ -427,9 +427,14 @@ dfu: $(TARGET).hex done @echo +ifeq ($(shell dfu-programmer --version 2>&1 | grep -q 0.7; echo $$?),0) dfu-programmer $(MCU) erase --force +else + dfu-programmer $(MCU) erase +endif + dfu-programmer $(MCU) flash $(TARGET).hex - dfu-programmer $(MCU) reset + dfu-programmer $(MCU) reset || true # ignore exit code dfu-start: dfu-programmer $(MCU) reset From a2d06a815119e4f82813376d08f59003cccab188 Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 14 Jul 2018 11:55:58 +0900 Subject: [PATCH 114/217] usb_usb: Add Cheery 0101010101010101 bug fix https://geekhack.org/index.php?topic=69169.msg2638223#msg2638223 --- protocol/usb_hid/parser.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/protocol/usb_hid/parser.cpp b/protocol/usb_hid/parser.cpp index 94e747ca..730a20d7 100644 --- a/protocol/usb_hid/parser.cpp +++ b/protocol/usb_hid/parser.cpp @@ -6,12 +6,19 @@ void KBDReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) { - ::memcpy(&report, buf, sizeof(report_keyboard_t)); - time_stamp = millis(); - - dprintf("input %d: %02X %02X", hid->GetAddress(), report.mods, report.reserved); - for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { - dprintf(" %02X", report.keys[i]); + dprintf("input %d:", hid->GetAddress()); + for (uint8_t i = 0; i < len; i++) { + dprintf(" %02X", buf[i]); } dprint("\r\n"); + + // ignore Cherry 0101010101010101 bug report + // https://geekhack.org/index.php?topic=69169.msg2638223#msg2638223 + if (buf[1] == 0x01) { + dprint("Cherry bug: ignored\r\n"); + return; + } + + ::memcpy(&report, buf, sizeof(report_keyboard_t)); + time_stamp = millis(); } From 66abfdd5879fe72de8866c43d91f178b52f36c59 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 25 Jul 2018 18:53:38 +0900 Subject: [PATCH 115/217] core: Add ring buffer file --- common/ringbuf.h | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 common/ringbuf.h diff --git a/common/ringbuf.h b/common/ringbuf.h new file mode 100644 index 00000000..23bb41e0 --- /dev/null +++ b/common/ringbuf.h @@ -0,0 +1,73 @@ +#ifndef RINGBUF_H +#define RINGBUF_H + +#include +#include + +// NOTE: buffer size must be 2^n and up to 255. size_mask should be 2^n - 1 due to using &(AND) instead of %(modulo) +typedef struct { + uint8_t *buffer; + uint8_t head; + uint8_t tail; + uint8_t size_mask; +} ringbuf_t; + +static inline void ringbuf_init(ringbuf_t *buf, uint8_t *array, uint8_t size); +static inline int16_t ringbuf_get(ringbuf_t *buf); +static inline bool ringbuf_put(ringbuf_t *buf, uint8_t data); +static inline void ringbuf_write(ringbuf_t *buf, uint8_t data); +static inline bool ringbuf_is_empty(ringbuf_t *buf); +static inline bool ringbuf_is_full(ringbuf_t *buf); +static inline void ringbuf_reset(ringbuf_t *buf); + +static inline void ringbuf_init(ringbuf_t *buf, uint8_t *array, uint8_t size) +{ + buf->buffer = array; + buf->head = 0; + buf->tail = 0; + buf->size_mask = size - 1; +} +static inline int16_t ringbuf_get(ringbuf_t *buf) +{ + if (ringbuf_is_empty(buf)) return -1; + uint8_t data = buf->buffer[buf->tail]; + buf->tail++; + buf->tail &= buf->size_mask; + return data; +} +static inline bool ringbuf_put(ringbuf_t *buf, uint8_t data) +{ + if (ringbuf_is_full(buf)) { + return false; + } + buf->buffer[buf->head] = data; + buf->head++; + buf->head &= buf->size_mask; + return true; +} +// this overrides data in buffer when it is full +static inline void ringbuf_write(ringbuf_t *buf, uint8_t data) +{ + buf->buffer[buf->head] = data; + buf->head++; + buf->head &= buf->size_mask; + // eat tail: override data yet to be consumed + if (buf->head == buf->tail) { + buf->tail++; + buf->tail &= buf->size_mask; + } +} +static inline bool ringbuf_is_empty(ringbuf_t *buf) +{ + return (buf->head == buf->tail); +} +static inline bool ringbuf_is_full(ringbuf_t *buf) +{ + return (((buf->head + 1) & buf->size_mask) == buf->tail); +} +static inline void ringbuf_reset(ringbuf_t *buf) +{ + buf->head = 0; + buf->tail = 0; +} +#endif From acedbf4eb93e499a984e5cb1a2dc0499db195bca Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 10 Sep 2018 09:05:21 +0900 Subject: [PATCH 116/217] core: lufa: Fix console output and init sequence console_putc: Linux: works very well in general Windows: also works very well and connection seems to be faster than Linux Mac: to be: confirmed NOTE: long session of matrix_print still blocks keyboard_task in main loop and prevents it from sending keyboard report. XT protocol buffer overflow occurs when slamng on keys TODO: check when print functions are called in ISR --- protocol/lufa/lufa.c | 206 +++++++++++++++++++------------------------ 1 file changed, 92 insertions(+), 114 deletions(-) diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index 60849aea..4dce8adc 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -43,6 +43,7 @@ #include "action.h" #include "led.h" #include "sendchar.h" +#include "ringbuf.h" #include "debug.h" #ifdef SLEEP_LED_ENABLE #include "sleep_led.h" @@ -89,60 +90,97 @@ host_driver_t lufa_driver = { * Console ******************************************************************************/ #ifdef CONSOLE_ENABLE -static void Console_Task(void) +#define SENDBUF_SIZE 256 +static uint8_t sbuf[SENDBUF_SIZE]; +static ringbuf_t sendbuf = { + .buffer = sbuf, + .head = 0, + .tail = 0, + .size_mask = SENDBUF_SIZE - 1 +}; + +static bool console_putc(uint8_t c) { - /* Device must be connected and configured for the task to run */ + // return immediately if called while interrupt + if (!(SREG & (1< Date: Thu, 20 Sep 2018 22:14:03 +0900 Subject: [PATCH 117/217] core: lufa: Fix timeout of send_keyboard Change 128*40us(5.12ms) to 128*80us(10.24ms) for 6KRO --- protocol/lufa/lufa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index 4dce8adc..cfd76c2e 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -468,7 +468,7 @@ static void send_keyboard(report_keyboard_t *report) Endpoint_SelectEndpoint(KEYBOARD_IN_EPNUM); /* Check if write ready for a polling interval around 10ms */ - while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); + while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(80); if (!Endpoint_IsReadWriteAllowed()) return; /* Write Keyboard Report Data */ From 94fc110f9df0685db39ddef742232939217e95cb Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 23 Sep 2018 11:40:06 +0900 Subject: [PATCH 118/217] core: lufa: Fix wait for console startup --- protocol/lufa/lufa.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index cfd76c2e..b1567fa9 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -634,15 +634,19 @@ int main(void) keyboard_init(); /* wait for Console startup */ - // TODO: long delay often works anyhoo but proper startup would be better - // 1000ms delay of hid_listen may affect this - uint16_t delay = 2000; - while (delay--) { -#ifndef INTERRUPT_CONTROL_ENDPOINT - USB_USBTask(); -#endif - _delay_ms(1); + // TODO: 2000ms delay often works anyhoo but proper startup would be better + // 1000ms delay of hid_listen affects this probably + #ifdef CONSOLE_ENABLE + if (debug_enable) { + uint16_t delay = 2000; + while (delay--) { + #ifndef INTERRUPT_CONTROL_ENDPOINT + USB_USBTask(); + #endif + _delay_ms(1); + } } + #endif hook_late_init(); From 8411a4b06f663ed4016564f6786a82c60a7514ae Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 11 Sep 2018 01:11:06 +0900 Subject: [PATCH 119/217] xt_usb: Change ring buffer and control Data line --- protocol/xt_interrupt.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/protocol/xt_interrupt.c b/protocol/xt_interrupt.c index a0c55e9c..ebaa436b 100644 --- a/protocol/xt_interrupt.c +++ b/protocol/xt_interrupt.c @@ -39,10 +39,20 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include "pbuff.h" #include "xt.h" #include "wait.h" #include "print.h" +#include "ringbuf.h" + + +#define BUF_SIZE 16 +static uint8_t buf[BUF_SIZE]; +static ringbuf_t rb = { + .buffer = buf, + .head = 0, + .tail = 0, + .size_mask = BUF_SIZE - 1 +}; void xt_host_init(void) { @@ -69,10 +79,12 @@ void xt_host_init(void) /* get data received by interrupt */ uint8_t xt_host_recv(void) { - if (pbuf_has_data()) { - return pbuf_dequeue(); - } else { + if (ringbuf_is_empty(&rb)) { return 0; + } else { + int16_t d = ringbuf_get(&rb); + XT_DATA_IN(); // ready to receive from keyboard + return d; } } @@ -111,7 +123,11 @@ ISR(XT_INT_VECT) break; } if (state++ == BIT7) { - pbuf_enqueue(data); + ringbuf_put(&rb, data); + if (ringbuf_is_full(&rb)) { + XT_DATA_LO(); // inhibit keyboard sending + print("Full"); + } state = START; data = 0; } From 3439a9d106a707a86ed76d7e7af049506e314260 Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 16 Oct 2018 00:40:14 +0900 Subject: [PATCH 120/217] core: Update console startup for hid_listen --- protocol/lufa/lufa.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index b1567fa9..a709d1f1 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -50,6 +50,7 @@ #endif #include "suspend.h" #include "hook.h" +#include "timer.h" #ifdef LUFA_DEBUG_SUART #include "avr/suart.h" @@ -99,14 +100,31 @@ static ringbuf_t sendbuf = { .size_mask = SENDBUF_SIZE - 1 }; +// TODO: Around 2500ms delay often works anyhoo but proper startup would be better +// 1000ms delay of hid_listen affects this probably +/* wait for Console startup */ +static bool console_is_ready(void) +{ + static bool hid_listen_ready = false; + if (!hid_listen_ready) { + if (timer_read32() < 2500) + return false; + hid_listen_ready = true; + } + return true; +} + static bool console_putc(uint8_t c) { + if (!console_is_ready()) + goto EXIT; + // return immediately if called while interrupt if (!(SREG & (1< Date: Wed, 31 Oct 2018 01:34:01 +0100 Subject: [PATCH 121/217] Fix header guard in tmk_core/common/command.h (#581) --- common/command.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/command.h b/common/command.h index b57a6c1c..961edf15 100644 --- a/common/command.h +++ b/common/command.h @@ -16,7 +16,7 @@ along with this program. If not, see . */ #ifndef COMMAND_H -#define COMMAND +#define COMMAND_H /* TODO: Refactoring */ typedef enum { ONESHOT, CONSOLE, MOUSEKEY } command_state_t; From 5542f5de01ed80255d37158411d9c9ba3cad15bb Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 28 Oct 2018 13:43:59 +0900 Subject: [PATCH 122/217] lufa: usb-usb: Use LUFA startup instead of cusotom - Change keyboard_init() timing and matrix_scan() is called in USB startup wait loop for FC660C - FC660C startup seems to be faster and it doesn't work without this fix when plugin the keyboard and converter at same time --- protocol/lufa/lufa.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index a709d1f1..4a42f789 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -643,6 +643,8 @@ int main(void) sei(); + keyboard_init(); + /* wait for USB startup */ while (USB_DeviceState != DEVICE_STATE_Configured) { #if defined(INTERRUPT_CONTROL_ENDPOINT) @@ -650,10 +652,9 @@ int main(void) #else USB_USBTask(); #endif + matrix_scan(); } - keyboard_init(); - hook_late_init(); print("\nKeyboard start.\n"); From 968eecaff7a50781838ccd42782d42f36f72c917 Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 30 Oct 2018 17:25:20 +0900 Subject: [PATCH 123/217] usb_hid: Remove USB_Host_Shield_2.0 --- .../USB_Host_Shield_2.0/.gitattributes | 23 - .../usb_hid/USB_Host_Shield_2.0/.gitignore | 4 - .../usb_hid/USB_Host_Shield_2.0/.gitmodules | 12 - protocol/usb_hid/USB_Host_Shield_2.0/BTD.cpp | 1364 -------------- protocol/usb_hid/USB_Host_Shield_2.0/BTD.h | 620 ------- .../usb_hid/USB_Host_Shield_2.0/BTHID.cpp | 399 ----- protocol/usb_hid/USB_Host_Shield_2.0/BTHID.h | 155 -- .../usb_hid/USB_Host_Shield_2.0/PS3BT.cpp | 634 ------- protocol/usb_hid/USB_Host_Shield_2.0/PS3BT.h | 240 --- .../usb_hid/USB_Host_Shield_2.0/PS3Enums.h | 141 -- .../usb_hid/USB_Host_Shield_2.0/PS3USB.cpp | 572 ------ protocol/usb_hid/USB_Host_Shield_2.0/PS3USB.h | 303 ---- protocol/usb_hid/USB_Host_Shield_2.0/PS4BT.h | 121 -- .../usb_hid/USB_Host_Shield_2.0/PS4Parser.cpp | 116 -- .../usb_hid/USB_Host_Shield_2.0/PS4Parser.h | 407 ----- protocol/usb_hid/USB_Host_Shield_2.0/PS4USB.h | 130 -- .../usb_hid/USB_Host_Shield_2.0/PSBuzz.cpp | 82 - protocol/usb_hid/USB_Host_Shield_2.0/PSBuzz.h | 185 -- .../usb_hid/USB_Host_Shield_2.0/README.md | 351 ---- protocol/usb_hid/USB_Host_Shield_2.0/SPP.cpp | 829 --------- protocol/usb_hid/USB_Host_Shield_2.0/SPP.h | 225 --- protocol/usb_hid/USB_Host_Shield_2.0/Usb.cpp | 812 --------- protocol/usb_hid/USB_Host_Shield_2.0/Usb.h | 41 - .../usb_hid/USB_Host_Shield_2.0/UsbCore.h | 298 ---- protocol/usb_hid/USB_Host_Shield_2.0/Wii.cpp | 1268 ------------- protocol/usb_hid/USB_Host_Shield_2.0/Wii.h | 518 ------ .../USB_Host_Shield_2.0/WiiCameraReadme.md | 13 - .../usb_hid/USB_Host_Shield_2.0/XBOXOLD.cpp | 337 ---- .../usb_hid/USB_Host_Shield_2.0/XBOXOLD.h | 185 -- .../usb_hid/USB_Host_Shield_2.0/XBOXONE.cpp | 374 ---- .../usb_hid/USB_Host_Shield_2.0/XBOXONE.h | 172 -- .../usb_hid/USB_Host_Shield_2.0/XBOXRECV.cpp | 583 ------ .../usb_hid/USB_Host_Shield_2.0/XBOXRECV.h | 276 --- .../usb_hid/USB_Host_Shield_2.0/XBOXUSB.cpp | 361 ---- .../usb_hid/USB_Host_Shield_2.0/XBOXUSB.h | 225 --- .../usb_hid/USB_Host_Shield_2.0/address.h | 282 --- protocol/usb_hid/USB_Host_Shield_2.0/adk.cpp | 371 ---- protocol/usb_hid/USB_Host_Shield_2.0/adk.h | 140 -- .../usb_hid/USB_Host_Shield_2.0/avrpins.h | 1130 ------------ .../USB_Host_Shield_2.0/cdc_XR21B1411.cpp | 211 --- .../USB_Host_Shield_2.0/cdc_XR21B1411.h | 272 --- .../usb_hid/USB_Host_Shield_2.0/cdcacm.cpp | 331 ---- protocol/usb_hid/USB_Host_Shield_2.0/cdcacm.h | 252 --- .../usb_hid/USB_Host_Shield_2.0/cdcftdi.cpp | 334 ---- .../usb_hid/USB_Host_Shield_2.0/cdcftdi.h | 145 -- .../USB_Host_Shield_2.0/cdcprolific.cpp | 247 --- .../usb_hid/USB_Host_Shield_2.0/cdcprolific.h | 159 -- .../USB_Host_Shield_2.0/confdescparser.h | 213 --- .../USB_Host_Shield_2.0/controllerEnums.h | 204 --- .../examples/Bluetooth/BTHID/BTHID.ino | 55 - .../examples/Bluetooth/BTHID/KeyboardParser.h | 105 -- .../examples/Bluetooth/BTHID/MouseParser.h | 46 - .../examples/Bluetooth/PS3BT/PS3BT.ino | 188 -- .../examples/Bluetooth/PS3Multi/PS3Multi.ino | 149 -- .../examples/Bluetooth/PS3SPP/PS3SPP.ino | 162 -- .../examples/Bluetooth/PS4BT/PS4BT.ino | 146 -- .../examples/Bluetooth/SPP/SPP.ino | 52 - .../examples/Bluetooth/SPPMulti/SPPMulti.ino | 67 - .../examples/Bluetooth/Wii/Wii.ino | 118 -- .../WiiBalanceBoard/WiiBalanceBoard.ino | 51 - .../Bluetooth/WiiIRCamera/WiiIRCamera.ino | 133 -- .../examples/Bluetooth/WiiMulti/WiiMulti.ino | 132 -- .../WiiUProController/WiiUProController.ino | 104 -- .../HID/USBHIDBootKbd/USBHIDBootKbd.ino | 129 -- .../USBHIDBootKbdAndMouse.ino | 178 -- .../HID/USBHIDBootMouse/USBHIDBootMouse.ino | 83 - .../HID/USBHIDJoystick/USBHIDJoystick.ino | 38 - .../USBHIDJoystick/hidjoystickrptparser.cpp | 84 - .../HID/USBHIDJoystick/hidjoystickrptparser.h | 33 - .../examples/HID/USBHID_desc/USBHID_desc.ino | 77 - .../examples/HID/USBHID_desc/pgmstrings.h | 52 - .../examples/HID/le3dp/le3dp.ino | 42 - .../examples/HID/le3dp/le3dp_rptparser.cpp | 43 - .../examples/HID/le3dp/le3dp_rptparser.h | 42 - .../examples/HID/scale/scale.ino | 51 - .../examples/HID/scale/scale_rptparser.cpp | 150 -- .../examples/HID/scale/scale_rptparser.h | 55 - .../examples/PS3USB/PS3USB.ino | 148 -- .../examples/PS4USB/PS4USB.ino | 133 -- .../examples/PSBuzz/PSBuzz.ino | 49 - .../examples/USB_desc/USB_desc.ino | 349 ---- .../examples/USB_desc/pgmstrings.h | 52 - .../examples/Xbox/XBOXOLD/XBOXOLD.ino | 110 -- .../examples/Xbox/XBOXONE/XBOXONE.ino | 106 -- .../examples/Xbox/XBOXRECV/XBOXRECV.ino | 122 -- .../examples/Xbox/XBOXUSB/XBOXUSB.ino | 113 -- .../acm/acm_terminal/acm_terminal.ino | 100 -- .../examples/acm/acm_terminal/pgmstrings.h | 52 - .../adk/ArduinoBlinkLED/ArduinoBlinkLED.ino | 89 - .../examples/adk/adk_barcode/adk_barcode.ino | 91 - .../examples/adk/demokit_20/demokit_20.ino | 103 -- .../examples/adk/term_test/term_test.ino | 65 - .../examples/adk/term_time/term_time.ino | 50 - .../examples/board_qc/board_qc.ino | 259 --- .../cdc_XR21B1411/XR_terminal/XR_terminal.ino | 83 - .../ftdi/USBFTDILoopback/USBFTDILoopback.ino | 98 - .../ftdi/USBFTDILoopback/pgmstrings.h | 52 - .../examples/hub_demo/hub_demo.ino | 345 ---- .../examples/hub_demo/pgmstrings.h | 52 - .../examples/max_LCD/max_LCD.ino | 29 - .../pl2303_gprs_terminal.ino | 101 -- .../examples/pl2303/pl2303_gps/pl2303_gps.ino | 88 - .../pl2303/pl2303_tinygps/pl2303_tinygps.ino | 217 --- .../pl2303_xbee_terminal.ino | 117 -- .../examples/testusbhostFAT/Makefile | 64 - .../examples/testusbhostFAT/README.md | 29 - .../testusbhostFAT/testusbhostFAT.ino | 736 -------- protocol/usb_hid/USB_Host_Shield_2.0/gpl2.txt | 340 ---- .../usb_hid/USB_Host_Shield_2.0/hexdump.h | 61 - protocol/usb_hid/USB_Host_Shield_2.0/hid.cpp | 112 -- protocol/usb_hid/USB_Host_Shield_2.0/hid.h | 188 -- .../usb_hid/USB_Host_Shield_2.0/hidboot.cpp | 201 --- .../usb_hid/USB_Host_Shield_2.0/hidboot.h | 618 ------- .../hidescriptorparser.cpp | 1588 ----------------- .../USB_Host_Shield_2.0/hidescriptorparser.h | 176 -- .../USB_Host_Shield_2.0/hiduniversal.cpp | 425 ----- .../USB_Host_Shield_2.0/hiduniversal.h | 108 -- .../usb_hid/USB_Host_Shield_2.0/hidusagestr.h | 977 ---------- .../hidusagetitlearrays.cpp | 1048 ----------- .../usb_hid/USB_Host_Shield_2.0/keywords.txt | 371 ---- .../usb_hid/USB_Host_Shield_2.0/library.json | 47 - .../USB_Host_Shield_2.0/library.properties | 9 - protocol/usb_hid/USB_Host_Shield_2.0/macros.h | 82 - .../USB_Host_Shield_2.0/masstorage.cpp | 1266 ------------- .../usb_hid/USB_Host_Shield_2.0/masstorage.h | 571 ------ .../usb_hid/USB_Host_Shield_2.0/max3421e.h | 228 --- .../usb_hid/USB_Host_Shield_2.0/max_LCD.cpp | 255 --- .../usb_hid/USB_Host_Shield_2.0/max_LCD.h | 106 -- .../usb_hid/USB_Host_Shield_2.0/message.cpp | 116 -- .../usb_hid/USB_Host_Shield_2.0/message.h | 78 - .../USB_Host_Shield_2.0/parsetools.cpp | 67 - .../usb_hid/USB_Host_Shield_2.0/parsetools.h | 140 -- .../usb_hid/USB_Host_Shield_2.0/printhex.h | 84 - .../usb_hid/USB_Host_Shield_2.0/settings.h | 139 -- .../usb_hid/USB_Host_Shield_2.0/sink_parser.h | 41 - .../usb_hid/USB_Host_Shield_2.0/usb_ch9.h | 166 -- .../usb_hid/USB_Host_Shield_2.0/usbhost.h | 529 ------ .../usb_hid/USB_Host_Shield_2.0/usbhub.cpp | 425 ----- protocol/usb_hid/USB_Host_Shield_2.0/usbhub.h | 252 --- .../USB_Host_Shield_2.0/version_helper.h | 194 -- .../usb_hid/USB_Host_Shield_2.0/xboxEnums.h | 65 - 141 files changed, 34307 deletions(-) delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/.gitattributes delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/.gitignore delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/.gitmodules delete mode 100755 protocol/usb_hid/USB_Host_Shield_2.0/BTD.cpp delete mode 100755 protocol/usb_hid/USB_Host_Shield_2.0/BTD.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/BTHID.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/BTHID.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/PS3BT.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/PS3BT.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/PS3Enums.h delete mode 100755 protocol/usb_hid/USB_Host_Shield_2.0/PS3USB.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/PS3USB.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/PS4BT.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/PS4Parser.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/PS4Parser.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/PS4USB.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/PSBuzz.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/PSBuzz.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/README.md delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/SPP.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/SPP.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/Usb.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/Usb.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/UsbCore.h delete mode 100755 protocol/usb_hid/USB_Host_Shield_2.0/Wii.cpp delete mode 100755 protocol/usb_hid/USB_Host_Shield_2.0/Wii.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/WiiCameraReadme.md delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/XBOXOLD.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/XBOXOLD.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/XBOXONE.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/XBOXONE.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/XBOXRECV.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/XBOXRECV.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/XBOXUSB.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/XBOXUSB.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/address.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/adk.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/adk.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/avrpins.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/cdc_XR21B1411.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/cdc_XR21B1411.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/cdcacm.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/cdcacm.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/cdcftdi.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/cdcftdi.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/cdcprolific.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/cdcprolific.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/confdescparser.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/controllerEnums.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/BTHID/BTHID.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/BTHID/KeyboardParser.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/BTHID/MouseParser.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/PS3BT/PS3BT.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/PS3Multi/PS3Multi.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/PS3SPP/PS3SPP.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/PS4BT/PS4BT.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/SPP/SPP.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/SPPMulti/SPPMulti.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/Wii/Wii.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/WiiBalanceBoard/WiiBalanceBoard.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/WiiIRCamera/WiiIRCamera.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/WiiMulti/WiiMulti.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/WiiUProController/WiiUProController.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootKbdAndMouse/USBHIDBootKbdAndMouse.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootMouse/USBHIDBootMouse.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/USBHIDJoystick.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHID_desc/USBHID_desc.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHID_desc/pgmstrings.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/PS3USB/PS3USB.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/PS4USB/PS4USB.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/PSBuzz/PSBuzz.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/USB_desc/USB_desc.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/USB_desc/pgmstrings.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/Xbox/XBOXOLD/XBOXOLD.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/Xbox/XBOXONE/XBOXONE.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/Xbox/XBOXRECV/XBOXRECV.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/Xbox/XBOXUSB/XBOXUSB.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/acm/acm_terminal/acm_terminal.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/acm/acm_terminal/pgmstrings.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/ArduinoBlinkLED/ArduinoBlinkLED.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/adk_barcode/adk_barcode.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/demokit_20/demokit_20.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/term_test/term_test.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/term_time/term_time.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/board_qc/board_qc.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/cdc_XR21B1411/XR_terminal/XR_terminal.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/ftdi/USBFTDILoopback/USBFTDILoopback.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/ftdi/USBFTDILoopback/pgmstrings.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/hub_demo/hub_demo.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/hub_demo/pgmstrings.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/max_LCD/max_LCD.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/pl2303/pl2303_gprs_terminal/pl2303_gprs_terminal.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/pl2303/pl2303_gps/pl2303_gps.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/pl2303/pl2303_tinygps/pl2303_tinygps.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/pl2303/pl2303_xbee_terminal/pl2303_xbee_terminal.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/testusbhostFAT/Makefile delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/testusbhostFAT/README.md delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/examples/testusbhostFAT/testusbhostFAT.ino delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/gpl2.txt delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/hexdump.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/hid.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/hid.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/hidboot.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/hidboot.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/hidescriptorparser.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/hidescriptorparser.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/hiduniversal.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/hiduniversal.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/hidusagestr.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/hidusagetitlearrays.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/keywords.txt delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/library.json delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/library.properties delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/macros.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/masstorage.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/masstorage.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/max3421e.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/max_LCD.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/max_LCD.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/message.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/message.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/parsetools.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/parsetools.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/printhex.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/settings.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/sink_parser.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/usb_ch9.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/usbhost.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/usbhub.cpp delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/usbhub.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/version_helper.h delete mode 100644 protocol/usb_hid/USB_Host_Shield_2.0/xboxEnums.h diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/.gitattributes b/protocol/usb_hid/USB_Host_Shield_2.0/.gitattributes deleted file mode 100644 index 6238b035..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/.gitattributes +++ /dev/null @@ -1,23 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto -* text eol=lf - -# Custom for Visual Studio -*.cs diff=csharp -*.sln merge=union -*.csproj merge=union -*.vbproj merge=union -*.fsproj merge=union -*.dbproj merge=union - -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/.gitignore b/protocol/usb_hid/USB_Host_Shield_2.0/.gitignore deleted file mode 100644 index 7e69f457..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.bak -*.zip -*.rar -build/ \ No newline at end of file diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/.gitmodules b/protocol/usb_hid/USB_Host_Shield_2.0/.gitmodules deleted file mode 100644 index 32a0783a..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/.gitmodules +++ /dev/null @@ -1,12 +0,0 @@ -[submodule "examples/testusbhostFAT/generic_storage"] - path = examples/testusbhostFAT/generic_storage - url = https://github.com/xxxajk/generic_storage -[submodule "examples/testusbhostFAT/xmem2"] - path = examples/testusbhostFAT/xmem2 - url = https://github.com/xxxajk/xmem2 -[submodule "examples/testusbhostFAT/Arduino_Makefile_master"] - path = examples/testusbhostFAT/Arduino_Makefile_master - url = https://github.com/xxxajk/Arduino_Makefile_master -[submodule "examples/testusbhostFAT/RTClib"] - path = examples/testusbhostFAT/RTClib - url = https://github.com/xxxajk/RTClib diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/BTD.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/BTD.cpp deleted file mode 100755 index bcfba14b..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/BTD.cpp +++ /dev/null @@ -1,1364 +0,0 @@ -/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#include "BTD.h" -// To enable serial debugging see "settings.h" -//#define EXTRADEBUG // Uncomment to get even more debugging data - -const uint8_t BTD::BTD_CONTROL_PIPE = 0; -const uint8_t BTD::BTD_EVENT_PIPE = 1; -const uint8_t BTD::BTD_DATAIN_PIPE = 2; -const uint8_t BTD::BTD_DATAOUT_PIPE = 3; - -BTD::BTD(USB *p) : -connectToWii(false), -pairWithWii(false), -connectToHIDDevice(false), -pairWithHIDDevice(false), -pUsb(p), // Pointer to USB class instance - mandatory -bAddress(0), // Device address - mandatory -bNumEP(1), // If config descriptor needs to be parsed -qNextPollTime(0), // Reset NextPollTime -pollInterval(0), -bPollEnable(false) // Don't start polling before dongle is connected -{ - for(uint8_t i = 0; i < BTD_NUM_SERVICES; i++) - btService[i] = NULL; - - Initialize(); // Set all variables, endpoint structs etc. to default values - - if(pUsb) // Register in USB subsystem - pUsb->RegisterDeviceClass(this); // Set devConfig[] entry -} - -uint8_t BTD::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) { - const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR); - uint8_t buf[constBufSize]; - USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); - uint8_t rcode; - UsbDevice *p = NULL; - EpInfo *oldep_ptr = NULL; - - Initialize(); // Set all variables, endpoint structs etc. to default values - - AddressPool &addrPool = pUsb->GetAddressPool(); // Get memory address of USB device address pool -#ifdef EXTRADEBUG - Notify(PSTR("\r\nBTD ConfigureDevice"), 0x80); -#endif - - if(bAddress) { // Check if address has already been assigned to an instance -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nAddress in use"), 0x80); -#endif - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - } - - p = addrPool.GetUsbDevicePtr(0); // Get pointer to pseudo device with address 0 assigned - if(!p) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nAddress not found"), 0x80); -#endif - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - } - - if(!p->epinfo) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nepinfo is null"), 0x80); -#endif - return USB_ERROR_EPINFO_IS_NULL; - } - - oldep_ptr = p->epinfo; // Save old pointer to EP_RECORD of address 0 - p->epinfo = epInfo; // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->lowspeed = lowspeed; - rcode = pUsb->getDevDescr(0, 0, constBufSize, (uint8_t*)buf); // Get device descriptor - addr, ep, nbytes, data - - p->epinfo = oldep_ptr; // Restore p->epinfo - - if(rcode) - goto FailGetDevDescr; - - bAddress = addrPool.AllocAddress(parent, false, port); // Allocate new address according to device class - - if(!bAddress) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nOut of address space"), 0x80); -#endif - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - } - - epInfo[0].maxPktSize = udd->bMaxPacketSize0; // Extract Max Packet Size from device descriptor - epInfo[1].epAddr = udd->bNumConfigurations; // Steal and abuse from epInfo structure to save memory - - VID = udd->idVendor; - PID = udd->idProduct; - - return USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET; - -FailGetDevDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetDevDescr(rcode); -#endif - if(rcode != hrJERR) - rcode = USB_ERROR_FailGetDevDescr; - Release(); - return rcode; -}; - -uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) { - uint8_t rcode; - uint8_t num_of_conf = epInfo[1].epAddr; // Number of configurations - epInfo[1].epAddr = 0; - - AddressPool &addrPool = pUsb->GetAddressPool(); -#ifdef EXTRADEBUG - Notify(PSTR("\r\nBTD Init"), 0x80); -#endif - UsbDevice *p = addrPool.GetUsbDevicePtr(bAddress); // Get pointer to assigned address record - - if(!p) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nAddress not found"), 0x80); -#endif - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - } - - delay(300); // Assign new address to the device - - rcode = pUsb->setAddr(0, 0, bAddress); // Assign new address to the device - if(rcode) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nsetAddr: "), 0x80); - D_PrintHex (rcode, 0x80); -#endif - p->lowspeed = false; - goto Fail; - } -#ifdef EXTRADEBUG - Notify(PSTR("\r\nAddr: "), 0x80); - D_PrintHex (bAddress, 0x80); -#endif - - p->lowspeed = false; - - p = addrPool.GetUsbDevicePtr(bAddress); // Get pointer to assigned address record - if(!p) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nAddress not found"), 0x80); -#endif - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - } - - p->lowspeed = lowspeed; - - rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo); // Assign epInfo to epinfo pointer - only EP0 is known - if(rcode) - goto FailSetDevTblEntry; - - if(VID == PS3_VID && (PID == PS3_PID || PID == PS3NAVIGATION_PID || PID == PS3MOVE_PID)) { - delay(100); - rcode = pUsb->setConf(bAddress, epInfo[ BTD_CONTROL_PIPE ].epAddr, 1); // We only need the Control endpoint, so we don't have to initialize the other endpoints of device - if(rcode) - goto FailSetConfDescr; - -#ifdef DEBUG_USB_HOST - if(PID == PS3_PID || PID == PS3NAVIGATION_PID) { - if(PID == PS3_PID) - Notify(PSTR("\r\nDualshock 3 Controller Connected"), 0x80); - else // It must be a navigation controller - Notify(PSTR("\r\nNavigation Controller Connected"), 0x80); - } else // It must be a Motion controller - Notify(PSTR("\r\nMotion Controller Connected"), 0x80); -#endif - - if(my_bdaddr[0] == 0x00 && my_bdaddr[1] == 0x00 && my_bdaddr[2] == 0x00 && my_bdaddr[3] == 0x00 && my_bdaddr[4] == 0x00 && my_bdaddr[5] == 0x00) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nPlease plug in the dongle before trying to pair with the PS3 Controller\r\nor set the Bluetooth address in the constructor of the PS3BT class"), 0x80); -#endif - } else { - if(PID == PS3_PID || PID == PS3NAVIGATION_PID) - setBdaddr(my_bdaddr); // Set internal Bluetooth address - else - setMoveBdaddr(my_bdaddr); // Set internal Bluetooth address -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80); - for(int8_t i = 5; i > 0; i--) { - D_PrintHex (my_bdaddr[i], 0x80); - Notify(PSTR(":"), 0x80); - } - D_PrintHex (my_bdaddr[0], 0x80); -#endif - } - - pUsb->setConf(bAddress, epInfo[ BTD_CONTROL_PIPE ].epAddr, 0); // Reset configuration value - pUsb->setAddr(bAddress, 0, 0); // Reset address - Release(); // Release device - return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; // Return - } else { - // Check if attached device is a Bluetooth dongle and fill endpoint data structure - // First interface in the configuration must have Bluetooth assigned Class/Subclass/Protocol - // And 3 endpoints - interrupt-IN, bulk-IN, bulk-OUT, not necessarily in this order - for(uint8_t i = 0; i < num_of_conf; i++) { - if(VID == IOGEAR_GBU521_VID && PID == IOGEAR_GBU521_PID) { - ConfigDescParser confDescrParser(this); // Needed for the IOGEAR GBU521 - rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser); - } else { - ConfigDescParser confDescrParser(this); - rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser); - } - if(rcode) // Check error code - goto FailGetConfDescr; - if(bNumEP >= BTD_MAX_ENDPOINTS) // All endpoints extracted - break; - } - - if(bNumEP < BTD_MAX_ENDPOINTS) - goto FailUnknownDevice; - - // Assign epInfo to epinfo pointer - this time all 3 endpoins - rcode = pUsb->setEpInfoEntry(bAddress, bNumEP, epInfo); - if(rcode) - goto FailSetDevTblEntry; - - // Set Configuration Value - rcode = pUsb->setConf(bAddress, epInfo[ BTD_CONTROL_PIPE ].epAddr, bConfNum); - if(rcode) - goto FailSetConfDescr; - - hci_num_reset_loops = 100; // only loop 100 times before trying to send the hci reset command - hci_counter = 0; - hci_state = HCI_INIT_STATE; - watingForConnection = false; - bPollEnable = true; - -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nBluetooth Dongle Initialized"), 0x80); -#endif - } - return 0; // Successful configuration - - /* Diagnostic messages */ -FailSetDevTblEntry: -#ifdef DEBUG_USB_HOST - NotifyFailSetDevTblEntry(); - goto Fail; -#endif - -FailGetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetConfDescr(); - goto Fail; -#endif - -FailSetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailSetConfDescr(); -#endif - goto Fail; - -FailUnknownDevice: -#ifdef DEBUG_USB_HOST - NotifyFailUnknownDevice(VID, PID); -#endif - pUsb->setAddr(bAddress, 0, 0); // Reset address - rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; -Fail: -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nBTD Init Failed, error code: "), 0x80); - NotifyFail(rcode); -#endif - Release(); - return rcode; -} - -void BTD::Initialize() { - uint8_t i; - for(i = 0; i < BTD_MAX_ENDPOINTS; i++) { - epInfo[i].epAddr = 0; - epInfo[i].maxPktSize = (i) ? 0 : 8; - epInfo[i].epAttribs = 0; - epInfo[i].bmNakPower = (i) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER; - } - for(i = 0; i < BTD_NUM_SERVICES; i++) { - if(btService[i]) - btService[i]->Reset(); // Reset all Bluetooth services - } - - connectToWii = false; - incomingWii = false; - connectToHIDDevice = false; - incomingHIDDevice = false; - incomingPS4 = false; - bAddress = 0; // Clear device address - bNumEP = 1; // Must have to be reset to 1 - qNextPollTime = 0; // Reset next poll time - pollInterval = 0; - bPollEnable = false; // Don't start polling before dongle is connected -} - -/* Extracts interrupt-IN, bulk-IN, bulk-OUT endpoint information from config descriptor */ -void BTD::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) { - //ErrorMessage(PSTR("Conf.Val"),conf); - //ErrorMessage(PSTR("Iface Num"),iface); - //ErrorMessage(PSTR("Alt.Set"),alt); - - if(alt) // Wrong interface - by BT spec, no alt setting - return; - - bConfNum = conf; - uint8_t index; - - if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) { // Interrupt In endpoint found - index = BTD_EVENT_PIPE; - epInfo[index].bmNakPower = USB_NAK_NOWAIT; - } else { - if((pep->bmAttributes & 0x02) == 2) // Bulk endpoint found - index = ((pep->bEndpointAddress & 0x80) == 0x80) ? BTD_DATAIN_PIPE : BTD_DATAOUT_PIPE; - else - return; - } - - // Fill the rest of endpoint data structure - epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F); - epInfo[index].maxPktSize = (uint8_t)pep->wMaxPacketSize; -#ifdef EXTRADEBUG - PrintEndpointDescriptor(pep); -#endif - if(pollInterval < pep->bInterval) // Set the polling interval as the largest polling interval obtained from endpoints - pollInterval = pep->bInterval; - bNumEP++; -} - -void BTD::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) { -#ifdef EXTRADEBUG - Notify(PSTR("\r\nEndpoint descriptor:"), 0x80); - Notify(PSTR("\r\nLength:\t\t"), 0x80); - D_PrintHex (ep_ptr->bLength, 0x80); - Notify(PSTR("\r\nType:\t\t"), 0x80); - D_PrintHex (ep_ptr->bDescriptorType, 0x80); - Notify(PSTR("\r\nAddress:\t"), 0x80); - D_PrintHex (ep_ptr->bEndpointAddress, 0x80); - Notify(PSTR("\r\nAttributes:\t"), 0x80); - D_PrintHex (ep_ptr->bmAttributes, 0x80); - Notify(PSTR("\r\nMaxPktSize:\t"), 0x80); - D_PrintHex (ep_ptr->wMaxPacketSize, 0x80); - Notify(PSTR("\r\nPoll Intrv:\t"), 0x80); - D_PrintHex (ep_ptr->bInterval, 0x80); -#endif -} - -/* Performs a cleanup after failed Init() attempt */ -uint8_t BTD::Release() { - Initialize(); // Set all variables, endpoint structs etc. to default values - pUsb->GetAddressPool().FreeAddress(bAddress); - return 0; -} - -uint8_t BTD::Poll() { - if(!bPollEnable) - return 0; - if((long)(millis() - qNextPollTime) >= 0L) { // Don't poll if shorter than polling interval - qNextPollTime = millis() + pollInterval; // Set new poll time - HCI_event_task(); // Poll the HCI event pipe - HCI_task(); // HCI state machine - ACL_event_task(); // Poll the ACL input pipe too - } - return 0; -} - -void BTD::disconnect() { - for(uint8_t i = 0; i < BTD_NUM_SERVICES; i++) - if(btService[i]) - btService[i]->disconnect(); -}; - -void BTD::HCI_event_task() { - uint16_t length = BULK_MAXPKTSIZE; // Request more than 16 bytes anyway, the inTransfer routine will take care of this - uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[ BTD_EVENT_PIPE ].epAddr, &length, hcibuf); // Input on endpoint 1 - - if(!rcode || rcode == hrNAK) { // Check for errors - switch(hcibuf[0]) { // Switch on event type - case EV_COMMAND_COMPLETE: - if(!hcibuf[5]) { // Check if command succeeded - hci_set_flag(HCI_FLAG_CMD_COMPLETE); // Set command complete flag - if((hcibuf[3] == 0x01) && (hcibuf[4] == 0x10)) { // Parameters from read local version information - hci_version = hcibuf[6]; // Used to check if it supports 2.0+EDR - see http://www.bluetooth.org/Technical/AssignedNumbers/hci.htm - hci_set_flag(HCI_FLAG_READ_VERSION); - } else if((hcibuf[3] == 0x09) && (hcibuf[4] == 0x10)) { // Parameters from read local bluetooth address - for(uint8_t i = 0; i < 6; i++) - my_bdaddr[i] = hcibuf[6 + i]; - hci_set_flag(HCI_FLAG_READ_BDADDR); - } - } - break; - - case EV_COMMAND_STATUS: - if(hcibuf[2]) { // Show status on serial if not OK -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nHCI Command Failed: "), 0x80); - D_PrintHex (hcibuf[2], 0x80); -#endif - } - break; - - case EV_INQUIRY_COMPLETE: - if(inquiry_counter >= 5 && (pairWithWii || pairWithHIDDevice)) { - inquiry_counter = 0; -#ifdef DEBUG_USB_HOST - if(pairWithWii) - Notify(PSTR("\r\nCouldn't find Wiimote"), 0x80); - else - Notify(PSTR("\r\nCouldn't find HID device"), 0x80); -#endif - connectToWii = false; - pairWithWii = false; - connectToHIDDevice = false; - pairWithHIDDevice = false; - hci_state = HCI_SCANNING_STATE; - } - inquiry_counter++; - break; - - case EV_INQUIRY_RESULT: - if(hcibuf[2]) { // Check that there is more than zero responses -#ifdef EXTRADEBUG - Notify(PSTR("\r\nNumber of responses: "), 0x80); - Notify(hcibuf[2], 0x80); -#endif - for(uint8_t i = 0; i < hcibuf[2]; i++) { - uint8_t offset = 8 * hcibuf[2] + 3 * i; - - for(uint8_t j = 0; j < 3; j++) - classOfDevice[j] = hcibuf[j + 4 + offset]; - -#ifdef EXTRADEBUG - Notify(PSTR("\r\nClass of device: "), 0x80); - D_PrintHex (classOfDevice[2], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (classOfDevice[1], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (classOfDevice[0], 0x80); -#endif - - if(pairWithWii && classOfDevice[2] == 0x00 && (classOfDevice[1] & 0x05) && (classOfDevice[0] & 0x0C)) { // See http://wiibrew.org/wiki/Wiimote#SDP_information - checkRemoteName = true; // Check remote name to distinguish between the different controllers - - for(uint8_t j = 0; j < 6; j++) - disc_bdaddr[j] = hcibuf[j + 3 + 6 * i]; - - hci_set_flag(HCI_FLAG_DEVICE_FOUND); - break; - } else if(pairWithHIDDevice && (classOfDevice[1] & 0x05) && (classOfDevice[0] & 0xC8)) { // Check if it is a mouse, keyboard or a gamepad - see: http://bluetooth-pentest.narod.ru/software/bluetooth_class_of_device-service_generator.html -#ifdef DEBUG_USB_HOST - if(classOfDevice[0] & 0x80) - Notify(PSTR("\r\nMouse found"), 0x80); - if(classOfDevice[0] & 0x40) - Notify(PSTR("\r\nKeyboard found"), 0x80); - if(classOfDevice[0] & 0x08) - Notify(PSTR("\r\nGamepad found"), 0x80); -#endif - - for(uint8_t j = 0; j < 6; j++) - disc_bdaddr[j] = hcibuf[j + 3 + 6 * i]; - - hci_set_flag(HCI_FLAG_DEVICE_FOUND); - break; - } - } - } - break; - - case EV_CONNECT_COMPLETE: - hci_set_flag(HCI_FLAG_CONNECT_EVENT); - if(!hcibuf[2]) { // Check if connected OK -#ifdef EXTRADEBUG - Notify(PSTR("\r\nConnection established"), 0x80); -#endif - hci_handle = hcibuf[3] | ((hcibuf[4] & 0x0F) << 8); // Store the handle for the ACL connection - hci_set_flag(HCI_FLAG_CONNECT_COMPLETE); // Set connection complete flag - } else { - hci_state = HCI_CHECK_DEVICE_SERVICE; -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nConnection Failed: "), 0x80); - D_PrintHex (hcibuf[2], 0x80); -#endif - } - break; - - case EV_DISCONNECT_COMPLETE: - if(!hcibuf[2]) { // Check if disconnected OK - hci_set_flag(HCI_FLAG_DISCONNECT_COMPLETE); // Set disconnect command complete flag - hci_clear_flag(HCI_FLAG_CONNECT_COMPLETE); // Clear connection complete flag - } - break; - - case EV_REMOTE_NAME_COMPLETE: - if(!hcibuf[2]) { // Check if reading is OK - for(uint8_t i = 0; i < min(sizeof (remote_name), sizeof (hcibuf) - 9); i++) { - remote_name[i] = hcibuf[9 + i]; - if(remote_name[i] == '\0') // End of string - break; - } - // TODO: Altid sæt '\0' i remote name! - hci_set_flag(HCI_FLAG_REMOTE_NAME_COMPLETE); - } - break; - - case EV_INCOMING_CONNECT: - for(uint8_t i = 0; i < 6; i++) - disc_bdaddr[i] = hcibuf[i + 2]; - - for(uint8_t i = 0; i < 3; i++) - classOfDevice[i] = hcibuf[i + 8]; - - if((classOfDevice[1] & 0x05) && (classOfDevice[0] & 0xC8)) { // Check if it is a mouse, keyboard or a gamepad -#ifdef DEBUG_USB_HOST - if(classOfDevice[0] & 0x80) - Notify(PSTR("\r\nMouse is connecting"), 0x80); - if(classOfDevice[0] & 0x40) - Notify(PSTR("\r\nKeyboard is connecting"), 0x80); - if(classOfDevice[0] & 0x08) - Notify(PSTR("\r\nGamepad is connecting"), 0x80); -#endif - incomingHIDDevice = true; - } - -#ifdef EXTRADEBUG - Notify(PSTR("\r\nClass of device: "), 0x80); - D_PrintHex (classOfDevice[2], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (classOfDevice[1], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (classOfDevice[0], 0x80); -#endif - hci_set_flag(HCI_FLAG_INCOMING_REQUEST); - break; - - case EV_PIN_CODE_REQUEST: - if(pairWithWii) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nPairing with Wiimote"), 0x80); -#endif - hci_pin_code_request_reply(); - } else if(btdPin != NULL) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nBluetooth pin is set too: "), 0x80); - NotifyStr(btdPin, 0x80); -#endif - hci_pin_code_request_reply(); - } else { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nNo pin was set"), 0x80); -#endif - hci_pin_code_negative_request_reply(); - } - break; - - case EV_LINK_KEY_REQUEST: -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nReceived Key Request"), 0x80); -#endif - hci_link_key_request_negative_reply(); - break; - - case EV_AUTHENTICATION_COMPLETE: - if(pairWithWii && !connectToWii) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nPairing successful with Wiimote"), 0x80); -#endif - connectToWii = true; // Used to indicate to the Wii service, that it should connect to this device - } else if(pairWithHIDDevice && !connectToHIDDevice) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nPairing successful with HID device"), 0x80); -#endif - connectToHIDDevice = true; // Used to indicate to the BTHID service, that it should connect to this device - } - break; - /* We will just ignore the following events */ - case EV_NUM_COMPLETE_PKT: - case EV_ROLE_CHANGED: - case EV_PAGE_SCAN_REP_MODE: - case EV_LOOPBACK_COMMAND: - case EV_DATA_BUFFER_OVERFLOW: - case EV_CHANGE_CONNECTION_LINK: - case EV_MAX_SLOTS_CHANGE: - case EV_QOS_SETUP_COMPLETE: - case EV_LINK_KEY_NOTIFICATION: - case EV_ENCRYPTION_CHANGE: - case EV_READ_REMOTE_VERSION_INFORMATION_COMPLETE: - break; -#ifdef EXTRADEBUG - default: - if(hcibuf[0] != 0x00) { - Notify(PSTR("\r\nUnmanaged HCI Event: "), 0x80); - D_PrintHex (hcibuf[0], 0x80); - } - break; -#endif - } // Switch - } -#ifdef EXTRADEBUG - else { - Notify(PSTR("\r\nHCI event error: "), 0x80); - D_PrintHex (rcode, 0x80); - } -#endif -} - -/* Poll Bluetooth and print result */ -void BTD::HCI_task() { - switch(hci_state) { - case HCI_INIT_STATE: - hci_counter++; - if(hci_counter > hci_num_reset_loops) { // wait until we have looped x times to clear any old events - hci_reset(); - hci_state = HCI_RESET_STATE; - hci_counter = 0; - } - break; - - case HCI_RESET_STATE: - hci_counter++; - if(hci_check_flag(HCI_FLAG_CMD_COMPLETE)) { - hci_counter = 0; -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nHCI Reset complete"), 0x80); -#endif - hci_state = HCI_CLASS_STATE; - hci_write_class_of_device(); - } else if(hci_counter > hci_num_reset_loops) { - hci_num_reset_loops *= 10; - if(hci_num_reset_loops > 2000) - hci_num_reset_loops = 2000; -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nNo response to HCI Reset"), 0x80); -#endif - hci_state = HCI_INIT_STATE; - hci_counter = 0; - } - break; - - case HCI_CLASS_STATE: - if(hci_check_flag(HCI_FLAG_CMD_COMPLETE)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nWrite class of device"), 0x80); -#endif - hci_state = HCI_BDADDR_STATE; - hci_read_bdaddr(); - } - break; - - case HCI_BDADDR_STATE: - if(hci_check_flag(HCI_FLAG_READ_BDADDR)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nLocal Bluetooth Address: "), 0x80); - for(int8_t i = 5; i > 0; i--) { - D_PrintHex (my_bdaddr[i], 0x80); - Notify(PSTR(":"), 0x80); - } - D_PrintHex (my_bdaddr[0], 0x80); -#endif - hci_read_local_version_information(); - hci_state = HCI_LOCAL_VERSION_STATE; - } - break; - - case HCI_LOCAL_VERSION_STATE: // The local version is used by the PS3BT class - if(hci_check_flag(HCI_FLAG_READ_VERSION)) { - if(btdName != NULL) { - hci_set_local_name(btdName); - hci_state = HCI_SET_NAME_STATE; - } else - hci_state = HCI_CHECK_DEVICE_SERVICE; - } - break; - - case HCI_SET_NAME_STATE: - if(hci_check_flag(HCI_FLAG_CMD_COMPLETE)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nThe name is set to: "), 0x80); - NotifyStr(btdName, 0x80); -#endif - hci_state = HCI_CHECK_DEVICE_SERVICE; - } - break; - - case HCI_CHECK_DEVICE_SERVICE: - if(pairWithHIDDevice || pairWithWii) { // Check if it should try to connect to a Wiimote -#ifdef DEBUG_USB_HOST - if(pairWithWii) - Notify(PSTR("\r\nStarting inquiry\r\nPress 1 & 2 on the Wiimote\r\nOr press the SYNC button if you are using a Wii U Pro Controller or a Wii Balance Board"), 0x80); - else - Notify(PSTR("\r\nPlease enable discovery of your device"), 0x80); -#endif - hci_inquiry(); - hci_state = HCI_INQUIRY_STATE; - } else - hci_state = HCI_SCANNING_STATE; // Don't try to connect to a Wiimote - break; - - case HCI_INQUIRY_STATE: - if(hci_check_flag(HCI_FLAG_DEVICE_FOUND)) { - hci_inquiry_cancel(); // Stop inquiry -#ifdef DEBUG_USB_HOST - if(pairWithWii) - Notify(PSTR("\r\nWiimote found"), 0x80); - else - Notify(PSTR("\r\nHID device found"), 0x80); - - Notify(PSTR("\r\nNow just create the instance like so:"), 0x80); - if(pairWithWii) - Notify(PSTR("\r\nWII Wii(&Btd);"), 0x80); - else - Notify(PSTR("\r\nBTHID bthid(&Btd);"), 0x80); - - Notify(PSTR("\r\nAnd then press any button on the "), 0x80); - if(pairWithWii) - Notify(PSTR("Wiimote"), 0x80); - else - Notify(PSTR("device"), 0x80); -#endif - if(checkRemoteName) { - hci_remote_name(); // We need to know the name to distinguish between the Wiimote, the new Wiimote with Motion Plus inside, a Wii U Pro Controller and a Wii Balance Board - hci_state = HCI_REMOTE_NAME_STATE; - } else - hci_state = HCI_CONNECT_DEVICE_STATE; - } - break; - - case HCI_CONNECT_DEVICE_STATE: - if(hci_check_flag(HCI_FLAG_CMD_COMPLETE)) { -#ifdef DEBUG_USB_HOST - if(pairWithWii) - Notify(PSTR("\r\nConnecting to Wiimote"), 0x80); - else - Notify(PSTR("\r\nConnecting to HID device"), 0x80); -#endif - checkRemoteName = false; - hci_connect(); - hci_state = HCI_CONNECTED_DEVICE_STATE; - } - break; - - case HCI_CONNECTED_DEVICE_STATE: - if(hci_check_flag(HCI_FLAG_CONNECT_EVENT)) { - if(hci_check_flag(HCI_FLAG_CONNECT_COMPLETE)) { -#ifdef DEBUG_USB_HOST - if(pairWithWii) - Notify(PSTR("\r\nConnected to Wiimote"), 0x80); - else - Notify(PSTR("\r\nConnected to HID device"), 0x80); -#endif - hci_authentication_request(); // This will start the pairing with the Wiimote - hci_state = HCI_SCANNING_STATE; - } else { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nTrying to connect one more time..."), 0x80); -#endif - hci_connect(); // Try to connect one more time - } - } - break; - - case HCI_SCANNING_STATE: - if(!connectToWii && !pairWithWii && !connectToHIDDevice && !pairWithHIDDevice) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nWait For Incoming Connection Request"), 0x80); -#endif - hci_write_scan_enable(); - watingForConnection = true; - hci_state = HCI_CONNECT_IN_STATE; - } - break; - - case HCI_CONNECT_IN_STATE: - if(hci_check_flag(HCI_FLAG_INCOMING_REQUEST)) { - watingForConnection = false; -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nIncoming Connection Request"), 0x80); -#endif - hci_remote_name(); - hci_state = HCI_REMOTE_NAME_STATE; - } else if(hci_check_flag(HCI_FLAG_DISCONNECT_COMPLETE)) - hci_state = HCI_DISCONNECT_STATE; - break; - - case HCI_REMOTE_NAME_STATE: - if(hci_check_flag(HCI_FLAG_REMOTE_NAME_COMPLETE)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nRemote Name: "), 0x80); - for(uint8_t i = 0; i < strlen(remote_name); i++) - Notifyc(remote_name[i], 0x80); -#endif - if(strncmp((const char*)remote_name, "Nintendo", 8) == 0) { - incomingWii = true; - motionPlusInside = false; - wiiUProController = false; - pairWiiUsingSync = false; -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nWiimote is connecting"), 0x80); -#endif - if(strncmp((const char*)remote_name, "Nintendo RVL-CNT-01-TR", 22) == 0) { -#ifdef DEBUG_USB_HOST - Notify(PSTR(" with Motion Plus Inside"), 0x80); -#endif - motionPlusInside = true; - } else if(strncmp((const char*)remote_name, "Nintendo RVL-CNT-01-UC", 22) == 0) { -#ifdef DEBUG_USB_HOST - Notify(PSTR(" - Wii U Pro Controller"), 0x80); -#endif - wiiUProController = motionPlusInside = pairWiiUsingSync = true; - } else if(strncmp((const char*)remote_name, "Nintendo RVL-WBC-01", 19) == 0) { -#ifdef DEBUG_USB_HOST - Notify(PSTR(" - Wii Balance Board"), 0x80); -#endif - pairWiiUsingSync = true; - } - } - if(classOfDevice[2] == 0 && classOfDevice[1] == 0x25 && classOfDevice[0] == 0x08 && strncmp((const char*)remote_name, "Wireless Controller", 19) == 0) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nPS4 controller is connecting"), 0x80); -#endif - incomingPS4 = true; - } - if(pairWithWii && checkRemoteName) - hci_state = HCI_CONNECT_DEVICE_STATE; - else { - hci_accept_connection(); - hci_state = HCI_CONNECTED_STATE; - } - } - break; - - case HCI_CONNECTED_STATE: - if(hci_check_flag(HCI_FLAG_CONNECT_COMPLETE)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nConnected to Device: "), 0x80); - for(int8_t i = 5; i > 0; i--) { - D_PrintHex (disc_bdaddr[i], 0x80); - Notify(PSTR(":"), 0x80); - } - D_PrintHex (disc_bdaddr[0], 0x80); -#endif - if(incomingPS4) - connectToHIDDevice = true; // We should always connect to the PS4 controller - - // Clear these flags for a new connection - l2capConnectionClaimed = false; - sdpConnectionClaimed = false; - rfcommConnectionClaimed = false; - - hci_event_flag = 0; - hci_state = HCI_DONE_STATE; - } - break; - - case HCI_DONE_STATE: - hci_counter++; - if(hci_counter > 1000) { // Wait until we have looped 1000 times to make sure that the L2CAP connection has been started - hci_counter = 0; - hci_state = HCI_SCANNING_STATE; - } - break; - - case HCI_DISCONNECT_STATE: - if(hci_check_flag(HCI_FLAG_DISCONNECT_COMPLETE)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nHCI Disconnected from Device"), 0x80); -#endif - hci_event_flag = 0; // Clear all flags - - // Reset all buffers - memset(hcibuf, 0, BULK_MAXPKTSIZE); - memset(l2capinbuf, 0, BULK_MAXPKTSIZE); - - connectToWii = incomingWii = pairWithWii = false; - connectToHIDDevice = incomingHIDDevice = pairWithHIDDevice = checkRemoteName = false; - incomingPS4 = false; - - hci_state = HCI_SCANNING_STATE; - } - break; - default: - break; - } -} - -void BTD::ACL_event_task() { - uint16_t length = BULK_MAXPKTSIZE; - uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[ BTD_DATAIN_PIPE ].epAddr, &length, l2capinbuf); // Input on endpoint 2 - - if(!rcode) { // Check for errors - if(length > 0) { // Check if any data was read - for(uint8_t i = 0; i < BTD_NUM_SERVICES; i++) { - if(btService[i]) - btService[i]->ACLData(l2capinbuf); - } - } - } -#ifdef EXTRADEBUG - else if(rcode != hrNAK) { - Notify(PSTR("\r\nACL data in error: "), 0x80); - D_PrintHex (rcode, 0x80); - } -#endif - for(uint8_t i = 0; i < BTD_NUM_SERVICES; i++) - if(btService[i]) - btService[i]->Run(); -} - -/************************************************************/ -/* HCI Commands */ - -/************************************************************/ -void BTD::HCI_Command(uint8_t* data, uint16_t nbytes) { - hci_clear_flag(HCI_FLAG_CMD_COMPLETE); - pUsb->ctrlReq(bAddress, epInfo[ BTD_CONTROL_PIPE ].epAddr, bmREQ_HCI_OUT, 0x00, 0x00, 0x00, 0x00, nbytes, nbytes, data, NULL); -} - -void BTD::hci_reset() { - hci_event_flag = 0; // Clear all the flags - hcibuf[0] = 0x03; // HCI OCF = 3 - hcibuf[1] = 0x03 << 2; // HCI OGF = 3 - hcibuf[2] = 0x00; - - HCI_Command(hcibuf, 3); -} - -void BTD::hci_write_scan_enable() { - hci_clear_flag(HCI_FLAG_INCOMING_REQUEST); - hcibuf[0] = 0x1A; // HCI OCF = 1A - hcibuf[1] = 0x03 << 2; // HCI OGF = 3 - hcibuf[2] = 0x01; // parameter length = 1 - if(btdName != NULL) - hcibuf[3] = 0x03; // Inquiry Scan enabled. Page Scan enabled. - else - hcibuf[3] = 0x02; // Inquiry Scan disabled. Page Scan enabled. - - HCI_Command(hcibuf, 4); -} - -void BTD::hci_write_scan_disable() { - hcibuf[0] = 0x1A; // HCI OCF = 1A - hcibuf[1] = 0x03 << 2; // HCI OGF = 3 - hcibuf[2] = 0x01; // parameter length = 1 - hcibuf[3] = 0x00; // Inquiry Scan disabled. Page Scan disabled. - - HCI_Command(hcibuf, 4); -} - -void BTD::hci_read_bdaddr() { - hci_clear_flag(HCI_FLAG_READ_BDADDR); - hcibuf[0] = 0x09; // HCI OCF = 9 - hcibuf[1] = 0x04 << 2; // HCI OGF = 4 - hcibuf[2] = 0x00; - - HCI_Command(hcibuf, 3); -} - -void BTD::hci_read_local_version_information() { - hci_clear_flag(HCI_FLAG_READ_VERSION); - hcibuf[0] = 0x01; // HCI OCF = 1 - hcibuf[1] = 0x04 << 2; // HCI OGF = 4 - hcibuf[2] = 0x00; - - HCI_Command(hcibuf, 3); -} - -void BTD::hci_accept_connection() { - hci_clear_flag(HCI_FLAG_CONNECT_COMPLETE); - hcibuf[0] = 0x09; // HCI OCF = 9 - hcibuf[1] = 0x01 << 2; // HCI OGF = 1 - hcibuf[2] = 0x07; // parameter length 7 - hcibuf[3] = disc_bdaddr[0]; // 6 octet bdaddr - hcibuf[4] = disc_bdaddr[1]; - hcibuf[5] = disc_bdaddr[2]; - hcibuf[6] = disc_bdaddr[3]; - hcibuf[7] = disc_bdaddr[4]; - hcibuf[8] = disc_bdaddr[5]; - hcibuf[9] = 0x00; // Switch role to master - - HCI_Command(hcibuf, 10); -} - -void BTD::hci_remote_name() { - hci_clear_flag(HCI_FLAG_REMOTE_NAME_COMPLETE); - hcibuf[0] = 0x19; // HCI OCF = 19 - hcibuf[1] = 0x01 << 2; // HCI OGF = 1 - hcibuf[2] = 0x0A; // parameter length = 10 - hcibuf[3] = disc_bdaddr[0]; // 6 octet bdaddr - hcibuf[4] = disc_bdaddr[1]; - hcibuf[5] = disc_bdaddr[2]; - hcibuf[6] = disc_bdaddr[3]; - hcibuf[7] = disc_bdaddr[4]; - hcibuf[8] = disc_bdaddr[5]; - hcibuf[9] = 0x01; // Page Scan Repetition Mode - hcibuf[10] = 0x00; // Reserved - hcibuf[11] = 0x00; // Clock offset - low byte - hcibuf[12] = 0x00; // Clock offset - high byte - - HCI_Command(hcibuf, 13); -} - -void BTD::hci_set_local_name(const char* name) { - hcibuf[0] = 0x13; // HCI OCF = 13 - hcibuf[1] = 0x03 << 2; // HCI OGF = 3 - hcibuf[2] = strlen(name) + 1; // parameter length = the length of the string + end byte - uint8_t i; - for(i = 0; i < strlen(name); i++) - hcibuf[i + 3] = name[i]; - hcibuf[i + 3] = 0x00; // End of string - - HCI_Command(hcibuf, 4 + strlen(name)); -} - -void BTD::hci_inquiry() { - hci_clear_flag(HCI_FLAG_DEVICE_FOUND); - hcibuf[0] = 0x01; - hcibuf[1] = 0x01 << 2; // HCI OGF = 1 - hcibuf[2] = 0x05; // Parameter Total Length = 5 - hcibuf[3] = 0x33; // LAP: Genera/Unlimited Inquiry Access Code (GIAC = 0x9E8B33) - see https://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm - hcibuf[4] = 0x8B; - hcibuf[5] = 0x9E; - hcibuf[6] = 0x30; // Inquiry time = 61.44 sec (maximum) - hcibuf[7] = 0x0A; // 10 number of responses - - HCI_Command(hcibuf, 8); -} - -void BTD::hci_inquiry_cancel() { - hcibuf[0] = 0x02; - hcibuf[1] = 0x01 << 2; // HCI OGF = 1 - hcibuf[2] = 0x00; // Parameter Total Length = 0 - - HCI_Command(hcibuf, 3); -} - -void BTD::hci_connect() { - hci_connect(disc_bdaddr); // Use last discovered device -} - -void BTD::hci_connect(uint8_t *bdaddr) { - hci_clear_flag(HCI_FLAG_CONNECT_COMPLETE | HCI_FLAG_CONNECT_EVENT); - hcibuf[0] = 0x05; - hcibuf[1] = 0x01 << 2; // HCI OGF = 1 - hcibuf[2] = 0x0D; // parameter Total Length = 13 - hcibuf[3] = bdaddr[0]; // 6 octet bdaddr (LSB) - hcibuf[4] = bdaddr[1]; - hcibuf[5] = bdaddr[2]; - hcibuf[6] = bdaddr[3]; - hcibuf[7] = bdaddr[4]; - hcibuf[8] = bdaddr[5]; - hcibuf[9] = 0x18; // DM1 or DH1 may be used - hcibuf[10] = 0xCC; // DM3, DH3, DM5, DH5 may be used - hcibuf[11] = 0x01; // Page repetition mode R1 - hcibuf[12] = 0x00; // Reserved - hcibuf[13] = 0x00; // Clock offset - hcibuf[14] = 0x00; // Invalid clock offset - hcibuf[15] = 0x00; // Do not allow role switch - - HCI_Command(hcibuf, 16); -} - -void BTD::hci_pin_code_request_reply() { - hcibuf[0] = 0x0D; // HCI OCF = 0D - hcibuf[1] = 0x01 << 2; // HCI OGF = 1 - hcibuf[2] = 0x17; // parameter length 23 - hcibuf[3] = disc_bdaddr[0]; // 6 octet bdaddr - hcibuf[4] = disc_bdaddr[1]; - hcibuf[5] = disc_bdaddr[2]; - hcibuf[6] = disc_bdaddr[3]; - hcibuf[7] = disc_bdaddr[4]; - hcibuf[8] = disc_bdaddr[5]; - if(pairWithWii) { - hcibuf[9] = 6; // Pin length is the length of the Bluetooth address - if(pairWiiUsingSync) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nParing with Wii controller via SYNC"), 0x80); -#endif - for(uint8_t i = 0; i < 6; i++) - hcibuf[10 + i] = my_bdaddr[i]; // The pin is the Bluetooth dongles Bluetooth address backwards - } else { - for(uint8_t i = 0; i < 6; i++) - hcibuf[10 + i] = disc_bdaddr[i]; // The pin is the Wiimote's Bluetooth address backwards - } - for(uint8_t i = 16; i < 26; i++) - hcibuf[i] = 0x00; // The rest should be 0 - } else { - hcibuf[9] = strlen(btdPin); // Length of pin - uint8_t i; - for(i = 0; i < strlen(btdPin); i++) // The maximum size of the pin is 16 - hcibuf[i + 10] = btdPin[i]; - for(; i < 16; i++) - hcibuf[i + 10] = 0x00; // The rest should be 0 - } - - HCI_Command(hcibuf, 26); -} - -void BTD::hci_pin_code_negative_request_reply() { - hcibuf[0] = 0x0E; // HCI OCF = 0E - hcibuf[1] = 0x01 << 2; // HCI OGF = 1 - hcibuf[2] = 0x06; // parameter length 6 - hcibuf[3] = disc_bdaddr[0]; // 6 octet bdaddr - hcibuf[4] = disc_bdaddr[1]; - hcibuf[5] = disc_bdaddr[2]; - hcibuf[6] = disc_bdaddr[3]; - hcibuf[7] = disc_bdaddr[4]; - hcibuf[8] = disc_bdaddr[5]; - - HCI_Command(hcibuf, 9); -} - -void BTD::hci_link_key_request_negative_reply() { - hcibuf[0] = 0x0C; // HCI OCF = 0C - hcibuf[1] = 0x01 << 2; // HCI OGF = 1 - hcibuf[2] = 0x06; // parameter length 6 - hcibuf[3] = disc_bdaddr[0]; // 6 octet bdaddr - hcibuf[4] = disc_bdaddr[1]; - hcibuf[5] = disc_bdaddr[2]; - hcibuf[6] = disc_bdaddr[3]; - hcibuf[7] = disc_bdaddr[4]; - hcibuf[8] = disc_bdaddr[5]; - - HCI_Command(hcibuf, 9); -} - -void BTD::hci_authentication_request() { - hcibuf[0] = 0x11; // HCI OCF = 11 - hcibuf[1] = 0x01 << 2; // HCI OGF = 1 - hcibuf[2] = 0x02; // parameter length = 2 - hcibuf[3] = (uint8_t)(hci_handle & 0xFF); //connection handle - low byte - hcibuf[4] = (uint8_t)((hci_handle >> 8) & 0x0F); //connection handle - high byte - - HCI_Command(hcibuf, 5); -} - -void BTD::hci_disconnect(uint16_t handle) { // This is called by the different services - hci_clear_flag(HCI_FLAG_DISCONNECT_COMPLETE); - hcibuf[0] = 0x06; // HCI OCF = 6 - hcibuf[1] = 0x01 << 2; // HCI OGF = 1 - hcibuf[2] = 0x03; // parameter length = 3 - hcibuf[3] = (uint8_t)(handle & 0xFF); //connection handle - low byte - hcibuf[4] = (uint8_t)((handle >> 8) & 0x0F); //connection handle - high byte - hcibuf[5] = 0x13; // reason - - HCI_Command(hcibuf, 6); -} - -void BTD::hci_write_class_of_device() { // See http://bluetooth-pentest.narod.ru/software/bluetooth_class_of_device-service_generator.html - hcibuf[0] = 0x24; // HCI OCF = 24 - hcibuf[1] = 0x03 << 2; // HCI OGF = 3 - hcibuf[2] = 0x03; // parameter length = 3 - hcibuf[3] = 0x04; // Robot - hcibuf[4] = 0x08; // Toy - hcibuf[5] = 0x00; - - HCI_Command(hcibuf, 6); -} -/******************************************************************* - * * - * HCI ACL Data Packet * - * * - * buf[0] buf[1] buf[2] buf[3] - * 0 4 8 11 12 16 24 31 MSB - * .-+-+-+-+-+-+-+-|-+-+-+-|-+-|-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-. - * | HCI Handle |PB |BC | Data Total Length | HCI ACL Data Packet - * .-+-+-+-+-+-+-+-|-+-+-+-|-+-|-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-. - * - * buf[4] buf[5] buf[6] buf[7] - * 0 8 16 31 MSB - * .-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-. - * | Length | Channel ID | Basic L2CAP header - * .-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-. - * - * buf[8] buf[9] buf[10] buf[11] - * 0 8 16 31 MSB - * .-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-. - * | Code | Identifier | Length | Control frame (C-frame) - * .-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-. (signaling packet format) - */ -/************************************************************/ -/* L2CAP Commands */ - -/************************************************************/ -void BTD::L2CAP_Command(uint16_t handle, uint8_t* data, uint8_t nbytes, uint8_t channelLow, uint8_t channelHigh) { - uint8_t buf[8 + nbytes]; - buf[0] = (uint8_t)(handle & 0xff); // HCI handle with PB,BC flag - buf[1] = (uint8_t)(((handle >> 8) & 0x0f) | 0x20); - buf[2] = (uint8_t)((4 + nbytes) & 0xff); // HCI ACL total data length - buf[3] = (uint8_t)((4 + nbytes) >> 8); - buf[4] = (uint8_t)(nbytes & 0xff); // L2CAP header: Length - buf[5] = (uint8_t)(nbytes >> 8); - buf[6] = channelLow; - buf[7] = channelHigh; - - for(uint16_t i = 0; i < nbytes; i++) // L2CAP C-frame - buf[8 + i] = data[i]; - - uint8_t rcode = pUsb->outTransfer(bAddress, epInfo[ BTD_DATAOUT_PIPE ].epAddr, (8 + nbytes), buf); - if(rcode) { - delay(100); // This small delay prevents it from overflowing if it fails -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nError sending L2CAP message: 0x"), 0x80); - D_PrintHex (rcode, 0x80); - Notify(PSTR(" - Channel ID: "), 0x80); - D_PrintHex (channelHigh, 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (channelLow, 0x80); -#endif - } -} - -void BTD::l2cap_connection_request(uint16_t handle, uint8_t rxid, uint8_t* scid, uint16_t psm) { - l2capoutbuf[0] = L2CAP_CMD_CONNECTION_REQUEST; // Code - l2capoutbuf[1] = rxid; // Identifier - l2capoutbuf[2] = 0x04; // Length - l2capoutbuf[3] = 0x00; - l2capoutbuf[4] = (uint8_t)(psm & 0xff); // PSM - l2capoutbuf[5] = (uint8_t)(psm >> 8); - l2capoutbuf[6] = scid[0]; // Source CID - l2capoutbuf[7] = scid[1]; - - L2CAP_Command(handle, l2capoutbuf, 8); -} - -void BTD::l2cap_connection_response(uint16_t handle, uint8_t rxid, uint8_t* dcid, uint8_t* scid, uint8_t result) { - l2capoutbuf[0] = L2CAP_CMD_CONNECTION_RESPONSE; // Code - l2capoutbuf[1] = rxid; // Identifier - l2capoutbuf[2] = 0x08; // Length - l2capoutbuf[3] = 0x00; - l2capoutbuf[4] = dcid[0]; // Destination CID - l2capoutbuf[5] = dcid[1]; - l2capoutbuf[6] = scid[0]; // Source CID - l2capoutbuf[7] = scid[1]; - l2capoutbuf[8] = result; // Result: Pending or Success - l2capoutbuf[9] = 0x00; - l2capoutbuf[10] = 0x00; // No further information - l2capoutbuf[11] = 0x00; - - L2CAP_Command(handle, l2capoutbuf, 12); -} - -void BTD::l2cap_config_request(uint16_t handle, uint8_t rxid, uint8_t* dcid) { - l2capoutbuf[0] = L2CAP_CMD_CONFIG_REQUEST; // Code - l2capoutbuf[1] = rxid; // Identifier - l2capoutbuf[2] = 0x08; // Length - l2capoutbuf[3] = 0x00; - l2capoutbuf[4] = dcid[0]; // Destination CID - l2capoutbuf[5] = dcid[1]; - l2capoutbuf[6] = 0x00; // Flags - l2capoutbuf[7] = 0x00; - l2capoutbuf[8] = 0x01; // Config Opt: type = MTU (Maximum Transmission Unit) - Hint - l2capoutbuf[9] = 0x02; // Config Opt: length - l2capoutbuf[10] = 0xFF; // MTU - l2capoutbuf[11] = 0xFF; - - L2CAP_Command(handle, l2capoutbuf, 12); -} - -void BTD::l2cap_config_response(uint16_t handle, uint8_t rxid, uint8_t* scid) { - l2capoutbuf[0] = L2CAP_CMD_CONFIG_RESPONSE; // Code - l2capoutbuf[1] = rxid; // Identifier - l2capoutbuf[2] = 0x0A; // Length - l2capoutbuf[3] = 0x00; - l2capoutbuf[4] = scid[0]; // Source CID - l2capoutbuf[5] = scid[1]; - l2capoutbuf[6] = 0x00; // Flag - l2capoutbuf[7] = 0x00; - l2capoutbuf[8] = 0x00; // Result - l2capoutbuf[9] = 0x00; - l2capoutbuf[10] = 0x01; // Config - l2capoutbuf[11] = 0x02; - l2capoutbuf[12] = 0xA0; - l2capoutbuf[13] = 0x02; - - L2CAP_Command(handle, l2capoutbuf, 14); -} - -void BTD::l2cap_disconnection_request(uint16_t handle, uint8_t rxid, uint8_t* dcid, uint8_t* scid) { - l2capoutbuf[0] = L2CAP_CMD_DISCONNECT_REQUEST; // Code - l2capoutbuf[1] = rxid; // Identifier - l2capoutbuf[2] = 0x04; // Length - l2capoutbuf[3] = 0x00; - l2capoutbuf[4] = dcid[0]; - l2capoutbuf[5] = dcid[1]; - l2capoutbuf[6] = scid[0]; - l2capoutbuf[7] = scid[1]; - - L2CAP_Command(handle, l2capoutbuf, 8); -} - -void BTD::l2cap_disconnection_response(uint16_t handle, uint8_t rxid, uint8_t* dcid, uint8_t* scid) { - l2capoutbuf[0] = L2CAP_CMD_DISCONNECT_RESPONSE; // Code - l2capoutbuf[1] = rxid; // Identifier - l2capoutbuf[2] = 0x04; // Length - l2capoutbuf[3] = 0x00; - l2capoutbuf[4] = dcid[0]; - l2capoutbuf[5] = dcid[1]; - l2capoutbuf[6] = scid[0]; - l2capoutbuf[7] = scid[1]; - - L2CAP_Command(handle, l2capoutbuf, 8); -} - -void BTD::l2cap_information_response(uint16_t handle, uint8_t rxid, uint8_t infoTypeLow, uint8_t infoTypeHigh) { - l2capoutbuf[0] = L2CAP_CMD_INFORMATION_RESPONSE; // Code - l2capoutbuf[1] = rxid; // Identifier - l2capoutbuf[2] = 0x08; // Length - l2capoutbuf[3] = 0x00; - l2capoutbuf[4] = infoTypeLow; - l2capoutbuf[5] = infoTypeHigh; - l2capoutbuf[6] = 0x00; // Result = success - l2capoutbuf[7] = 0x00; // Result = success - l2capoutbuf[8] = 0x00; - l2capoutbuf[9] = 0x00; - l2capoutbuf[10] = 0x00; - l2capoutbuf[11] = 0x00; - - L2CAP_Command(handle, l2capoutbuf, 12); -} - -/* PS3 Commands - only set Bluetooth address is implemented in this library */ -void BTD::setBdaddr(uint8_t* bdaddr) { - /* Set the internal Bluetooth address */ - uint8_t buf[8]; - buf[0] = 0x01; - buf[1] = 0x00; - - for(uint8_t i = 0; i < 6; i++) - buf[i + 2] = bdaddr[5 - i]; // Copy into buffer, has to be written reversed, so it is MSB first - - // bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0xF5), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data - pUsb->ctrlReq(bAddress, epInfo[BTD_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0xF5, 0x03, 0x00, 8, 8, buf, NULL); -} - -void BTD::setMoveBdaddr(uint8_t* bdaddr) { - /* Set the internal Bluetooth address */ - uint8_t buf[11]; - buf[0] = 0x05; - buf[7] = 0x10; - buf[8] = 0x01; - buf[9] = 0x02; - buf[10] = 0x12; - - for(uint8_t i = 0; i < 6; i++) - buf[i + 1] = bdaddr[i]; - - // bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x05), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data - pUsb->ctrlReq(bAddress, epInfo[BTD_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x05, 0x03, 0x00, 11, 11, buf, NULL); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/BTD.h b/protocol/usb_hid/USB_Host_Shield_2.0/BTD.h deleted file mode 100755 index 6549c30c..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/BTD.h +++ /dev/null @@ -1,620 +0,0 @@ -/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#ifndef _btd_h_ -#define _btd_h_ - -#include "Usb.h" -#include "hid.h" - -//PID and VID of the Sony PS3 devices -#define PS3_VID 0x054C // Sony Corporation -#define PS3_PID 0x0268 // PS3 Controller DualShock 3 -#define PS3NAVIGATION_PID 0x042F // Navigation controller -#define PS3MOVE_PID 0x03D5 // Motion controller - -#define IOGEAR_GBU521_VID 0x0A5C // The IOGEAR GBU521 dongle does not presents itself correctly, so we have to check for it manually -#define IOGEAR_GBU521_PID 0x21E8 - -/* Bluetooth dongle data taken from descriptors */ -#define BULK_MAXPKTSIZE 64 // Max size for ACL data - -// Used in control endpoint header for HCI Commands -#define bmREQ_HCI_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE - -/* Bluetooth HCI states for hci_task() */ -#define HCI_INIT_STATE 0 -#define HCI_RESET_STATE 1 -#define HCI_CLASS_STATE 2 -#define HCI_BDADDR_STATE 3 -#define HCI_LOCAL_VERSION_STATE 4 -#define HCI_SET_NAME_STATE 5 -#define HCI_CHECK_DEVICE_SERVICE 6 - -#define HCI_INQUIRY_STATE 7 // These three states are only used if it should pair and connect to a device -#define HCI_CONNECT_DEVICE_STATE 8 -#define HCI_CONNECTED_DEVICE_STATE 9 - -#define HCI_SCANNING_STATE 10 -#define HCI_CONNECT_IN_STATE 11 -#define HCI_REMOTE_NAME_STATE 12 -#define HCI_CONNECTED_STATE 13 -#define HCI_DISABLE_SCAN_STATE 14 -#define HCI_DONE_STATE 15 -#define HCI_DISCONNECT_STATE 16 - -/* HCI event flags*/ -#define HCI_FLAG_CMD_COMPLETE (1UL << 0) -#define HCI_FLAG_CONNECT_COMPLETE (1UL << 1) -#define HCI_FLAG_DISCONNECT_COMPLETE (1UL << 2) -#define HCI_FLAG_REMOTE_NAME_COMPLETE (1UL << 3) -#define HCI_FLAG_INCOMING_REQUEST (1UL << 4) -#define HCI_FLAG_READ_BDADDR (1UL << 5) -#define HCI_FLAG_READ_VERSION (1UL << 6) -#define HCI_FLAG_DEVICE_FOUND (1UL << 7) -#define HCI_FLAG_CONNECT_EVENT (1UL << 8) - -/* Macros for HCI event flag tests */ -#define hci_check_flag(flag) (hci_event_flag & (flag)) -#define hci_set_flag(flag) (hci_event_flag |= (flag)) -#define hci_clear_flag(flag) (hci_event_flag &= ~(flag)) - -/* HCI Events managed */ -#define EV_INQUIRY_COMPLETE 0x01 -#define EV_INQUIRY_RESULT 0x02 -#define EV_CONNECT_COMPLETE 0x03 -#define EV_INCOMING_CONNECT 0x04 -#define EV_DISCONNECT_COMPLETE 0x05 -#define EV_AUTHENTICATION_COMPLETE 0x06 -#define EV_REMOTE_NAME_COMPLETE 0x07 -#define EV_ENCRYPTION_CHANGE 0x08 -#define EV_CHANGE_CONNECTION_LINK 0x09 -#define EV_ROLE_CHANGED 0x12 -#define EV_NUM_COMPLETE_PKT 0x13 -#define EV_PIN_CODE_REQUEST 0x16 -#define EV_LINK_KEY_REQUEST 0x17 -#define EV_LINK_KEY_NOTIFICATION 0x18 -#define EV_DATA_BUFFER_OVERFLOW 0x1A -#define EV_MAX_SLOTS_CHANGE 0x1B -#define EV_READ_REMOTE_VERSION_INFORMATION_COMPLETE 0x0C -#define EV_QOS_SETUP_COMPLETE 0x0D -#define EV_COMMAND_COMPLETE 0x0E -#define EV_COMMAND_STATUS 0x0F -#define EV_LOOPBACK_COMMAND 0x19 -#define EV_PAGE_SCAN_REP_MODE 0x20 - -/* Bluetooth states for the different Bluetooth drivers */ -#define L2CAP_WAIT 0 -#define L2CAP_DONE 1 - -/* Used for HID Control channel */ -#define L2CAP_CONTROL_CONNECT_REQUEST 2 -#define L2CAP_CONTROL_CONFIG_REQUEST 3 -#define L2CAP_CONTROL_SUCCESS 4 -#define L2CAP_CONTROL_DISCONNECT 5 - -/* Used for HID Interrupt channel */ -#define L2CAP_INTERRUPT_SETUP 6 -#define L2CAP_INTERRUPT_CONNECT_REQUEST 7 -#define L2CAP_INTERRUPT_CONFIG_REQUEST 8 -#define L2CAP_INTERRUPT_DISCONNECT 9 - -/* Used for SDP channel */ -#define L2CAP_SDP_WAIT 10 -#define L2CAP_SDP_SUCCESS 11 - -/* Used for RFCOMM channel */ -#define L2CAP_RFCOMM_WAIT 12 -#define L2CAP_RFCOMM_SUCCESS 13 - -#define L2CAP_DISCONNECT_RESPONSE 14 // Used for both SDP and RFCOMM channel - -/* Bluetooth states used by some drivers */ -#define TURN_ON_LED 17 -#define PS3_ENABLE_SIXAXIS 18 -#define WII_CHECK_MOTION_PLUS_STATE 19 -#define WII_CHECK_EXTENSION_STATE 20 -#define WII_INIT_MOTION_PLUS_STATE 21 - -/* L2CAP event flags for HID Control channel */ -#define L2CAP_FLAG_CONNECTION_CONTROL_REQUEST (1UL << 0) -#define L2CAP_FLAG_CONFIG_CONTROL_SUCCESS (1UL << 1) -#define L2CAP_FLAG_CONTROL_CONNECTED (1UL << 2) -#define L2CAP_FLAG_DISCONNECT_CONTROL_RESPONSE (1UL << 3) - -/* L2CAP event flags for HID Interrupt channel */ -#define L2CAP_FLAG_CONNECTION_INTERRUPT_REQUEST (1UL << 4) -#define L2CAP_FLAG_CONFIG_INTERRUPT_SUCCESS (1UL << 5) -#define L2CAP_FLAG_INTERRUPT_CONNECTED (1UL << 6) -#define L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE (1UL << 7) - -/* L2CAP event flags for SDP channel */ -#define L2CAP_FLAG_CONNECTION_SDP_REQUEST (1UL << 8) -#define L2CAP_FLAG_CONFIG_SDP_SUCCESS (1UL << 9) -#define L2CAP_FLAG_DISCONNECT_SDP_REQUEST (1UL << 10) - -/* L2CAP event flags for RFCOMM channel */ -#define L2CAP_FLAG_CONNECTION_RFCOMM_REQUEST (1UL << 11) -#define L2CAP_FLAG_CONFIG_RFCOMM_SUCCESS (1UL << 12) -#define L2CAP_FLAG_DISCONNECT_RFCOMM_REQUEST (1UL << 13) - -#define L2CAP_FLAG_DISCONNECT_RESPONSE (1UL << 14) - -/* Macros for L2CAP event flag tests */ -#define l2cap_check_flag(flag) (l2cap_event_flag & (flag)) -#define l2cap_set_flag(flag) (l2cap_event_flag |= (flag)) -#define l2cap_clear_flag(flag) (l2cap_event_flag &= ~(flag)) - -/* L2CAP signaling commands */ -#define L2CAP_CMD_COMMAND_REJECT 0x01 -#define L2CAP_CMD_CONNECTION_REQUEST 0x02 -#define L2CAP_CMD_CONNECTION_RESPONSE 0x03 -#define L2CAP_CMD_CONFIG_REQUEST 0x04 -#define L2CAP_CMD_CONFIG_RESPONSE 0x05 -#define L2CAP_CMD_DISCONNECT_REQUEST 0x06 -#define L2CAP_CMD_DISCONNECT_RESPONSE 0x07 -#define L2CAP_CMD_INFORMATION_REQUEST 0x0A -#define L2CAP_CMD_INFORMATION_RESPONSE 0x0B - -// Used For Connection Response - Remember to Include High Byte -#define PENDING 0x01 -#define SUCCESSFUL 0x00 - -/* Bluetooth L2CAP PSM - see http://www.bluetooth.org/Technical/AssignedNumbers/logical_link.htm */ -#define SDP_PSM 0x01 // Service Discovery Protocol PSM Value -#define RFCOMM_PSM 0x03 // RFCOMM PSM Value -#define HID_CTRL_PSM 0x11 // HID_Control PSM Value -#define HID_INTR_PSM 0x13 // HID_Interrupt PSM Value - -// Used to determine if it is a Bluetooth dongle -#define WI_SUBCLASS_RF 0x01 // RF Controller -#define WI_PROTOCOL_BT 0x01 // Bluetooth Programming Interface - -#define BTD_MAX_ENDPOINTS 4 -#define BTD_NUM_SERVICES 4 // Max number of Bluetooth services - if you need more than 4 simply increase this number - -#define PAIR 1 - -class BluetoothService; - -/** - * The Bluetooth Dongle class will take care of all the USB communication - * and then pass the data to the BluetoothService classes. - */ -class BTD : public USBDeviceConfig, public UsbConfigXtracter { -public: - /** - * Constructor for the BTD class. - * @param p Pointer to USB class instance. - */ - BTD(USB *p); - - /** @name USBDeviceConfig implementation */ - /** - * Address assignment and basic initialization is done here. - * @param parent Hub number. - * @param port Port number on the hub. - * @param lowspeed Speed of the device. - * @return 0 on success. - */ - uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed); - /** - * Initialize the Bluetooth dongle. - * @param parent Hub number. - * @param port Port number on the hub. - * @param lowspeed Speed of the device. - * @return 0 on success. - */ - uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - /** - * Release the USB device. - * @return 0 on success. - */ - uint8_t Release(); - /** - * Poll the USB Input endpoints and run the state machines. - * @return 0 on success. - */ - uint8_t Poll(); - - /** - * Get the device address. - * @return The device address. - */ - virtual uint8_t GetAddress() { - return bAddress; - }; - - /** - * Used to check if the dongle has been initialized. - * @return True if it's ready. - */ - virtual bool isReady() { - return bPollEnable; - }; - - /** - * Used by the USB core to check what this driver support. - * @param klass The device's USB class. - * @return Returns true if the device's USB class matches this driver. - */ - virtual bool DEVCLASSOK(uint8_t klass) { - return (klass == USB_CLASS_WIRELESS_CTRL); - }; - - /** - * Used by the USB core to check what this driver support. - * Used to set the Bluetooth address into the PS3 controllers. - * @param vid The device's VID. - * @param pid The device's PID. - * @return Returns true if the device's VID and PID matches this driver. - */ - virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { - if(vid == IOGEAR_GBU521_VID && pid == IOGEAR_GBU521_PID) - return true; - if(my_bdaddr[0] != 0x00 || my_bdaddr[1] != 0x00 || my_bdaddr[2] != 0x00 || my_bdaddr[3] != 0x00 || my_bdaddr[4] != 0x00 || my_bdaddr[5] != 0x00) { // Check if Bluetooth address is set - if(vid == PS3_VID && (pid == PS3_PID || pid == PS3NAVIGATION_PID || pid == PS3MOVE_PID)) - return true; - } - return false; - }; - /**@}*/ - - /** @name UsbConfigXtracter implementation */ - /** - * UsbConfigXtracter implementation, used to extract endpoint information. - * @param conf Configuration value. - * @param iface Interface number. - * @param alt Alternate setting. - * @param proto Interface Protocol. - * @param ep Endpoint Descriptor. - */ - void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); - /**@}*/ - - /** Disconnects both the L2CAP Channel and the HCI Connection for all Bluetooth services. */ - void disconnect(); - - /** - * Register Bluetooth dongle members/services. - * @param pService Pointer to BluetoothService class instance. - * @return The service ID on success or -1 on fail. - */ - int8_t registerBluetoothService(BluetoothService *pService) { - for(uint8_t i = 0; i < BTD_NUM_SERVICES; i++) { - if(!btService[i]) { - btService[i] = pService; - return i; // Return ID - } - } - return -1; // Error registering BluetoothService - }; - - /** @name HCI Commands */ - /** - * Used to send a HCI Command. - * @param data Data to send. - * @param nbytes Number of bytes to send. - */ - void HCI_Command(uint8_t* data, uint16_t nbytes); - /** Reset the Bluetooth dongle. */ - void hci_reset(); - /** Read the Bluetooth address of the dongle. */ - void hci_read_bdaddr(); - /** Read the HCI Version of the Bluetooth dongle. */ - void hci_read_local_version_information(); - /** - * Set the local name of the Bluetooth dongle. - * @param name Desired name. - */ - void hci_set_local_name(const char* name); - /** Enable visibility to other Bluetooth devices. */ - void hci_write_scan_enable(); - /** Disable visibility to other Bluetooth devices. */ - void hci_write_scan_disable(); - /** Read the remote devices name. */ - void hci_remote_name(); - /** Accept the connection with the Bluetooth device. */ - void hci_accept_connection(); - /** - * Disconnect the HCI connection. - * @param handle The HCI Handle for the connection. - */ - void hci_disconnect(uint16_t handle); - /** - * Respond with the pin for the connection. - * The pin is automatically set for the Wii library, - * but can be customized for the SPP library. - */ - void hci_pin_code_request_reply(); - /** Respons when no pin was set. */ - void hci_pin_code_negative_request_reply(); - /** - * Command is used to reply to a Link Key Request event from the BR/EDR Controller - * if the Host does not have a stored Link Key for the connection. - */ - void hci_link_key_request_negative_reply(); - /** Used to try to authenticate with the remote device. */ - void hci_authentication_request(); - /** Start a HCI inquiry. */ - void hci_inquiry(); - /** Cancel a HCI inquiry. */ - void hci_inquiry_cancel(); - /** Connect to last device communicated with. */ - void hci_connect(); - /** - * Connect to device. - * @param bdaddr Bluetooth address of the device. - */ - void hci_connect(uint8_t *bdaddr); - /** Used to a set the class of the device. */ - void hci_write_class_of_device(); - /**@}*/ - - /** @name L2CAP Commands */ - /** - * Used to send L2CAP Commands. - * @param handle HCI Handle. - * @param data Data to send. - * @param nbytes Number of bytes to send. - * @param channelLow,channelHigh Low and high byte of channel to send to. - * If argument is omitted then the Standard L2CAP header: Channel ID (0x01) for ACL-U will be used. - */ - void L2CAP_Command(uint16_t handle, uint8_t* data, uint8_t nbytes, uint8_t channelLow = 0x01, uint8_t channelHigh = 0x00); - /** - * L2CAP Connection Request. - * @param handle HCI handle. - * @param rxid Identifier. - * @param scid Source Channel Identifier. - * @param psm Protocol/Service Multiplexer - see: https://www.bluetooth.org/Technical/AssignedNumbers/logical_link.htm. - */ - void l2cap_connection_request(uint16_t handle, uint8_t rxid, uint8_t* scid, uint16_t psm); - /** - * L2CAP Connection Response. - * @param handle HCI handle. - * @param rxid Identifier. - * @param dcid Destination Channel Identifier. - * @param scid Source Channel Identifier. - * @param result Result - First send ::PENDING and then ::SUCCESSFUL. - */ - void l2cap_connection_response(uint16_t handle, uint8_t rxid, uint8_t* dcid, uint8_t* scid, uint8_t result); - /** - * L2CAP Config Request. - * @param handle HCI Handle. - * @param rxid Identifier. - * @param dcid Destination Channel Identifier. - */ - void l2cap_config_request(uint16_t handle, uint8_t rxid, uint8_t* dcid); - /** - * L2CAP Config Response. - * @param handle HCI Handle. - * @param rxid Identifier. - * @param scid Source Channel Identifier. - */ - void l2cap_config_response(uint16_t handle, uint8_t rxid, uint8_t* scid); - /** - * L2CAP Disconnection Request. - * @param handle HCI Handle. - * @param rxid Identifier. - * @param dcid Device Channel Identifier. - * @param scid Source Channel Identifier. - */ - void l2cap_disconnection_request(uint16_t handle, uint8_t rxid, uint8_t* dcid, uint8_t* scid); - /** - * L2CAP Disconnection Response. - * @param handle HCI Handle. - * @param rxid Identifier. - * @param dcid Device Channel Identifier. - * @param scid Source Channel Identifier. - */ - void l2cap_disconnection_response(uint16_t handle, uint8_t rxid, uint8_t* dcid, uint8_t* scid); - /** - * L2CAP Information Response. - * @param handle HCI Handle. - * @param rxid Identifier. - * @param infoTypeLow,infoTypeHigh Infotype. - */ - void l2cap_information_response(uint16_t handle, uint8_t rxid, uint8_t infoTypeLow, uint8_t infoTypeHigh); - /**@}*/ - - /** Use this to see if it is waiting for a incoming connection. */ - bool watingForConnection; - /** This is used by the service to know when to store the device information. */ - bool l2capConnectionClaimed; - /** This is used by the SPP library to claim the current SDP incoming request. */ - bool sdpConnectionClaimed; - /** This is used by the SPP library to claim the current RFCOMM incoming request. */ - bool rfcommConnectionClaimed; - - /** The name you wish to make the dongle show up as. It is set automatically by the SPP library. */ - const char* btdName; - /** The pin you wish to make the dongle use for authentication. It is set automatically by the SPP and BTHID library. */ - const char* btdPin; - - /** The bluetooth dongles Bluetooth address. */ - uint8_t my_bdaddr[6]; - /** HCI handle for the last connection. */ - uint16_t hci_handle; - /** Last incoming devices Bluetooth address. */ - uint8_t disc_bdaddr[6]; - /** First 30 chars of last remote name. */ - char remote_name[30]; - /** - * The supported HCI Version read from the Bluetooth dongle. - * Used by the PS3BT library to check the HCI Version of the Bluetooth dongle, - * it should be at least 3 to work properly with the library. - */ - uint8_t hci_version; - - /** Call this function to pair with a Wiimote */ - void pairWithWiimote() { - pairWithWii = true; - hci_state = HCI_CHECK_DEVICE_SERVICE; - }; - /** Used to only send the ACL data to the Wiimote. */ - bool connectToWii; - /** True if a Wiimote is connecting. */ - bool incomingWii; - /** True when it should pair with a Wiimote. */ - bool pairWithWii; - /** True if it's the new Wiimote with the Motion Plus Inside or a Wii U Pro Controller. */ - bool motionPlusInside; - /** True if it's a Wii U Pro Controller. */ - bool wiiUProController; - - /** Call this function to pair with a Wiimote */ - void pairWithHID() { - pairWithHIDDevice = true; - hci_state = HCI_CHECK_DEVICE_SERVICE; - }; - /** Used to only send the ACL data to the Wiimote. */ - bool connectToHIDDevice; - /** True if a Wiimote is connecting. */ - bool incomingHIDDevice; - /** True when it should pair with a device like a mouse or keyboard. */ - bool pairWithHIDDevice; - - /** - * Read the poll interval taken from the endpoint descriptors. - * @return The poll interval in ms. - */ - uint8_t readPollInterval() { - return pollInterval; - }; - -protected: - /** Pointer to USB class instance. */ - USB *pUsb; - /** Device address. */ - uint8_t bAddress; - /** Endpoint info structure. */ - EpInfo epInfo[BTD_MAX_ENDPOINTS]; - - /** Configuration number. */ - uint8_t bConfNum; - /** Total number of endpoints in the configuration. */ - uint8_t bNumEP; - /** Next poll time based on poll interval taken from the USB descriptor. */ - uint32_t qNextPollTime; - - /** Bluetooth dongle control endpoint. */ - static const uint8_t BTD_CONTROL_PIPE; - /** HCI event endpoint index. */ - static const uint8_t BTD_EVENT_PIPE; - /** ACL In endpoint index. */ - static const uint8_t BTD_DATAIN_PIPE; - /** ACL Out endpoint index. */ - static const uint8_t BTD_DATAOUT_PIPE; - - /** - * Used to print the USB Endpoint Descriptor. - * @param ep_ptr Pointer to USB Endpoint Descriptor. - */ - void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); - -private: - void Initialize(); // Set all variables, endpoint structs etc. to default values - BluetoothService *btService[BTD_NUM_SERVICES]; - - uint16_t PID, VID; // PID and VID of device connected - - uint8_t pollInterval; - bool bPollEnable; - - bool pairWiiUsingSync; // True if paring was done using the Wii SYNC button. - bool checkRemoteName; // Used to check remote device's name before connecting. - bool incomingPS4; // True if a PS4 controller is connecting - uint8_t classOfDevice[3]; // Class of device of last device - - /* Variables used by high level HCI task */ - uint8_t hci_state; // Current state of Bluetooth HCI connection - uint16_t hci_counter; // Counter used for Bluetooth HCI reset loops - uint16_t hci_num_reset_loops; // This value indicate how many times it should read before trying to reset - uint16_t hci_event_flag; // HCI flags of received Bluetooth events - uint8_t inquiry_counter; - - uint8_t hcibuf[BULK_MAXPKTSIZE]; // General purpose buffer for HCI data - uint8_t l2capinbuf[BULK_MAXPKTSIZE]; // General purpose buffer for L2CAP in data - uint8_t l2capoutbuf[14]; // General purpose buffer for L2CAP out data - - /* State machines */ - void HCI_event_task(); // Poll the HCI event pipe - void HCI_task(); // HCI state machine - void ACL_event_task(); // ACL input pipe - - /* Used to set the Bluetooth Address internally to the PS3 Controllers */ - void setBdaddr(uint8_t* BDADDR); - void setMoveBdaddr(uint8_t* BDADDR); -}; - -/** All Bluetooth services should inherit this class. */ -class BluetoothService { -public: - BluetoothService(BTD *p) : pBtd(p) { - if(pBtd) - pBtd->registerBluetoothService(this); // Register it as a Bluetooth service - }; - /** - * Used to pass acldata to the Bluetooth service. - * @param ACLData Pointer to the incoming acldata. - */ - virtual void ACLData(uint8_t* ACLData) = 0; - /** Used to run the different state machines in the Bluetooth service. */ - virtual void Run() = 0; - /** Used to reset the Bluetooth service. */ - virtual void Reset() = 0; - /** Used to disconnect both the L2CAP Channel and the HCI Connection for the Bluetooth service. */ - virtual void disconnect() = 0; - - /** - * Used to call your own function when the device is successfully initialized. - * @param funcOnInit Function to call. - */ - void attachOnInit(void (*funcOnInit)(void)) { - pFuncOnInit = funcOnInit; // TODO: This really belong in a class of it's own as it is repeated several times - }; - -protected: - /** - * Called when a device is successfully initialized. - * Use attachOnInit(void (*funcOnInit)(void)) to call your own function. - * This is useful for instance if you want to set the LEDs in a specific way. - */ - virtual void onInit() = 0; - - /** Used to check if the incoming L2CAP data matches the HCI Handle */ - bool checkHciHandle(uint8_t *buf, uint16_t handle) { - return (buf[0] == (handle & 0xFF)) && (buf[1] == ((handle >> 8) | 0x20)); - } - - /** Pointer to function called in onInit(). */ - void (*pFuncOnInit)(void); - - /** Pointer to BTD instance. */ - BTD *pBtd; - - /** The HCI Handle for the connection. */ - uint16_t hci_handle; - - /** L2CAP flags of received Bluetooth events. */ - uint32_t l2cap_event_flag; - - /** Identifier for L2CAP commands. */ - uint8_t identifier; -}; - -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/BTHID.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/BTHID.cpp deleted file mode 100644 index bfa9202c..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/BTHID.cpp +++ /dev/null @@ -1,399 +0,0 @@ -/* Copyright (C) 2013 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#include "BTHID.h" -// To enable serial debugging see "settings.h" -//#define EXTRADEBUG // Uncomment to get even more debugging data -//#define PRINTREPORT // Uncomment to print the report send by the HID device - -BTHID::BTHID(BTD *p, bool pair, const char *pin) : -BluetoothService(p), // Pointer to USB class instance - mandatory -protocolMode(HID_BOOT_PROTOCOL) { - for(uint8_t i = 0; i < NUM_PARSERS; i++) - pRptParser[i] = NULL; - - pBtd->pairWithHIDDevice = pair; - pBtd->btdPin = pin; - - /* Set device cid for the control and intterrupt channelse - LSB */ - control_dcid[0] = 0x70; // 0x0070 - control_dcid[1] = 0x00; - interrupt_dcid[0] = 0x71; // 0x0071 - interrupt_dcid[1] = 0x00; - - Reset(); -} - -void BTHID::Reset() { - connected = false; - activeConnection = false; - l2cap_event_flag = 0; // Reset flags - l2cap_state = L2CAP_WAIT; - ResetBTHID(); -} - -void BTHID::disconnect() { // Use this void to disconnect the device - // First the HID interrupt channel has to be disconnected, then the HID control channel and finally the HCI connection - pBtd->l2cap_disconnection_request(hci_handle, ++identifier, interrupt_scid, interrupt_dcid); - Reset(); - l2cap_state = L2CAP_INTERRUPT_DISCONNECT; -} - -void BTHID::ACLData(uint8_t* l2capinbuf) { - if(!pBtd->l2capConnectionClaimed && pBtd->incomingHIDDevice && !connected && !activeConnection) { - if(l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) { - if((l2capinbuf[12] | (l2capinbuf[13] << 8)) == HID_CTRL_PSM) { - pBtd->incomingHIDDevice = false; - pBtd->l2capConnectionClaimed = true; // Claim that the incoming connection belongs to this service - activeConnection = true; - hci_handle = pBtd->hci_handle; // Store the HCI Handle for the connection - l2cap_state = L2CAP_WAIT; - } - } - } - - if(checkHciHandle(l2capinbuf, hci_handle)) { // acl_handle_ok - if((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001U) { // l2cap_control - Channel ID for ACL-U - if(l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80); - D_PrintHex (l2capinbuf[13], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[12], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[17], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[16], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[15], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[14], 0x80); -#endif - } else if(l2capinbuf[8] == L2CAP_CMD_CONNECTION_RESPONSE) { - if(((l2capinbuf[16] | (l2capinbuf[17] << 8)) == 0x0000) && ((l2capinbuf[18] | (l2capinbuf[19] << 8)) == SUCCESSFUL)) { // Success - if(l2capinbuf[14] == control_dcid[0] && l2capinbuf[15] == control_dcid[1]) { - //Notify(PSTR("\r\nHID Control Connection Complete"), 0x80); - identifier = l2capinbuf[9]; - control_scid[0] = l2capinbuf[12]; - control_scid[1] = l2capinbuf[13]; - l2cap_set_flag(L2CAP_FLAG_CONTROL_CONNECTED); - } else if(l2capinbuf[14] == interrupt_dcid[0] && l2capinbuf[15] == interrupt_dcid[1]) { - //Notify(PSTR("\r\nHID Interrupt Connection Complete"), 0x80); - identifier = l2capinbuf[9]; - interrupt_scid[0] = l2capinbuf[12]; - interrupt_scid[1] = l2capinbuf[13]; - l2cap_set_flag(L2CAP_FLAG_INTERRUPT_CONNECTED); - } - } - } else if(l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) { -#ifdef EXTRADEBUG - Notify(PSTR("\r\nL2CAP Connection Request - PSM: "), 0x80); - D_PrintHex (l2capinbuf[13], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[12], 0x80); - Notify(PSTR(" SCID: "), 0x80); - D_PrintHex (l2capinbuf[15], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[14], 0x80); - Notify(PSTR(" Identifier: "), 0x80); - D_PrintHex (l2capinbuf[9], 0x80); -#endif - if((l2capinbuf[12] | (l2capinbuf[13] << 8)) == HID_CTRL_PSM) { - identifier = l2capinbuf[9]; - control_scid[0] = l2capinbuf[14]; - control_scid[1] = l2capinbuf[15]; - l2cap_set_flag(L2CAP_FLAG_CONNECTION_CONTROL_REQUEST); - } else if((l2capinbuf[12] | (l2capinbuf[13] << 8)) == HID_INTR_PSM) { - identifier = l2capinbuf[9]; - interrupt_scid[0] = l2capinbuf[14]; - interrupt_scid[1] = l2capinbuf[15]; - l2cap_set_flag(L2CAP_FLAG_CONNECTION_INTERRUPT_REQUEST); - } - } else if(l2capinbuf[8] == L2CAP_CMD_CONFIG_RESPONSE) { - if((l2capinbuf[16] | (l2capinbuf[17] << 8)) == 0x0000) { // Success - if(l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) { - //Notify(PSTR("\r\nHID Control Configuration Complete"), 0x80); - identifier = l2capinbuf[9]; - l2cap_set_flag(L2CAP_FLAG_CONFIG_CONTROL_SUCCESS); - } else if(l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) { - //Notify(PSTR("\r\nHID Interrupt Configuration Complete"), 0x80); - identifier = l2capinbuf[9]; - l2cap_set_flag(L2CAP_FLAG_CONFIG_INTERRUPT_SUCCESS); - } - } - } else if(l2capinbuf[8] == L2CAP_CMD_CONFIG_REQUEST) { - if(l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) { - //Notify(PSTR("\r\nHID Control Configuration Request"), 0x80); - pBtd->l2cap_config_response(hci_handle, l2capinbuf[9], control_scid); - } else if(l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) { - //Notify(PSTR("\r\nHID Interrupt Configuration Request"), 0x80); - pBtd->l2cap_config_response(hci_handle, l2capinbuf[9], interrupt_scid); - } - } else if(l2capinbuf[8] == L2CAP_CMD_DISCONNECT_REQUEST) { - if(l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nDisconnect Request: Control Channel"), 0x80); -#endif - identifier = l2capinbuf[9]; - pBtd->l2cap_disconnection_response(hci_handle, identifier, control_dcid, control_scid); - Reset(); - } else if(l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nDisconnect Request: Interrupt Channel"), 0x80); -#endif - identifier = l2capinbuf[9]; - pBtd->l2cap_disconnection_response(hci_handle, identifier, interrupt_dcid, interrupt_scid); - Reset(); - } - } else if(l2capinbuf[8] == L2CAP_CMD_DISCONNECT_RESPONSE) { - if(l2capinbuf[12] == control_scid[0] && l2capinbuf[13] == control_scid[1]) { - //Notify(PSTR("\r\nDisconnect Response: Control Channel"), 0x80); - identifier = l2capinbuf[9]; - l2cap_set_flag(L2CAP_FLAG_DISCONNECT_CONTROL_RESPONSE); - } else if(l2capinbuf[12] == interrupt_scid[0] && l2capinbuf[13] == interrupt_scid[1]) { - //Notify(PSTR("\r\nDisconnect Response: Interrupt Channel"), 0x80); - identifier = l2capinbuf[9]; - l2cap_set_flag(L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE); - } - } -#ifdef EXTRADEBUG - else { - identifier = l2capinbuf[9]; - Notify(PSTR("\r\nL2CAP Unknown Signaling Command: "), 0x80); - D_PrintHex (l2capinbuf[8], 0x80); - } -#endif - } else if(l2capinbuf[6] == interrupt_dcid[0] && l2capinbuf[7] == interrupt_dcid[1]) { // l2cap_interrupt -#ifdef PRINTREPORT - Notify(PSTR("\r\nL2CAP Interrupt: "), 0x80); - for(uint16_t i = 0; i < ((uint16_t)l2capinbuf[5] << 8 | l2capinbuf[4]); i++) { - D_PrintHex (l2capinbuf[i + 8], 0x80); - Notify(PSTR(" "), 0x80); - } -#endif - if(l2capinbuf[8] == 0xA1) { // HID_THDR_DATA_INPUT - uint16_t length = ((uint16_t)l2capinbuf[5] << 8 | l2capinbuf[4]); - ParseBTHIDData((uint8_t)(length - 1), &l2capinbuf[9]); - - switch(l2capinbuf[9]) { - case 0x01: // Keyboard or Joystick events - if(pRptParser[KEYBOARD_PARSER_ID]) - pRptParser[KEYBOARD_PARSER_ID]->Parse(reinterpret_cast(this), 0, (uint8_t)(length - 2), &l2capinbuf[10]); // Use reinterpret_cast again to extract the instance - break; - - case 0x02: // Mouse events - if(pRptParser[MOUSE_PARSER_ID]) - pRptParser[MOUSE_PARSER_ID]->Parse(reinterpret_cast(this), 0, (uint8_t)(length - 2), &l2capinbuf[10]); // Use reinterpret_cast again to extract the instance - break; -#ifdef EXTRADEBUG - default: - Notify(PSTR("\r\nUnknown Report type: "), 0x80); - D_PrintHex (l2capinbuf[9], 0x80); - break; -#endif - } - } - } else if(l2capinbuf[6] == control_dcid[0] && l2capinbuf[7] == control_dcid[1]) { // l2cap_control -#ifdef PRINTREPORT - Notify(PSTR("\r\nL2CAP Control: "), 0x80); - for(uint16_t i = 0; i < ((uint16_t)l2capinbuf[5] << 8 | l2capinbuf[4]); i++) { - D_PrintHex (l2capinbuf[i + 8], 0x80); - Notify(PSTR(" "), 0x80); - } -#endif - } -#ifdef EXTRADEBUG - else { - Notify(PSTR("\r\nUnsupported L2CAP Data - Channel ID: "), 0x80); - D_PrintHex (l2capinbuf[7], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[6], 0x80); - - Notify(PSTR("\r\nData: "), 0x80); - Notify(PSTR("\r\n"), 0x80); - for(uint16_t i = 0; i < ((uint16_t)l2capinbuf[5] << 8 | l2capinbuf[4]); i++) { - D_PrintHex (l2capinbuf[i + 8], 0x80); - Notify(PSTR(" "), 0x80); - } - } -#endif - L2CAP_task(); - } -} - -void BTHID::L2CAP_task() { - switch(l2cap_state) { - /* These states are used if the HID device is the host */ - case L2CAP_CONTROL_SUCCESS: - if(l2cap_check_flag(L2CAP_FLAG_CONFIG_CONTROL_SUCCESS)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nHID Control Successfully Configured"), 0x80); -#endif - setProtocol(); // Set protocol before establishing HID interrupt channel - l2cap_state = L2CAP_INTERRUPT_SETUP; - } - break; - - case L2CAP_INTERRUPT_SETUP: - if(l2cap_check_flag(L2CAP_FLAG_CONNECTION_INTERRUPT_REQUEST)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nHID Interrupt Incoming Connection Request"), 0x80); -#endif - pBtd->l2cap_connection_response(hci_handle, identifier, interrupt_dcid, interrupt_scid, PENDING); - delay(1); - pBtd->l2cap_connection_response(hci_handle, identifier, interrupt_dcid, interrupt_scid, SUCCESSFUL); - identifier++; - delay(1); - pBtd->l2cap_config_request(hci_handle, identifier, interrupt_scid); - - l2cap_state = L2CAP_INTERRUPT_CONFIG_REQUEST; - } - break; - - /* These states are used if the Arduino is the host */ - case L2CAP_CONTROL_CONNECT_REQUEST: - if(l2cap_check_flag(L2CAP_FLAG_CONTROL_CONNECTED)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSend HID Control Config Request"), 0x80); -#endif - identifier++; - pBtd->l2cap_config_request(hci_handle, identifier, control_scid); - l2cap_state = L2CAP_CONTROL_CONFIG_REQUEST; - } - break; - - case L2CAP_CONTROL_CONFIG_REQUEST: - if(l2cap_check_flag(L2CAP_FLAG_CONFIG_CONTROL_SUCCESS)) { - setProtocol(); // Set protocol before establishing HID interrupt channel - delay(1); // Short delay between commands - just to be sure -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSend HID Interrupt Connection Request"), 0x80); -#endif - identifier++; - pBtd->l2cap_connection_request(hci_handle, identifier, interrupt_dcid, HID_INTR_PSM); - l2cap_state = L2CAP_INTERRUPT_CONNECT_REQUEST; - } - break; - - case L2CAP_INTERRUPT_CONNECT_REQUEST: - if(l2cap_check_flag(L2CAP_FLAG_INTERRUPT_CONNECTED)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSend HID Interrupt Config Request"), 0x80); -#endif - identifier++; - pBtd->l2cap_config_request(hci_handle, identifier, interrupt_scid); - l2cap_state = L2CAP_INTERRUPT_CONFIG_REQUEST; - } - break; - - case L2CAP_INTERRUPT_CONFIG_REQUEST: - if(l2cap_check_flag(L2CAP_FLAG_CONFIG_INTERRUPT_SUCCESS)) { // Now the HID channels is established -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nHID Channels Established"), 0x80); -#endif - pBtd->connectToHIDDevice = false; - pBtd->pairWithHIDDevice = false; - connected = true; - onInit(); - l2cap_state = L2CAP_DONE; - } - break; - - case L2CAP_DONE: - break; - - case L2CAP_INTERRUPT_DISCONNECT: - if(l2cap_check_flag(L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nDisconnected Interrupt Channel"), 0x80); -#endif - identifier++; - pBtd->l2cap_disconnection_request(hci_handle, identifier, control_scid, control_dcid); - l2cap_state = L2CAP_CONTROL_DISCONNECT; - } - break; - - case L2CAP_CONTROL_DISCONNECT: - if(l2cap_check_flag(L2CAP_FLAG_DISCONNECT_CONTROL_RESPONSE)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nDisconnected Control Channel"), 0x80); -#endif - pBtd->hci_disconnect(hci_handle); - hci_handle = -1; // Reset handle - l2cap_event_flag = 0; // Reset flags - l2cap_state = L2CAP_WAIT; - } - break; - } -} - -void BTHID::Run() { - switch(l2cap_state) { - case L2CAP_WAIT: - if(pBtd->connectToHIDDevice && !pBtd->l2capConnectionClaimed && !connected && !activeConnection) { - pBtd->l2capConnectionClaimed = true; - activeConnection = true; -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSend HID Control Connection Request"), 0x80); -#endif - hci_handle = pBtd->hci_handle; // Store the HCI Handle for the connection - l2cap_event_flag = 0; // Reset flags - identifier = 0; - pBtd->l2cap_connection_request(hci_handle, identifier, control_dcid, HID_CTRL_PSM); - l2cap_state = L2CAP_CONTROL_CONNECT_REQUEST; - } else if(l2cap_check_flag(L2CAP_FLAG_CONNECTION_CONTROL_REQUEST)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nHID Control Incoming Connection Request"), 0x80); -#endif - pBtd->l2cap_connection_response(hci_handle, identifier, control_dcid, control_scid, PENDING); - delay(1); - pBtd->l2cap_connection_response(hci_handle, identifier, control_dcid, control_scid, SUCCESSFUL); - identifier++; - delay(1); - pBtd->l2cap_config_request(hci_handle, identifier, control_scid); - l2cap_state = L2CAP_CONTROL_SUCCESS; - } - break; - } -} - -/************************************************************/ -/* HID Commands */ - -/************************************************************/ -void BTHID::setProtocol() { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSet protocol mode: "), 0x80); - D_PrintHex (protocolMode, 0x80); -#endif - if (protocolMode != HID_BOOT_PROTOCOL && protocolMode != HID_RPT_PROTOCOL) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nNot a valid protocol mode. Using Boot protocol instead."), 0x80); -#endif - protocolMode = HID_BOOT_PROTOCOL; // Use Boot Protocol by default - } - uint8_t command = 0x70 | protocolMode; // Set Protocol, see Bluetooth HID specs page 33 - pBtd->L2CAP_Command(hci_handle, &command, 1, control_scid[0], control_scid[1]); -} - -void BTHID::setLeds(uint8_t data) { - uint8_t buf[3]; - buf[0] = 0xA2; // HID BT DATA_request (0xA0) | Report Type (Output 0x02) - buf[1] = 0x01; // Report ID - buf[2] = data; - pBtd->L2CAP_Command(hci_handle, buf, 3, interrupt_scid[0], interrupt_scid[1]); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/BTHID.h b/protocol/usb_hid/USB_Host_Shield_2.0/BTHID.h deleted file mode 100644 index 1a7d8687..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/BTHID.h +++ /dev/null @@ -1,155 +0,0 @@ -/* Copyright (C) 2013 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#ifndef _bthid_h_ -#define _bthid_h_ - -#include "BTD.h" -#include "hidboot.h" - -#define KEYBOARD_PARSER_ID 0 -#define MOUSE_PARSER_ID 1 -#define NUM_PARSERS 2 - -/** This BluetoothService class implements support for Bluetooth HID devices. */ -class BTHID : public BluetoothService { -public: - /** - * Constructor for the BTHID class. - * @param p Pointer to the BTD class instance. - * @param pair Set this to true in order to pair with the device. If the argument is omitted then it will not pair with it. One can use ::PAIR to set it to true. - * @param pin Write the pin to BTD#btdPin. If argument is omitted, then "0000" will be used. - */ - BTHID(BTD *p, bool pair = false, const char *pin = "0000"); - - /** @name BluetoothService implementation */ - /** Used this to disconnect the devices. */ - void disconnect(); - /**@}*/ - - /** - * Get HIDReportParser. - * @param id ID of parser. - * @return Returns the corresponding HIDReportParser. Returns NULL if id is not valid. - */ - HIDReportParser *GetReportParser(uint8_t id) { - if (id >= NUM_PARSERS) - return NULL; - return pRptParser[id]; - }; - - /** - * Set HIDReportParser to be used. - * @param id Id of parser. - * @param prs Pointer to HIDReportParser. - * @return Returns true if the HIDReportParser is set. False otherwise. - */ - bool SetReportParser(uint8_t id, HIDReportParser *prs) { - if (id >= NUM_PARSERS) - return false; - pRptParser[id] = prs; - return true; - }; - - /** - * Set HID protocol mode. - * @param mode HID protocol to use. Either HID_BOOT_PROTOCOL or HID_RPT_PROTOCOL. - */ - void setProtocolMode(uint8_t mode) { - protocolMode = mode; - }; - - /** - * Used to set the leds on a keyboard. - * @param data See KBDLEDS in hidboot.h - */ - void setLeds(uint8_t data); - - /** True if a device is connected */ - bool connected; - - /** Call this to start the paring sequence with a device */ - void pair(void) { - if(pBtd) - pBtd->pairWithHID(); - }; - -protected: - /** @name BluetoothService implementation */ - /** - * Used to pass acldata to the services. - * @param ACLData Incoming acldata. - */ - void ACLData(uint8_t* ACLData); - /** Used to run part of the state machine. */ - void Run(); - /** Use this to reset the service. */ - void Reset(); - /** - * Called when a device is successfully initialized. - * Use attachOnInit(void (*funcOnInit)(void)) to call your own function. - * This is useful for instance if you want to set the LEDs in a specific way. - */ - void onInit() { - if(pFuncOnInit) - pFuncOnInit(); // Call the user function - OnInitBTHID(); - }; - /**@}*/ - - /** @name Overridable functions */ - /** - * Used to parse Bluetooth HID data to any class that inherits this class. - * @param len The length of the incoming data. - * @param buf Pointer to the data buffer. - */ - virtual void ParseBTHIDData(uint8_t len, uint8_t *buf) { - return; - }; - /** Called when a device is connected */ - virtual void OnInitBTHID() { - return; - }; - /** Used to reset any buffers in the class that inherits this */ - virtual void ResetBTHID() { - return; - } - /**@}*/ - - /** L2CAP source CID for HID_Control */ - uint8_t control_scid[2]; - - /** L2CAP source CID for HID_Interrupt */ - uint8_t interrupt_scid[2]; - -private: - HIDReportParser *pRptParser[NUM_PARSERS]; // Pointer to HIDReportParsers. - - /** Set report protocol. */ - void setProtocol(); - uint8_t protocolMode; - - void L2CAP_task(); // L2CAP state machine - - bool activeConnection; // Used to indicate if it already has established a connection - - /* Variables used for L2CAP communication */ - uint8_t control_dcid[2]; // L2CAP device CID for HID_Control - Always 0x0070 - uint8_t interrupt_dcid[2]; // L2CAP device CID for HID_Interrupt - Always 0x0071 - uint8_t l2cap_state; -}; -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/PS3BT.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/PS3BT.cpp deleted file mode 100644 index 235092e0..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/PS3BT.cpp +++ /dev/null @@ -1,634 +0,0 @@ -/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#include "PS3BT.h" -// To enable serial debugging see "settings.h" -//#define EXTRADEBUG // Uncomment to get even more debugging data -//#define PRINTREPORT // Uncomment to print the report send by the PS3 Controllers - -PS3BT::PS3BT(BTD *p, uint8_t btadr5, uint8_t btadr4, uint8_t btadr3, uint8_t btadr2, uint8_t btadr1, uint8_t btadr0) : -BluetoothService(p) // Pointer to USB class instance - mandatory -{ - pBtd->my_bdaddr[5] = btadr5; // Change to your dongle's Bluetooth address instead - pBtd->my_bdaddr[4] = btadr4; - pBtd->my_bdaddr[3] = btadr3; - pBtd->my_bdaddr[2] = btadr2; - pBtd->my_bdaddr[1] = btadr1; - pBtd->my_bdaddr[0] = btadr0; - - HIDBuffer[0] = 0x52; // HID BT Set_report (0x50) | Report Type (Output 0x02) - HIDBuffer[1] = 0x01; // Report ID - - // Needed for PS3 Move Controller commands to work via bluetooth - HIDMoveBuffer[0] = 0xA2; // HID BT DATA_request (0xA0) | Report Type (Output 0x02) - HIDMoveBuffer[1] = 0x02; // Report ID - - /* Set device cid for the control and intterrupt channelse - LSB */ - control_dcid[0] = 0x40; // 0x0040 - control_dcid[1] = 0x00; - interrupt_dcid[0] = 0x41; // 0x0041 - interrupt_dcid[1] = 0x00; - - Reset(); -} - -bool PS3BT::getButtonPress(ButtonEnum b) { - return (ButtonState & pgm_read_dword(&PS3_BUTTONS[(uint8_t)b])); -} - -bool PS3BT::getButtonClick(ButtonEnum b) { - uint32_t button = pgm_read_dword(&PS3_BUTTONS[(uint8_t)b]); - bool click = (ButtonClickState & button); - ButtonClickState &= ~button; // Clear "click" event - return click; -} - -uint8_t PS3BT::getAnalogButton(ButtonEnum a) { - return (uint8_t)(l2capinbuf[pgm_read_byte(&PS3_ANALOG_BUTTONS[(uint8_t)a])]); -} - -uint8_t PS3BT::getAnalogHat(AnalogHatEnum a) { - return (uint8_t)(l2capinbuf[(uint8_t)a + 15]); -} - -int16_t PS3BT::getSensor(SensorEnum a) { - if(PS3Connected) { - if(a == aX || a == aY || a == aZ || a == gZ) - return ((l2capinbuf[(uint16_t)a] << 8) | l2capinbuf[(uint16_t)a + 1]); - else - return 0; - } else if(PS3MoveConnected) { - if(a == mXmove || a == mYmove) // These are all 12-bits long - return (((l2capinbuf[(uint16_t)a] & 0x0F) << 8) | (l2capinbuf[(uint16_t)a + 1])); - else if(a == mZmove || a == tempMove) // The tempearature is also 12 bits long - return ((l2capinbuf[(uint16_t)a] << 4) | ((l2capinbuf[(uint16_t)a + 1] & 0xF0) >> 4)); - else // aXmove, aYmove, aZmove, gXmove, gYmove and gZmove - return (l2capinbuf[(uint16_t)a] | (l2capinbuf[(uint16_t)a + 1] << 8)); - } else - return 0; -} - -double PS3BT::getAngle(AngleEnum a) { - double accXval, accYval, accZval; - - if(PS3Connected) { - // Data for the Kionix KXPC4 used in the DualShock 3 - const double zeroG = 511.5; // 1.65/3.3*1023 (1.65V) - accXval = -((double)getSensor(aX) - zeroG); - accYval = -((double)getSensor(aY) - zeroG); - accZval = -((double)getSensor(aZ) - zeroG); - } else if(PS3MoveConnected) { - // It's a Kionix KXSC4 inside the Motion controller - const uint16_t zeroG = 0x8000; - accXval = -(int16_t)(getSensor(aXmove) - zeroG); - accYval = (int16_t)(getSensor(aYmove) - zeroG); - accZval = (int16_t)(getSensor(aZmove) - zeroG); - } else - return 0; - - // Convert to 360 degrees resolution - // atan2 outputs the value of -π to π (radians) - // We are then converting it to 0 to 2π and then to degrees - if(a == Pitch) - return (atan2(accYval, accZval) + PI) * RAD_TO_DEG; - else - return (atan2(accXval, accZval) + PI) * RAD_TO_DEG; -} - -double PS3BT::get9DOFValues(SensorEnum a) { // Thanks to Manfred Piendl - if(!PS3MoveConnected) - return 0; - int16_t value = getSensor(a); - if(a == mXmove || a == mYmove || a == mZmove) { - if(value > 2047) - value -= 0x1000; - return (double)value / 3.2; // unit: muT = 10^(-6) Tesla - } else if(a == aXmove || a == aYmove || a == aZmove) { - if(value < 0) - value += 0x8000; - else - value -= 0x8000; - return (double)value / 442.0; // unit: m/(s^2) - } else if(a == gXmove || a == gYmove || a == gZmove) { - if(value < 0) - value += 0x8000; - else - value -= 0x8000; - if(a == gXmove) - return (double)value / 11.6; // unit: deg/s - else if(a == gYmove) - return (double)value / 11.2; // unit: deg/s - else // gZmove - return (double)value / 9.6; // unit: deg/s - } else - return 0; -} - -String PS3BT::getTemperature() { - if(PS3MoveConnected) { - int16_t input = getSensor(tempMove); - - String output = String(input / 100); - output += "."; - if(input % 100 < 10) - output += "0"; - output += String(input % 100); - - return output; - } else - return "Error"; -} - -bool PS3BT::getStatus(StatusEnum c) { - return (l2capinbuf[(uint16_t)c >> 8] == ((uint8_t)c & 0xff)); -} - -void PS3BT::printStatusString() { - char statusOutput[100]; // Max string length plus null character - if(PS3Connected || PS3NavigationConnected) { - strcpy_P(statusOutput, PSTR("ConnectionStatus: ")); - - if(getStatus(Plugged)) strcat_P(statusOutput, PSTR("Plugged")); - else if(getStatus(Unplugged)) strcat_P(statusOutput, PSTR("Unplugged")); - else strcat_P(statusOutput, PSTR("Error")); - - strcat_P(statusOutput, PSTR(" - PowerRating: ")); - - if(getStatus(Charging)) strcat_P(statusOutput, PSTR("Charging")); - else if(getStatus(NotCharging)) strcat_P(statusOutput, PSTR("Not Charging")); - else if(getStatus(Shutdown)) strcat_P(statusOutput, PSTR("Shutdown")); - else if(getStatus(Dying)) strcat_P(statusOutput, PSTR("Dying")); - else if(getStatus(Low)) strcat_P(statusOutput, PSTR("Low")); - else if(getStatus(High)) strcat_P(statusOutput, PSTR("High")); - else if(getStatus(Full)) strcat_P(statusOutput, PSTR("Full")); - else strcat_P(statusOutput, PSTR("Error")); - - strcat_P(statusOutput, PSTR(" - WirelessStatus: ")); - - if(getStatus(CableRumble)) strcat_P(statusOutput, PSTR("Cable - Rumble is on")); - else if(getStatus(Cable)) strcat_P(statusOutput, PSTR("Cable - Rumble is off")); - else if(getStatus(BluetoothRumble)) strcat_P(statusOutput, PSTR("Bluetooth - Rumble is on")); - else if(getStatus(Bluetooth)) strcat_P(statusOutput, PSTR("Bluetooth - Rumble is off")); - else strcat_P(statusOutput, PSTR("Error")); - } else if(PS3MoveConnected) { - strcpy_P(statusOutput, PSTR("PowerRating: ")); - - if(getStatus(MoveCharging)) strcat_P(statusOutput, PSTR("Charging")); - else if(getStatus(MoveNotCharging)) strcat_P(statusOutput, PSTR("Not Charging")); - else if(getStatus(MoveShutdown)) strcat_P(statusOutput, PSTR("Shutdown")); - else if(getStatus(MoveDying)) strcat_P(statusOutput, PSTR("Dying")); - else if(getStatus(MoveLow)) strcat_P(statusOutput, PSTR("Low")); - else if(getStatus(MoveHigh)) strcat_P(statusOutput, PSTR("High")); - else if(getStatus(MoveFull)) strcat_P(statusOutput, PSTR("Full")); - else strcat_P(statusOutput, PSTR("Error")); - } else - strcpy_P(statusOutput, PSTR("Error")); - - USB_HOST_SERIAL.write(statusOutput); -} - -void PS3BT::Reset() { - PS3Connected = false; - PS3MoveConnected = false; - PS3NavigationConnected = false; - activeConnection = false; - l2cap_event_flag = 0; // Reset flags - l2cap_state = L2CAP_WAIT; - - // Needed for PS3 Dualshock Controller commands to work via Bluetooth - for(uint8_t i = 0; i < PS3_REPORT_BUFFER_SIZE; i++) - HIDBuffer[i + 2] = pgm_read_byte(&PS3_REPORT_BUFFER[i]); // First two bytes reserved for report type and ID -} - -void PS3BT::disconnect() { // Use this void to disconnect any of the controllers - // First the HID interrupt channel has to be disconnected, then the HID control channel and finally the HCI connection - pBtd->l2cap_disconnection_request(hci_handle, ++identifier, interrupt_scid, interrupt_dcid); - Reset(); - l2cap_state = L2CAP_INTERRUPT_DISCONNECT; -} - -void PS3BT::ACLData(uint8_t* ACLData) { - if(!pBtd->l2capConnectionClaimed && !PS3Connected && !PS3MoveConnected && !PS3NavigationConnected && !activeConnection && !pBtd->connectToWii && !pBtd->incomingWii && !pBtd->pairWithWii) { - if(ACLData[8] == L2CAP_CMD_CONNECTION_REQUEST) { - if((ACLData[12] | (ACLData[13] << 8)) == HID_CTRL_PSM) { - pBtd->l2capConnectionClaimed = true; // Claim that the incoming connection belongs to this service - activeConnection = true; - hci_handle = pBtd->hci_handle; // Store the HCI Handle for the connection - l2cap_state = L2CAP_WAIT; - remote_name_first = pBtd->remote_name[0]; // Store the first letter in remote name for the connection -#ifdef DEBUG_USB_HOST - if(pBtd->hci_version < 3) { // Check the HCI Version of the Bluetooth dongle - Notify(PSTR("\r\nYour dongle may not support reading the analog buttons, sensors and status\r\nYour HCI Version is: "), 0x80); - Notify(pBtd->hci_version, 0x80); - Notify(PSTR("\r\nBut should be at least 3\r\nThis means that it doesn't support Bluetooth Version 2.0+EDR"), 0x80); - } -#endif - } - } - } - - if(checkHciHandle(ACLData, hci_handle)) { // acl_handle_ok - memcpy(l2capinbuf, ACLData, BULK_MAXPKTSIZE); - if((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001U) { // l2cap_control - Channel ID for ACL-U - if(l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80); - D_PrintHex (l2capinbuf[13], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[12], 0x80); - Notify(PSTR(" Data: "), 0x80); - D_PrintHex (l2capinbuf[17], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[16], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[15], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[14], 0x80); -#endif - } else if(l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) { -#ifdef EXTRADEBUG - Notify(PSTR("\r\nL2CAP Connection Request - PSM: "), 0x80); - D_PrintHex (l2capinbuf[13], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[12], 0x80); - Notify(PSTR(" SCID: "), 0x80); - D_PrintHex (l2capinbuf[15], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[14], 0x80); - Notify(PSTR(" Identifier: "), 0x80); - D_PrintHex (l2capinbuf[9], 0x80); -#endif - if((l2capinbuf[12] | (l2capinbuf[13] << 8)) == HID_CTRL_PSM) { - identifier = l2capinbuf[9]; - control_scid[0] = l2capinbuf[14]; - control_scid[1] = l2capinbuf[15]; - l2cap_set_flag(L2CAP_FLAG_CONNECTION_CONTROL_REQUEST); - } else if((l2capinbuf[12] | (l2capinbuf[13] << 8)) == HID_INTR_PSM) { - identifier = l2capinbuf[9]; - interrupt_scid[0] = l2capinbuf[14]; - interrupt_scid[1] = l2capinbuf[15]; - l2cap_set_flag(L2CAP_FLAG_CONNECTION_INTERRUPT_REQUEST); - } - } else if(l2capinbuf[8] == L2CAP_CMD_CONFIG_RESPONSE) { - if((l2capinbuf[16] | (l2capinbuf[17] << 8)) == 0x0000) { // Success - if(l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) { - //Notify(PSTR("\r\nHID Control Configuration Complete"), 0x80); - l2cap_set_flag(L2CAP_FLAG_CONFIG_CONTROL_SUCCESS); - } else if(l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) { - //Notify(PSTR("\r\nHID Interrupt Configuration Complete"), 0x80); - l2cap_set_flag(L2CAP_FLAG_CONFIG_INTERRUPT_SUCCESS); - } - } - } else if(l2capinbuf[8] == L2CAP_CMD_CONFIG_REQUEST) { - if(l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) { - //Notify(PSTR("\r\nHID Control Configuration Request"), 0x80); - pBtd->l2cap_config_response(hci_handle, l2capinbuf[9], control_scid); - } else if(l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) { - //Notify(PSTR("\r\nHID Interrupt Configuration Request"), 0x80); - pBtd->l2cap_config_response(hci_handle, l2capinbuf[9], interrupt_scid); - } - } else if(l2capinbuf[8] == L2CAP_CMD_DISCONNECT_REQUEST) { - if(l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nDisconnect Request: Control Channel"), 0x80); -#endif - identifier = l2capinbuf[9]; - pBtd->l2cap_disconnection_response(hci_handle, identifier, control_dcid, control_scid); - Reset(); - } else if(l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nDisconnect Request: Interrupt Channel"), 0x80); -#endif - identifier = l2capinbuf[9]; - pBtd->l2cap_disconnection_response(hci_handle, identifier, interrupt_dcid, interrupt_scid); - Reset(); - } - } else if(l2capinbuf[8] == L2CAP_CMD_DISCONNECT_RESPONSE) { - if(l2capinbuf[12] == control_scid[0] && l2capinbuf[13] == control_scid[1]) { - //Notify(PSTR("\r\nDisconnect Response: Control Channel"), 0x80); - identifier = l2capinbuf[9]; - l2cap_set_flag(L2CAP_FLAG_DISCONNECT_CONTROL_RESPONSE); - } else if(l2capinbuf[12] == interrupt_scid[0] && l2capinbuf[13] == interrupt_scid[1]) { - //Notify(PSTR("\r\nDisconnect Response: Interrupt Channel"), 0x80); - identifier = l2capinbuf[9]; - l2cap_set_flag(L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE); - } - } -#ifdef EXTRADEBUG - else { - Notify(PSTR("\r\nL2CAP Unknown Signaling Command: "), 0x80); - D_PrintHex (l2capinbuf[8], 0x80); - } -#endif - } else if(l2capinbuf[6] == interrupt_dcid[0] && l2capinbuf[7] == interrupt_dcid[1]) { // l2cap_interrupt - //Notify(PSTR("\r\nL2CAP Interrupt"), 0x80); - if(PS3Connected || PS3MoveConnected || PS3NavigationConnected) { - /* Read Report */ - if(l2capinbuf[8] == 0xA1) { // HID_THDR_DATA_INPUT - lastMessageTime = millis(); // Store the last message time - - if(PS3Connected || PS3NavigationConnected) - ButtonState = (uint32_t)(l2capinbuf[11] | ((uint16_t)l2capinbuf[12] << 8) | ((uint32_t)l2capinbuf[13] << 16)); - else if(PS3MoveConnected) - ButtonState = (uint32_t)(l2capinbuf[10] | ((uint16_t)l2capinbuf[11] << 8) | ((uint32_t)l2capinbuf[12] << 16)); - - //Notify(PSTR("\r\nButtonState", 0x80); - //PrintHex(ButtonState, 0x80); - - if(ButtonState != OldButtonState) { - ButtonClickState = ButtonState & ~OldButtonState; // Update click state variable - OldButtonState = ButtonState; - } - -#ifdef PRINTREPORT // Uncomment "#define PRINTREPORT" to print the report send by the PS3 Controllers - for(uint8_t i = 10; i < 58; i++) { - D_PrintHex (l2capinbuf[i], 0x80); - Notify(PSTR(" "), 0x80); - } - Notify(PSTR("\r\n"), 0x80); -#endif - } - } - } - L2CAP_task(); - } -} - -void PS3BT::L2CAP_task() { - switch(l2cap_state) { - case L2CAP_WAIT: - if(l2cap_check_flag(L2CAP_FLAG_CONNECTION_CONTROL_REQUEST)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nHID Control Incoming Connection Request"), 0x80); -#endif - pBtd->l2cap_connection_response(hci_handle, identifier, control_dcid, control_scid, PENDING); - delay(1); - pBtd->l2cap_connection_response(hci_handle, identifier, control_dcid, control_scid, SUCCESSFUL); - identifier++; - delay(1); - pBtd->l2cap_config_request(hci_handle, identifier, control_scid); - l2cap_state = L2CAP_CONTROL_SUCCESS; - } - break; - - case L2CAP_CONTROL_SUCCESS: - if(l2cap_check_flag(L2CAP_FLAG_CONFIG_CONTROL_SUCCESS)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nHID Control Successfully Configured"), 0x80); -#endif - l2cap_state = L2CAP_INTERRUPT_SETUP; - } - break; - - case L2CAP_INTERRUPT_SETUP: - if(l2cap_check_flag(L2CAP_FLAG_CONNECTION_INTERRUPT_REQUEST)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nHID Interrupt Incoming Connection Request"), 0x80); -#endif - pBtd->l2cap_connection_response(hci_handle, identifier, interrupt_dcid, interrupt_scid, PENDING); - delay(1); - pBtd->l2cap_connection_response(hci_handle, identifier, interrupt_dcid, interrupt_scid, SUCCESSFUL); - identifier++; - delay(1); - pBtd->l2cap_config_request(hci_handle, identifier, interrupt_scid); - - l2cap_state = L2CAP_INTERRUPT_CONFIG_REQUEST; - } - break; - - case L2CAP_INTERRUPT_CONFIG_REQUEST: - if(l2cap_check_flag(L2CAP_FLAG_CONFIG_INTERRUPT_SUCCESS)) { // Now the HID channels is established -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nHID Interrupt Successfully Configured"), 0x80); -#endif - if(remote_name_first == 'M') { // First letter in Motion Controller ('M') - memset(l2capinbuf, 0, BULK_MAXPKTSIZE); // Reset l2cap in buffer as it sometimes read it as a button has been pressed - l2cap_state = TURN_ON_LED; - } else - l2cap_state = PS3_ENABLE_SIXAXIS; - timer = millis(); - } - break; - - /* These states are handled in Run() */ - - case L2CAP_INTERRUPT_DISCONNECT: - if(l2cap_check_flag(L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nDisconnected Interrupt Channel"), 0x80); -#endif - identifier++; - pBtd->l2cap_disconnection_request(hci_handle, identifier, control_scid, control_dcid); - l2cap_state = L2CAP_CONTROL_DISCONNECT; - } - break; - - case L2CAP_CONTROL_DISCONNECT: - if(l2cap_check_flag(L2CAP_FLAG_DISCONNECT_CONTROL_RESPONSE)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nDisconnected Control Channel"), 0x80); -#endif - pBtd->hci_disconnect(hci_handle); - hci_handle = -1; // Reset handle - l2cap_event_flag = 0; // Reset flags - l2cap_state = L2CAP_WAIT; - } - break; - } -} - -void PS3BT::Run() { - switch(l2cap_state) { - case PS3_ENABLE_SIXAXIS: - if(millis() - timer > 1000) { // loop 1 second before sending the command - memset(l2capinbuf, 0, BULK_MAXPKTSIZE); // Reset l2cap in buffer as it sometimes read it as a button has been pressed - for(uint8_t i = 15; i < 19; i++) - l2capinbuf[i] = 0x7F; // Set the analog joystick values to center position - enable_sixaxis(); - l2cap_state = TURN_ON_LED; - timer = millis(); - } - break; - - case TURN_ON_LED: - if(millis() - timer > 1000) { // loop 1 second before sending the command - if(remote_name_first == 'P') { // First letter in PLAYSTATION(R)3 Controller ('P') -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nDualshock 3 Controller Enabled\r\n"), 0x80); -#endif - PS3Connected = true; - } else if(remote_name_first == 'N') { // First letter in Navigation Controller ('N') -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nNavigation Controller Enabled\r\n"), 0x80); -#endif - PS3NavigationConnected = true; - } else if(remote_name_first == 'M') { // First letter in Motion Controller ('M') - timer = millis(); -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nMotion Controller Enabled\r\n"), 0x80); -#endif - PS3MoveConnected = true; - } - ButtonState = 0; // Clear all values - OldButtonState = 0; - ButtonClickState = 0; - - onInit(); // Turn on the LED on the controller - l2cap_state = L2CAP_DONE; - } - break; - - case L2CAP_DONE: - if(PS3MoveConnected) { // The Bulb and rumble values, has to be send at approximately every 5th second for it to stay on - if(millis() - timer > 4000) { // Send at least every 4th second - HIDMove_Command(HIDMoveBuffer, HID_BUFFERSIZE); // The Bulb and rumble values, has to be written again and again, for it to stay turned on - timer = millis(); - } - } - break; - } -} - -/************************************************************/ -/* HID Commands */ -/************************************************************/ - -// Playstation Sixaxis Dualshock and Navigation Controller commands - -void PS3BT::HID_Command(uint8_t* data, uint8_t nbytes) { - if(millis() - timerHID <= 150) // Check if is has been more than 150ms since last command - delay((uint32_t)(150 - (millis() - timerHID))); // There have to be a delay between commands - pBtd->L2CAP_Command(hci_handle, data, nbytes, control_scid[0], control_scid[1]); // Both the Navigation and Dualshock controller sends data via the control channel - timerHID = millis(); -} - -void PS3BT::setAllOff() { - HIDBuffer[3] = 0x00; // Rumble bytes - HIDBuffer[4] = 0x00; - HIDBuffer[5] = 0x00; - HIDBuffer[6] = 0x00; - - HIDBuffer[11] = 0x00; // LED byte - - HID_Command(HIDBuffer, HID_BUFFERSIZE); -} - -void PS3BT::setRumbleOff() { - HIDBuffer[3] = 0x00; - HIDBuffer[4] = 0x00; - HIDBuffer[5] = 0x00; - HIDBuffer[6] = 0x00; - - HID_Command(HIDBuffer, HID_BUFFERSIZE); -} - -void PS3BT::setRumbleOn(RumbleEnum mode) { - uint8_t power[2] = {0xff, 0x00}; // Defaults to RumbleLow - if(mode == RumbleHigh) { - power[0] = 0x00; - power[1] = 0xff; - } - setRumbleOn(0xfe, power[0], 0xfe, power[1]); -} - -void PS3BT::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower) { - HIDBuffer[3] = rightDuration; - HIDBuffer[4] = rightPower; - HIDBuffer[5] = leftDuration; - HIDBuffer[6] = leftPower; - HID_Command(HIDBuffer, HID_BUFFERSIZE); -} - -void PS3BT::setLedRaw(uint8_t value) { - HIDBuffer[11] = value << 1; - HID_Command(HIDBuffer, HID_BUFFERSIZE); -} - -void PS3BT::setLedOff(LEDEnum a) { - HIDBuffer[11] &= ~((uint8_t)((pgm_read_byte(&PS3_LEDS[(uint8_t)a]) & 0x0f) << 1)); - HID_Command(HIDBuffer, HID_BUFFERSIZE); -} - -void PS3BT::setLedOn(LEDEnum a) { - if(a == OFF) - setLedRaw(0); - else { - HIDBuffer[11] |= (uint8_t)((pgm_read_byte(&PS3_LEDS[(uint8_t)a]) & 0x0f) << 1); - HID_Command(HIDBuffer, HID_BUFFERSIZE); - } -} - -void PS3BT::setLedToggle(LEDEnum a) { - HIDBuffer[11] ^= (uint8_t)((pgm_read_byte(&PS3_LEDS[(uint8_t)a]) & 0x0f) << 1); - HID_Command(HIDBuffer, HID_BUFFERSIZE); -} - -void PS3BT::enable_sixaxis() { // Command used to enable the Dualshock 3 and Navigation controller to send data via Bluetooth - uint8_t cmd_buf[6]; - cmd_buf[0] = 0x53; // HID BT Set_report (0x50) | Report Type (Feature 0x03) - cmd_buf[1] = 0xF4; // Report ID - cmd_buf[2] = 0x42; // Special PS3 Controller enable commands - cmd_buf[3] = 0x03; - cmd_buf[4] = 0x00; - cmd_buf[5] = 0x00; - - HID_Command(cmd_buf, 6); -} - -// Playstation Move Controller commands - -void PS3BT::HIDMove_Command(uint8_t* data, uint8_t nbytes) { - if(millis() - timerHID <= 150)// Check if is has been less than 150ms since last command - delay((uint32_t)(150 - (millis() - timerHID))); // There have to be a delay between commands - pBtd->L2CAP_Command(hci_handle, data, nbytes, interrupt_scid[0], interrupt_scid[1]); // The Move controller sends it's data via the intterrupt channel - timerHID = millis(); -} - -void PS3BT::moveSetBulb(uint8_t r, uint8_t g, uint8_t b) { // Use this to set the Color using RGB values - // Set the Bulb's values into the write buffer - HIDMoveBuffer[3] = r; - HIDMoveBuffer[4] = g; - HIDMoveBuffer[5] = b; - - HIDMove_Command(HIDMoveBuffer, HID_BUFFERSIZE); -} - -void PS3BT::moveSetBulb(ColorsEnum color) { // Use this to set the Color using the predefined colors in enum - moveSetBulb((uint8_t)(color >> 16), (uint8_t)(color >> 8), (uint8_t)(color)); -} - -void PS3BT::moveSetRumble(uint8_t rumble) { -#ifdef DEBUG_USB_HOST - if(rumble < 64 && rumble != 0) // The rumble value has to at least 64, or approximately 25% (64/255*100) - Notify(PSTR("\r\nThe rumble value has to at least 64, or approximately 25%"), 0x80); -#endif - // Set the rumble value into the write buffer - HIDMoveBuffer[7] = rumble; - - HIDMove_Command(HIDMoveBuffer, HID_BUFFERSIZE); -} - -void PS3BT::onInit() { - if(pFuncOnInit) - pFuncOnInit(); // Call the user function - else { - if(PS3MoveConnected) - moveSetBulb(Red); - else // Dualshock 3 or Navigation controller - setLedOn(LED1); - } -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/PS3BT.h b/protocol/usb_hid/USB_Host_Shield_2.0/PS3BT.h deleted file mode 100644 index c25ac5e5..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/PS3BT.h +++ /dev/null @@ -1,240 +0,0 @@ -/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#ifndef _ps3bt_h_ -#define _ps3bt_h_ - -#include "BTD.h" -#include "PS3Enums.h" - -#define HID_BUFFERSIZE 50 // Size of the buffer for the Playstation Motion Controller - -/** - * This BluetoothService class implements support for all the official PS3 Controllers: - * Dualshock 3, Navigation or a Motion controller via Bluetooth. - * - * Information about the protocol can be found at the wiki: https://github.com/felis/USB_Host_Shield_2.0/wiki/PS3-Information. - */ -class PS3BT : public BluetoothService { -public: - /** - * Constructor for the PS3BT class. - * @param pBtd Pointer to BTD class instance. - * @param btadr5,btadr4,btadr3,btadr2,btadr1,btadr0 - * Pass your dongles Bluetooth address into the constructor, - * This will set BTD#my_bdaddr, so you don't have to plug in the dongle before pairing with your controller. - */ - PS3BT(BTD *pBtd, uint8_t btadr5 = 0, uint8_t btadr4 = 0, uint8_t btadr3 = 0, uint8_t btadr2 = 0, uint8_t btadr1 = 0, uint8_t btadr0 = 0); - - /** @name BluetoothService implementation */ - /** Used this to disconnect any of the controllers. */ - void disconnect(); - /**@}*/ - - /** @name PS3 Controller functions */ - /** - * getButtonPress(ButtonEnum b) will return true as long as the button is held down. - * - * While getButtonClick(ButtonEnum b) will only return it once. - * - * So you instance if you need to increase a variable once you would use getButtonClick(ButtonEnum b), - * but if you need to drive a robot forward you would use getButtonPress(ButtonEnum b). - * @param b ::ButtonEnum to read. - * @return getButtonPress(ButtonEnum b) will return a true as long as a button is held down, while getButtonClick(ButtonEnum b) will return true once for each button press. - */ - bool getButtonPress(ButtonEnum b); - bool getButtonClick(ButtonEnum b); - /**@}*/ - /** @name PS3 Controller functions */ - /** - * Used to get the analog value from button presses. - * @param a The ::ButtonEnum to read. - * The supported buttons are: - * ::UP, ::RIGHT, ::DOWN, ::LEFT, ::L1, ::L2, ::R1, ::R2, - * ::TRIANGLE, ::CIRCLE, ::CROSS, ::SQUARE, and ::T. - * @return Analog value in the range of 0-255. - */ - uint8_t getAnalogButton(ButtonEnum a); - /** - * Used to read the analog joystick. - * @param a ::LeftHatX, ::LeftHatY, ::RightHatX, and ::RightHatY. - * @return Return the analog value in the range of 0-255. - */ - uint8_t getAnalogHat(AnalogHatEnum a); - /** - * Used to read the sensors inside the Dualshock 3 and Move controller. - * @param a - * The Dualshock 3 has a 3-axis accelerometer and a 1-axis gyro inside. - * The Move controller has a 3-axis accelerometer, a 3-axis gyro, a 3-axis magnetometer - * and a temperature sensor inside. - * @return Return the raw sensor value. - */ - int16_t getSensor(SensorEnum a); - /** - * Use this to get ::Pitch and ::Roll calculated using the accelerometer. - * @param a Either ::Pitch or ::Roll. - * @return Return the angle in the range of 0-360. - */ - double getAngle(AngleEnum a); - /** - * Read the sensors inside the Move controller. - * @param a ::aXmove, ::aYmove, ::aZmove, ::gXmove, ::gYmove, ::gZmove, ::mXmove, ::mYmove, and ::mXmove. - * @return The value in SI units. - */ - double get9DOFValues(SensorEnum a); - /** - * Get the status from the controller. - * @param c The ::StatusEnum you want to read. - * @return True if correct and false if not. - */ - bool getStatus(StatusEnum c); - /** Read all the available statuses from the controller and prints it as a nice formated string. */ - void printStatusString(); - /** - * Read the temperature from the Move controller. - * @return The temperature in degrees Celsius. - */ - String getTemperature(); - - /** Used to set all LEDs and rumble off. */ - void setAllOff(); - /** Turn off rumble. */ - void setRumbleOff(); - /** - * Turn on rumble. - * @param mode Either ::RumbleHigh or ::RumbleLow. - */ - void setRumbleOn(RumbleEnum mode); - /** - * Turn on rumble using custom duration and power. - * @param rightDuration The duration of the right/low rumble effect. - * @param rightPower The intensity of the right/low rumble effect. - * @param leftDuration The duration of the left/high rumble effect. - * @param leftPower The intensity of the left/high rumble effect. - */ - void setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower); - - /** - * Set LED value without using ::LEDEnum. - * @param value See: ::LEDEnum. - */ - void setLedRaw(uint8_t value); - - /** Turn all LEDs off. */ - void setLedOff() { - setLedRaw(0); - }; - /** - * Turn the specific LED off. - * @param a The ::LEDEnum to turn off. - */ - void setLedOff(LEDEnum a); - /** - * Turn the specific LED on. - * @param a The ::LEDEnum to turn on. - */ - void setLedOn(LEDEnum a); - /** - * Toggle the specific LED. - * @param a The ::LEDEnum to toggle. - */ - void setLedToggle(LEDEnum a); - - /** - * Use this to set the Color using RGB values. - * @param r,g,b RGB value. - */ - void moveSetBulb(uint8_t r, uint8_t g, uint8_t b); - /** - * Use this to set the color using the predefined colors in ::ColorsEnum. - * @param color The desired color. - */ - void moveSetBulb(ColorsEnum color); - /** - * Set the rumble value inside the Move controller. - * @param rumble The desired value in the range from 64-255. - */ - void moveSetRumble(uint8_t rumble); - - /** Used to get the millis() of the last message */ - uint32_t getLastMessageTime() { - return lastMessageTime; - }; - /**@}*/ - - /** Variable used to indicate if the normal Playstation controller is successfully connected. */ - bool PS3Connected; - /** Variable used to indicate if the Move controller is successfully connected. */ - bool PS3MoveConnected; - /** Variable used to indicate if the Navigation controller is successfully connected. */ - bool PS3NavigationConnected; - -protected: - /** @name BluetoothService implementation */ - /** - * Used to pass acldata to the services. - * @param ACLData Incoming acldata. - */ - void ACLData(uint8_t* ACLData); - /** Used to run part of the state machine. */ - void Run(); - /** Use this to reset the service. */ - void Reset(); - /** - * Called when the controller is successfully initialized. - * Use attachOnInit(void (*funcOnInit)(void)) to call your own function. - * This is useful for instance if you want to set the LEDs in a specific way. - */ - void onInit(); - /**@}*/ - -private: - - void L2CAP_task(); // L2CAP state machine - - /* Variables filled from HCI event management */ - char remote_name_first; // First letter in remote name - bool activeConnection; // Used to indicate if it's already has established a connection - - /* Variables used by high level L2CAP task */ - uint8_t l2cap_state; - - uint32_t lastMessageTime; // Variable used to store the millis value of the last message. - - uint32_t ButtonState; - uint32_t OldButtonState; - uint32_t ButtonClickState; - - uint32_t timer; // Timer used to limit time between messages and also used to continuously set PS3 Move controller Bulb and rumble values - uint32_t timerHID; // Timer used see if there has to be a delay before a new HID command - - uint8_t l2capinbuf[BULK_MAXPKTSIZE]; // General purpose buffer for L2CAP in data - uint8_t HIDBuffer[HID_BUFFERSIZE]; // Used to store HID commands - uint8_t HIDMoveBuffer[HID_BUFFERSIZE]; // Used to store HID commands for the Move controller - - /* L2CAP Channels */ - uint8_t control_scid[2]; // L2CAP source CID for HID_Control - uint8_t control_dcid[2]; // 0x0040 - uint8_t interrupt_scid[2]; // L2CAP source CID for HID_Interrupt - uint8_t interrupt_dcid[2]; // 0x0041 - - /* HID Commands */ - void HID_Command(uint8_t* data, uint8_t nbytes); - void HIDMove_Command(uint8_t* data, uint8_t nbytes); - void enable_sixaxis(); // Command used to enable the Dualshock 3 and Navigation controller to send data via Bluetooth -}; -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/PS3Enums.h b/protocol/usb_hid/USB_Host_Shield_2.0/PS3Enums.h deleted file mode 100644 index 77801945..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/PS3Enums.h +++ /dev/null @@ -1,141 +0,0 @@ -/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#ifndef _ps3enums_h -#define _ps3enums_h - -#include "controllerEnums.h" - -/** Size of the output report buffer for the Dualshock and Navigation controllers */ -#define PS3_REPORT_BUFFER_SIZE 48 - -/** Report buffer for all PS3 commands */ -const uint8_t PS3_REPORT_BUFFER[PS3_REPORT_BUFFER_SIZE] PROGMEM = { - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0x27, 0x10, 0x00, 0x32, - 0xff, 0x27, 0x10, 0x00, 0x32, - 0xff, 0x27, 0x10, 0x00, 0x32, - 0xff, 0x27, 0x10, 0x00, 0x32, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -/** Size of the output report buffer for the Move Controller */ -#define MOVE_REPORT_BUFFER_SIZE 7 - -/** Used to set the LEDs on the controllers */ -const uint8_t PS3_LEDS[] PROGMEM = { - 0x00, // OFF - 0x01, // LED1 - 0x02, // LED2 - 0x04, // LED3 - 0x08, // LED4 - - 0x09, // LED5 - 0x0A, // LED6 - 0x0C, // LED7 - 0x0D, // LED8 - 0x0E, // LED9 - 0x0F, // LED10 -}; - -/** - * Buttons on the controllers. - * Note: that the location is shifted 9 when it's connected via USB. - */ -const uint32_t PS3_BUTTONS[] PROGMEM = { - 0x10, // UP - 0x20, // RIGHT - 0x40, // DOWN - 0x80, // LEFT - - 0x01, // SELECT - 0x08, // START - 0x02, // L3 - 0x04, // R3 - - 0x0100, // L2 - 0x0200, // R2 - 0x0400, // L1 - 0x0800, // R1 - - 0x1000, // TRIANGLE - 0x2000, // CIRCLE - 0x4000, // CROSS - 0x8000, // SQUARE - - 0x010000, // PS - 0x080000, // MOVE - covers 12 bits - we only need to read the top 8 - 0x100000, // T - covers 12 bits - we only need to read the top 8 -}; - -/** - * Analog buttons on the controllers. - * Note: that the location is shifted 9 when it's connected via USB. - */ -const uint8_t PS3_ANALOG_BUTTONS[] PROGMEM = { - 23, // UP_ANALOG - 24, // RIGHT_ANALOG - 25, // DOWN_ANALOG - 26, // LEFT_ANALOG - 0, 0, 0, 0, // Skip SELECT, L3, R3 and START - - 27, // L2_ANALOG - 28, // R2_ANALOG - 29, // L1_ANALOG - 30, // R1_ANALOG - 31, // TRIANGLE_ANALOG - 32, // CIRCLE_ANALOG - 33, // CROSS_ANALOG - 34, // SQUARE_ANALOG - 0, 0, // Skip PS and MOVE - - // Playstation Move Controller - 15, // T_ANALOG - Both at byte 14 (last reading) and byte 15 (current reading) -}; - -enum StatusEnum { - // Note that the location is shifted 9 when it's connected via USB - // Byte location | bit location - Plugged = (38 << 8) | 0x02, - Unplugged = (38 << 8) | 0x03, - - Charging = (39 << 8) | 0xEE, - NotCharging = (39 << 8) | 0xF1, - Shutdown = (39 << 8) | 0x01, - Dying = (39 << 8) | 0x02, - Low = (39 << 8) | 0x03, - High = (39 << 8) | 0x04, - Full = (39 << 8) | 0x05, - - MoveCharging = (21 << 8) | 0xEE, - MoveNotCharging = (21 << 8) | 0xF1, - MoveShutdown = (21 << 8) | 0x01, - MoveDying = (21 << 8) | 0x02, - MoveLow = (21 << 8) | 0x03, - MoveHigh = (21 << 8) | 0x04, - MoveFull = (21 << 8) | 0x05, - - CableRumble = (40 << 8) | 0x10, // Operating by USB and rumble is turned on - Cable = (40 << 8) | 0x12, // Operating by USB and rumble is turned off - BluetoothRumble = (40 << 8) | 0x14, // Operating by Bluetooth and rumble is turned on - Bluetooth = (40 << 8) | 0x16, // Operating by Bluetooth and rumble is turned off -}; - -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/PS3USB.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/PS3USB.cpp deleted file mode 100755 index c3217538..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/PS3USB.cpp +++ /dev/null @@ -1,572 +0,0 @@ -/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#include "PS3USB.h" -// To enable serial debugging see "settings.h" -//#define EXTRADEBUG // Uncomment to get even more debugging data -//#define PRINTREPORT // Uncomment to print the report send by the PS3 Controllers - -PS3USB::PS3USB(USB *p, uint8_t btadr5, uint8_t btadr4, uint8_t btadr3, uint8_t btadr2, uint8_t btadr1, uint8_t btadr0) : -pUsb(p), // pointer to USB class instance - mandatory -bAddress(0), // device address - mandatory -bPollEnable(false) // don't start polling before dongle is connected -{ - for(uint8_t i = 0; i < PS3_MAX_ENDPOINTS; i++) { - epInfo[i].epAddr = 0; - epInfo[i].maxPktSize = (i) ? 0 : 8; - epInfo[i].epAttribs = 0; - epInfo[i].bmNakPower = (i) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER; - } - - if(pUsb) // register in USB subsystem - pUsb->RegisterDeviceClass(this); //set devConfig[] entry - - my_bdaddr[5] = btadr5; // Change to your dongle's Bluetooth address instead - my_bdaddr[4] = btadr4; - my_bdaddr[3] = btadr3; - my_bdaddr[2] = btadr2; - my_bdaddr[1] = btadr1; - my_bdaddr[0] = btadr0; -} - -uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) { - uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)]; - USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); - uint8_t rcode; - UsbDevice *p = NULL; - EpInfo *oldep_ptr = NULL; - uint16_t PID; - uint16_t VID; - - // get memory address of USB device address pool - AddressPool &addrPool = pUsb->GetAddressPool(); -#ifdef EXTRADEBUG - Notify(PSTR("\r\nPS3USB Init"), 0x80); -#endif - // check if address has already been assigned to an instance - if(bAddress) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nAddress in use"), 0x80); -#endif - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - } - - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - - if(!p) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nAddress not found"), 0x80); -#endif - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - } - - if(!p->epinfo) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nepinfo is null"), 0x80); -#endif - return USB_ERROR_EPINFO_IS_NULL; - } - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - - p->lowspeed = lowspeed; - - // Get device descriptor - rcode = pUsb->getDevDescr(0, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*)buf); // Get device descriptor - addr, ep, nbytes, data - // Restore p->epinfo - p->epinfo = oldep_ptr; - - if(rcode) - goto FailGetDevDescr; - - VID = udd->idVendor; - PID = udd->idProduct; - - if(VID != PS3_VID || (PID != PS3_PID && PID != PS3NAVIGATION_PID && PID != PS3MOVE_PID)) - goto FailUnknownDevice; - - // Allocate new address according to device class - bAddress = addrPool.AllocAddress(parent, false, port); - - if(!bAddress) - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - - // Extract Max Packet Size from device descriptor - epInfo[0].maxPktSize = udd->bMaxPacketSize0; - - // Assign new address to the device - rcode = pUsb->setAddr(0, 0, bAddress); - if(rcode) { - p->lowspeed = false; - addrPool.FreeAddress(bAddress); - bAddress = 0; -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nsetAddr: "), 0x80); - D_PrintHex (rcode, 0x80); -#endif - return rcode; - } -#ifdef EXTRADEBUG - Notify(PSTR("\r\nAddr: "), 0x80); - D_PrintHex (bAddress, 0x80); -#endif - //delay(300); // Spec says you should wait at least 200ms - - p->lowspeed = false; - - //get pointer to assigned address record - p = addrPool.GetUsbDevicePtr(bAddress); - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - p->lowspeed = lowspeed; - - // Assign epInfo to epinfo pointer - only EP0 is known - rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo); - if(rcode) - goto FailSetDevTblEntry; - - - /* The application will work in reduced host mode, so we can save program and data - memory space. After verifying the PID and VID we will use known values for the - configuration values for device, interface, endpoints and HID for the PS3 Controllers */ - - /* Initialize data structures for endpoints of device */ - epInfo[ PS3_OUTPUT_PIPE ].epAddr = 0x02; // PS3 output endpoint - epInfo[ PS3_OUTPUT_PIPE ].epAttribs = USB_TRANSFER_TYPE_INTERRUPT; - epInfo[ PS3_OUTPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints - epInfo[ PS3_OUTPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE; - epInfo[ PS3_OUTPUT_PIPE ].bmSndToggle = 0; - epInfo[ PS3_OUTPUT_PIPE ].bmRcvToggle = 0; - epInfo[ PS3_INPUT_PIPE ].epAddr = 0x01; // PS3 report endpoint - epInfo[ PS3_INPUT_PIPE ].epAttribs = USB_TRANSFER_TYPE_INTERRUPT; - epInfo[ PS3_INPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints - epInfo[ PS3_INPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE; - epInfo[ PS3_INPUT_PIPE ].bmSndToggle = 0; - epInfo[ PS3_INPUT_PIPE ].bmRcvToggle = 0; - - rcode = pUsb->setEpInfoEntry(bAddress, 3, epInfo); - if(rcode) - goto FailSetDevTblEntry; - - delay(200); //Give time for address change - - rcode = pUsb->setConf(bAddress, epInfo[ PS3_CONTROL_PIPE ].epAddr, 1); - if(rcode) - goto FailSetConfDescr; - - if(PID == PS3_PID || PID == PS3NAVIGATION_PID) { - if(PID == PS3_PID) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nDualshock 3 Controller Connected"), 0x80); -#endif - PS3Connected = true; - } else { // must be a navigation controller -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nNavigation Controller Connected"), 0x80); -#endif - PS3NavigationConnected = true; - } - enable_sixaxis(); // The PS3 controller needs a special command before it starts sending data - - // Needed for PS3 Dualshock and Navigation commands to work - for(uint8_t i = 0; i < PS3_REPORT_BUFFER_SIZE; i++) - writeBuf[i] = pgm_read_byte(&PS3_REPORT_BUFFER[i]); - - for(uint8_t i = 6; i < 10; i++) - readBuf[i] = 0x7F; // Set the analog joystick values to center position - } else { // must be a Motion controller -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nMotion Controller Connected"), 0x80); -#endif - PS3MoveConnected = true; - writeBuf[0] = 0x02; // Set report ID, this is needed for Move commands to work - } - if(my_bdaddr[0] != 0x00 || my_bdaddr[1] != 0x00 || my_bdaddr[2] != 0x00 || my_bdaddr[3] != 0x00 || my_bdaddr[4] != 0x00 || my_bdaddr[5] != 0x00) { - if(PS3MoveConnected) - setMoveBdaddr(my_bdaddr); // Set internal Bluetooth address - else - setBdaddr(my_bdaddr); // Set internal Bluetooth address - -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80); - for(int8_t i = 5; i > 0; i--) { - D_PrintHex (my_bdaddr[i], 0x80); - Notify(PSTR(":"), 0x80); - } - D_PrintHex (my_bdaddr[0], 0x80); -#endif - } - onInit(); - - bPollEnable = true; - Notify(PSTR("\r\n"), 0x80); - timer = millis(); - return 0; // Successful configuration - - /* Diagnostic messages */ -FailGetDevDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetDevDescr(); - goto Fail; -#endif - -FailSetDevTblEntry: -#ifdef DEBUG_USB_HOST - NotifyFailSetDevTblEntry(); - goto Fail; -#endif - -FailSetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailSetConfDescr(); -#endif - goto Fail; - -FailUnknownDevice: -#ifdef DEBUG_USB_HOST - NotifyFailUnknownDevice(VID, PID); -#endif - rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - -Fail: -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nPS3 Init Failed, error code: "), 0x80); - NotifyFail(rcode); -#endif - Release(); - return rcode; -} - -/* Performs a cleanup after failed Init() attempt */ -uint8_t PS3USB::Release() { - PS3Connected = false; - PS3MoveConnected = false; - PS3NavigationConnected = false; - pUsb->GetAddressPool().FreeAddress(bAddress); - bAddress = 0; - bPollEnable = false; - return 0; -} - -uint8_t PS3USB::Poll() { - if(!bPollEnable) - return 0; - - if(PS3Connected || PS3NavigationConnected) { - uint16_t BUFFER_SIZE = EP_MAXPKTSIZE; - pUsb->inTransfer(bAddress, epInfo[ PS3_INPUT_PIPE ].epAddr, &BUFFER_SIZE, readBuf); // input on endpoint 1 - if(millis() - timer > 100) { // Loop 100ms before processing data - readReport(); -#ifdef PRINTREPORT - printReport(); // Uncomment "#define PRINTREPORT" to print the report send by the PS3 Controllers -#endif - } - } else if(PS3MoveConnected) { // One can only set the color of the bulb, set the rumble, set and get the bluetooth address and calibrate the magnetometer via USB - if(millis() - timer > 4000) { // Send at least every 4th second - Move_Command(writeBuf, MOVE_REPORT_BUFFER_SIZE); // The Bulb and rumble values, has to be written again and again, for it to stay turned on - timer = millis(); - } - } - return 0; -} - -void PS3USB::readReport() { - ButtonState = (uint32_t)(readBuf[2] | ((uint16_t)readBuf[3] << 8) | ((uint32_t)readBuf[4] << 16)); - - //Notify(PSTR("\r\nButtonState", 0x80); - //PrintHex(ButtonState, 0x80); - - if(ButtonState != OldButtonState) { - ButtonClickState = ButtonState & ~OldButtonState; // Update click state variable - OldButtonState = ButtonState; - } -} - -void PS3USB::printReport() { // Uncomment "#define PRINTREPORT" to print the report send by the PS3 Controllers -#ifdef PRINTREPORT - for(uint8_t i = 0; i < PS3_REPORT_BUFFER_SIZE; i++) { - D_PrintHex (readBuf[i], 0x80); - Notify(PSTR(" "), 0x80); - } - Notify(PSTR("\r\n"), 0x80); -#endif -} - -bool PS3USB::getButtonPress(ButtonEnum b) { - return (ButtonState & pgm_read_dword(&PS3_BUTTONS[(uint8_t)b])); -} - -bool PS3USB::getButtonClick(ButtonEnum b) { - uint32_t button = pgm_read_dword(&PS3_BUTTONS[(uint8_t)b]); - bool click = (ButtonClickState & button); - ButtonClickState &= ~button; // Clear "click" event - return click; -} - -uint8_t PS3USB::getAnalogButton(ButtonEnum a) { - return (uint8_t)(readBuf[(pgm_read_byte(&PS3_ANALOG_BUTTONS[(uint8_t)a])) - 9]); -} - -uint8_t PS3USB::getAnalogHat(AnalogHatEnum a) { - return (uint8_t)(readBuf[((uint8_t)a + 6)]); -} - -uint16_t PS3USB::getSensor(SensorEnum a) { - return ((readBuf[((uint16_t)a) - 9] << 8) | readBuf[((uint16_t)a + 1) - 9]); -} - -double PS3USB::getAngle(AngleEnum a) { - if(PS3Connected) { - double accXval; - double accYval; - double accZval; - - // Data for the Kionix KXPC4 used in the DualShock 3 - const double zeroG = 511.5; // 1.65/3.3*1023 (1,65V) - accXval = -((double)getSensor(aX) - zeroG); - accYval = -((double)getSensor(aY) - zeroG); - accZval = -((double)getSensor(aZ) - zeroG); - - // Convert to 360 degrees resolution - // atan2 outputs the value of -π to π (radians) - // We are then converting it to 0 to 2π and then to degrees - if(a == Pitch) - return (atan2(accYval, accZval) + PI) * RAD_TO_DEG; - else - return (atan2(accXval, accZval) + PI) * RAD_TO_DEG; - } else - return 0; -} - -bool PS3USB::getStatus(StatusEnum c) { - return (readBuf[((uint16_t)c >> 8) - 9] == ((uint8_t)c & 0xff)); -} - -void PS3USB::printStatusString() { - char statusOutput[100]; // Max string length plus null character - if(PS3Connected || PS3NavigationConnected) { - strcpy_P(statusOutput, PSTR("ConnectionStatus: ")); - - if(getStatus(Plugged)) strcat_P(statusOutput, PSTR("Plugged")); - else if(getStatus(Unplugged)) strcat_P(statusOutput, PSTR("Unplugged")); - else strcat_P(statusOutput, PSTR("Error")); - - strcat_P(statusOutput, PSTR(" - PowerRating: ")); - - if(getStatus(Charging)) strcat_P(statusOutput, PSTR("Charging")); - else if(getStatus(NotCharging)) strcat_P(statusOutput, PSTR("Not Charging")); - else if(getStatus(Shutdown)) strcat_P(statusOutput, PSTR("Shutdown")); - else if(getStatus(Dying)) strcat_P(statusOutput, PSTR("Dying")); - else if(getStatus(Low)) strcat_P(statusOutput, PSTR("Low")); - else if(getStatus(High)) strcat_P(statusOutput, PSTR("High")); - else if(getStatus(Full)) strcat_P(statusOutput, PSTR("Full")); - else strcat_P(statusOutput, PSTR("Error")); - - strcat_P(statusOutput, PSTR(" - WirelessStatus: ")); - - if(getStatus(CableRumble)) strcat_P(statusOutput, PSTR("Cable - Rumble is on")); - else if(getStatus(Cable)) strcat_P(statusOutput, PSTR("Cable - Rumble is off")); - else if(getStatus(BluetoothRumble)) strcat_P(statusOutput, PSTR("Bluetooth - Rumble is on")); - else if(getStatus(Bluetooth)) strcat_P(statusOutput, PSTR("Bluetooth - Rumble is off")); - else strcat_P(statusOutput, PSTR("Error")); - } else - strcpy_P(statusOutput, PSTR("Error")); - - USB_HOST_SERIAL.write(statusOutput); -} - -/* Playstation Sixaxis Dualshock and Navigation Controller commands */ -void PS3USB::PS3_Command(uint8_t *data, uint16_t nbytes) { - // bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x01), Report Type (Output 0x02), interface (0x00), datalength, datalength, data) - pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x01, 0x02, 0x00, nbytes, nbytes, data, NULL); -} - -void PS3USB::setAllOff() { - for(uint8_t i = 0; i < PS3_REPORT_BUFFER_SIZE; i++) - writeBuf[i] = pgm_read_byte(&PS3_REPORT_BUFFER[i]); // Reset buffer - - PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE); -} - -void PS3USB::setRumbleOff() { - writeBuf[1] = 0x00; - writeBuf[2] = 0x00; // Low mode off - writeBuf[3] = 0x00; - writeBuf[4] = 0x00; // High mode off - - PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE); -} - -void PS3USB::setRumbleOn(RumbleEnum mode) { - if((mode & 0x30) > 0x00) { - uint8_t power[2] = {0xff, 0x00}; // Defaults to RumbleLow - if(mode == RumbleHigh) { - power[0] = 0x00; - power[1] = 0xff; - } - setRumbleOn(0xfe, power[0], 0xfe, power[1]); - } -} - -void PS3USB::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower) { - writeBuf[1] = rightDuration; - writeBuf[2] = rightPower; - writeBuf[3] = leftDuration; - writeBuf[4] = leftPower; - PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE); -} - -void PS3USB::setLedRaw(uint8_t value) { - writeBuf[9] = value << 1; - PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE); -} - -void PS3USB::setLedOff(LEDEnum a) { - writeBuf[9] &= ~((uint8_t)((pgm_read_byte(&PS3_LEDS[(uint8_t)a]) & 0x0f) << 1)); - PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE); -} - -void PS3USB::setLedOn(LEDEnum a) { - if(a == OFF) - setLedRaw(0); - else { - writeBuf[9] |= (uint8_t)((pgm_read_byte(&PS3_LEDS[(uint8_t)a]) & 0x0f) << 1); - PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE); - } -} - -void PS3USB::setLedToggle(LEDEnum a) { - writeBuf[9] ^= (uint8_t)((pgm_read_byte(&PS3_LEDS[(uint8_t)a]) & 0x0f) << 1); - PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE); -} - -void PS3USB::setBdaddr(uint8_t *bdaddr) { - /* Set the internal Bluetooth address */ - uint8_t buf[8]; - buf[0] = 0x01; - buf[1] = 0x00; - - for(uint8_t i = 0; i < 6; i++) - buf[i + 2] = bdaddr[5 - i]; // Copy into buffer, has to be written reversed, so it is MSB first - - // bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0xF5), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data - pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0xF5, 0x03, 0x00, 8, 8, buf, NULL); -} - -void PS3USB::getBdaddr(uint8_t *bdaddr) { - uint8_t buf[8]; - - // bmRequest = Device to host (0x80) | Class (0x20) | Interface (0x01) = 0xA1, bRequest = Get Report (0x01), Report ID (0xF5), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data - pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_IN, HID_REQUEST_GET_REPORT, 0xF5, 0x03, 0x00, 8, 8, buf, NULL); - - for(uint8_t i = 0; i < 6; i++) - bdaddr[5 - i] = buf[i + 2]; // Copy into buffer reversed, so it is LSB first -} - -void PS3USB::enable_sixaxis() { // Command used to enable the Dualshock 3 and Navigation controller to send data via USB - uint8_t cmd_buf[4]; - cmd_buf[0] = 0x42; // Special PS3 Controller enable commands - cmd_buf[1] = 0x0c; - cmd_buf[2] = 0x00; - cmd_buf[3] = 0x00; - - // bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0xF4), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data) - pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0xF4, 0x03, 0x00, 4, 4, cmd_buf, NULL); -} - -/* Playstation Move Controller commands */ -void PS3USB::Move_Command(uint8_t *data, uint16_t nbytes) { - pUsb->outTransfer(bAddress, epInfo[ PS3_OUTPUT_PIPE ].epAddr, nbytes, data); -} - -void PS3USB::moveSetBulb(uint8_t r, uint8_t g, uint8_t b) { // Use this to set the Color using RGB values - // Set the Bulb's values into the write buffer - writeBuf[2] = r; - writeBuf[3] = g; - writeBuf[4] = b; - - Move_Command(writeBuf, MOVE_REPORT_BUFFER_SIZE); -} - -void PS3USB::moveSetBulb(ColorsEnum color) { // Use this to set the Color using the predefined colors in "enums.h" - moveSetBulb((uint8_t)(color >> 16), (uint8_t)(color >> 8), (uint8_t)(color)); -} - -void PS3USB::moveSetRumble(uint8_t rumble) { -#ifdef DEBUG_USB_HOST - if(rumble < 64 && rumble != 0) // The rumble value has to at least 64, or approximately 25% (64/255*100) - Notify(PSTR("\r\nThe rumble value has to at least 64, or approximately 25%"), 0x80); -#endif - writeBuf[6] = rumble; // Set the rumble value into the write buffer - - Move_Command(writeBuf, MOVE_REPORT_BUFFER_SIZE); -} - -void PS3USB::setMoveBdaddr(uint8_t *bdaddr) { - /* Set the internal Bluetooth address */ - uint8_t buf[11]; - buf[0] = 0x05; - buf[7] = 0x10; - buf[8] = 0x01; - buf[9] = 0x02; - buf[10] = 0x12; - - for(uint8_t i = 0; i < 6; i++) - buf[i + 1] = bdaddr[i]; - - // bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x05), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data - pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x05, 0x03, 0x00, 11, 11, buf, NULL); -} - -void PS3USB::getMoveBdaddr(uint8_t *bdaddr) { - uint8_t buf[16]; - - // bmRequest = Device to host (0x80) | Class (0x20) | Interface (0x01) = 0xA1, bRequest = Get Report (0x01), Report ID (0x04), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data - pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_IN, HID_REQUEST_GET_REPORT, 0x04, 0x03, 0x00, 16, 16, buf, NULL); - - for(uint8_t i = 0; i < 6; i++) - bdaddr[i] = buf[10 + i]; -} - -void PS3USB::getMoveCalibration(uint8_t *data) { - uint8_t buf[49]; - - for(uint8_t i = 0; i < 3; i++) { - // bmRequest = Device to host (0x80) | Class (0x20) | Interface (0x01) = 0xA1, bRequest = Get Report (0x01), Report ID (0x10), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data - pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_IN, HID_REQUEST_GET_REPORT, 0x10, 0x03, 0x00, 49, 49, buf, NULL); - - for(byte j = 0; j < 49; j++) - data[49 * i + j] = buf[j]; - } -} - -void PS3USB::onInit() { - if(pFuncOnInit) - pFuncOnInit(); // Call the user function - else { - if(PS3MoveConnected) - moveSetBulb(Red); - else // Dualshock 3 or Navigation controller - setLedOn(LED1); - } -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/PS3USB.h b/protocol/usb_hid/USB_Host_Shield_2.0/PS3USB.h deleted file mode 100644 index 2eba9258..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/PS3USB.h +++ /dev/null @@ -1,303 +0,0 @@ -/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#ifndef _ps3usb_h_ -#define _ps3usb_h_ - -#include "Usb.h" -#include "hid.h" -#include "PS3Enums.h" - -/* PS3 data taken from descriptors */ -#define EP_MAXPKTSIZE 64 // max size for data via USB - -/* Names we give to the 3 ps3 pipes - this is only used for setting the bluetooth address into the ps3 controllers */ -#define PS3_CONTROL_PIPE 0 -#define PS3_OUTPUT_PIPE 1 -#define PS3_INPUT_PIPE 2 - -//PID and VID of the different devices -#define PS3_VID 0x054C // Sony Corporation -#define PS3_PID 0x0268 // PS3 Controller DualShock 3 -#define PS3NAVIGATION_PID 0x042F // Navigation controller -#define PS3MOVE_PID 0x03D5 // Motion controller - -#define PS3_MAX_ENDPOINTS 3 - -/** - * This class implements support for all the official PS3 Controllers: - * Dualshock 3, Navigation or a Motion controller via USB. - * - * One can only set the color of the bulb, set the rumble, set and get the bluetooth address and calibrate the magnetometer via USB on the Move controller. - * - * Information about the protocol can be found at the wiki: https://github.com/felis/USB_Host_Shield_2.0/wiki/PS3-Information. - */ -class PS3USB : public USBDeviceConfig { -public: - /** - * Constructor for the PS3USB class. - * @param pUsb Pointer to USB class instance. - * @param btadr5,btadr4,btadr3,btadr2,btadr1,btadr0 - * Pass your dongles Bluetooth address into the constructor, - * so you are able to pair the controller with a Bluetooth dongle. - */ - PS3USB(USB *pUsb, uint8_t btadr5 = 0, uint8_t btadr4 = 0, uint8_t btadr3 = 0, uint8_t btadr2 = 0, uint8_t btadr1 = 0, uint8_t btadr0 = 0); - - /** @name USBDeviceConfig implementation */ - /** - * Initialize the PS3 Controller. - * @param parent Hub number. - * @param port Port number on the hub. - * @param lowspeed Speed of the device. - * @return 0 on success. - */ - uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - /** - * Release the USB device. - * @return 0 on success. - */ - uint8_t Release(); - /** - * Poll the USB Input endpoins and run the state machines. - * @return 0 on success. - */ - uint8_t Poll(); - - /** - * Get the device address. - * @return The device address. - */ - virtual uint8_t GetAddress() { - return bAddress; - }; - - /** - * Used to check if the controller has been initialized. - * @return True if it's ready. - */ - virtual bool isReady() { - return bPollEnable; - }; - - /** - * Used by the USB core to check what this driver support. - * @param vid The device's VID. - * @param pid The device's PID. - * @return Returns true if the device's VID and PID matches this driver. - */ - virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { - return (vid == PS3_VID && (pid == PS3_PID || pid == PS3NAVIGATION_PID || pid == PS3MOVE_PID)); - }; - /**@}*/ - - /** - * Used to set the Bluetooth address inside the Dualshock 3 and Navigation controller. - * Set using LSB first. - * @param bdaddr Your dongles Bluetooth address. - */ - void setBdaddr(uint8_t *bdaddr); - /** - * Used to get the Bluetooth address inside the Dualshock 3 and Navigation controller. - * Will return LSB first. - * @param bdaddr Your dongles Bluetooth address. - */ - void getBdaddr(uint8_t *bdaddr); - - /** - * Used to set the Bluetooth address inside the Move controller. - * Set using LSB first. - * @param bdaddr Your dongles Bluetooth address. - */ - void setMoveBdaddr(uint8_t *bdaddr); - /** - * Used to get the Bluetooth address inside the Move controller. - * Will return LSB first. - * @param bdaddr Your dongles Bluetooth address. - */ - void getMoveBdaddr(uint8_t *bdaddr); - /** - * Used to get the calibration data inside the Move controller. - * @param data Buffer to store data in. Must be at least 147 bytes - */ - void getMoveCalibration(uint8_t *data); - - /** @name PS3 Controller functions */ - /** - * getButtonPress(ButtonEnum b) will return true as long as the button is held down. - * - * While getButtonClick(ButtonEnum b) will only return it once. - * - * So you instance if you need to increase a variable once you would use getButtonClick(ButtonEnum b), - * but if you need to drive a robot forward you would use getButtonPress(ButtonEnum b). - * @param b ::ButtonEnum to read. - * @return getButtonPress(ButtonEnum b) will return a true as long as a button is held down, while getButtonClick(ButtonEnum b) will return true once for each button press. - */ - bool getButtonPress(ButtonEnum b); - bool getButtonClick(ButtonEnum b); - /**@}*/ - /** @name PS3 Controller functions */ - /** - * Used to get the analog value from button presses. - * @param a The ::ButtonEnum to read. - * The supported buttons are: - * ::UP, ::RIGHT, ::DOWN, ::LEFT, ::L1, ::L2, ::R1, ::R2, - * ::TRIANGLE, ::CIRCLE, ::CROSS, ::SQUARE, and ::T. - * @return Analog value in the range of 0-255. - */ - uint8_t getAnalogButton(ButtonEnum a); - /** - * Used to read the analog joystick. - * @param a ::LeftHatX, ::LeftHatY, ::RightHatX, and ::RightHatY. - * @return Return the analog value in the range of 0-255. - */ - uint8_t getAnalogHat(AnalogHatEnum a); - /** - * Used to read the sensors inside the Dualshock 3 controller. - * @param a - * The Dualshock 3 has a 3-axis accelerometer and a 1-axis gyro inside. - * @return Return the raw sensor value. - */ - uint16_t getSensor(SensorEnum a); - /** - * Use this to get ::Pitch and ::Roll calculated using the accelerometer. - * @param a Either ::Pitch or ::Roll. - * @return Return the angle in the range of 0-360. - */ - double getAngle(AngleEnum a); - /** - * Get the ::StatusEnum from the controller. - * @param c The ::StatusEnum you want to read. - * @return True if correct and false if not. - */ - bool getStatus(StatusEnum c); - /** Read all the available statuses from the controller and prints it as a nice formated string. */ - void printStatusString(); - - /** Used to set all LEDs and rumble off. */ - void setAllOff(); - /** Turn off rumble. */ - void setRumbleOff(); - /** - * Turn on rumble. - * @param mode Either ::RumbleHigh or ::RumbleLow. - */ - void setRumbleOn(RumbleEnum mode); - /** - * Turn on rumble using custom duration and power. - * @param rightDuration The duration of the right/low rumble effect. - * @param rightPower The intensity of the right/low rumble effect. - * @param leftDuration The duration of the left/high rumble effect. - * @param leftPower The intensity of the left/high rumble effect. - */ - void setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower); - - /** - * Set LED value without using the ::LEDEnum. - * @param value See: ::LEDEnum. - */ - void setLedRaw(uint8_t value); - - /** Turn all LEDs off. */ - void setLedOff() { - setLedRaw(0); - } - /** - * Turn the specific ::LEDEnum off. - * @param a The ::LEDEnum to turn off. - */ - void setLedOff(LEDEnum a); - /** - * Turn the specific ::LEDEnum on. - * @param a The ::LEDEnum to turn on. - */ - void setLedOn(LEDEnum a); - /** - * Toggle the specific ::LEDEnum. - * @param a The ::LEDEnum to toggle. - */ - void setLedToggle(LEDEnum a); - - /** - * Use this to set the Color using RGB values. - * @param r,g,b RGB value. - */ - void moveSetBulb(uint8_t r, uint8_t g, uint8_t b); - /** - * Use this to set the color using the predefined colors in ::ColorsEnum. - * @param color The desired color. - */ - void moveSetBulb(ColorsEnum color); - /** - * Set the rumble value inside the Move controller. - * @param rumble The desired value in the range from 64-255. - */ - void moveSetRumble(uint8_t rumble); - - /** - * Used to call your own function when the controller is successfully initialized. - * @param funcOnInit Function to call. - */ - void attachOnInit(void (*funcOnInit)(void)) { - pFuncOnInit = funcOnInit; - }; - /**@}*/ - - /** Variable used to indicate if the normal playstation controller is successfully connected. */ - bool PS3Connected; - /** Variable used to indicate if the move controller is successfully connected. */ - bool PS3MoveConnected; - /** Variable used to indicate if the navigation controller is successfully connected. */ - bool PS3NavigationConnected; - -protected: - /** Pointer to USB class instance. */ - USB *pUsb; - /** Device address. */ - uint8_t bAddress; - /** Endpoint info structure. */ - EpInfo epInfo[PS3_MAX_ENDPOINTS]; - -private: - /** - * Called when the controller is successfully initialized. - * Use attachOnInit(void (*funcOnInit)(void)) to call your own function. - * This is useful for instance if you want to set the LEDs in a specific way. - */ - void onInit(); - void (*pFuncOnInit)(void); // Pointer to function called in onInit() - - bool bPollEnable; - - uint32_t timer; // used to continuously set PS3 Move controller Bulb and rumble values - - uint32_t ButtonState; - uint32_t OldButtonState; - uint32_t ButtonClickState; - - uint8_t my_bdaddr[6]; // Change to your dongles Bluetooth address in the constructor - uint8_t readBuf[EP_MAXPKTSIZE]; // General purpose buffer for input data - uint8_t writeBuf[EP_MAXPKTSIZE]; // General purpose buffer for output data - - void readReport(); // read incoming data - void printReport(); // print incoming date - Uncomment for debugging - - /* Private commands */ - void PS3_Command(uint8_t *data, uint16_t nbytes); - void enable_sixaxis(); // Command used to enable the Dualshock 3 and Navigation controller to send data via USB - void Move_Command(uint8_t *data, uint16_t nbytes); -}; -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/PS4BT.h b/protocol/usb_hid/USB_Host_Shield_2.0/PS4BT.h deleted file mode 100644 index b7eb4b5a..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/PS4BT.h +++ /dev/null @@ -1,121 +0,0 @@ -/* Copyright (C) 2014 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#ifndef _ps4bt_h_ -#define _ps4bt_h_ - -#include "BTHID.h" -#include "PS4Parser.h" - -/** - * This class implements support for the PS4 controller via Bluetooth. - * It uses the BTHID class for all the Bluetooth communication. - */ -class PS4BT : public BTHID, public PS4Parser { -public: - /** - * Constructor for the PS4BT class. - * @param p Pointer to the BTD class instance. - * @param pair Set this to true in order to pair with the device. If the argument is omitted then it will not pair with it. One can use ::PAIR to set it to true. - * @param pin Write the pin to BTD#btdPin. If argument is omitted, then "0000" will be used. - */ - PS4BT(BTD *p, bool pair = false, const char *pin = "0000") : - BTHID(p, pair, pin) { - PS4Parser::Reset(); - }; - - /** - * Used to check if a PS4 controller is connected. - * @return Returns true if it is connected. - */ - bool connected() { - return BTHID::connected; - }; - -protected: - /** @name BTHID implementation */ - /** - * Used to parse Bluetooth HID data. - * @param len The length of the incoming data. - * @param buf Pointer to the data buffer. - */ - virtual void ParseBTHIDData(uint8_t len, uint8_t *buf) { - PS4Parser::Parse(len, buf); - }; - - /** - * Called when a device is successfully initialized. - * Use attachOnInit(void (*funcOnInit)(void)) to call your own function. - * This is useful for instance if you want to set the LEDs in a specific way. - */ - virtual void OnInitBTHID() { - PS4Parser::Reset(); - enable_sixaxis(); // Make the controller send out the entire output report - if (pFuncOnInit) - pFuncOnInit(); // Call the user function - else - setLed(Blue); - }; - - /** Used to reset the different buffers to there default values */ - virtual void ResetBTHID() { - PS4Parser::Reset(); - }; - /**@}*/ - - /** @name PS4Parser implementation */ - virtual void sendOutputReport(PS4Output *output) { // Source: https://github.com/chrippa/ds4drv - uint8_t buf[79]; - memset(buf, 0, sizeof(buf)); - - buf[0] = 0x52; // HID BT Set_report (0x50) | Report Type (Output 0x02) - buf[1] = 0x11; // Report ID - buf[2] = 0x80; - buf[4]= 0xFF; - - buf[7] = output->smallRumble; // Small Rumble - buf[8] = output->bigRumble; // Big rumble - - buf[9] = output->r; // Red - buf[10] = output->g; // Green - buf[11] = output->b; // Blue - - buf[12] = output->flashOn; // Time to flash bright (255 = 2.5 seconds) - buf[13] = output->flashOff; // Time to flash dark (255 = 2.5 seconds) - - output->reportChanged = false; - - // The PS4 console actually set the four last bytes to a CRC32 checksum, but it seems like it is actually not needed - - HID_Command(buf, sizeof(buf)); - }; - /**@}*/ - -private: - void enable_sixaxis() { // Command used to make the PS4 controller send out the entire output report - uint8_t buf[2]; - buf[0] = 0x43; // HID BT Get_report (0x40) | Report Type (Feature 0x03) - buf[1] = 0x02; // Report ID - - HID_Command(buf, 2); - }; - - void HID_Command(uint8_t *data, uint8_t nbytes) { - pBtd->L2CAP_Command(hci_handle, data, nbytes, control_scid[0], control_scid[1]); - }; -}; -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/PS4Parser.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/PS4Parser.cpp deleted file mode 100644 index ca6adce4..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/PS4Parser.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* Copyright (C) 2014 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#include "PS4Parser.h" - -// To enable serial debugging see "settings.h" -//#define PRINTREPORT // Uncomment to print the report send by the PS4 Controller - -bool PS4Parser::checkDpad(ButtonEnum b) { - switch (b) { - case UP: - return ps4Data.btn.dpad == DPAD_LEFT_UP || ps4Data.btn.dpad == DPAD_UP || ps4Data.btn.dpad == DPAD_UP_RIGHT; - case RIGHT: - return ps4Data.btn.dpad == DPAD_UP_RIGHT || ps4Data.btn.dpad == DPAD_RIGHT || ps4Data.btn.dpad == DPAD_RIGHT_DOWN; - case DOWN: - return ps4Data.btn.dpad == DPAD_RIGHT_DOWN || ps4Data.btn.dpad == DPAD_DOWN || ps4Data.btn.dpad == DPAD_DOWN_LEFT; - case LEFT: - return ps4Data.btn.dpad == DPAD_DOWN_LEFT || ps4Data.btn.dpad == DPAD_LEFT || ps4Data.btn.dpad == DPAD_LEFT_UP; - default: - return false; - } -} - -bool PS4Parser::getButtonPress(ButtonEnum b) { - if (b <= LEFT) // Dpad - return checkDpad(b); - else - return ps4Data.btn.val & (1UL << pgm_read_byte(&PS4_BUTTONS[(uint8_t)b])); -} - -bool PS4Parser::getButtonClick(ButtonEnum b) { - uint32_t mask = 1UL << pgm_read_byte(&PS4_BUTTONS[(uint8_t)b]); - bool click = buttonClickState.val & mask; - buttonClickState.val &= ~mask; // Clear "click" event - return click; -} - -uint8_t PS4Parser::getAnalogButton(ButtonEnum b) { - if (b == L2) // These are the only analog buttons on the controller - return ps4Data.trigger[0]; - else if (b == R2) - return ps4Data.trigger[1]; - return 0; -} - -uint8_t PS4Parser::getAnalogHat(AnalogHatEnum a) { - return ps4Data.hatValue[(uint8_t)a]; -} - -void PS4Parser::Parse(uint8_t len, uint8_t *buf) { - if (len > 1 && buf) { -#ifdef PRINTREPORT - Notify(PSTR("\r\n"), 0x80); - for (uint8_t i = 0; i < len; i++) { - D_PrintHex (buf[i], 0x80); - Notify(PSTR(" "), 0x80); - } -#endif - - if (buf[0] == 0x01) // Check report ID - memcpy(&ps4Data, buf + 1, min((uint8_t)(len - 1), sizeof(ps4Data))); - else if (buf[0] == 0x11) { // This report is send via Bluetooth, it has an offset of 2 compared to the USB data - if (len < 4) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nReport is too short: "), 0x80); - D_PrintHex (len, 0x80); -#endif - return; - } - memcpy(&ps4Data, buf + 3, min((uint8_t)(len - 3), sizeof(ps4Data))); - } else { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nUnknown report id: "), 0x80); - D_PrintHex (buf[0], 0x80); -#endif - return; - } - - if (ps4Data.btn.val != oldButtonState.val) { // Check if anything has changed - buttonClickState.val = ps4Data.btn.val & ~oldButtonState.val; // Update click state variable - oldButtonState.val = ps4Data.btn.val; - - // The DPAD buttons does not set the different bits, but set a value corresponding to the buttons pressed, we will simply set the bits ourself - uint8_t newDpad = 0; - if (checkDpad(UP)) - newDpad |= 1 << UP; - if (checkDpad(RIGHT)) - newDpad |= 1 << RIGHT; - if (checkDpad(DOWN)) - newDpad |= 1 << DOWN; - if (checkDpad(LEFT)) - newDpad |= 1 << LEFT; - if (newDpad != oldDpad) { - buttonClickState.dpad = newDpad & ~oldDpad; // Override values - oldDpad = newDpad; - } - } - } - - if (ps4Output.reportChanged) - sendOutputReport(&ps4Output); // Send output report -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/PS4Parser.h b/protocol/usb_hid/USB_Host_Shield_2.0/PS4Parser.h deleted file mode 100644 index 51f08063..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/PS4Parser.h +++ /dev/null @@ -1,407 +0,0 @@ -/* Copyright (C) 2014 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#ifndef _ps4parser_h_ -#define _ps4parser_h_ - -#include "Usb.h" -#include "controllerEnums.h" - -/** Buttons on the controller */ -const uint8_t PS4_BUTTONS[] PROGMEM = { - UP, // UP - RIGHT, // RIGHT - DOWN, // DOWN - LEFT, // LEFT - - 0x0C, // SHARE - 0x0D, // OPTIONS - 0x0E, // L3 - 0x0F, // R3 - - 0x0A, // L2 - 0x0B, // R2 - 0x08, // L1 - 0x09, // R1 - - 0x07, // TRIANGLE - 0x06, // CIRCLE - 0x05, // CROSS - 0x04, // SQUARE - - 0x10, // PS - 0x11, // TOUCHPAD -}; - -union PS4Buttons { - struct { - uint8_t dpad : 4; - uint8_t square : 1; - uint8_t cross : 1; - uint8_t circle : 1; - uint8_t triangle : 1; - - uint8_t l1 : 1; - uint8_t r1 : 1; - uint8_t l2 : 1; - uint8_t r2 : 1; - uint8_t share : 1; - uint8_t options : 1; - uint8_t l3 : 1; - uint8_t r3 : 1; - - uint8_t ps : 1; - uint8_t touchpad : 1; - uint8_t reportCounter : 6; - } __attribute__((packed)); - uint32_t val : 24; -} __attribute__((packed)); - -struct touchpadXY { - uint8_t dummy; // I can not figure out what this data is for, it seems to change randomly, maybe a timestamp? - struct { - uint8_t counter : 7; // Increments every time a finger is touching the touchpad - uint8_t touching : 1; // The top bit is cleared if the finger is touching the touchpad - uint16_t x : 12; - uint16_t y : 12; - } __attribute__((packed)) finger[2]; // 0 = first finger, 1 = second finger -} __attribute__((packed)); - -struct PS4Status { - uint8_t battery : 4; - uint8_t usb : 1; - uint8_t audio : 1; - uint8_t mic : 1; - uint8_t unknown : 1; // Extension port? -} __attribute__((packed)); - -struct PS4Data { - /* Button and joystick values */ - uint8_t hatValue[4]; - PS4Buttons btn; - uint8_t trigger[2]; - - /* Gyro and accelerometer values */ - uint8_t dummy[3]; // First two looks random, while the third one might be some kind of status - it increments once in a while - int16_t gyroY, gyroZ, gyroX; - int16_t accX, accZ, accY; - - uint8_t dummy2[5]; - PS4Status status; - uint8_t dummy3[3]; - - /* The rest is data for the touchpad */ - touchpadXY xy[3]; // It looks like it sends out three coordinates each time, this might be because the microcontroller inside the PS4 controller is much faster than the Bluetooth connection. - // The last data is read from the last position in the array while the oldest measurement is from the first position. - // The first position will also keep it's value after the finger is released, while the other two will set them to zero. - // Note that if you read fast enough from the device, then only the first one will contain any data. - - // The last three bytes are always: 0x00, 0x80, 0x00 -} __attribute__((packed)); - -struct PS4Output { - uint8_t bigRumble, smallRumble; // Rumble - uint8_t r, g, b; // RGB - uint8_t flashOn, flashOff; // Time to flash bright/dark (255 = 2.5 seconds) - bool reportChanged; // The data is send when data is received from the controller -} __attribute__((packed)); - -enum DPADEnum { - DPAD_UP = 0x0, - DPAD_UP_RIGHT = 0x1, - DPAD_RIGHT = 0x2, - DPAD_RIGHT_DOWN = 0x3, - DPAD_DOWN = 0x4, - DPAD_DOWN_LEFT = 0x5, - DPAD_LEFT = 0x6, - DPAD_LEFT_UP = 0x7, - DPAD_OFF = 0x8, -}; - -/** This class parses all the data sent by the PS4 controller */ -class PS4Parser { -public: - /** Constructor for the PS4Parser class. */ - PS4Parser() { - Reset(); - }; - - /** @name PS4 Controller functions */ - /** - * getButtonPress(ButtonEnum b) will return true as long as the button is held down. - * - * While getButtonClick(ButtonEnum b) will only return it once. - * - * So you instance if you need to increase a variable once you would use getButtonClick(ButtonEnum b), - * but if you need to drive a robot forward you would use getButtonPress(ButtonEnum b). - * @param b ::ButtonEnum to read. - * @return getButtonPress(ButtonEnum b) will return a true as long as a button is held down, while getButtonClick(ButtonEnum b) will return true once for each button press. - */ - bool getButtonPress(ButtonEnum b); - bool getButtonClick(ButtonEnum b); - /**@}*/ - /** @name PS4 Controller functions */ - /** - * Used to get the analog value from button presses. - * @param b The ::ButtonEnum to read. - * The supported buttons are: - * ::UP, ::RIGHT, ::DOWN, ::LEFT, ::L1, ::L2, ::R1, ::R2, - * ::TRIANGLE, ::CIRCLE, ::CROSS, ::SQUARE, and ::T. - * @return Analog value in the range of 0-255. - */ - uint8_t getAnalogButton(ButtonEnum b); - - /** - * Used to read the analog joystick. - * @param a ::LeftHatX, ::LeftHatY, ::RightHatX, and ::RightHatY. - * @return Return the analog value in the range of 0-255. - */ - uint8_t getAnalogHat(AnalogHatEnum a); - - /** - * Get the x-coordinate of the touchpad. Position 0 is in the top left. - * @param finger 0 = first finger, 1 = second finger. If omitted, then 0 will be used. - * @param xyId The controller sends out three packets with the same structure. - * The third one will contain the last measure, but if you read from the controller then there is only be data in the first one. - * For that reason it will be set to 0 if the argument is omitted. - * @return Returns the x-coordinate of the finger. - */ - uint16_t getX(uint8_t finger = 0, uint8_t xyId = 0) { - return ps4Data.xy[xyId].finger[finger].x; - }; - - /** - * Get the y-coordinate of the touchpad. Position 0 is in the top left. - * @param finger 0 = first finger, 1 = second finger. If omitted, then 0 will be used. - * @param xyId The controller sends out three packets with the same structure. - * The third one will contain the last measure, but if you read from the controller then there is only be data in the first one. - * For that reason it will be set to 0 if the argument is omitted. - * @return Returns the y-coordinate of the finger. - */ - uint16_t getY(uint8_t finger = 0, uint8_t xyId = 0) { - return ps4Data.xy[xyId].finger[finger].y; - }; - - /** - * Returns whenever the user is toucing the touchpad. - * @param finger 0 = first finger, 1 = second finger. If omitted, then 0 will be used. - * @param xyId The controller sends out three packets with the same structure. - * The third one will contain the last measure, but if you read from the controller then there is only be data in the first one. - * For that reason it will be set to 0 if the argument is omitted. - * @return Returns true if the specific finger is touching the touchpad. - */ - bool isTouching(uint8_t finger = 0, uint8_t xyId = 0) { - return !(ps4Data.xy[xyId].finger[finger].touching); // The bit is cleared when a finger is touching the touchpad - }; - - /** - * This counter increments every time a finger touches the touchpad. - * @param finger 0 = first finger, 1 = second finger. If omitted, then 0 will be used. - * @param xyId The controller sends out three packets with the same structure. - * The third one will contain the last measure, but if you read from the controller then there is only be data in the first one. - * For that reason it will be set to 0 if the argument is omitted. - * @return Return the value of the counter, note that it is only a 7-bit value. - */ - uint8_t getTouchCounter(uint8_t finger = 0, uint8_t xyId = 0) { - return ps4Data.xy[xyId].finger[finger].counter; - }; - - /** - * Get the angle of the controller calculated using the accelerometer. - * @param a Either ::Pitch or ::Roll. - * @return Return the angle in the range of 0-360. - */ - double getAngle(AngleEnum a) { - if (a == Pitch) - return (atan2(ps4Data.accY, ps4Data.accZ) + PI) * RAD_TO_DEG; - else - return (atan2(ps4Data.accX, ps4Data.accZ) + PI) * RAD_TO_DEG; - }; - - /** - * Used to get the raw values from the 3-axis gyroscope and 3-axis accelerometer inside the PS4 controller. - * @param s The sensor to read. - * @return Returns the raw sensor reading. - */ - int16_t getSensor(SensorEnum s) { - switch(s) { - case gX: - return ps4Data.gyroX; - case gY: - return ps4Data.gyroY; - case gZ: - return ps4Data.gyroZ; - case aX: - return ps4Data.accX; - case aY: - return ps4Data.accY; - case aZ: - return ps4Data.accZ; - default: - return 0; - } - }; - - /** - * Return the battery level of the PS4 controller. - * @return The battery level in the range 0-15. - */ - uint8_t getBatteryLevel() { - return ps4Data.status.battery; - }; - - /** - * Use this to check if an USB cable is connected to the PS4 controller. - * @return Returns true if an USB cable is connected. - */ - bool getUsbStatus() { - return ps4Data.status.usb; - }; - - /** - * Use this to check if an audio jack cable is connected to the PS4 controller. - * @return Returns true if an audio jack cable is connected. - */ - bool getAudioStatus() { - return ps4Data.status.audio; - }; - - /** - * Use this to check if a microphone is connected to the PS4 controller. - * @return Returns true if a microphone is connected. - */ - bool getMicStatus() { - return ps4Data.status.mic; - }; - - /** Turn both rumble and the LEDs off. */ - void setAllOff() { - setRumbleOff(); - setLedOff(); - }; - - /** Set rumble off. */ - void setRumbleOff() { - setRumbleOn(0, 0); - }; - - /** - * Turn on rumble. - * @param mode Either ::RumbleHigh or ::RumbleLow. - */ - void setRumbleOn(RumbleEnum mode) { - if (mode == RumbleLow) - setRumbleOn(0x00, 0xFF); - else - setRumbleOn(0xFF, 0x00); - }; - - /** - * Turn on rumble. - * @param bigRumble Value for big motor. - * @param smallRumble Value for small motor. - */ - void setRumbleOn(uint8_t bigRumble, uint8_t smallRumble) { - ps4Output.bigRumble = bigRumble; - ps4Output.smallRumble = smallRumble; - ps4Output.reportChanged = true; - }; - - /** Turn all LEDs off. */ - void setLedOff() { - setLed(0, 0, 0); - }; - - /** - * Use this to set the color using RGB values. - * @param r,g,b RGB value. - */ - void setLed(uint8_t r, uint8_t g, uint8_t b) { - ps4Output.r = r; - ps4Output.g = g; - ps4Output.b = b; - ps4Output.reportChanged = true; - }; - - /** - * Use this to set the color using the predefined colors in ::ColorsEnum. - * @param color The desired color. - */ - void setLed(ColorsEnum color) { - setLed((uint8_t)(color >> 16), (uint8_t)(color >> 8), (uint8_t)(color)); - }; - - /** - * Set the LEDs flash time. - * @param flashOn Time to flash bright (255 = 2.5 seconds). - * @param flashOff Time to flash dark (255 = 2.5 seconds). - */ - void setLedFlash(uint8_t flashOn, uint8_t flashOff) { - ps4Output.flashOn = flashOn; - ps4Output.flashOff = flashOff; - ps4Output.reportChanged = true; - }; - /**@}*/ - -protected: - /** - * Used to parse data sent from the PS4 controller. - * @param len Length of the data. - * @param buf Pointer to the data buffer. - */ - void Parse(uint8_t len, uint8_t *buf); - - /** Used to reset the different buffers to their default values */ - void Reset() { - uint8_t i; - for (i = 0; i < sizeof(ps4Data.hatValue); i++) - ps4Data.hatValue[i] = 127; // Center value - ps4Data.btn.val = 0; - oldButtonState.val = 0; - for (i = 0; i < sizeof(ps4Data.trigger); i++) - ps4Data.trigger[i] = 0; - for (i = 0; i < sizeof(ps4Data.xy)/sizeof(ps4Data.xy[0]); i++) { - for (uint8_t j = 0; j < sizeof(ps4Data.xy[0].finger)/sizeof(ps4Data.xy[0].finger[0]); j++) - ps4Data.xy[i].finger[j].touching = 1; // The bit is cleared if the finger is touching the touchpad - } - - ps4Data.btn.dpad = DPAD_OFF; - oldButtonState.dpad = DPAD_OFF; - buttonClickState.dpad = 0; - oldDpad = 0; - - ps4Output.bigRumble = ps4Output.smallRumble = 0; - ps4Output.r = ps4Output.g = ps4Output.b = 0; - ps4Output.flashOn = ps4Output.flashOff = 0; - ps4Output.reportChanged = false; - }; - - /** - * Send the output to the PS4 controller. This is implemented in PS4BT.h and PS4USB.h. - * @param output Pointer to PS4Output buffer; - */ - virtual void sendOutputReport(PS4Output *output) = 0; - -private: - bool checkDpad(ButtonEnum b); // Used to check PS4 DPAD buttons - - PS4Data ps4Data; - PS4Buttons oldButtonState, buttonClickState; - PS4Output ps4Output; - uint8_t oldDpad; -}; -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/PS4USB.h b/protocol/usb_hid/USB_Host_Shield_2.0/PS4USB.h deleted file mode 100644 index b43079a6..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/PS4USB.h +++ /dev/null @@ -1,130 +0,0 @@ -/* Copyright (C) 2014 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#ifndef _ps4usb_h_ -#define _ps4usb_h_ - -#include "hiduniversal.h" -#include "PS4Parser.h" - -#define PS4_VID 0x054C // Sony Corporation -#define PS4_PID 0x05C4 // PS4 Controller - -/** - * This class implements support for the PS4 controller via USB. - * It uses the HIDUniversal class for all the USB communication. - */ -class PS4USB : public HIDUniversal, public PS4Parser { -public: - /** - * Constructor for the PS4USB class. - * @param p Pointer to the USB class instance. - */ - PS4USB(USB *p) : - HIDUniversal(p) { - PS4Parser::Reset(); - }; - - /** - * Used to check if a PS4 controller is connected. - * @return Returns true if it is connected. - */ - bool connected() { - return HIDUniversal::isReady() && HIDUniversal::VID == PS4_VID && HIDUniversal::PID == PS4_PID; - }; - - /** - * Used to call your own function when the device is successfully initialized. - * @param funcOnInit Function to call. - */ - void attachOnInit(void (*funcOnInit)(void)) { - pFuncOnInit = funcOnInit; - }; - -protected: - /** @name HIDUniversal implementation */ - /** - * Used to parse USB HID data. - * @param hid Pointer to the HID class. - * @param is_rpt_id Only used for Hubs. - * @param len The length of the incoming data. - * @param buf Pointer to the data buffer. - */ - virtual void ParseHIDData(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) { - if (HIDUniversal::VID == PS4_VID && HIDUniversal::PID == PS4_PID) - PS4Parser::Parse(len, buf); - }; - - /** - * Called when a device is successfully initialized. - * Use attachOnInit(void (*funcOnInit)(void)) to call your own function. - * This is useful for instance if you want to set the LEDs in a specific way. - */ - virtual uint8_t OnInitSuccessful() { - if (HIDUniversal::VID == PS4_VID && HIDUniversal::PID == PS4_PID) { - PS4Parser::Reset(); - if (pFuncOnInit) - pFuncOnInit(); // Call the user function - else - setLed(Blue); - }; - return 0; - }; - /**@}*/ - - /** @name PS4Parser implementation */ - virtual void sendOutputReport(PS4Output *output) { // Source: https://github.com/chrippa/ds4drv - uint8_t buf[32]; - memset(buf, 0, sizeof(buf)); - - buf[0] = 0x05; // Report ID - buf[1]= 0xFF; - - buf[4] = output->smallRumble; // Small Rumble - buf[5] = output->bigRumble; // Big rumble - - buf[6] = output->r; // Red - buf[7] = output->g; // Green - buf[8] = output->b; // Blue - - buf[9] = output->flashOn; // Time to flash bright (255 = 2.5 seconds) - buf[10] = output->flashOff; // Time to flash dark (255 = 2.5 seconds) - - output->reportChanged = false; - - // The PS4 console actually set the four last bytes to a CRC32 checksum, but it seems like it is actually not needed - - pUsb->outTransfer(bAddress, epInfo[ hidInterfaces[0].epIndex[epInterruptOutIndex] ].epAddr, sizeof(buf), buf); - }; - /**@}*/ - - /** @name USBDeviceConfig implementation */ - /** - * Used by the USB core to check what this driver support. - * @param vid The device's VID. - * @param pid The device's PID. - * @return Returns true if the device's VID and PID matches this driver. - */ - virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { - return (vid == PS4_VID && pid == PS4_PID); - }; - /**@}*/ - -private: - void (*pFuncOnInit)(void); // Pointer to function called in onInit() -}; -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/PSBuzz.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/PSBuzz.cpp deleted file mode 100644 index 498164d5..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/PSBuzz.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (C) 2014 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#include "PSBuzz.h" - -// To enable serial debugging see "settings.h" -//#define PRINTREPORT // Uncomment to print the report send by the PS Buzz Controllers - -void PSBuzz::ParseHIDData(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) { - if (HIDUniversal::VID == PSBUZZ_VID && HIDUniversal::PID == PSBUZZ_PID && len > 2 && buf) { -#ifdef PRINTREPORT - Notify(PSTR("\r\n"), 0x80); - for (uint8_t i = 0; i < len; i++) { - D_PrintHex (buf[i], 0x80); - Notify(PSTR(" "), 0x80); - } -#endif - memcpy(&psbuzzButtons, buf + 2, min((uint8_t)(len - 2), sizeof(psbuzzButtons))); - - if (psbuzzButtons.val != oldButtonState.val) { // Check if anything has changed - buttonClickState.val = psbuzzButtons.val & ~oldButtonState.val; // Update click state variable - oldButtonState.val = psbuzzButtons.val; - } - } -}; - -uint8_t PSBuzz::OnInitSuccessful() { - if (HIDUniversal::VID == PSBUZZ_VID && HIDUniversal::PID == PSBUZZ_PID) { - Reset(); - if (pFuncOnInit) - pFuncOnInit(); // Call the user function - else - setLedOnAll(); // Turn the LED on, on all four controllers - }; - return 0; -}; - -bool PSBuzz::getButtonPress(ButtonEnum b, uint8_t controller) { - return psbuzzButtons.val & (1UL << (b + 5 * controller)); // Each controller uses 5 bits, so the value is shifted 5 for each controller -}; - -bool PSBuzz::getButtonClick(ButtonEnum b, uint8_t controller) { - uint32_t mask = (1UL << (b + 5 * controller)); // Each controller uses 5 bits, so the value is shifted 5 for each controller - bool click = buttonClickState.val & mask; - buttonClickState.val &= ~mask; // Clear "click" event - return click; -}; - -// Source: http://www.developerfusion.com/article/84338/making-usb-c-friendly/ and https://github.com/torvalds/linux/blob/master/drivers/hid/hid-sony.c -void PSBuzz::setLedRaw(bool value, uint8_t controller) { - ledState[controller] = value; // Save value for next time it is called - - uint8_t buf[7]; - buf[0] = 0x00; - buf[1] = ledState[0] ? 0xFF : 0x00; - buf[2] = ledState[1] ? 0xFF : 0x00; - buf[3] = ledState[2] ? 0xFF : 0x00; - buf[4] = ledState[3] ? 0xFF : 0x00; - buf[5] = 0x00; - buf[6] = 0x00; - - PSBuzz_Command(buf, sizeof(buf)); -}; - -void PSBuzz::PSBuzz_Command(uint8_t *data, uint16_t nbytes) { - // bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x00), Report Type (Output 0x02), interface (0x00), datalength, datalength, data) - pUsb->ctrlReq(bAddress, epInfo[0].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL); -}; diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/PSBuzz.h b/protocol/usb_hid/USB_Host_Shield_2.0/PSBuzz.h deleted file mode 100644 index 8880d9e5..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/PSBuzz.h +++ /dev/null @@ -1,185 +0,0 @@ -/* Copyright (C) 2014 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#ifndef _psbuzz_h_ -#define _psbuzz_h_ - -#include "hiduniversal.h" -#include "controllerEnums.h" - -#define PSBUZZ_VID 0x054C // Sony Corporation -#define PSBUZZ_PID 0x1000 // PS Buzz Controller - -/** Struct used to easily read the different buttons on the controllers */ -union PSBUZZButtons { - struct { - uint8_t red : 1; - uint8_t yellow : 1; - uint8_t green : 1; - uint8_t orange : 1; - uint8_t blue : 1; - } __attribute__((packed)) btn[4]; - uint32_t val : 20; -} __attribute__((packed)); - -/** - * This class implements support for the PS Buzz controllers via USB. - * It uses the HIDUniversal class for all the USB communication. - */ -class PSBuzz : public HIDUniversal { -public: - /** - * Constructor for the PSBuzz class. - * @param p Pointer to the USB class instance. - */ - PSBuzz(USB *p) : - HIDUniversal(p) { - Reset(); - }; - - /** - * Used to check if a PS Buzz controller is connected. - * @return Returns true if it is connected. - */ - bool connected() { - return HIDUniversal::isReady() && HIDUniversal::VID == PSBUZZ_VID && HIDUniversal::PID == PSBUZZ_PID; - }; - - /** - * Used to call your own function when the device is successfully initialized. - * @param funcOnInit Function to call. - */ - void attachOnInit(void (*funcOnInit)(void)) { - pFuncOnInit = funcOnInit; - }; - - /** @name PS Buzzer Controller functions */ - /** - * getButtonPress(ButtonEnum b) will return true as long as the button is held down. - * - * While getButtonClick(ButtonEnum b) will only return it once. - * - * So you instance if you need to increase a variable once you would use getButtonClick(ButtonEnum b), - * but if you need to drive a robot forward you would use getButtonPress(ButtonEnum b). - * @param b ::ButtonEnum to read. - * @param controller The controller to read from. Default to 0. - * @return getButtonPress(ButtonEnum b) will return a true as long as a button is held down, while getButtonClick(ButtonEnum b) will return true once for each button press. - */ - bool getButtonPress(ButtonEnum b, uint8_t controller = 0); - bool getButtonClick(ButtonEnum b, uint8_t controller = 0); - /**@}*/ - /** @name PS Buzzer Controller functions */ - /** - * Set LED value without using ::LEDEnum. - * @param value See: ::LEDEnum. - */ - /** - * Set LED values directly. - * @param value Used to set whenever the LED should be on or off - * @param controller The controller to control. Defaults to 0. - */ - void setLedRaw(bool value, uint8_t controller = 0); - - /** Turn all LEDs off. */ - void setLedOffAll() { - for (uint8_t i = 1; i < 4; i++) // Skip first as it will be set in setLedRaw - ledState[i] = false; // Just an easy way to set all four off at the same time - setLedRaw(false); // Turn the LED off, on all four controllers - }; - - /** - * Turn the LED off on a specific controller. - * @param controller The controller to turn off. Defaults to 0. - */ - void setLedOff(uint8_t controller = 0) { - setLedRaw(false, controller); - }; - - - /** Turn all LEDs on. */ - void setLedOnAll() { - for (uint8_t i = 1; i < 4; i++) // Skip first as it will be set in setLedRaw - ledState[i] = true; // Just an easy way to set all four off at the same time - setLedRaw(true); // Turn the LED on, on all four controllers - }; - - /** - * Turn the LED on on a specific controller. - * @param controller The controller to turn off. Defaults to 0. - */ - void setLedOn(uint8_t controller = 0) { - setLedRaw(true, controller); - }; - - /** - * Toggle the LED on a specific controller. - * @param controller The controller to turn off. Defaults to 0. - */ - void setLedToggle(uint8_t controller = 0) { - setLedRaw(!ledState[controller], controller); - }; - /**@}*/ - -protected: - /** @name HIDUniversal implementation */ - /** - * Used to parse USB HID data. - * @param hid Pointer to the HID class. - * @param is_rpt_id Only used for Hubs. - * @param len The length of the incoming data. - * @param buf Pointer to the data buffer. - */ - void ParseHIDData(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); - - /** - * Called when a device is successfully initialized. - * Use attachOnInit(void (*funcOnInit)(void)) to call your own function. - * This is useful for instance if you want to set the LEDs in a specific way. - */ - uint8_t OnInitSuccessful(); - /**@}*/ - - /** Used to reset the different buffers to their default values */ - void Reset() { - psbuzzButtons.val = 0; - oldButtonState.val = 0; - buttonClickState.val = 0; - for (uint8_t i = 0; i < sizeof(ledState); i++) - ledState[i] = 0; - }; - - /** @name USBDeviceConfig implementation */ - /** - * Used by the USB core to check what this driver support. - * @param vid The device's VID. - * @param pid The device's PID. - * @return Returns true if the device's VID and PID matches this driver. - */ - virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { - return (vid == PSBUZZ_VID && pid == PSBUZZ_PID); - }; - /**@}*/ - -private: - void (*pFuncOnInit)(void); // Pointer to function called in onInit() - - void PSBuzz_Command(uint8_t *data, uint16_t nbytes); - - PSBUZZButtons psbuzzButtons, oldButtonState, buttonClickState; - bool ledState[4]; -}; -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/README.md b/protocol/usb_hid/USB_Host_Shield_2.0/README.md deleted file mode 100644 index 49cd83e0..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/README.md +++ /dev/null @@ -1,351 +0,0 @@ -# USB Host Library Rev.2.0 - -The code is released under the GNU General Public License. -__________ - -# Summary -This is Revision 2.0 of MAX3421E-based USB Host Shield Library for AVR's. - -Project main web site is: . - -Some information can also be found at: . - -The shield can be purchased at the main site: or from [TKJ Electronics](http://tkjelectronics.com/): . - -![USB Host Shield](http://shop.tkjelectronics.dk/images/USB_Host_Shield1.jpg) - -For more information about the hardware see the [Hardware Manual](http://www.circuitsathome.com/usb-host-shield-hardware-manual). - -# Developed By - -* __Oleg Mazurov, Circuits@Home__ - -* __Alexei Glushchenko, Circuits@Home__ - - * Developers of the USB Core, HID, FTDI, ADK, ACM, and PL2303 libraries -* __Kristian Lauszus, TKJ Electronics__ - - * Developer of the [BTD](#bluetooth-libraries), [BTHID](#bthid-library), [SPP](#spp-library), [PS4](#ps4-library), [PS3](#ps3-library), [Wii](#wii-library), [Xbox](#xbox-library), and [PSBuzz](#ps-buzz-library) libraries -* __Andrew Kroll__ - - * Major contributor to mass storage code -* __guruthree__ - * [Xbox ONE](#xbox-one-library) controller support - -# Donate - -Help yourself by helping us support you! Many thousands of hours have been spent developing the USB Host Shield library. Since you find it useful, please consider donating via the button below. Donations will allow us to support you by ensuring hardware that you have can be acquired in order to add support for your microcontroller board. - -PayPal - The safer, easier way to pay online! - -# Table of Contents - -* [How to include the library](#how-to-include-the-library) - * [Arduino Library Manager](#arduino-library-manager) - * [Manual installation](#manual-installation) -* [How to use the library](#how-to-use-the-library) - * [Documentation](#documentation) - * [Enable debugging](#enable-debugging) - * [Boards](#boards) - * [Bluetooth libraries](#bluetooth-libraries) - * [BTHID library](#bthid-library) - * [SPP library](#spp-library) - * [PS4 Library](#ps4-library) - * [PS3 Library](#ps3-library) - * [Xbox Libraries](#xbox-libraries) - * [Xbox library](#xbox-library) - * [Xbox 360 Library](#xbox-360-library) - * [Xbox ONE Library](#xbox-one-library) - * [Wii library](#wii-library) - * [PS Buzz Library](#ps-buzz-library) -* [Interface modifications](#interface-modifications) -* [FAQ](#faq) - -# How to include the library - -### Arduino Library Manager - -First install Arduino IDE version 1.6.2 or newer, then simply use the Arduino Library Manager to install the library. - -Please see the following page for instructions: . - -### Manual installation - -First download the library by clicking on the following link: . - -Then uncompress the zip folder and rename the directory to "USB\_Host\_Shield\_20", as any special characters are not supported by the Arduino IDE. - -Now open up the Arduino IDE and open "File>Preferences". There you will see the location of your sketchbook. Open that directory and create a directory called "libraries" inside that directory. -Now move the "USB\_Host\_Shield\_20" directory to the "libraries" directory. - -The final structure should look like this: - -* Arduino/ - * libraries/ - * USB\_Host\_Shield\_20/ - -Now quit the Arduino IDE and reopen it. - -Now you should be able to go open all the examples codes by navigating to "File>Examples>USB\_Host\_Shield\_20" and then select the example you will like to open. - -For more information visit the following sites: and . - -# How to use the library - -### Documentation - -Documentation for the library can be found at the following link: . - -### Enable debugging - -By default serial debugging is disabled. To turn it on simply change ```ENABLE_UHS_DEBUGGING``` to 1 in [settings.h](settings.h) like so: - -```C++ -#define ENABLE_UHS_DEBUGGING 1 -``` - -### Boards - -Currently the following boards are supported by the library: - -* All official Arduino AVR boards (Uno, Duemilanove, Mega, Mega 2560, Mega ADK, Leonardo etc.) -* Arduino Due, Intel Galileo, Intel Galileo 2, and Intel Edison - * Note that the Intel Galileo uses pin 2 and 3 as INT and SS pin respectively by default, so some modifications to the shield are needed. See the "Interface modifications" section in the [hardware manual](https://www.circuitsathome.com/usb-host-shield-hardware-manual) for more information. -* Teensy (Teensy++ 1.0, Teensy 2.0, Teensy++ 2.0, and Teensy 3.x) - * Note if you are using the Teensy 3.x you should download this SPI library as well: . You should then add ```#include ``` to your .ino file. -* Balanduino -* Sanguino -* Black Widdow -* RedBearLab nRF51822 -* Digilent chipKIT - * Please see: . - -The following boards need to be activated manually in [settings.h](settings.h): - -* Arduino Mega ADK - * If you are using Arduino 1.5.5 or newer there is no need to activate the Arduino Mega ADK manually -* Black Widdow - -Simply set the corresponding value to 1 instead of 0. - -### [Bluetooth libraries](BTD.cpp) - -The [BTD library](BTD.cpp) is a general purpose library for an ordinary Bluetooth dongle. -This library make it easy to add support for different Bluetooth services like a PS3 or a Wii controller or SPP which is a virtual serial port via Bluetooth. -Some different examples can be found in the [example directory](examples/Bluetooth). - -The BTD library also makes it possible to use multiple services at once, the following example sketch is an example of this: -[PS3SPP.ino](examples/Bluetooth/PS3SPP/PS3SPP.ino). - -### [BTHID library](BTHID.cpp) - -The [Bluetooth HID library](BTHID.cpp) allows you to connect HID devices via Bluetooth to the USB Host Shield. - -Currently HID mice and keyboards are supported. - -It uses the standard Boot protocol by default, but it is also able to use the Report protocol as well. You would simply have to call ```setProtocolMode()``` and then parse ```HID_RPT_PROTOCOL``` as an argument. You will then have to modify the parser for your device. See the example: [BTHID.ino](examples/Bluetooth/BTHID/BTHID.ino) for more information. - -The [PS4 library](#ps4-library) also uses this class to handle all Bluetooth communication. - -For information see the following blog post: . - -### [SPP library](SPP.cpp) - -SPP stands for "Serial Port Profile" and is a Bluetooth protocol that implements a virtual comport which allows you to send data back and forth from your computer/phone to your Arduino via Bluetooth. -It has been tested successfully on Windows, Mac OS X, Linux, and Android. - -Take a look at the [SPP.ino](examples/Bluetooth/SPP/SPP.ino) example for more information. - -More information can be found at these blog posts: - -* -* - -To implement the SPP protocol I used a Bluetooth sniffing tool called [PacketLogger](http://www.tkjelectronics.com/uploads/PacketLogger.zip) developed by Apple. -It enables me to see the Bluetooth communication between my Mac and any device. - -### PS4 Library - -The PS4BT library is split up into the [PS4BT](PS4BT.h) and the [PS4USB](PS4USB.h) library. These allow you to use the Sony PS4 controller via Bluetooth and USB. - -The [PS4BT.ino](examples/Bluetooth/PS4BT/PS4BT.ino) and [PS4USB.ino](examples/PS4USB/PS4USB.ino) examples shows how to easily read the buttons, joysticks, touchpad and IMU on the controller via Bluetooth and USB respectively. It is also possible to control the rumble and light on the controller and get the battery level. - -Before you can use the PS4 controller via Bluetooth you will need to pair with it. - -Simply create the PS4BT instance like so: ```PS4BT PS4(&Btd, PAIR);``` and then hold down the Share button and then hold down the PS without releasing the Share button. The PS4 controller will then start to blink rapidly indicating that it is in paring mode. - -It should then automatically pair the dongle with your controller. This only have to be done once. - -For information see the following blog post: . - -Also check out this excellent Wiki by Frank Zhao about the PS4 controller: and this Linux driver: . - -### PS3 Library - -These libraries consist of the [PS3BT](PS3BT.cpp) and [PS3USB](PS3USB.cpp). These libraries allows you to use a Dualshock 3, Navigation or a Motion controller with the USB Host Shield both via Bluetooth and USB. - -In order to use your Playstation controller via Bluetooth you have to set the Bluetooth address of the dongle internally to your PS3 Controller. This can be achieved by first plugging in the Bluetooth dongle and wait a few seconds. Now plug in the controller via USB and wait until the LEDs start to flash. The library has now written the Bluetooth address of the dongle to the PS3 controller. - -Finally simply plug in the Bluetooth dongle again and press PS on the PS3 controller. After a few seconds it should be connected to the dongle and ready to use. - -__Note:__ You will have to plug in the Bluetooth dongle before connecting the controller, as the library needs to read the address of the dongle. Alternatively you could set it in code like so: [PS3BT.ino#L20](examples/Bluetooth/PS3BT/PS3BT.ino#L20). - -For more information about the PS3 protocol see the official wiki: . - -Also take a look at the blog posts: - -* -* -* - -A special thanks go to the following people: - -1. _Richard Ibbotson_ who made this excellent guide: -2. _Tomoyuki Tanaka_ for releasing his code for the Arduino USB Host shield connected to the wiimote: - -Also a big thanks all the people behind these sites about the Motion controller: - -* -* -* -* - -### Xbox Libraries - -The library supports both the original Xbox controller via USB and the Xbox 360 controller both via USB and wirelessly. - -#### Xbox library - -The [XBOXOLD](XBOXOLD.cpp) class implements support for the original Xbox controller via USB. - -All the information are from the following sites: - -* -* -* -* - -#### Xbox 360 Library - -The library support one Xbox 360 via USB or up to four Xbox 360 controllers wirelessly by using a [Xbox 360 wireless receiver](http://blog.tkjelectronics.dk/wp-content/uploads/xbox360-wireless-receiver.jpg). - -To use it via USB use the [XBOXUSB](XBOXUSB.cpp) library or to use it wirelessly use the [XBOXRECV](XBOXRECV.cpp) library. - -__Note that a Wireless controller can NOT be used via USB!__ - -Examples code can be found in the [examples directory](examples/Xbox). - -Also see the following blog posts: - -* -* -* - -All the information regarding the Xbox 360 controller protocol are form these sites: - -* -* -* - -#### Xbox ONE Library - -An Xbox ONE controller is supported via USB in the [XBOXONE](XBOXONE.cpp) class. It is heavily based on the 360 library above. In addition to cross referencing the above, information on the protocol was found at: - -* -* -* - -### [Wii library](Wii.cpp) - -The [Wii](Wii.cpp) library support the Wiimote, but also the Nunchuch and Motion Plus extensions via Bluetooth. The Wii U Pro Controller and Wii Balance Board are also supported via Bluetooth. - -First you have to pair with the controller, this is done automatically by the library if you create the instance like so: - -```C++ -WII Wii(&Btd, PAIR); -``` - -And then press 1 & 2 at once on the Wiimote or the SYNC buttons if you are using a Wii U Pro Controller or a Wii Balance Board. - -After that you can simply create the instance like so: - -```C++ -WII Wii(&Btd); -``` - -Then just press any button on the Wiimote and it will then connect to the dongle. - -Take a look at the example for more information: [Wii.ino](examples/Bluetooth/Wii/Wii.ino). - -Also take a look at the blog post: - -* - -The Wii IR camera can also be used, but you will have to activate the code for it manually as it is quite large. Simply set ```ENABLE_WII_IR_CAMERA``` to 1 in [settings.h](settings.h). - -The [WiiIRCamera.ino](examples/Bluetooth/WiiIRCamera/WiiIRCamera.ino) example shows how it can be used. - -All the information about the Wii controllers are from these sites: - -* -* -* -* -* -* The old library created by _Tomoyuki Tanaka_: also helped a lot. - -### [PS Buzz Library](PSBuzz.cpp) - -This library implements support for the Playstation Buzz controllers via USB. - -It is essentially just a wrapper around the [HIDUniversal](hiduniversal.cpp) which takes care of the initializing and reading of the controllers. The [PSBuzz](PSBuzz.cpp) class simply inherits this and parses the data, so it is easy for users to read the buttons and turn the big red button on the controllers on and off. - -The example [PSBuzz.ino](examples/PSBuzz/PSBuzz.ino) shows how one can do this with just a few lines of code. - -More information about the controller can be found at the following sites: - -* http://www.developerfusion.com/article/84338/making-usb-c-friendly/ -* https://github.com/torvalds/linux/blob/master/drivers/hid/hid-sony.c - -# Interface modifications - -The shield is using SPI for communicating with the MAX3421E USB host controller. It uses the SCK, MISO and MOSI pins via the ICSP on your board. - -Note this means that it uses pin 13, 12, 11 on an Arduino Uno, so these pins can not be used for anything else than SPI communication! - -Furthermore it uses one pin as SS and one INT pin. These are by default located on pin 10 and 9 respectively. They can easily be reconfigured in case you need to use them for something else by cutting the jumper on the shield and then solder a wire from the pad to the new pin. - -After that you need modify the following entry in [UsbCore.h](UsbCore.h): - -```C++ -typedef MAX3421e MAX3421E; -``` - -For instance if you have rerouted SS to pin 7 it should read: - -```C++ -typedef MAX3421e MAX3421E; -``` - -See the "Interface modifications" section in the [hardware manual](https://www.circuitsathome.com/usb-host-shield-hardware-manual) for more information. - -# FAQ - -> When I plug my device into the USB connector nothing happens? - -* Try to connect a external power supply to the Arduino - this solves the problem in most cases. -* You can also use a powered hub between the device and the USB Host Shield. You should then include the USB hub library: ```#include ``` and create the instance like so: ```USBHub Hub1(&Usb);```. - -> When I connecting my PS3 controller I get a output like this: - -``` -Dualshock 3 Controller Enabled - -LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0 -LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0 -LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0 -LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0 -LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0 -``` - -* This means that your dongle does not support 2.0+EDR, so you will need another dongle. Please see the following [list](https://github.com/felis/USB_Host_Shield_2.0/wiki/Bluetooth-dongles) for tested working dongles. - -> When compiling I am getting the following error: "fatal error: SPI.h: No such file or directory". - -* Please make sure to include the SPI library like so: ```#include ``` in your .ino file. diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/SPP.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/SPP.cpp deleted file mode 100644 index 0f4ee5e9..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/SPP.cpp +++ /dev/null @@ -1,829 +0,0 @@ -/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#include "SPP.h" -// To enable serial debugging see "settings.h" -//#define EXTRADEBUG // Uncomment to get even more debugging data -//#define PRINTREPORT // Uncomment to print the report sent to the Arduino - -/* - * CRC (reversed crc) lookup table as calculated by the table generator in ETSI TS 101 369 V6.3.0. - */ -const uint8_t rfcomm_crc_table[256] PROGMEM = {/* reversed, 8-bit, poly=0x07 */ - 0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B, - 0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67, - 0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43, - 0x24, 0xB5, 0xC7, 0x56, 0x23, 0xB2, 0xC0, 0x51, 0x2A, 0xBB, 0xC9, 0x58, 0x2D, 0xBC, 0xCE, 0x5F, - 0x70, 0xE1, 0x93, 0x02, 0x77, 0xE6, 0x94, 0x05, 0x7E, 0xEF, 0x9D, 0x0C, 0x79, 0xE8, 0x9A, 0x0B, - 0x6C, 0xFD, 0x8F, 0x1E, 0x6B, 0xFA, 0x88, 0x19, 0x62, 0xF3, 0x81, 0x10, 0x65, 0xF4, 0x86, 0x17, - 0x48, 0xD9, 0xAB, 0x3A, 0x4F, 0xDE, 0xAC, 0x3D, 0x46, 0xD7, 0xA5, 0x34, 0x41, 0xD0, 0xA2, 0x33, - 0x54, 0xC5, 0xB7, 0x26, 0x53, 0xC2, 0xB0, 0x21, 0x5A, 0xCB, 0xB9, 0x28, 0x5D, 0xCC, 0xBE, 0x2F, - 0xE0, 0x71, 0x03, 0x92, 0xE7, 0x76, 0x04, 0x95, 0xEE, 0x7F, 0x0D, 0x9C, 0xE9, 0x78, 0x0A, 0x9B, - 0xFC, 0x6D, 0x1F, 0x8E, 0xFB, 0x6A, 0x18, 0x89, 0xF2, 0x63, 0x11, 0x80, 0xF5, 0x64, 0x16, 0x87, - 0xD8, 0x49, 0x3B, 0xAA, 0xDF, 0x4E, 0x3C, 0xAD, 0xD6, 0x47, 0x35, 0xA4, 0xD1, 0x40, 0x32, 0xA3, - 0xC4, 0x55, 0x27, 0xB6, 0xC3, 0x52, 0x20, 0xB1, 0xCA, 0x5B, 0x29, 0xB8, 0xCD, 0x5C, 0x2E, 0xBF, - 0x90, 0x01, 0x73, 0xE2, 0x97, 0x06, 0x74, 0xE5, 0x9E, 0x0F, 0x7D, 0xEC, 0x99, 0x08, 0x7A, 0xEB, - 0x8C, 0x1D, 0x6F, 0xFE, 0x8B, 0x1A, 0x68, 0xF9, 0x82, 0x13, 0x61, 0xF0, 0x85, 0x14, 0x66, 0xF7, - 0xA8, 0x39, 0x4B, 0xDA, 0xAF, 0x3E, 0x4C, 0xDD, 0xA6, 0x37, 0x45, 0xD4, 0xA1, 0x30, 0x42, 0xD3, - 0xB4, 0x25, 0x57, 0xC6, 0xB3, 0x22, 0x50, 0xC1, 0xBA, 0x2B, 0x59, 0xC8, 0xBD, 0x2C, 0x5E, 0xCF -}; - -SPP::SPP(BTD *p, const char* name, const char* pin) : -BluetoothService(p) // Pointer to BTD class instance - mandatory -{ - pBtd->btdName = name; - pBtd->btdPin = pin; - - /* Set device cid for the SDP and RFCOMM channelse */ - sdp_dcid[0] = 0x50; // 0x0050 - sdp_dcid[1] = 0x00; - rfcomm_dcid[0] = 0x51; // 0x0051 - rfcomm_dcid[1] = 0x00; - - Reset(); -} - -void SPP::Reset() { - connected = false; - RFCOMMConnected = false; - SDPConnected = false; - waitForLastCommand = false; - l2cap_sdp_state = L2CAP_SDP_WAIT; - l2cap_rfcomm_state = L2CAP_RFCOMM_WAIT; - l2cap_event_flag = 0; - sppIndex = 0; - creditSent = false; -} - -void SPP::disconnect() { - connected = false; - // First the two L2CAP channels has to be disconnected and then the HCI connection - if(RFCOMMConnected) - pBtd->l2cap_disconnection_request(hci_handle, ++identifier, rfcomm_scid, rfcomm_dcid); - if(RFCOMMConnected && SDPConnected) - delay(1); // Add delay between commands - if(SDPConnected) - pBtd->l2cap_disconnection_request(hci_handle, ++identifier, sdp_scid, sdp_dcid); - l2cap_sdp_state = L2CAP_DISCONNECT_RESPONSE; -} - -void SPP::ACLData(uint8_t* l2capinbuf) { - if(!connected) { - if(l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) { - if((l2capinbuf[12] | (l2capinbuf[13] << 8)) == SDP_PSM && !pBtd->sdpConnectionClaimed) { - pBtd->sdpConnectionClaimed = true; - hci_handle = pBtd->hci_handle; // Store the HCI Handle for the connection - l2cap_sdp_state = L2CAP_SDP_WAIT; // Reset state - } else if((l2capinbuf[12] | (l2capinbuf[13] << 8)) == RFCOMM_PSM && !pBtd->rfcommConnectionClaimed) { - pBtd->rfcommConnectionClaimed = true; - hci_handle = pBtd->hci_handle; // Store the HCI Handle for the connection - l2cap_rfcomm_state = L2CAP_RFCOMM_WAIT; // Reset state - } - } - } - - if(checkHciHandle(l2capinbuf, hci_handle)) { // acl_handle_ok - if((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001U) { // l2cap_control - Channel ID for ACL-U - if(l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80); - D_PrintHex (l2capinbuf[13], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[12], 0x80); - Notify(PSTR(" Data: "), 0x80); - D_PrintHex (l2capinbuf[17], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[16], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[15], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[14], 0x80); -#endif - } else if(l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) { -#ifdef EXTRADEBUG - Notify(PSTR("\r\nL2CAP Connection Request - PSM: "), 0x80); - D_PrintHex (l2capinbuf[13], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[12], 0x80); - Notify(PSTR(" SCID: "), 0x80); - D_PrintHex (l2capinbuf[15], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[14], 0x80); - Notify(PSTR(" Identifier: "), 0x80); - D_PrintHex (l2capinbuf[9], 0x80); -#endif - if((l2capinbuf[12] | (l2capinbuf[13] << 8)) == SDP_PSM) { // It doesn't matter if it receives another reqeust, since it waits for the channel to disconnect in the L2CAP_SDP_DONE state, and the l2cap_event_flag will be cleared if so - identifier = l2capinbuf[9]; - sdp_scid[0] = l2capinbuf[14]; - sdp_scid[1] = l2capinbuf[15]; - l2cap_set_flag(L2CAP_FLAG_CONNECTION_SDP_REQUEST); - } else if((l2capinbuf[12] | (l2capinbuf[13] << 8)) == RFCOMM_PSM) { // ----- || ----- - identifier = l2capinbuf[9]; - rfcomm_scid[0] = l2capinbuf[14]; - rfcomm_scid[1] = l2capinbuf[15]; - l2cap_set_flag(L2CAP_FLAG_CONNECTION_RFCOMM_REQUEST); - } - } else if(l2capinbuf[8] == L2CAP_CMD_CONFIG_RESPONSE) { - if((l2capinbuf[16] | (l2capinbuf[17] << 8)) == 0x0000) { // Success - if(l2capinbuf[12] == sdp_dcid[0] && l2capinbuf[13] == sdp_dcid[1]) { - //Notify(PSTR("\r\nSDP Configuration Complete"), 0x80); - l2cap_set_flag(L2CAP_FLAG_CONFIG_SDP_SUCCESS); - } else if(l2capinbuf[12] == rfcomm_dcid[0] && l2capinbuf[13] == rfcomm_dcid[1]) { - //Notify(PSTR("\r\nRFCOMM Configuration Complete"), 0x80); - l2cap_set_flag(L2CAP_FLAG_CONFIG_RFCOMM_SUCCESS); - } - } - } else if(l2capinbuf[8] == L2CAP_CMD_CONFIG_REQUEST) { - if(l2capinbuf[12] == sdp_dcid[0] && l2capinbuf[13] == sdp_dcid[1]) { - //Notify(PSTR("\r\nSDP Configuration Request"), 0x80); - pBtd->l2cap_config_response(hci_handle, l2capinbuf[9], sdp_scid); - } else if(l2capinbuf[12] == rfcomm_dcid[0] && l2capinbuf[13] == rfcomm_dcid[1]) { - //Notify(PSTR("\r\nRFCOMM Configuration Request"), 0x80); - pBtd->l2cap_config_response(hci_handle, l2capinbuf[9], rfcomm_scid); - } - } else if(l2capinbuf[8] == L2CAP_CMD_DISCONNECT_REQUEST) { - if(l2capinbuf[12] == sdp_dcid[0] && l2capinbuf[13] == sdp_dcid[1]) { - //Notify(PSTR("\r\nDisconnect Request: SDP Channel"), 0x80); - identifier = l2capinbuf[9]; - l2cap_set_flag(L2CAP_FLAG_DISCONNECT_SDP_REQUEST); - } else if(l2capinbuf[12] == rfcomm_dcid[0] && l2capinbuf[13] == rfcomm_dcid[1]) { - //Notify(PSTR("\r\nDisconnect Request: RFCOMM Channel"), 0x80); - identifier = l2capinbuf[9]; - l2cap_set_flag(L2CAP_FLAG_DISCONNECT_RFCOMM_REQUEST); - } - } else if(l2capinbuf[8] == L2CAP_CMD_DISCONNECT_RESPONSE) { - if(l2capinbuf[12] == sdp_scid[0] && l2capinbuf[13] == sdp_scid[1]) { - //Notify(PSTR("\r\nDisconnect Response: SDP Channel"), 0x80); - identifier = l2capinbuf[9]; - l2cap_set_flag(L2CAP_FLAG_DISCONNECT_RESPONSE); - } else if(l2capinbuf[12] == rfcomm_scid[0] && l2capinbuf[13] == rfcomm_scid[1]) { - //Notify(PSTR("\r\nDisconnect Response: RFCOMM Channel"), 0x80); - identifier = l2capinbuf[9]; - l2cap_set_flag(L2CAP_FLAG_DISCONNECT_RESPONSE); - } - } else if(l2capinbuf[8] == L2CAP_CMD_INFORMATION_REQUEST) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nInformation request"), 0x80); -#endif - identifier = l2capinbuf[9]; - pBtd->l2cap_information_response(hci_handle, identifier, l2capinbuf[12], l2capinbuf[13]); - } -#ifdef EXTRADEBUG - else { - Notify(PSTR("\r\nL2CAP Unknown Signaling Command: "), 0x80); - D_PrintHex (l2capinbuf[8], 0x80); - } -#endif - } else if(l2capinbuf[6] == sdp_dcid[0] && l2capinbuf[7] == sdp_dcid[1]) { // SDP - if(l2capinbuf[8] == SDP_SERVICE_SEARCH_ATTRIBUTE_REQUEST_PDU) { - if(((l2capinbuf[16] << 8 | l2capinbuf[17]) == SERIALPORT_UUID) || ((l2capinbuf[16] << 8 | l2capinbuf[17]) == 0x0000 && (l2capinbuf[18] << 8 | l2capinbuf[19]) == SERIALPORT_UUID)) { // Check if it's sending the full UUID, see: https://www.bluetooth.org/Technical/AssignedNumbers/service_discovery.htm, we will just check the first four bytes - if(firstMessage) { - serialPortResponse1(l2capinbuf[9], l2capinbuf[10]); - firstMessage = false; - } else { - serialPortResponse2(l2capinbuf[9], l2capinbuf[10]); // Serialport continuation state - firstMessage = true; - } - } else if(((l2capinbuf[16] << 8 | l2capinbuf[17]) == L2CAP_UUID) || ((l2capinbuf[16] << 8 | l2capinbuf[17]) == 0x0000 && (l2capinbuf[18] << 8 | l2capinbuf[19]) == L2CAP_UUID)) { - if(firstMessage) { - l2capResponse1(l2capinbuf[9], l2capinbuf[10]); - firstMessage = false; - } else { - l2capResponse2(l2capinbuf[9], l2capinbuf[10]); // L2CAP continuation state - firstMessage = true; - } - } else - serviceNotSupported(l2capinbuf[9], l2capinbuf[10]); // The service is not supported -#ifdef EXTRADEBUG - Notify(PSTR("\r\nUUID: "), 0x80); - uint16_t uuid; - if((l2capinbuf[16] << 8 | l2capinbuf[17]) == 0x0000) // Check if it's sending the UUID as a 128-bit UUID - uuid = (l2capinbuf[18] << 8 | l2capinbuf[19]); - else // Short UUID - uuid = (l2capinbuf[16] << 8 | l2capinbuf[17]); - D_PrintHex (uuid, 0x80); - - Notify(PSTR("\r\nLength: "), 0x80); - uint16_t length = l2capinbuf[11] << 8 | l2capinbuf[12]; - D_PrintHex (length, 0x80); - Notify(PSTR("\r\nData: "), 0x80); - for(uint8_t i = 0; i < length; i++) { - D_PrintHex (l2capinbuf[13 + i], 0x80); - Notify(PSTR(" "), 0x80); - } -#endif - } -#ifdef EXTRADEBUG - else { - Notify(PSTR("\r\nUnknown PDU: "), 0x80); - D_PrintHex (l2capinbuf[8], 0x80); - } -#endif - } else if(l2capinbuf[6] == rfcomm_dcid[0] && l2capinbuf[7] == rfcomm_dcid[1]) { // RFCOMM - rfcommChannel = l2capinbuf[8] & 0xF8; - rfcommDirection = l2capinbuf[8] & 0x04; - rfcommCommandResponse = l2capinbuf[8] & 0x02; - rfcommChannelType = l2capinbuf[9] & 0xEF; - rfcommPfBit = l2capinbuf[9] & 0x10; - - if(rfcommChannel >> 3 != 0x00) - rfcommChannelConnection = rfcommChannel; - -#ifdef EXTRADEBUG - Notify(PSTR("\r\nRFCOMM Channel: "), 0x80); - D_PrintHex (rfcommChannel >> 3, 0x80); - Notify(PSTR(" Direction: "), 0x80); - D_PrintHex (rfcommDirection >> 2, 0x80); - Notify(PSTR(" CommandResponse: "), 0x80); - D_PrintHex (rfcommCommandResponse >> 1, 0x80); - Notify(PSTR(" ChannelType: "), 0x80); - D_PrintHex (rfcommChannelType, 0x80); - Notify(PSTR(" PF_BIT: "), 0x80); - D_PrintHex (rfcommPfBit, 0x80); -#endif - if(rfcommChannelType == RFCOMM_DISC) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nReceived Disconnect RFCOMM Command on channel: "), 0x80); - D_PrintHex (rfcommChannel >> 3, 0x80); -#endif - connected = false; - sendRfcomm(rfcommChannel, rfcommDirection, rfcommCommandResponse, RFCOMM_UA, rfcommPfBit, rfcommbuf, 0x00); // UA Command - } - if(connected) { - /* Read the incoming message */ - if(rfcommChannelType == RFCOMM_UIH && rfcommChannel == rfcommChannelConnection) { - uint8_t length = l2capinbuf[10] >> 1; // Get length - uint8_t offset = l2capinbuf[4] - length - 4; // Check if there is credit - if(checkFcs(&l2capinbuf[8], l2capinbuf[11 + length + offset])) { - uint8_t i = 0; - for(; i < length; i++) { - if(rfcommAvailable + i >= sizeof (rfcommDataBuffer)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nWarning: Buffer is full!"), 0x80); -#endif - break; - } - rfcommDataBuffer[rfcommAvailable + i] = l2capinbuf[11 + i + offset]; - } - rfcommAvailable += i; -#ifdef EXTRADEBUG - Notify(PSTR("\r\nRFCOMM Data Available: "), 0x80); - Notify(rfcommAvailable, 0x80); - if(offset) { - Notify(PSTR(" - Credit: 0x"), 0x80); - D_PrintHex (l2capinbuf[11], 0x80); - } -#endif - } -#ifdef DEBUG_USB_HOST - else - Notify(PSTR("\r\nError in FCS checksum!"), 0x80); -#endif -#ifdef PRINTREPORT // Uncomment "#define PRINTREPORT" to print the report send to the Arduino via Bluetooth - for(uint8_t i = 0; i < length; i++) - Notifyc(l2capinbuf[i + 11 + offset], 0x80); -#endif - } else if(rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_RPN_CMD) { // UIH Remote Port Negotiation Command -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nReceived UIH Remote Port Negotiation Command"), 0x80); -#endif - rfcommbuf[0] = BT_RFCOMM_RPN_RSP; // Command - rfcommbuf[1] = l2capinbuf[12]; // Length and shiftet like so: length << 1 | 1 - rfcommbuf[2] = l2capinbuf[13]; // Channel: channel << 1 | 1 - rfcommbuf[3] = l2capinbuf[14]; // Pre difined for Bluetooth, see 5.5.3 of TS 07.10 Adaption for RFCOMM - rfcommbuf[4] = l2capinbuf[15]; // Priority - rfcommbuf[5] = l2capinbuf[16]; // Timer - rfcommbuf[6] = l2capinbuf[17]; // Max Fram Size LSB - rfcommbuf[7] = l2capinbuf[18]; // Max Fram Size MSB - rfcommbuf[8] = l2capinbuf[19]; // MaxRatransm. - rfcommbuf[9] = l2capinbuf[20]; // Number of Frames - sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x0A); // UIH Remote Port Negotiation Response - } else if(rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_MSC_CMD) { // UIH Modem Status Command -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSend UIH Modem Status Response"), 0x80); -#endif - rfcommbuf[0] = BT_RFCOMM_MSC_RSP; // UIH Modem Status Response - rfcommbuf[1] = 2 << 1 | 1; // Length and shiftet like so: length << 1 | 1 - rfcommbuf[2] = l2capinbuf[13]; // Channel: (1 << 0) | (1 << 1) | (0 << 2) | (channel << 3) - rfcommbuf[3] = l2capinbuf[14]; - sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x04); - } - } else { - if(rfcommChannelType == RFCOMM_SABM) { // SABM Command - this is sent twice: once for channel 0 and then for the channel to establish -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nReceived SABM Command"), 0x80); -#endif - sendRfcomm(rfcommChannel, rfcommDirection, rfcommCommandResponse, RFCOMM_UA, rfcommPfBit, rfcommbuf, 0x00); // UA Command - } else if(rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_PN_CMD) { // UIH Parameter Negotiation Command -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nReceived UIH Parameter Negotiation Command"), 0x80); -#endif - rfcommbuf[0] = BT_RFCOMM_PN_RSP; // UIH Parameter Negotiation Response - rfcommbuf[1] = l2capinbuf[12]; // Length and shiftet like so: length << 1 | 1 - rfcommbuf[2] = l2capinbuf[13]; // Channel: channel << 1 | 1 - rfcommbuf[3] = 0xE0; // Pre difined for Bluetooth, see 5.5.3 of TS 07.10 Adaption for RFCOMM - rfcommbuf[4] = 0x00; // Priority - rfcommbuf[5] = 0x00; // Timer - rfcommbuf[6] = BULK_MAXPKTSIZE - 14; // Max Fram Size LSB - set to the size of received data (50) - rfcommbuf[7] = 0x00; // Max Fram Size MSB - rfcommbuf[8] = 0x00; // MaxRatransm. - rfcommbuf[9] = 0x00; // Number of Frames - sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x0A); - } else if(rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_MSC_CMD) { // UIH Modem Status Command -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSend UIH Modem Status Response"), 0x80); -#endif - rfcommbuf[0] = BT_RFCOMM_MSC_RSP; // UIH Modem Status Response - rfcommbuf[1] = 2 << 1 | 1; // Length and shiftet like so: length << 1 | 1 - rfcommbuf[2] = l2capinbuf[13]; // Channel: (1 << 0) | (1 << 1) | (0 << 2) | (channel << 3) - rfcommbuf[3] = l2capinbuf[14]; - sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x04); - - delay(1); -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSend UIH Modem Status Command"), 0x80); -#endif - rfcommbuf[0] = BT_RFCOMM_MSC_CMD; // UIH Modem Status Command - rfcommbuf[1] = 2 << 1 | 1; // Length and shiftet like so: length << 1 | 1 - rfcommbuf[2] = l2capinbuf[13]; // Channel: (1 << 0) | (1 << 1) | (0 << 2) | (channel << 3) - rfcommbuf[3] = 0x8D; // Can receive frames (YES), Ready to Communicate (YES), Ready to Receive (YES), Incomig Call (NO), Data is Value (YES) - - sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x04); - } else if(rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_MSC_RSP) { // UIH Modem Status Response - if(!creditSent) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSend UIH Command with credit"), 0x80); -#endif - sendRfcommCredit(rfcommChannelConnection, rfcommDirection, 0, RFCOMM_UIH, 0x10, sizeof (rfcommDataBuffer)); // Send credit - creditSent = true; - timer = millis(); - waitForLastCommand = true; - } - } else if(rfcommChannelType == RFCOMM_UIH && l2capinbuf[10] == 0x01) { // UIH Command with credit -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nReceived UIH Command with credit"), 0x80); -#endif - } else if(rfcommChannelType == RFCOMM_UIH && l2capinbuf[11] == BT_RFCOMM_RPN_CMD) { // UIH Remote Port Negotiation Command -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nReceived UIH Remote Port Negotiation Command"), 0x80); -#endif - rfcommbuf[0] = BT_RFCOMM_RPN_RSP; // Command - rfcommbuf[1] = l2capinbuf[12]; // Length and shiftet like so: length << 1 | 1 - rfcommbuf[2] = l2capinbuf[13]; // Channel: channel << 1 | 1 - rfcommbuf[3] = l2capinbuf[14]; // Pre difined for Bluetooth, see 5.5.3 of TS 07.10 Adaption for RFCOMM - rfcommbuf[4] = l2capinbuf[15]; // Priority - rfcommbuf[5] = l2capinbuf[16]; // Timer - rfcommbuf[6] = l2capinbuf[17]; // Max Fram Size LSB - rfcommbuf[7] = l2capinbuf[18]; // Max Fram Size MSB - rfcommbuf[8] = l2capinbuf[19]; // MaxRatransm. - rfcommbuf[9] = l2capinbuf[20]; // Number of Frames - sendRfcomm(rfcommChannel, rfcommDirection, 0, RFCOMM_UIH, rfcommPfBit, rfcommbuf, 0x0A); // UIH Remote Port Negotiation Response -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nRFCOMM Connection is now established\r\n"), 0x80); -#endif - onInit(); - } -#ifdef EXTRADEBUG - else if(rfcommChannelType != RFCOMM_DISC) { - Notify(PSTR("\r\nUnsupported RFCOMM Data - ChannelType: "), 0x80); - D_PrintHex (rfcommChannelType, 0x80); - Notify(PSTR(" Command: "), 0x80); - D_PrintHex (l2capinbuf[11], 0x80); - } -#endif - } - } -#ifdef EXTRADEBUG - else { - Notify(PSTR("\r\nUnsupported L2CAP Data - Channel ID: "), 0x80); - D_PrintHex (l2capinbuf[7], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[6], 0x80); - } -#endif - SDP_task(); - RFCOMM_task(); - } -} - -void SPP::Run() { - if(waitForLastCommand && (millis() - timer) > 100) { // We will only wait 100ms and see if the UIH Remote Port Negotiation Command is send, as some deviced don't send it -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nRFCOMM Connection is now established - Automatic\r\n"), 0x80); -#endif - onInit(); - } - send(); // Send all bytes currently in the buffer -} - -void SPP::onInit() { - creditSent = false; - waitForLastCommand = false; - connected = true; // The RFCOMM channel is now established - sppIndex = 0; - if(pFuncOnInit) - pFuncOnInit(); // Call the user function -}; - -void SPP::SDP_task() { - switch(l2cap_sdp_state) { - case L2CAP_SDP_WAIT: - if(l2cap_check_flag(L2CAP_FLAG_CONNECTION_SDP_REQUEST)) { - l2cap_clear_flag(L2CAP_FLAG_CONNECTION_SDP_REQUEST); // Clear flag -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSDP Incoming Connection Request"), 0x80); -#endif - pBtd->l2cap_connection_response(hci_handle, identifier, sdp_dcid, sdp_scid, PENDING); - delay(1); - pBtd->l2cap_connection_response(hci_handle, identifier, sdp_dcid, sdp_scid, SUCCESSFUL); - identifier++; - delay(1); - pBtd->l2cap_config_request(hci_handle, identifier, sdp_scid); - l2cap_sdp_state = L2CAP_SDP_SUCCESS; - } else if(l2cap_check_flag(L2CAP_FLAG_DISCONNECT_SDP_REQUEST)) { - l2cap_clear_flag(L2CAP_FLAG_DISCONNECT_SDP_REQUEST); // Clear flag - SDPConnected = false; -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nDisconnected SDP Channel"), 0x80); -#endif - pBtd->l2cap_disconnection_response(hci_handle, identifier, sdp_dcid, sdp_scid); - } - break; - case L2CAP_SDP_SUCCESS: - if(l2cap_check_flag(L2CAP_FLAG_CONFIG_SDP_SUCCESS)) { - l2cap_clear_flag(L2CAP_FLAG_CONFIG_SDP_SUCCESS); // Clear flag -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSDP Successfully Configured"), 0x80); -#endif - firstMessage = true; // Reset bool - SDPConnected = true; - l2cap_sdp_state = L2CAP_SDP_WAIT; - } - break; - - case L2CAP_DISCONNECT_RESPONSE: // This is for both disconnection response from the RFCOMM and SDP channel if they were connected - if(l2cap_check_flag(L2CAP_FLAG_DISCONNECT_RESPONSE)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nDisconnected L2CAP Connection"), 0x80); -#endif - pBtd->hci_disconnect(hci_handle); - hci_handle = -1; // Reset handle - Reset(); - } - break; - } -} - -void SPP::RFCOMM_task() { - switch(l2cap_rfcomm_state) { - case L2CAP_RFCOMM_WAIT: - if(l2cap_check_flag(L2CAP_FLAG_CONNECTION_RFCOMM_REQUEST)) { - l2cap_clear_flag(L2CAP_FLAG_CONNECTION_RFCOMM_REQUEST); // Clear flag -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nRFCOMM Incoming Connection Request"), 0x80); -#endif - pBtd->l2cap_connection_response(hci_handle, identifier, rfcomm_dcid, rfcomm_scid, PENDING); - delay(1); - pBtd->l2cap_connection_response(hci_handle, identifier, rfcomm_dcid, rfcomm_scid, SUCCESSFUL); - identifier++; - delay(1); - pBtd->l2cap_config_request(hci_handle, identifier, rfcomm_scid); - l2cap_rfcomm_state = L2CAP_RFCOMM_SUCCESS; - } else if(l2cap_check_flag(L2CAP_FLAG_DISCONNECT_RFCOMM_REQUEST)) { - l2cap_clear_flag(L2CAP_FLAG_DISCONNECT_RFCOMM_REQUEST); // Clear flag - RFCOMMConnected = false; - connected = false; -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nDisconnected RFCOMM Channel"), 0x80); -#endif - pBtd->l2cap_disconnection_response(hci_handle, identifier, rfcomm_dcid, rfcomm_scid); - } - break; - case L2CAP_RFCOMM_SUCCESS: - if(l2cap_check_flag(L2CAP_FLAG_CONFIG_RFCOMM_SUCCESS)) { - l2cap_clear_flag(L2CAP_FLAG_CONFIG_RFCOMM_SUCCESS); // Clear flag -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nRFCOMM Successfully Configured"), 0x80); -#endif - rfcommAvailable = 0; // Reset number of bytes available - bytesRead = 0; // Reset number of bytes received - RFCOMMConnected = true; - l2cap_rfcomm_state = L2CAP_RFCOMM_WAIT; - } - break; - } -} -/************************************************************/ -/* SDP Commands */ - -/************************************************************/ -void SPP::SDP_Command(uint8_t* data, uint8_t nbytes) { // See page 223 in the Bluetooth specs - pBtd->L2CAP_Command(hci_handle, data, nbytes, sdp_scid[0], sdp_scid[1]); -} - -void SPP::serviceNotSupported(uint8_t transactionIDHigh, uint8_t transactionIDLow) { // See page 235 in the Bluetooth specs - l2capoutbuf[0] = SDP_SERVICE_SEARCH_ATTRIBUTE_RESPONSE_PDU; - l2capoutbuf[1] = transactionIDHigh; - l2capoutbuf[2] = transactionIDLow; - l2capoutbuf[3] = 0x00; // MSB Parameter Length - l2capoutbuf[4] = 0x05; // LSB Parameter Length = 5 - l2capoutbuf[5] = 0x00; // MSB AttributeListsByteCount - l2capoutbuf[6] = 0x02; // LSB AttributeListsByteCount = 2 - - /* Attribute ID/Value Sequence: */ - l2capoutbuf[7] = 0x35; // Data element sequence - length in next byte - l2capoutbuf[8] = 0x00; // Length = 0 - l2capoutbuf[9] = 0x00; // No continuation state - - SDP_Command(l2capoutbuf, 10); -} - -void SPP::serialPortResponse1(uint8_t transactionIDHigh, uint8_t transactionIDLow) { - l2capoutbuf[0] = SDP_SERVICE_SEARCH_ATTRIBUTE_RESPONSE_PDU; - l2capoutbuf[1] = transactionIDHigh; - l2capoutbuf[2] = transactionIDLow; - l2capoutbuf[3] = 0x00; // MSB Parameter Length - l2capoutbuf[4] = 0x2B; // LSB Parameter Length = 43 - l2capoutbuf[5] = 0x00; // MSB AttributeListsByteCount - l2capoutbuf[6] = 0x26; // LSB AttributeListsByteCount = 38 - - /* Attribute ID/Value Sequence: */ - l2capoutbuf[7] = 0x36; // Data element sequence - length in next two bytes - l2capoutbuf[8] = 0x00; // MSB Length - l2capoutbuf[9] = 0x3C; // LSB Length = 60 - - l2capoutbuf[10] = 0x36; // Data element sequence - length in next two bytes - l2capoutbuf[11] = 0x00; // MSB Length - l2capoutbuf[12] = 0x39; // LSB Length = 57 - - l2capoutbuf[13] = 0x09; // Unsigned Integer - length 2 bytes - l2capoutbuf[14] = 0x00; // MSB ServiceRecordHandle - l2capoutbuf[15] = 0x00; // LSB ServiceRecordHandle - l2capoutbuf[16] = 0x0A; // Unsigned int - length 4 bytes - l2capoutbuf[17] = 0x00; // ServiceRecordHandle value - TODO: Is this related to HCI_Handle? - l2capoutbuf[18] = 0x01; - l2capoutbuf[19] = 0x00; - l2capoutbuf[20] = 0x06; - - l2capoutbuf[21] = 0x09; // Unsigned Integer - length 2 bytes - l2capoutbuf[22] = 0x00; // MSB ServiceClassIDList - l2capoutbuf[23] = 0x01; // LSB ServiceClassIDList - l2capoutbuf[24] = 0x35; // Data element sequence - length in next byte - l2capoutbuf[25] = 0x03; // Length = 3 - l2capoutbuf[26] = 0x19; // UUID (universally unique identifier) - length = 2 bytes - l2capoutbuf[27] = 0x11; // MSB SerialPort - l2capoutbuf[28] = 0x01; // LSB SerialPort - - l2capoutbuf[29] = 0x09; // Unsigned Integer - length 2 bytes - l2capoutbuf[30] = 0x00; // MSB ProtocolDescriptorList - l2capoutbuf[31] = 0x04; // LSB ProtocolDescriptorList - l2capoutbuf[32] = 0x35; // Data element sequence - length in next byte - l2capoutbuf[33] = 0x0C; // Length = 12 - - l2capoutbuf[34] = 0x35; // Data element sequence - length in next byte - l2capoutbuf[35] = 0x03; // Length = 3 - l2capoutbuf[36] = 0x19; // UUID (universally unique identifier) - length = 2 bytes - l2capoutbuf[37] = 0x01; // MSB L2CAP - l2capoutbuf[38] = 0x00; // LSB L2CAP - - l2capoutbuf[39] = 0x35; // Data element sequence - length in next byte - l2capoutbuf[40] = 0x05; // Length = 5 - l2capoutbuf[41] = 0x19; // UUID (universally unique identifier) - length = 2 bytes - l2capoutbuf[42] = 0x00; // MSB RFCOMM - l2capoutbuf[43] = 0x03; // LSB RFCOMM - l2capoutbuf[44] = 0x08; // Unsigned Integer - length 1 byte - - l2capoutbuf[45] = 0x02; // ContinuationState - Two more bytes - l2capoutbuf[46] = 0x00; // MSB length - l2capoutbuf[47] = 0x19; // LSB length = 25 more bytes to come - - SDP_Command(l2capoutbuf, 48); -} - -void SPP::serialPortResponse2(uint8_t transactionIDHigh, uint8_t transactionIDLow) { - l2capoutbuf[0] = SDP_SERVICE_SEARCH_ATTRIBUTE_RESPONSE_PDU; - l2capoutbuf[1] = transactionIDHigh; - l2capoutbuf[2] = transactionIDLow; - l2capoutbuf[3] = 0x00; // MSB Parameter Length - l2capoutbuf[4] = 0x1C; // LSB Parameter Length = 28 - l2capoutbuf[5] = 0x00; // MSB AttributeListsByteCount - l2capoutbuf[6] = 0x19; // LSB AttributeListsByteCount = 25 - - /* Attribute ID/Value Sequence: */ - l2capoutbuf[7] = 0x01; // Channel 1 - TODO: Try different values, so multiple servers can be used at once - - l2capoutbuf[8] = 0x09; // Unsigned Integer - length 2 bytes - l2capoutbuf[9] = 0x00; // MSB LanguageBaseAttributeIDList - l2capoutbuf[10] = 0x06; // LSB LanguageBaseAttributeIDList - l2capoutbuf[11] = 0x35; // Data element sequence - length in next byte - l2capoutbuf[12] = 0x09; // Length = 9 - - // Identifier representing the natural language = en = English - see: "ISO 639:1988" - l2capoutbuf[13] = 0x09; // Unsigned Integer - length 2 bytes - l2capoutbuf[14] = 0x65; // 'e' - l2capoutbuf[15] = 0x6E; // 'n' - - // "The second element of each triplet contains an identifier that specifies a character encoding used for the language" - // Encoding is set to 106 (UTF-8) - see: http://www.iana.org/assignments/character-sets/character-sets.xhtml - l2capoutbuf[16] = 0x09; // Unsigned Integer - length 2 bytes - l2capoutbuf[17] = 0x00; // MSB of character encoding - l2capoutbuf[18] = 0x6A; // LSB of character encoding (106) - - // Attribute ID that serves as the base attribute ID for the natural language in the service record - // "To facilitate the retrieval of human-readable universal attributes in a principal language, the base attribute ID value for the primary language supported by a service record shall be 0x0100" - l2capoutbuf[19] = 0x09; // Unsigned Integer - length 2 bytes - l2capoutbuf[20] = 0x01; - l2capoutbuf[21] = 0x00; - - l2capoutbuf[22] = 0x09; // Unsigned Integer - length 2 bytes - l2capoutbuf[23] = 0x01; // MSB ServiceDescription - l2capoutbuf[24] = 0x00; // LSB ServiceDescription - - l2capoutbuf[25] = 0x25; // Text string - length in next byte - l2capoutbuf[26] = 0x05; // Name length - l2capoutbuf[27] = 'T'; - l2capoutbuf[28] = 'K'; - l2capoutbuf[29] = 'J'; - l2capoutbuf[30] = 'S'; - l2capoutbuf[31] = 'P'; - l2capoutbuf[32] = 0x00; // No continuation state - - SDP_Command(l2capoutbuf, 33); -} - -void SPP::l2capResponse1(uint8_t transactionIDHigh, uint8_t transactionIDLow) { - serialPortResponse1(transactionIDHigh, transactionIDLow); // These has to send all the supported functions, since it only supports virtual serialport it just sends the message again -} - -void SPP::l2capResponse2(uint8_t transactionIDHigh, uint8_t transactionIDLow) { - serialPortResponse2(transactionIDHigh, transactionIDLow); // Same data as serialPortResponse2 -} -/************************************************************/ -/* RFCOMM Commands */ - -/************************************************************/ -void SPP::RFCOMM_Command(uint8_t* data, uint8_t nbytes) { - pBtd->L2CAP_Command(hci_handle, data, nbytes, rfcomm_scid[0], rfcomm_scid[1]); -} - -void SPP::sendRfcomm(uint8_t channel, uint8_t direction, uint8_t CR, uint8_t channelType, uint8_t pfBit, uint8_t* data, uint8_t length) { - l2capoutbuf[0] = channel | direction | CR | extendAddress; // RFCOMM Address - l2capoutbuf[1] = channelType | pfBit; // RFCOMM Control - l2capoutbuf[2] = length << 1 | 0x01; // Length and format (always 0x01 bytes format) - uint8_t i = 0; - for(; i < length; i++) - l2capoutbuf[i + 3] = data[i]; - l2capoutbuf[i + 3] = calcFcs(l2capoutbuf); -#ifdef EXTRADEBUG - Notify(PSTR(" - RFCOMM Data: "), 0x80); - for(i = 0; i < length + 4; i++) { - D_PrintHex (l2capoutbuf[i], 0x80); - Notify(PSTR(" "), 0x80); - } -#endif - RFCOMM_Command(l2capoutbuf, length + 4); -} - -void SPP::sendRfcommCredit(uint8_t channel, uint8_t direction, uint8_t CR, uint8_t channelType, uint8_t pfBit, uint8_t credit) { - l2capoutbuf[0] = channel | direction | CR | extendAddress; // RFCOMM Address - l2capoutbuf[1] = channelType | pfBit; // RFCOMM Control - l2capoutbuf[2] = 0x01; // Length = 0 - l2capoutbuf[3] = credit; // Credit - l2capoutbuf[4] = calcFcs(l2capoutbuf); -#ifdef EXTRADEBUG - Notify(PSTR(" - RFCOMM Credit Data: "), 0x80); - for(uint8_t i = 0; i < 5; i++) { - D_PrintHex (l2capoutbuf[i], 0x80); - Notify(PSTR(" "), 0x80); - } -#endif - RFCOMM_Command(l2capoutbuf, 5); -} - -/* CRC on 2 bytes */ -uint8_t SPP::crc(uint8_t *data) { - return (pgm_read_byte(&rfcomm_crc_table[pgm_read_byte(&rfcomm_crc_table[0xFF ^ data[0]]) ^ data[1]])); -} - -/* Calculate FCS */ -uint8_t SPP::calcFcs(uint8_t *data) { - uint8_t temp = crc(data); - if((data[1] & 0xEF) == RFCOMM_UIH) - return (0xFF - temp); // FCS on 2 bytes - else - return (0xFF - pgm_read_byte(&rfcomm_crc_table[temp ^ data[2]])); // FCS on 3 bytes -} - -/* Check FCS */ -bool SPP::checkFcs(uint8_t *data, uint8_t fcs) { - uint8_t temp = crc(data); - if((data[1] & 0xEF) != RFCOMM_UIH) - temp = pgm_read_byte(&rfcomm_crc_table[temp ^ data[2]]); // FCS on 3 bytes - return (pgm_read_byte(&rfcomm_crc_table[temp ^ fcs]) == 0xCF); -} - -/* Serial commands */ -#if defined(ARDUINO) && ARDUINO >=100 - -size_t SPP::write(uint8_t data) { - return write(&data, 1); -} -#else - -void SPP::write(uint8_t data) { - write(&data, 1); -} -#endif - -#if defined(ARDUINO) && ARDUINO >=100 - -size_t SPP::write(const uint8_t *data, size_t size) { -#else - -void SPP::write(const uint8_t *data, size_t size) { -#endif - for(uint8_t i = 0; i < size; i++) { - if(sppIndex >= sizeof (sppOutputBuffer) / sizeof (sppOutputBuffer[0])) - send(); // Send the current data in the buffer - sppOutputBuffer[sppIndex++] = data[i]; // All the bytes are put into a buffer and then send using the send() function - } -#if defined(ARDUINO) && ARDUINO >=100 - return size; -#endif -} - -void SPP::send() { - if(!connected || !sppIndex) - return; - uint8_t length; // This is the length of the string we are sending - uint8_t offset = 0; // This is used to keep track of where we are in the string - - l2capoutbuf[0] = rfcommChannelConnection | 0 | 0 | extendAddress; // RFCOMM Address - l2capoutbuf[1] = RFCOMM_UIH; // RFCOMM Control - - while(sppIndex) { // We will run this while loop until this variable is 0 - if(sppIndex > (sizeof (l2capoutbuf) - 4)) // Check if the string is larger than the outgoing buffer - length = sizeof (l2capoutbuf) - 4; - else - length = sppIndex; - - l2capoutbuf[2] = length << 1 | 1; // Length - uint8_t i = 0; - for(; i < length; i++) - l2capoutbuf[i + 3] = sppOutputBuffer[i + offset]; - l2capoutbuf[i + 3] = calcFcs(l2capoutbuf); // Calculate checksum - - RFCOMM_Command(l2capoutbuf, length + 4); - - sppIndex -= length; - offset += length; // Increment the offset - } -} - -int SPP::available(void) { - return rfcommAvailable; -}; - -void SPP::discard(void) { - rfcommAvailable = 0; -} - -int SPP::peek(void) { - if(rfcommAvailable == 0) // Don't read if there is nothing in the buffer - return -1; - return rfcommDataBuffer[0]; -} - -int SPP::read(void) { - if(rfcommAvailable == 0) // Don't read if there is nothing in the buffer - return -1; - uint8_t output = rfcommDataBuffer[0]; - for(uint8_t i = 1; i < rfcommAvailable; i++) - rfcommDataBuffer[i - 1] = rfcommDataBuffer[i]; // Shift the buffer one left - rfcommAvailable--; - bytesRead++; - if(bytesRead > (sizeof (rfcommDataBuffer) - 5)) { // We will send the command just before it runs out of credit - bytesRead = 0; - sendRfcommCredit(rfcommChannelConnection, rfcommDirection, 0, RFCOMM_UIH, 0x10, sizeof (rfcommDataBuffer)); // Send more credit -#ifdef EXTRADEBUG - Notify(PSTR("\r\nSent "), 0x80); - Notify((uint8_t)sizeof (rfcommDataBuffer), 0x80); - Notify(PSTR(" more credit"), 0x80); -#endif - } - return output; -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/SPP.h b/protocol/usb_hid/USB_Host_Shield_2.0/SPP.h deleted file mode 100644 index 233ac611..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/SPP.h +++ /dev/null @@ -1,225 +0,0 @@ -/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#ifndef _spp_h_ -#define _spp_h_ - -#include "BTD.h" - -/* Used for SDP */ -#define SDP_SERVICE_SEARCH_ATTRIBUTE_REQUEST_PDU 0x06 // See the RFCOMM specs -#define SDP_SERVICE_SEARCH_ATTRIBUTE_RESPONSE_PDU 0x07 // See the RFCOMM specs -#define SERIALPORT_UUID 0x1101 // See http://www.bluetooth.org/Technical/AssignedNumbers/service_discovery.htm -#define L2CAP_UUID 0x0100 - -/* Used for RFCOMM */ -#define RFCOMM_SABM 0x2F -#define RFCOMM_UA 0x63 -#define RFCOMM_UIH 0xEF -//#define RFCOMM_DM 0x0F -#define RFCOMM_DISC 0x43 - -#define extendAddress 0x01 // Always 1 - -// Multiplexer message types -#define BT_RFCOMM_PN_CMD 0x83 -#define BT_RFCOMM_PN_RSP 0x81 -#define BT_RFCOMM_MSC_CMD 0xE3 -#define BT_RFCOMM_MSC_RSP 0xE1 -#define BT_RFCOMM_RPN_CMD 0x93 -#define BT_RFCOMM_RPN_RSP 0x91 -/* -#define BT_RFCOMM_TEST_CMD 0x23 -#define BT_RFCOMM_TEST_RSP 0x21 -#define BT_RFCOMM_FCON_CMD 0xA3 -#define BT_RFCOMM_FCON_RSP 0xA1 -#define BT_RFCOMM_FCOFF_CMD 0x63 -#define BT_RFCOMM_FCOFF_RSP 0x61 -#define BT_RFCOMM_RLS_CMD 0x53 -#define BT_RFCOMM_RLS_RSP 0x51 -#define BT_RFCOMM_NSC_RSP 0x11 - */ - -/** - * This BluetoothService class implements the Serial Port Protocol (SPP). - * It inherits the Arduino Stream class. This allows it to use all the standard Arduino print and stream functions. - */ -class SPP : public BluetoothService, public Stream { -public: - /** - * Constructor for the SPP class. - * @param p Pointer to BTD class instance. - * @param name Set the name to BTD#btdName. If argument is omitted, then "Arduino" will be used. - * @param pin Write the pin to BTD#btdPin. If argument is omitted, then "0000" will be used. - */ - SPP(BTD *p, const char *name = "Arduino", const char *pin = "0000"); - - /** @name BluetoothService implementation */ - /** Used this to disconnect the virtual serial port. */ - void disconnect(); - /**@}*/ - - /** - * Used to provide Boolean tests for the class. - * @return Return true if SPP communication is connected. - */ - operator bool() { - return connected; - } - /** Variable used to indicate if the connection is established. */ - bool connected; - - /** @name Serial port profile (SPP) Print functions */ - /** - * Get number of bytes waiting to be read. - * @return Return the number of bytes ready to be read. - */ - int available(void); - - /** Send out all bytes in the buffer. */ - void flush(void) { - send(); - }; - /** - * Used to read the next value in the buffer without advancing to the next one. - * @return Return the byte. Will return -1 if no bytes are available. - */ - int peek(void); - /** - * Used to read the buffer. - * @return Return the byte. Will return -1 if no bytes are available. - */ - int read(void); - -#if defined(ARDUINO) && ARDUINO >=100 - /** - * Writes the byte to send to a buffer. The message is send when either send() or after Usb.Task() is called. - * @param data The byte to write. - * @return Return the number of bytes written. - */ - size_t write(uint8_t data); - /** - * Writes the bytes to send to a buffer. The message is send when either send() or after Usb.Task() is called. - * @param data The data array to send. - * @param size Size of the data. - * @return Return the number of bytes written. - */ - size_t write(const uint8_t* data, size_t size); - /** Pull in write(const char *str) from Print */ - using Print::write; -#else - /** - * Writes the byte to send to a buffer. The message is send when either send() or after Usb.Task() is called. - * @param data The byte to write. - */ - void write(uint8_t data); - /** - * Writes the bytes to send to a buffer. The message is send when either send() or after Usb.Task() is called. - * @param data The data array to send. - * @param size Size of the data. - */ - void write(const uint8_t* data, size_t size); -#endif - - /** Discard all the bytes in the buffer. */ - void discard(void); - /** - * This will send all the bytes in the buffer. - * This is called whenever Usb.Task() is called, - * but can also be called via this function. - */ - void send(void); - /**@}*/ - -protected: - /** @name BluetoothService implementation */ - /** - * Used to pass acldata to the services. - * @param ACLData Incoming acldata. - */ - void ACLData(uint8_t* ACLData); - /** Used to establish the connection automatically. */ - void Run(); - /** Use this to reset the service. */ - void Reset(); - /** - * Called when a device is successfully initialized. - * Use attachOnInit(void (*funcOnInit)(void)) to call your own function. - * This is useful for instance if you want to set the LEDs in a specific way. - */ - void onInit(); - /**@}*/ - -private: - /* Set true when a channel is created */ - bool SDPConnected; - bool RFCOMMConnected; - - /* Variables used by L2CAP state machines */ - uint8_t l2cap_sdp_state; - uint8_t l2cap_rfcomm_state; - - uint8_t l2capoutbuf[BULK_MAXPKTSIZE]; // General purpose buffer for l2cap out data - uint8_t rfcommbuf[10]; // Buffer for RFCOMM Commands - - /* L2CAP Channels */ - uint8_t sdp_scid[2]; // L2CAP source CID for SDP - uint8_t sdp_dcid[2]; // 0x0050 - uint8_t rfcomm_scid[2]; // L2CAP source CID for RFCOMM - uint8_t rfcomm_dcid[2]; // 0x0051 - - /* RFCOMM Variables */ - uint8_t rfcommChannel; - uint8_t rfcommChannelConnection; // This is the channel the SPP channel will be running at - uint8_t rfcommDirection; - uint8_t rfcommCommandResponse; - uint8_t rfcommChannelType; - uint8_t rfcommPfBit; - - uint32_t timer; - bool waitForLastCommand; - bool creditSent; - - uint8_t rfcommDataBuffer[100]; // Create a 100 sized buffer for incoming data - uint8_t sppOutputBuffer[100]; // Create a 100 sized buffer for outgoing SPP data - uint8_t sppIndex; - uint8_t rfcommAvailable; - - bool firstMessage; // Used to see if it's the first SDP request received - uint8_t bytesRead; // Counter to see when it's time to send more credit - - /* State machines */ - void SDP_task(); // SDP state machine - void RFCOMM_task(); // RFCOMM state machine - - /* SDP Commands */ - void SDP_Command(uint8_t *data, uint8_t nbytes); - void serviceNotSupported(uint8_t transactionIDHigh, uint8_t transactionIDLow); - void serialPortResponse1(uint8_t transactionIDHigh, uint8_t transactionIDLow); - void serialPortResponse2(uint8_t transactionIDHigh, uint8_t transactionIDLow); - void l2capResponse1(uint8_t transactionIDHigh, uint8_t transactionIDLow); - void l2capResponse2(uint8_t transactionIDHigh, uint8_t transactionIDLow); - - /* RFCOMM Commands */ - void RFCOMM_Command(uint8_t *data, uint8_t nbytes); - void sendRfcomm(uint8_t channel, uint8_t direction, uint8_t CR, uint8_t channelType, uint8_t pfBit, uint8_t *data, uint8_t length); - void sendRfcommCredit(uint8_t channel, uint8_t direction, uint8_t CR, uint8_t channelType, uint8_t pfBit, uint8_t credit); - uint8_t calcFcs(uint8_t *data); - bool checkFcs(uint8_t *data, uint8_t fcs); - uint8_t crc(uint8_t *data); -}; -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/Usb.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/Usb.cpp deleted file mode 100644 index 14272588..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/Usb.cpp +++ /dev/null @@ -1,812 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -/* USB functions */ - -#include "Usb.h" - -static uint8_t usb_error = 0; -static uint8_t usb_task_state; - -/* constructor */ -USB::USB() : bmHubPre(0) { - usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE; //set up state machine - init(); -} - -/* Initialize data structures */ -void USB::init() { - //devConfigIndex = 0; - bmHubPre = 0; -} - -uint8_t USB::getUsbTaskState(void) { - return ( usb_task_state); -} - -void USB::setUsbTaskState(uint8_t state) { - usb_task_state = state; -} - -EpInfo* USB::getEpInfoEntry(uint8_t addr, uint8_t ep) { - UsbDevice *p = addrPool.GetUsbDevicePtr(addr); - - if(!p || !p->epinfo) - return NULL; - - EpInfo *pep = p->epinfo; - - for(uint8_t i = 0; i < p->epcount; i++) { - if((pep)->epAddr == ep) - return pep; - - pep++; - } - return NULL; -} - -/* set device table entry */ - -/* each device is different and has different number of endpoints. This function plugs endpoint record structure, defined in application, to devtable */ -uint8_t USB::setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo* eprecord_ptr) { - if(!eprecord_ptr) - return USB_ERROR_INVALID_ARGUMENT; - - UsbDevice *p = addrPool.GetUsbDevicePtr(addr); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - p->address.devAddress = addr; - p->epinfo = eprecord_ptr; - p->epcount = epcount; - - return 0; -} - -uint8_t USB::SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t *nak_limit) { - UsbDevice *p = addrPool.GetUsbDevicePtr(addr); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - if(!p->epinfo) - return USB_ERROR_EPINFO_IS_NULL; - - *ppep = getEpInfoEntry(addr, ep); - - if(!*ppep) - return USB_ERROR_EP_NOT_FOUND_IN_TBL; - - *nak_limit = (0x0001UL << (((*ppep)->bmNakPower > USB_NAK_MAX_POWER) ? USB_NAK_MAX_POWER : (*ppep)->bmNakPower)); - (*nak_limit)--; - /* - USBTRACE2("\r\nAddress: ", addr); - USBTRACE2(" EP: ", ep); - USBTRACE2(" NAK Power: ",(*ppep)->bmNakPower); - USBTRACE2(" NAK Limit: ", nak_limit); - USBTRACE("\r\n"); - */ - regWr(rPERADDR, addr); //set peripheral address - - uint8_t mode = regRd(rMODE); - - //Serial.print("\r\nMode: "); - //Serial.println( mode, HEX); - //Serial.print("\r\nLS: "); - //Serial.println(p->lowspeed, HEX); - - - - // Set bmLOWSPEED and bmHUBPRE in case of low-speed device, reset them otherwise - regWr(rMODE, (p->lowspeed) ? mode | bmLOWSPEED | bmHubPre : mode & ~(bmHUBPRE | bmLOWSPEED)); - - return 0; -} - -/* Control transfer. Sets address, endpoint, fills control packet with necessary data, dispatches control packet, and initiates bulk IN transfer, */ -/* depending on request. Actual requests are defined as inlines */ -/* return codes: */ -/* 00 = success */ - -/* 01-0f = non-zero HRSLT */ -uint8_t USB::ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi, - uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t* dataptr, USBReadParser *p) { - bool direction = false; //request direction, IN or OUT - uint8_t rcode; - SETUP_PKT setup_pkt; - - EpInfo *pep = NULL; - uint16_t nak_limit = 0; - - rcode = SetAddress(addr, ep, &pep, &nak_limit); - - if(rcode) - return rcode; - - direction = ((bmReqType & 0x80) > 0); - - /* fill in setup packet */ - setup_pkt.ReqType_u.bmRequestType = bmReqType; - setup_pkt.bRequest = bRequest; - setup_pkt.wVal_u.wValueLo = wValLo; - setup_pkt.wVal_u.wValueHi = wValHi; - setup_pkt.wIndex = wInd; - setup_pkt.wLength = total; - - bytesWr(rSUDFIFO, 8, (uint8_t*) & setup_pkt); //transfer to setup packet FIFO - - rcode = dispatchPkt(tokSETUP, ep, nak_limit); //dispatch packet - - if(rcode) //return HRSLT if not zero - return ( rcode); - - if(dataptr != NULL) //data stage, if present - { - if(direction) //IN transfer - { - uint16_t left = total; - - pep->bmRcvToggle = 1; //bmRCVTOG1; - - while(left) { - // Bytes read into buffer - uint16_t read = nbytes; - //uint16_t read = (leftbmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; - continue; - } - - if(rcode) - return rcode; - - // Invoke callback function if inTransfer completed successfully and callback function pointer is specified - if(!rcode && p) - ((USBReadParser*)p)->Parse(read, dataptr, total - left); - - left -= read; - - if(read < nbytes) - break; - } - } else //OUT transfer - { - pep->bmSndToggle = 1; //bmSNDTOG1; - rcode = OutTransfer(pep, nak_limit, nbytes, dataptr); - } - if(rcode) //return error - return ( rcode); - } - // Status stage - return dispatchPkt((direction) ? tokOUTHS : tokINHS, ep, nak_limit); //GET if direction -} - -/* IN transfer to arbitrary endpoint. Assumes PERADDR is set. Handles multiple packets if necessary. Transfers 'nbytes' bytes. */ -/* Keep sending INs and writes data to memory area pointed by 'data' */ - -/* rcode 0 if no errors. rcode 01-0f is relayed from dispatchPkt(). Rcode f0 means RCVDAVIRQ error, - fe USB xfer timeout */ -uint8_t USB::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data) { - EpInfo *pep = NULL; - uint16_t nak_limit = 0; - - uint8_t rcode = SetAddress(addr, ep, &pep, &nak_limit); - - if(rcode) { - USBTRACE3("(USB::InTransfer) SetAddress Failed ", rcode, 0x81); - USBTRACE3("(USB::InTransfer) addr requested ", addr, 0x81); - USBTRACE3("(USB::InTransfer) ep requested ", ep, 0x81); - return rcode; - } - return InTransfer(pep, nak_limit, nbytesptr, data); -} - -uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t* data) { - uint8_t rcode = 0; - uint8_t pktsize; - - uint16_t nbytes = *nbytesptr; - //printf("Requesting %i bytes ", nbytes); - uint8_t maxpktsize = pep->maxPktSize; - - *nbytesptr = 0; - regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value - - // use a 'break' to exit this loop - while(1) { - rcode = dispatchPkt(tokIN, pep->epAddr, nak_limit); //IN packet to EP-'endpoint'. Function takes care of NAKS. - if(rcode == hrTOGERR) { - // yes, we flip it wrong here so that next time it is actually correct! - pep->bmRcvToggle = (regRd(rHRSL) & bmRCVTOGRD) ? 0 : 1; - regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value - continue; - } - if(rcode) { - //printf(">>>>>>>> Problem! dispatchPkt %2.2x\r\n", rcode); - break; //should be 0, indicating ACK. Else return error code. - } - /* check for RCVDAVIRQ and generate error if not present */ - /* the only case when absence of RCVDAVIRQ makes sense is when toggle error occurred. Need to add handling for that */ - if((regRd(rHIRQ) & bmRCVDAVIRQ) == 0) { - //printf(">>>>>>>> Problem! NO RCVDAVIRQ!\r\n"); - rcode = 0xf0; //receive error - break; - } - pktsize = regRd(rRCVBC); //number of received bytes - //printf("Got %i bytes \r\n", pktsize); - // This would be OK, but... - //assert(pktsize <= nbytes); - if(pktsize > nbytes) { - // This can happen. Use of assert on Arduino locks up the Arduino. - // So I will trim the value, and hope for the best. - //printf(">>>>>>>> Problem! Wanted %i bytes but got %i.\r\n", nbytes, pktsize); - pktsize = nbytes; - } - - int16_t mem_left = (int16_t)nbytes - *((int16_t*)nbytesptr); - - if(mem_left < 0) - mem_left = 0; - - data = bytesRd(rRCVFIFO, ((pktsize > mem_left) ? mem_left : pktsize), data); - - regWr(rHIRQ, bmRCVDAVIRQ); // Clear the IRQ & free the buffer - *nbytesptr += pktsize; // add this packet's byte count to total transfer length - - /* The transfer is complete under two conditions: */ - /* 1. The device sent a short packet (L.T. maxPacketSize) */ - /* 2. 'nbytes' have been transferred. */ - if((pktsize < maxpktsize) || (*nbytesptr >= nbytes)) // have we transferred 'nbytes' bytes? - { - // Save toggle value - pep->bmRcvToggle = ((regRd(rHRSL) & bmRCVTOGRD)) ? 1 : 0; - //printf("\r\n"); - rcode = 0; - break; - } // if - } //while( 1 ) - return ( rcode); -} - -/* OUT transfer to arbitrary endpoint. Handles multiple packets if necessary. Transfers 'nbytes' bytes. */ -/* Handles NAK bug per Maxim Application Note 4000 for single buffer transfer */ - -/* rcode 0 if no errors. rcode 01-0f is relayed from HRSL */ -uint8_t USB::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data) { - EpInfo *pep = NULL; - uint16_t nak_limit = 0; - - uint8_t rcode = SetAddress(addr, ep, &pep, &nak_limit); - - if(rcode) - return rcode; - - return OutTransfer(pep, nak_limit, nbytes, data); -} - -uint8_t USB::OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data) { - uint8_t rcode = hrSUCCESS, retry_count; - uint8_t *data_p = data; //local copy of the data pointer - uint16_t bytes_tosend, nak_count; - uint16_t bytes_left = nbytes; - - uint8_t maxpktsize = pep->maxPktSize; - - if(maxpktsize < 1 || maxpktsize > 64) - return USB_ERROR_INVALID_MAX_PKT_SIZE; - - unsigned long timeout = millis() + USB_XFER_TIMEOUT; - - regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value - - while(bytes_left) { - retry_count = 0; - nak_count = 0; - bytes_tosend = (bytes_left >= maxpktsize) ? maxpktsize : bytes_left; - bytesWr(rSNDFIFO, bytes_tosend, data_p); //filling output FIFO - regWr(rSNDBC, bytes_tosend); //set number of bytes - regWr(rHXFR, (tokOUT | pep->epAddr)); //dispatch packet - while(!(regRd(rHIRQ) & bmHXFRDNIRQ)); //wait for the completion IRQ - regWr(rHIRQ, bmHXFRDNIRQ); //clear IRQ - rcode = (regRd(rHRSL) & 0x0f); - - while(rcode && ((long)(millis() - timeout) < 0L)) { - switch(rcode) { - case hrNAK: - nak_count++; - if(nak_limit && (nak_count == nak_limit)) - goto breakout; - //return ( rcode); - break; - case hrTIMEOUT: - retry_count++; - if(retry_count == USB_RETRY_LIMIT) - goto breakout; - //return ( rcode); - break; - case hrTOGERR: - // yes, we flip it wrong here so that next time it is actually correct! - pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; - regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value - break; - default: - goto breakout; - }//switch( rcode - - /* process NAK according to Host out NAK bug */ - regWr(rSNDBC, 0); - regWr(rSNDFIFO, *data_p); - regWr(rSNDBC, bytes_tosend); - regWr(rHXFR, (tokOUT | pep->epAddr)); //dispatch packet - while(!(regRd(rHIRQ) & bmHXFRDNIRQ)); //wait for the completion IRQ - regWr(rHIRQ, bmHXFRDNIRQ); //clear IRQ - rcode = (regRd(rHRSL) & 0x0f); - }//while( rcode && .... - bytes_left -= bytes_tosend; - data_p += bytes_tosend; - }//while( bytes_left... -breakout: - - pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 1 : 0; //bmSNDTOG1 : bmSNDTOG0; //update toggle - return ( rcode); //should be 0 in all cases -} -/* dispatch USB packet. Assumes peripheral address is set and relevant buffer is loaded/empty */ -/* If NAK, tries to re-send up to nak_limit times */ -/* If nak_limit == 0, do not count NAKs, exit after timeout */ -/* If bus timeout, re-sends up to USB_RETRY_LIMIT times */ - -/* return codes 0x00-0x0f are HRSLT( 0x00 being success ), 0xff means timeout */ -uint8_t USB::dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit) { - unsigned long timeout = millis() + USB_XFER_TIMEOUT; - uint8_t tmpdata; - uint8_t rcode = hrSUCCESS; - uint8_t retry_count = 0; - uint16_t nak_count = 0; - - while((long)(millis() - timeout) < 0L) { - regWr(rHXFR, (token | ep)); //launch the transfer - rcode = USB_ERROR_TRANSFER_TIMEOUT; - - while((long)(millis() - timeout) < 0L) //wait for transfer completion - { - tmpdata = regRd(rHIRQ); - - if(tmpdata & bmHXFRDNIRQ) { - regWr(rHIRQ, bmHXFRDNIRQ); //clear the interrupt - rcode = 0x00; - break; - }//if( tmpdata & bmHXFRDNIRQ - - }//while ( millis() < timeout - - //if (rcode != 0x00) //exit if timeout - // return ( rcode); - - rcode = (regRd(rHRSL) & 0x0f); //analyze transfer result - - switch(rcode) { - case hrNAK: - nak_count++; - if(nak_limit && (nak_count == nak_limit)) - return (rcode); - break; - case hrTIMEOUT: - retry_count++; - if(retry_count == USB_RETRY_LIMIT) - return (rcode); - break; - default: - return (rcode); - }//switch( rcode - - }//while( timeout > millis() - return ( rcode); -} - -/* USB main task. Performs enumeration/cleanup */ -void USB::Task(void) //USB state machine -{ - uint8_t rcode; - uint8_t tmpdata; - static unsigned long delay = 0; - //USB_DEVICE_DESCRIPTOR buf; - bool lowspeed = false; - - MAX3421E::Task(); - - tmpdata = getVbusState(); - - /* modify USB task state if Vbus changed */ - switch(tmpdata) { - case SE1: //illegal state - usb_task_state = USB_DETACHED_SUBSTATE_ILLEGAL; - lowspeed = false; - break; - case SE0: //disconnected - if((usb_task_state & USB_STATE_MASK) != USB_STATE_DETACHED) - usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE; - lowspeed = false; - break; - case LSHOST: - - lowspeed = true; - //intentional fallthrough - case FSHOST: //attached - if((usb_task_state & USB_STATE_MASK) == USB_STATE_DETACHED) { - delay = millis() + USB_SETTLE_DELAY; - usb_task_state = USB_ATTACHED_SUBSTATE_SETTLE; - } - break; - }// switch( tmpdata - - for(uint8_t i = 0; i < USB_NUMDEVICES; i++) - if(devConfig[i]) - rcode = devConfig[i]->Poll(); - - switch(usb_task_state) { - case USB_DETACHED_SUBSTATE_INITIALIZE: - init(); - - for(uint8_t i = 0; i < USB_NUMDEVICES; i++) - if(devConfig[i]) - rcode = devConfig[i]->Release(); - - usb_task_state = USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE; - break; - case USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE: //just sit here - break; - case USB_DETACHED_SUBSTATE_ILLEGAL: //just sit here - break; - case USB_ATTACHED_SUBSTATE_SETTLE: //settle time for just attached device - if((long)(millis() - delay) >= 0L) - usb_task_state = USB_ATTACHED_SUBSTATE_RESET_DEVICE; - else break; // don't fall through - case USB_ATTACHED_SUBSTATE_RESET_DEVICE: - regWr(rHCTL, bmBUSRST); //issue bus reset - usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_RESET_COMPLETE; - break; - case USB_ATTACHED_SUBSTATE_WAIT_RESET_COMPLETE: - if((regRd(rHCTL) & bmBUSRST) == 0) { - tmpdata = regRd(rMODE) | bmSOFKAENAB; //start SOF generation - regWr(rMODE, tmpdata); - usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_SOF; - //delay = millis() + 20; //20ms wait after reset per USB spec - } - break; - case USB_ATTACHED_SUBSTATE_WAIT_SOF: //todo: change check order - if(regRd(rHIRQ) & bmFRAMEIRQ) { - //when first SOF received _and_ 20ms has passed we can continue - /* - if (delay < millis()) //20ms passed - usb_task_state = USB_STATE_CONFIGURING; - */ - usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_RESET; - delay = millis() + 20; - } - break; - case USB_ATTACHED_SUBSTATE_WAIT_RESET: - if((long)(millis() - delay) >= 0L) usb_task_state = USB_STATE_CONFIGURING; - else break; // don't fall through - case USB_STATE_CONFIGURING: - - //Serial.print("\r\nConf.LS: "); - //Serial.println(lowspeed, HEX); - - rcode = Configuring(0, 0, lowspeed); - - if(rcode) { - if(rcode != USB_DEV_CONFIG_ERROR_DEVICE_INIT_INCOMPLETE) { - usb_error = rcode; - usb_task_state = USB_STATE_ERROR; - } - } else - usb_task_state = USB_STATE_RUNNING; - break; - case USB_STATE_RUNNING: - break; - case USB_STATE_ERROR: - //MAX3421E::Init(); - break; - } // switch( usb_task_state ) -} - -uint8_t USB::DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed) { - //uint8_t buf[12]; - uint8_t rcode; - UsbDevice *p0 = NULL, *p = NULL; - - // Get pointer to pseudo device with address 0 assigned - p0 = addrPool.GetUsbDevicePtr(0); - - if(!p0) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - if(!p0->epinfo) - return USB_ERROR_EPINFO_IS_NULL; - - p0->lowspeed = (lowspeed) ? true : false; - - // Allocate new address according to device class - uint8_t bAddress = addrPool.AllocAddress(parent, false, port); - - if(!bAddress) - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - - p = addrPool.GetUsbDevicePtr(bAddress); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - p->lowspeed = lowspeed; - - // Assign new address to the device - rcode = setAddr(0, 0, bAddress); - - if(rcode) { - addrPool.FreeAddress(bAddress); - bAddress = 0; - return rcode; - } - return 0; -}; - -uint8_t USB::AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lowspeed) { - //printf("AttemptConfig: parent = %i, port = %i\r\n", parent, port); - uint8_t retries = 0; - -again: - uint8_t rcode = devConfig[driver]->ConfigureDevice(parent, port, lowspeed); - if(rcode == USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET) { - if(parent == 0) { - // Send a bus reset on the root interface. - regWr(rHCTL, bmBUSRST); //issue bus reset - delay(102); // delay 102ms, compensate for clock inaccuracy. - } else { - // reset parent port - devConfig[parent]->ResetHubPort(port); - } - } else if(rcode == hrJERR && retries < 3) { // Some devices returns this when plugged in - trying to initialize the device again usually works - delay(100); - retries++; - goto again; - } else if(rcode) - return rcode; - - rcode = devConfig[driver]->Init(parent, port, lowspeed); - if(rcode == hrJERR && retries < 3) { // Some devices returns this when plugged in - trying to initialize the device again usually works - delay(100); - retries++; - goto again; - } - if(rcode) { - // Issue a bus reset, because the device may be in a limbo state - if(parent == 0) { - // Send a bus reset on the root interface. - regWr(rHCTL, bmBUSRST); //issue bus reset - delay(102); // delay 102ms, compensate for clock inaccuracy. - } else { - // reset parent port - devConfig[parent]->ResetHubPort(port); - } - } - return rcode; -} - -/* - * This is broken. We need to enumerate differently. - * It causes major problems with several devices if detected in an unexpected order. - * - * - * Oleg - I wouldn't do anything before the newly connected device is considered sane. - * i.e.(delays are not indicated for brevity): - * 1. reset - * 2. GetDevDescr(); - * 3a. If ACK, continue with allocating address, addressing, etc. - * 3b. Else reset again, count resets, stop at some number (5?). - * 4. When max.number of resets is reached, toggle power/fail - * If desired, this could be modified by performing two resets with GetDevDescr() in the middle - however, from my experience, if a device answers to GDD() - * it doesn't need to be reset again - * New steps proposal: - * 1: get address pool instance. exit on fail - * 2: pUsb->getDevDescr(0, 0, constBufSize, (uint8_t*)buf). exit on fail. - * 3: bus reset, 100ms delay - * 4: set address - * 5: pUsb->setEpInfoEntry(bAddress, 1, epInfo), exit on fail - * 6: while (configurations) { - * for(each configuration) { - * for (each driver) { - * 6a: Ask device if it likes configuration. Returns 0 on OK. - * If successful, the driver configured device. - * The driver now owns the endpoints, and takes over managing them. - * The following will need codes: - * Everything went well, instance consumed, exit with success. - * Instance already in use, ignore it, try next driver. - * Not a supported device, ignore it, try next driver. - * Not a supported configuration for this device, ignore it, try next driver. - * Could not configure device, fatal, exit with fail. - * } - * } - * } - * 7: for(each driver) { - * 7a: Ask device if it knows this VID/PID. Acts exactly like 6a, but using VID/PID - * 8: if we get here, no driver likes the device plugged in, so exit failure. - * - */ -uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) { - //uint8_t bAddress = 0; - //printf("Configuring: parent = %i, port = %i\r\n", parent, port); - uint8_t devConfigIndex; - uint8_t rcode = 0; - uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)]; - USB_DEVICE_DESCRIPTOR *udd = reinterpret_cast(buf); - UsbDevice *p = NULL; - EpInfo *oldep_ptr = NULL; - EpInfo epInfo; - - epInfo.epAddr = 0; - epInfo.maxPktSize = 8; - epInfo.epAttribs = 0; - epInfo.bmNakPower = USB_NAK_MAX_POWER; - - //delay(2000); - AddressPool &addrPool = GetAddressPool(); - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - if(!p) { - //printf("Configuring error: USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL\r\n"); - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - } - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to - // avoid toggle inconsistence - - p->epinfo = &epInfo; - - p->lowspeed = lowspeed; - // Get device descriptor - rcode = getDevDescr(0, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*)buf); - - // Restore p->epinfo - p->epinfo = oldep_ptr; - - if(rcode) { - //printf("Configuring error: Can't get USB_DEVICE_DESCRIPTOR\r\n"); - return rcode; - } - - // to-do? - // Allocate new address according to device class - //bAddress = addrPool.AllocAddress(parent, false, port); - - uint16_t vid = udd->idVendor; - uint16_t pid = udd->idProduct; - uint8_t klass = udd->bDeviceClass; - uint8_t subklass = udd->bDeviceSubClass; - // Attempt to configure if VID/PID or device class matches with a driver - // Qualify with subclass too. - // - // VID/PID & class tests default to false for drivers not yet ported - // subclass defaults to true, so you don't have to define it if you don't have to. - // - for(devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) { - if(!devConfig[devConfigIndex]) continue; // no driver - if(devConfig[devConfigIndex]->GetAddress()) continue; // consumed - if(devConfig[devConfigIndex]->DEVSUBCLASSOK(subklass) && (devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass))) { - rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed); - if(rcode != USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED) - break; - } - } - - if(devConfigIndex < USB_NUMDEVICES) { - return rcode; - } - - - // blindly attempt to configure - for(devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) { - if(!devConfig[devConfigIndex]) continue; - if(devConfig[devConfigIndex]->GetAddress()) continue; // consumed - if(devConfig[devConfigIndex]->DEVSUBCLASSOK(subklass) && (devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass))) continue; // If this is true it means it must have returned USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED above - rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed); - - //printf("ERROR ENUMERATING %2.2x\r\n", rcode); - if(!(rcode == USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED || rcode == USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE)) { - // in case of an error dev_index should be reset to 0 - // in order to start from the very beginning the - // next time the program gets here - //if (rcode != USB_DEV_CONFIG_ERROR_DEVICE_INIT_INCOMPLETE) - // devConfigIndex = 0; - return rcode; - } - } - // if we get here that means that the device class is not supported by any of registered classes - rcode = DefaultAddressing(parent, port, lowspeed); - - return rcode; -} - -uint8_t USB::ReleaseDevice(uint8_t addr) { - if(!addr) - return 0; - - for(uint8_t i = 0; i < USB_NUMDEVICES; i++) { - if(!devConfig[i]) continue; - if(devConfig[i]->GetAddress() == addr) - return devConfig[i]->Release(); - } - return 0; -} - -#if 1 //!defined(USB_METHODS_INLINE) -//get device descriptor - -uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr) { - return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, nbytes, dataptr, NULL)); -} -//get configuration descriptor - -uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr) { - return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, nbytes, dataptr, NULL)); -} - -/* Requests Configuration Descriptor. Sends two Get Conf Descr requests. The first one gets the total length of all descriptors, then the second one requests this - total length. The length of the first request can be shorter ( 4 bytes ), however, there are devices which won't work unless this length is set to 9 */ -uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser *p) { - const uint8_t bufSize = 64; - uint8_t buf[bufSize]; - USB_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast(buf); - - uint8_t ret = getConfDescr(addr, ep, 9, conf, buf); - - if(ret) - return ret; - - uint16_t total = ucd->wTotalLength; - - //USBTRACE2("\r\ntotal conf.size:", total); - - return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, total, bufSize, buf, p)); -} - -//get string descriptor - -uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t ns, uint8_t index, uint16_t langid, uint8_t* dataptr) { - return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, ns, ns, dataptr, NULL)); -} -//set address - -uint8_t USB::setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr) { - uint8_t rcode = ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL); - //delay(2); //per USB 2.0 sect.9.2.6.3 - delay(300); // Older spec says you should wait at least 200ms - return rcode; - //return ( ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL)); -} -//set configuration - -uint8_t USB::setConf(uint8_t addr, uint8_t ep, uint8_t conf_value) { - return ( ctrlReq(addr, ep, bmREQ_SET, USB_REQUEST_SET_CONFIGURATION, conf_value, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL)); -} - -#endif // defined(USB_METHODS_INLINE) diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/Usb.h b/protocol/usb_hid/USB_Host_Shield_2.0/Usb.h deleted file mode 100644 index 47bd626c..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/Usb.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -/* USB functions */ -#ifndef _usb_h_ -#define _usb_h_ - -// WARNING: Do not change the order of includes, or stuff will break! -#include -#include -#include - -// None of these should ever be included by a driver, or a user's sketch. -#include "settings.h" -#include "printhex.h" -#include "message.h" -#include "hexdump.h" -#include "sink_parser.h" -#include "max3421e.h" -#include "address.h" -#include "avrpins.h" -#include "usb_ch9.h" -#include "usbhost.h" -#include "UsbCore.h" -#include "parsetools.h" -#include "confdescparser.h" - -#endif //_usb_h_ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/UsbCore.h b/protocol/usb_hid/USB_Host_Shield_2.0/UsbCore.h deleted file mode 100644 index 5c6c7710..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/UsbCore.h +++ /dev/null @@ -1,298 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#if !defined(_usb_h_) || defined(USBCORE_H) -#error "Never include UsbCore.h directly; include Usb.h instead" -#else -#define USBCORE_H - -// Not used anymore? If anyone uses this, please let us know so that this may be -// moved to the proper place, settings.h. -//#define USB_METHODS_INLINE - -/* shield pins. First parameter - SS pin, second parameter - INT pin */ -#ifdef BOARD_BLACK_WIDDOW -typedef MAX3421e MAX3421E; // Black Widow -#elif defined(CORE_TEENSY) && (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)) -#if EXT_RAM -typedef MAX3421e MAX3421E; // Teensy++ 2.0 with XMEM2 -#else -typedef MAX3421e MAX3421E; // Teensy++ 1.0 and 2.0 -#endif -#elif defined(BOARD_MEGA_ADK) -typedef MAX3421e MAX3421E; // Arduino Mega ADK -#elif defined(ARDUINO_AVR_BALANDUINO) -typedef MAX3421e MAX3421E; // Balanduino -#elif defined(__ARDUINO_X86__) && PLATFORM_ID == 0x06 -typedef MAX3421e MAX3421E; // The Intel Galileo supports much faster read and write speed at pin 2 and 3 -#else -typedef MAX3421e MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega, 2560, Leonardo, Due etc.), Intel Edison, Intel Galileo 2 or Teensy 2.0 and 3.0 -#endif - -/* Common setup data constant combinations */ -#define bmREQ_GET_DESCR USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_DEVICE //get descriptor request type -#define bmREQ_SET USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_DEVICE //set request type for all but 'set feature' and 'set interface' -#define bmREQ_CL_GET_INTF USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE //get interface request type - -// D7 data transfer direction (0 - host-to-device, 1 - device-to-host) -// D6-5 Type (0- standard, 1 - class, 2 - vendor, 3 - reserved) -// D4-0 Recipient (0 - device, 1 - interface, 2 - endpoint, 3 - other, 4..31 - reserved) - -// USB Device Classes -#define USB_CLASS_USE_CLASS_INFO 0x00 // Use Class Info in the Interface Descriptors -#define USB_CLASS_AUDIO 0x01 // Audio -#define USB_CLASS_COM_AND_CDC_CTRL 0x02 // Communications and CDC Control -#define USB_CLASS_HID 0x03 // HID -#define USB_CLASS_PHYSICAL 0x05 // Physical -#define USB_CLASS_IMAGE 0x06 // Image -#define USB_CLASS_PRINTER 0x07 // Printer -#define USB_CLASS_MASS_STORAGE 0x08 // Mass Storage -#define USB_CLASS_HUB 0x09 // Hub -#define USB_CLASS_CDC_DATA 0x0a // CDC-Data -#define USB_CLASS_SMART_CARD 0x0b // Smart-Card -#define USB_CLASS_CONTENT_SECURITY 0x0d // Content Security -#define USB_CLASS_VIDEO 0x0e // Video -#define USB_CLASS_PERSONAL_HEALTH 0x0f // Personal Healthcare -#define USB_CLASS_DIAGNOSTIC_DEVICE 0xdc // Diagnostic Device -#define USB_CLASS_WIRELESS_CTRL 0xe0 // Wireless Controller -#define USB_CLASS_MISC 0xef // Miscellaneous -#define USB_CLASS_APP_SPECIFIC 0xfe // Application Specific -#define USB_CLASS_VENDOR_SPECIFIC 0xff // Vendor Specific - -// Additional Error Codes -#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED 0xD1 -#define USB_DEV_CONFIG_ERROR_DEVICE_INIT_INCOMPLETE 0xD2 -#define USB_ERROR_UNABLE_TO_REGISTER_DEVICE_CLASS 0xD3 -#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL 0xD4 -#define USB_ERROR_HUB_ADDRESS_OVERFLOW 0xD5 -#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL 0xD6 -#define USB_ERROR_EPINFO_IS_NULL 0xD7 -#define USB_ERROR_INVALID_ARGUMENT 0xD8 -#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE 0xD9 -#define USB_ERROR_INVALID_MAX_PKT_SIZE 0xDA -#define USB_ERROR_EP_NOT_FOUND_IN_TBL 0xDB -#define USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET 0xE0 -#define USB_ERROR_FailGetDevDescr 0xE1 -#define USB_ERROR_FailSetDevTblEntry 0xE2 -#define USB_ERROR_FailGetConfDescr 0xE3 -#define USB_ERROR_TRANSFER_TIMEOUT 0xFF - -#define USB_XFER_TIMEOUT 5000 // (5000) USB transfer timeout in milliseconds, per section 9.2.6.1 of USB 2.0 spec -//#define USB_NAK_LIMIT 32000 // NAK limit for a transfer. 0 means NAKs are not counted -#define USB_RETRY_LIMIT 3 // 3 retry limit for a transfer -#define USB_SETTLE_DELAY 200 // settle delay in milliseconds - -#define USB_NUMDEVICES 16 //number of USB devices -//#define HUB_MAX_HUBS 7 // maximum number of hubs that can be attached to the host controller -#define HUB_PORT_RESET_DELAY 20 // hub port reset delay 10 ms recomended, can be up to 20 ms - -/* USB state machine states */ -#define USB_STATE_MASK 0xf0 - -#define USB_STATE_DETACHED 0x10 -#define USB_DETACHED_SUBSTATE_INITIALIZE 0x11 -#define USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE 0x12 -#define USB_DETACHED_SUBSTATE_ILLEGAL 0x13 -#define USB_ATTACHED_SUBSTATE_SETTLE 0x20 -#define USB_ATTACHED_SUBSTATE_RESET_DEVICE 0x30 -#define USB_ATTACHED_SUBSTATE_WAIT_RESET_COMPLETE 0x40 -#define USB_ATTACHED_SUBSTATE_WAIT_SOF 0x50 -#define USB_ATTACHED_SUBSTATE_WAIT_RESET 0x51 -#define USB_ATTACHED_SUBSTATE_GET_DEVICE_DESCRIPTOR_SIZE 0x60 -#define USB_STATE_ADDRESSING 0x70 -#define USB_STATE_CONFIGURING 0x80 -#define USB_STATE_RUNNING 0x90 -#define USB_STATE_ERROR 0xa0 - -class USBDeviceConfig { -public: - - virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed) { - return 0; - } - - virtual uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) { - return 0; - } - - virtual uint8_t Release() { - return 0; - } - - virtual uint8_t Poll() { - return 0; - } - - virtual uint8_t GetAddress() { - return 0; - } - - virtual void ResetHubPort(uint8_t port) { - return; - } // Note used for hubs only! - - virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { - return false; - } - - virtual bool DEVCLASSOK(uint8_t klass) { - return false; - } - - virtual bool DEVSUBCLASSOK(uint8_t subklass) { - return true; - } - -}; - -/* USB Setup Packet Structure */ -typedef struct { - - union { // offset description - uint8_t bmRequestType; // 0 Bit-map of request type - - struct { - uint8_t recipient : 5; // Recipient of the request - uint8_t type : 2; // Type of request - uint8_t direction : 1; // Direction of data X-fer - } __attribute__((packed)); - } ReqType_u; - uint8_t bRequest; // 1 Request - - union { - uint16_t wValue; // 2 Depends on bRequest - - struct { - uint8_t wValueLo; - uint8_t wValueHi; - } __attribute__((packed)); - } wVal_u; - uint16_t wIndex; // 4 Depends on bRequest - uint16_t wLength; // 6 Depends on bRequest -} __attribute__((packed)) SETUP_PKT, *PSETUP_PKT; - - - -// Base class for incoming data parser - -class USBReadParser { -public: - virtual void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset) = 0; -}; - -class USB : public MAX3421E { - AddressPoolImpl addrPool; - USBDeviceConfig* devConfig[USB_NUMDEVICES]; - uint8_t bmHubPre; - -public: - USB(void); - - void SetHubPreMask() { - bmHubPre |= bmHUBPRE; - }; - - void ResetHubPreMask() { - bmHubPre &= (~bmHUBPRE); - }; - - AddressPool& GetAddressPool() { - return (AddressPool&)addrPool; - }; - - uint8_t RegisterDeviceClass(USBDeviceConfig *pdev) { - for(uint8_t i = 0; i < USB_NUMDEVICES; i++) { - if(!devConfig[i]) { - devConfig[i] = pdev; - return 0; - } - } - return USB_ERROR_UNABLE_TO_REGISTER_DEVICE_CLASS; - }; - - void ForEachUsbDevice(UsbDeviceHandleFunc pfunc) { - addrPool.ForEachUsbDevice(pfunc); - }; - uint8_t getUsbTaskState(void); - void setUsbTaskState(uint8_t state); - - EpInfo* getEpInfoEntry(uint8_t addr, uint8_t ep); - uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo* eprecord_ptr); - - /* Control requests */ - uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr); - uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr); - - uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser *p); - - uint8_t getStrDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t index, uint16_t langid, uint8_t* dataptr); - uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr); - uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value); - /**/ - uint8_t ctrlData(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr, bool direction); - uint8_t ctrlStatus(uint8_t ep, bool direction, uint16_t nak_limit); - uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data); - uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data); - uint8_t dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit); - - void Task(void); - - uint8_t DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed); - uint8_t Configuring(uint8_t parent, uint8_t port, bool lowspeed); - uint8_t ReleaseDevice(uint8_t addr); - - uint8_t ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi, - uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t* dataptr, USBReadParser *p); - -private: - void init(); - uint8_t SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t *nak_limit); - uint8_t OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data); - uint8_t InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data); - uint8_t AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lowspeed); -}; - -#if 0 //defined(USB_METHODS_INLINE) -//get device descriptor - -inline uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr) { - return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, dataptr)); -} -//get configuration descriptor - -inline uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr) { - return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, dataptr)); -} -//get string descriptor - -inline uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t nuint8_ts, uint8_t index, uint16_t langid, uint8_t* dataptr) { - return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, nuint8_ts, dataptr)); -} -//set address - -inline uint8_t USB::setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr) { - return ( ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, NULL)); -} -//set configuration - -inline uint8_t USB::setConf(uint8_t addr, uint8_t ep, uint8_t conf_value) { - return ( ctrlReq(addr, ep, bmREQ_SET, USB_REQUEST_SET_CONFIGURATION, conf_value, 0x00, 0x0000, 0x0000, NULL)); -} - -#endif // defined(USB_METHODS_INLINE) - -#endif /* USBCORE_H */ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/Wii.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/Wii.cpp deleted file mode 100755 index 4bbf4c91..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/Wii.cpp +++ /dev/null @@ -1,1268 +0,0 @@ -/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - - IR camera support added by Allan Glover (adglover9.81@gmail.com) and Kristian Lauszus - */ - -#include "Wii.h" -// To enable serial debugging see "settings.h" -//#define EXTRADEBUG // Uncomment to get even more debugging data -//#define PRINTREPORT // Uncomment to print the report send by the Wii controllers - -const uint8_t WII_LEDS[] PROGMEM = { - 0x00, // OFF - 0x10, // LED1 - 0x20, // LED2 - 0x40, // LED3 - 0x80, // LED4 - - 0x90, // LED5 - 0xA0, // LED6 - 0xC0, // LED7 - 0xD0, // LED8 - 0xE0, // LED9 - 0xF0, // LED10 -}; - -const uint32_t WII_BUTTONS[] PROGMEM = { - 0x00008, // UP - 0x00002, // RIGHT - 0x00004, // DOWN - 0x00001, // LEFT - - 0, // Skip - 0x00010, // PLUS - 0x00100, // TWO - 0x00200, // ONE - - 0x01000, // MINUS - 0x08000, // HOME - 0x10000, // Z - 0x20000, // C - - 0x00400, // B - 0x00800, // A -}; -const uint32_t WII_PROCONTROLLER_BUTTONS[] PROGMEM = { - 0x00100, // UP - 0x00080, // RIGHT - 0x00040, // DOWN - 0x00200, // LEFT - - 0, // Skip - 0x00004, // PLUS - 0x20000, // L3 - 0x10000, // R3 - - 0x00010, // MINUS - 0x00008, // HOME - 0, 0, // Skip - - 0x04000, // B - 0x01000, // A - 0x00800, // X - 0x02000, // Y - - 0x00020, // L - 0x00002, // R - 0x08000, // ZL - 0x00400, // ZR -}; - -WII::WII(BTD *p, bool pair) : -BluetoothService(p) // Pointer to USB class instance - mandatory -{ - pBtd->pairWithWii = pair; - - HIDBuffer[0] = 0xA2; // HID BT DATA_request (0xA0) | Report Type (Output 0x02) - - /* Set device cid for the control and intterrupt channelse - LSB */ - control_dcid[0] = 0x60; // 0x0060 - control_dcid[1] = 0x00; - interrupt_dcid[0] = 0x61; // 0x0061 - interrupt_dcid[1] = 0x00; - - Reset(); -} - -void WII::Reset() { - wiimoteConnected = false; - nunchuckConnected = false; - motionPlusConnected = false; - activateNunchuck = false; - motionValuesReset = false; - activeConnection = false; - motionPlusInside = false; - pBtd->wiiUProController = false; - wiiUProControllerConnected = false; - wiiBalanceBoardConnected = false; - l2cap_event_flag = 0; // Reset flags - l2cap_state = L2CAP_WAIT; -} - -void WII::disconnect() { // Use this void to disconnect any of the controllers - if(!motionPlusInside) { // The old Wiimote needs a delay after the first command or it will automatically reconnect - if(motionPlusConnected) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nDeactivating Motion Plus"), 0x80); -#endif - initExtension1(); // This will disable the Motion Plus extension - } - timer = millis() + 1000; // We have to wait for the message before the rest of the channels can be deactivated - } else - timer = millis(); // Don't wait - // First the HID interrupt channel has to be disconnected, then the HID control channel and finally the HCI connection - pBtd->l2cap_disconnection_request(hci_handle, ++identifier, interrupt_scid, interrupt_dcid); - Reset(); - l2cap_state = L2CAP_INTERRUPT_DISCONNECT; -} - -void WII::ACLData(uint8_t* l2capinbuf) { - if(!pBtd->l2capConnectionClaimed && pBtd->incomingWii && !wiimoteConnected && !activeConnection) { - if(l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) { - if((l2capinbuf[12] | (l2capinbuf[13] << 8)) == HID_CTRL_PSM) { - motionPlusInside = pBtd->motionPlusInside; - pBtd->incomingWii = false; - pBtd->l2capConnectionClaimed = true; // Claim that the incoming connection belongs to this service - activeConnection = true; - hci_handle = pBtd->hci_handle; // Store the HCI Handle for the connection - l2cap_state = L2CAP_WAIT; - } - } - } - - if(checkHciHandle(l2capinbuf, hci_handle)) { // acl_handle_ok - if((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001U) { // l2cap_control - Channel ID for ACL-U - if(l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80); - D_PrintHex (l2capinbuf[13], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[12], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[17], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[16], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[15], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[14], 0x80); -#endif - } else if(l2capinbuf[8] == L2CAP_CMD_CONNECTION_RESPONSE) { - if(((l2capinbuf[16] | (l2capinbuf[17] << 8)) == 0x0000) && ((l2capinbuf[18] | (l2capinbuf[19] << 8)) == SUCCESSFUL)) { // Success - if(l2capinbuf[14] == control_dcid[0] && l2capinbuf[15] == control_dcid[1]) { - //Notify(PSTR("\r\nHID Control Connection Complete"), 0x80); - identifier = l2capinbuf[9]; - control_scid[0] = l2capinbuf[12]; - control_scid[1] = l2capinbuf[13]; - l2cap_set_flag(L2CAP_FLAG_CONTROL_CONNECTED); - } else if(l2capinbuf[14] == interrupt_dcid[0] && l2capinbuf[15] == interrupt_dcid[1]) { - //Notify(PSTR("\r\nHID Interrupt Connection Complete"), 0x80); - identifier = l2capinbuf[9]; - interrupt_scid[0] = l2capinbuf[12]; - interrupt_scid[1] = l2capinbuf[13]; - l2cap_set_flag(L2CAP_FLAG_INTERRUPT_CONNECTED); - } - } - } else if(l2capinbuf[8] == L2CAP_CMD_CONNECTION_REQUEST) { -#ifdef EXTRADEBUG - Notify(PSTR("\r\nL2CAP Connection Request - PSM: "), 0x80); - D_PrintHex (l2capinbuf[13], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[12], 0x80); - Notify(PSTR(" SCID: "), 0x80); - D_PrintHex (l2capinbuf[15], 0x80); - Notify(PSTR(" "), 0x80); - D_PrintHex (l2capinbuf[14], 0x80); - Notify(PSTR(" Identifier: "), 0x80); - D_PrintHex (l2capinbuf[9], 0x80); -#endif - if((l2capinbuf[12] | (l2capinbuf[13] << 8)) == HID_CTRL_PSM) { - identifier = l2capinbuf[9]; - control_scid[0] = l2capinbuf[14]; - control_scid[1] = l2capinbuf[15]; - l2cap_set_flag(L2CAP_FLAG_CONNECTION_CONTROL_REQUEST); - } else if((l2capinbuf[12] | (l2capinbuf[13] << 8)) == HID_INTR_PSM) { - identifier = l2capinbuf[9]; - interrupt_scid[0] = l2capinbuf[14]; - interrupt_scid[1] = l2capinbuf[15]; - l2cap_set_flag(L2CAP_FLAG_CONNECTION_INTERRUPT_REQUEST); - } - } else if(l2capinbuf[8] == L2CAP_CMD_CONFIG_RESPONSE) { - if((l2capinbuf[16] | (l2capinbuf[17] << 8)) == 0x0000) { // Success - if(l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) { - //Notify(PSTR("\r\nHID Control Configuration Complete"), 0x80); - identifier = l2capinbuf[9]; - l2cap_set_flag(L2CAP_FLAG_CONFIG_CONTROL_SUCCESS); - } else if(l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) { - //Notify(PSTR("\r\nHID Interrupt Configuration Complete"), 0x80); - identifier = l2capinbuf[9]; - l2cap_set_flag(L2CAP_FLAG_CONFIG_INTERRUPT_SUCCESS); - } - } - } else if(l2capinbuf[8] == L2CAP_CMD_CONFIG_REQUEST) { - if(l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) { - //Notify(PSTR("\r\nHID Control Configuration Request"), 0x80); - pBtd->l2cap_config_response(hci_handle, l2capinbuf[9], control_scid); - } else if(l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) { - //Notify(PSTR("\r\nHID Interrupt Configuration Request"), 0x80); - pBtd->l2cap_config_response(hci_handle, l2capinbuf[9], interrupt_scid); - } - } else if(l2capinbuf[8] == L2CAP_CMD_DISCONNECT_REQUEST) { - if(l2capinbuf[12] == control_dcid[0] && l2capinbuf[13] == control_dcid[1]) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nDisconnect Request: Control Channel"), 0x80); -#endif - identifier = l2capinbuf[9]; - pBtd->l2cap_disconnection_response(hci_handle, identifier, control_dcid, control_scid); - Reset(); - } else if(l2capinbuf[12] == interrupt_dcid[0] && l2capinbuf[13] == interrupt_dcid[1]) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nDisconnect Request: Interrupt Channel"), 0x80); -#endif - identifier = l2capinbuf[9]; - pBtd->l2cap_disconnection_response(hci_handle, identifier, interrupt_dcid, interrupt_scid); - Reset(); - } - } else if(l2capinbuf[8] == L2CAP_CMD_DISCONNECT_RESPONSE) { - if(l2capinbuf[12] == control_scid[0] && l2capinbuf[13] == control_scid[1]) { - //Notify(PSTR("\r\nDisconnect Response: Control Channel"), 0x80); - identifier = l2capinbuf[9]; - l2cap_set_flag(L2CAP_FLAG_DISCONNECT_CONTROL_RESPONSE); - } else if(l2capinbuf[12] == interrupt_scid[0] && l2capinbuf[13] == interrupt_scid[1]) { - //Notify(PSTR("\r\nDisconnect Response: Interrupt Channel"), 0x80); - identifier = l2capinbuf[9]; - l2cap_set_flag(L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE); - } - } -#ifdef EXTRADEBUG - else { - identifier = l2capinbuf[9]; - Notify(PSTR("\r\nL2CAP Unknown Signaling Command: "), 0x80); - D_PrintHex (l2capinbuf[8], 0x80); - } -#endif - } else if(l2capinbuf[6] == interrupt_dcid[0] && l2capinbuf[7] == interrupt_dcid[1]) { // l2cap_interrupt - //Notify(PSTR("\r\nL2CAP Interrupt"), 0x80); - if(l2capinbuf[8] == 0xA1) { // HID_THDR_DATA_INPUT - if((l2capinbuf[9] >= 0x20 && l2capinbuf[9] <= 0x22) || (l2capinbuf[9] >= 0x30 && l2capinbuf[9] <= 0x37) || l2capinbuf[9] == 0x3e || l2capinbuf[9] == 0x3f) { // These reports include the buttons - if((l2capinbuf[9] >= 0x20 && l2capinbuf[9] <= 0x22) || l2capinbuf[9] == 0x31 || l2capinbuf[9] == 0x33) // These reports have no extensions bytes - ButtonState = (uint32_t)((l2capinbuf[10] & 0x1F) | ((uint16_t)(l2capinbuf[11] & 0x9F) << 8)); - else if(wiiUProControllerConnected) - ButtonState = (uint32_t)(((~l2capinbuf[23]) & 0xFE) | ((uint16_t)(~l2capinbuf[24]) << 8) | ((uint32_t)((~l2capinbuf[25]) & 0x03) << 16)); - else if(motionPlusConnected) { - if(l2capinbuf[20] & 0x02) // Only update the Wiimote buttons, since the extension bytes are from the Motion Plus - ButtonState = (uint32_t)((l2capinbuf[10] & 0x1F) | ((uint16_t)(l2capinbuf[11] & 0x9F) << 8) | ((uint32_t)(ButtonState & 0xFFFF0000))); - else if(nunchuckConnected) // Update if it's a report from the Nunchuck - ButtonState = (uint32_t)((l2capinbuf[10] & 0x1F) | ((uint16_t)(l2capinbuf[11] & 0x9F) << 8) | ((uint32_t)((~l2capinbuf[20]) & 0x0C) << 14)); - //else if(classicControllerConnected) // Update if it's a report from the Classic Controller - } else if(nunchuckConnected) // The Nunchuck is directly connected - ButtonState = (uint32_t)((l2capinbuf[10] & 0x1F) | ((uint16_t)(l2capinbuf[11] & 0x9F) << 8) | ((uint32_t)((~l2capinbuf[20]) & 0x03) << 16)); - //else if(classicControllerConnected) // The Classic Controller is directly connected - else if(!unknownExtensionConnected) - ButtonState = (uint32_t)((l2capinbuf[10] & 0x1F) | ((uint16_t)(l2capinbuf[11] & 0x9F) << 8)); -#ifdef PRINTREPORT - Notify(PSTR("ButtonState: "), 0x80); - D_PrintHex (ButtonState, 0x80); - Notify(PSTR("\r\n"), 0x80); -#endif - if(ButtonState != OldButtonState) { - ButtonClickState = ButtonState & ~OldButtonState; // Update click state variable - OldButtonState = ButtonState; - } - } - if(l2capinbuf[9] == 0x31 || l2capinbuf[9] == 0x33 || l2capinbuf[9] == 0x35 || l2capinbuf[9] == 0x37) { // Read the accelerometer - accXwiimote = ((l2capinbuf[12] << 2) | (l2capinbuf[10] & 0x60 >> 5)) - 500; - accYwiimote = ((l2capinbuf[13] << 2) | (l2capinbuf[11] & 0x20 >> 4)) - 500; - accZwiimote = ((l2capinbuf[14] << 2) | (l2capinbuf[11] & 0x40 >> 5)) - 500; - } - switch(l2capinbuf[9]) { - case 0x20: // Status Information - (a1) 20 BB BB LF 00 00 VV -#ifdef EXTRADEBUG - Notify(PSTR("\r\nStatus report was received"), 0x80); -#endif - wiiState = l2capinbuf[12]; // (0x01: Battery is nearly empty), (0x02: An Extension Controller is connected), (0x04: Speaker enabled), (0x08: IR enabled), (0x10: LED1, 0x20: LED2, 0x40: LED3, 0x80: LED4) - batteryLevel = l2capinbuf[15]; // Update battery level - - if(!checkBatteryLevel) { // If this is true it means that the user must have called getBatteryLevel() - if(l2capinbuf[12] & 0x02) { // Check if a extension is connected -#ifdef DEBUG_USB_HOST - if(!unknownExtensionConnected) - Notify(PSTR("\r\nExtension connected"), 0x80); -#endif - unknownExtensionConnected = true; -#ifdef WIICAMERA - if(!isIRCameraEnabled()) // Don't activate the Motion Plus if we are trying to initialize the IR camera -#endif - setReportMode(false, 0x35); // Also read the extension - } else { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nExtension disconnected"), 0x80); -#endif - if(motionPlusConnected) { -#ifdef DEBUG_USB_HOST - Notify(PSTR(" - from Motion Plus"), 0x80); -#endif - wii_clear_flag(WII_FLAG_NUNCHUCK_CONNECTED); - if(!activateNunchuck) // If it's already trying to initialize the Nunchuck don't set it to false - nunchuckConnected = false; - //else if(classicControllerConnected) - } else if(nunchuckConnected) { -#ifdef DEBUG_USB_HOST - Notify(PSTR(" - Nunchuck"), 0x80); -#endif - nunchuckConnected = false; // It must be the Nunchuck controller then - wii_clear_flag(WII_FLAG_NUNCHUCK_CONNECTED); - onInit(); - setReportMode(false, 0x31); // If there is no extension connected we will read the buttons and accelerometer - } else - setReportMode(false, 0x31); // If there is no extension connected we will read the buttons and accelerometer - } - } - else { -#ifdef EXTRADEBUG - Notify(PSTR("\r\nChecking battery level"), 0x80); -#endif - checkBatteryLevel = false; // Check for extensions by default - } -#ifdef DEBUG_USB_HOST - if(l2capinbuf[12] & 0x01) - Notify(PSTR("\r\nWARNING: Battery is nearly empty"), 0x80); -#endif - - break; - case 0x21: // Read Memory Data - if((l2capinbuf[12] & 0x0F) == 0) { // No error - uint8_t reportLength = (l2capinbuf[12] >> 4) + 1; // // Bit 4-7 is the length - 1 - // See: http://wiibrew.org/wiki/Wiimote/Extension_Controllers - if(l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x00 && l2capinbuf[20] == 0x00) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nNunchuck connected"), 0x80); -#endif - wii_set_flag(WII_FLAG_NUNCHUCK_CONNECTED); - } else if(l2capinbuf[16] == 0x00 && (l2capinbuf[17] == 0xA6 || l2capinbuf[17] == 0xA4) && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x00 && l2capinbuf[20] == 0x05) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nMotion Plus connected"), 0x80); -#endif - wii_set_flag(WII_FLAG_MOTION_PLUS_CONNECTED); - } else if(l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x04 && l2capinbuf[20] == 0x05) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nMotion Plus activated in normal mode"), 0x80); -#endif - motionPlusConnected = true; -#ifdef WIICAMERA - if(!isIRCameraEnabled()) // Don't activate the Motion Plus if we are trying to initialize the IR camera -#endif - setReportMode(false, 0x35); // Also read the extension - } else if(l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x05 && l2capinbuf[20] == 0x05) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nMotion Plus activated in Nunchuck pass-through mode"), 0x80); -#endif - activateNunchuck = false; - motionPlusConnected = true; - nunchuckConnected = true; -#ifdef WIICAMERA - if(!isIRCameraEnabled()) // Don't activate the Motion Plus if we are trying to initialize the IR camera -#endif - setReportMode(false, 0x35); // Also read the extension - } else if(l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA6 && l2capinbuf[18] == 0x20 && (l2capinbuf[19] == 0x00 || l2capinbuf[19] == 0x04 || l2capinbuf[19] == 0x05 || l2capinbuf[19] == 0x07) && l2capinbuf[20] == 0x05) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nInactive Wii Motion Plus"), 0x80); - Notify(PSTR("\r\nPlease unplug the Motion Plus, disconnect the Wiimote and then replug the Motion Plus Extension"), 0x80); -#endif - stateCounter = 300; // Skip the rest in "WII_CHECK_MOTION_PLUS_STATE" - } else if(l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x01 && l2capinbuf[20] == 0x20) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nWii U Pro Controller connected"), 0x80); -#endif - wiiUProControllerConnected = true; - } else if(l2capinbuf[16] == 0x00 && l2capinbuf[17] == 0xA4 && l2capinbuf[18] == 0x20 && l2capinbuf[19] == 0x04 && l2capinbuf[20] == 0x02) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nWii Balance Board connected"), 0x80); -#endif - setReportMode(false, 0x32); // Read the Wii Balance Board extension - wii_set_flag(WII_FLAG_CALIBRATE_BALANCE_BOARD); - } - // Wii Balance Board calibration reports (24 bits in total) - else if(l2capinbuf[13] == 0x00 && l2capinbuf[14] == 0x24 && reportLength == 16) { // First 16-bit - for(uint8_t i = 0; i < 2; i++) { - for(uint8_t j = 0; j < 4; j++) - wiiBalanceBoardCal[i][j] = l2capinbuf[16 + 8 * i + 2 * j] | l2capinbuf[15 + 8 * i + 2 * j] << 8; - } - } else if(l2capinbuf[13] == 0x00 && l2capinbuf[14] == 0x34 && reportLength == 8) { // Last 8-bit - for(uint8_t j = 0; j < 4; j++) - wiiBalanceBoardCal[2][j] = l2capinbuf[16 + 2 * j] | l2capinbuf[15 + 2 * j] << 8; -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nWii Balance Board calibration values read successfully"), 0x80); -#endif - wii_clear_flag(WII_FLAG_CALIBRATE_BALANCE_BOARD); - wiiBalanceBoardConnected = true; - } -#ifdef DEBUG_USB_HOST - else { - Notify(PSTR("\r\nUnknown Device: "), 0x80); - D_PrintHex (l2capinbuf[13], 0x80); - D_PrintHex (l2capinbuf[14], 0x80); - Notify(PSTR("\r\nData: "), 0x80); - for(uint8_t i = 0; i < reportLength; i++) { - D_PrintHex (l2capinbuf[15 + i], 0x80); - Notify(PSTR(" "), 0x80); - } - } -#endif - } -#ifdef EXTRADEBUG - else { - Notify(PSTR("\r\nReport Error: "), 0x80); - D_PrintHex (l2capinbuf[13], 0x80); - D_PrintHex (l2capinbuf[14], 0x80); - } -#endif - break; - case 0x22: // Acknowledge output report, return function result -#ifdef DEBUG_USB_HOST - if(l2capinbuf[13] != 0x00) { // Check if there is an error - Notify(PSTR("\r\nCommand failed: "), 0x80); - D_PrintHex (l2capinbuf[12], 0x80); - } -#endif - break; - case 0x30: // Core buttons - (a1) 30 BB BB - break; - case 0x31: // Core Buttons and Accelerometer - (a1) 31 BB BB AA AA AA - break; - case 0x32: // Core Buttons with 8 Extension bytes - (a1) 32 BB BB EE EE EE EE EE EE EE EE - // See: http://wiibrew.org/wiki/Wii_Balance_Board#Data_Format - wiiBalanceBoardRaw[TopRight] = l2capinbuf[13] | l2capinbuf[12] << 8; // Top right - wiiBalanceBoardRaw[BotRight] = l2capinbuf[15] | l2capinbuf[14] << 8; // Bottom right - wiiBalanceBoardRaw[TopLeft] = l2capinbuf[17] | l2capinbuf[16] << 8; // Top left - wiiBalanceBoardRaw[BotLeft] = l2capinbuf[19] | l2capinbuf[18] << 8; // Bottom left - break; - case 0x33: // Core Buttons with Accelerometer and 12 IR bytes - (a1) 33 BB BB AA AA AA II II II II II II II II II II II II -#ifdef WIICAMERA - // Read the IR data - IR_object_x1 = (l2capinbuf[15] | ((uint16_t)(l2capinbuf[17] & 0x30) << 4)); // x position - IR_object_y1 = (l2capinbuf[16] | ((uint16_t)(l2capinbuf[17] & 0xC0) << 2)); // y position - IR_object_s1 = (l2capinbuf[17] & 0x0F); // Size value, 0-15 - - IR_object_x2 = (l2capinbuf[18] | ((uint16_t)(l2capinbuf[20] & 0x30) << 4)); - IR_object_y2 = (l2capinbuf[19] | ((uint16_t)(l2capinbuf[20] & 0xC0) << 2)); - IR_object_s2 = (l2capinbuf[20] & 0x0F); - - IR_object_x3 = (l2capinbuf[21] | ((uint16_t)(l2capinbuf[23] & 0x30) << 4)); - IR_object_y3 = (l2capinbuf[22] | ((uint16_t)(l2capinbuf[23] & 0xC0) << 2)); - IR_object_s3 = (l2capinbuf[23] & 0x0F); - - IR_object_x4 = (l2capinbuf[24] | ((uint16_t)(l2capinbuf[26] & 0x30) << 4)); - IR_object_y4 = (l2capinbuf[25] | ((uint16_t)(l2capinbuf[26] & 0xC0) << 2)); - IR_object_s4 = (l2capinbuf[26] & 0x0F); -#endif - break; - case 0x34: // Core Buttons with 19 Extension bytes - (a1) 34 BB BB EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE - break; - /* 0x3e and 0x3f both give unknown report types when report mode is 0x3e or 0x3f with mode number 0x05 */ - case 0x3E: // Core Buttons with Accelerometer and 32 IR bytes - // (a1) 31 BB BB AA AA AA II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II II - // corresponds to output report mode 0x3e - - /**** for reading in full mode: DOES NOT WORK YET ****/ - /* When it works it will also have intensity and bounding box data */ - /* - IR_object_x1 = (l2capinbuf[13] | ((uint16_t)(l2capinbuf[15] & 0x30) << 4)); - IR_object_y1 = (l2capinbuf[14] | ((uint16_t)(l2capinbuf[15] & 0xC0) << 2)); - IR_object_s1 = (l2capinbuf[15] & 0x0F); - */ - break; - case 0x3F: - /* - IR_object_x1 = (l2capinbuf[13] | ((uint16_t)(l2capinbuf[15] & 0x30) << 4)); - IR_object_y1 = (l2capinbuf[14] | ((uint16_t)(l2capinbuf[15] & 0xC0) << 2)); - IR_object_s1 = (l2capinbuf[15] & 0x0F); - */ - break; - case 0x35: // Core Buttons and Accelerometer with 16 Extension Bytes - // (a1) 35 BB BB AA AA AA EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE -#if 1 // Set this to 0 if you don't want to use an extension, this reduceds the size of the library a lot! - if(motionPlusConnected) { - if(l2capinbuf[20] & 0x02) { // Check if it's a report from the Motion controller or the extension - if(motionValuesReset) { // We will only use the values when the gyro value has been set - gyroYawRaw = ((l2capinbuf[15] | ((l2capinbuf[18] & 0xFC) << 6)) - gyroYawZero); - gyroRollRaw = ((l2capinbuf[16] | ((l2capinbuf[19] & 0xFC) << 6)) - gyroRollZero); - gyroPitchRaw = ((l2capinbuf[17] | ((l2capinbuf[20] & 0xFC) << 6)) - gyroPitchZero); - - yawGyroSpeed = (double)gyroYawRaw / ((double)gyroYawZero / yawGyroScale); - rollGyroSpeed = -(double)gyroRollRaw / ((double)gyroRollZero / rollGyroScale); // We invert these values so they will fit the acc values - pitchGyroSpeed = (double)gyroPitchRaw / ((double)gyroPitchZero / pitchGyroScale); - - /* The onboard gyro has two ranges for slow and fast mode */ - if(!(l2capinbuf[18] & 0x02)) // Check if fast mode is used - yawGyroSpeed *= 4.545; - if(!(l2capinbuf[18] & 0x01)) // Check if fast mode is used - pitchGyroSpeed *= 4.545; - if(!(l2capinbuf[19] & 0x02)) // Check if fast mode is used - rollGyroSpeed *= 4.545; - - compPitch = (0.93 * (compPitch + (pitchGyroSpeed * (double)(micros() - timer) / 1000000)))+(0.07 * getWiimotePitch()); // Use a complimentary filter to calculate the angle - compRoll = (0.93 * (compRoll + (rollGyroSpeed * (double)(micros() - timer) / 1000000)))+(0.07 * getWiimoteRoll()); - - gyroYaw += (yawGyroSpeed * ((double)(micros() - timer) / 1000000)); - gyroRoll += (rollGyroSpeed * ((double)(micros() - timer) / 1000000)); - gyroPitch += (pitchGyroSpeed * ((double)(micros() - timer) / 1000000)); - timer = micros(); - /* - // Uncomment these lines to tune the gyro scale variabels - Notify(PSTR("\r\ngyroYaw: "), 0x80); - Notify(gyroYaw, 0x80); - Notify(PSTR("\tgyroRoll: "), 0x80); - Notify(gyroRoll, 0x80); - Notify(PSTR("\tgyroPitch: "), 0x80); - Notify(gyroPitch, 0x80); - */ - /* - Notify(PSTR("\twiimoteRoll: "), 0x80); - Notify(wiimoteRoll, 0x80); - Notify(PSTR("\twiimotePitch: "), 0x80); - Notify(wiimotePitch, 0x80); - */ - } else { - if((micros() - timer) > 1000000) { // Loop for 1 sec before resetting the values -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nThe gyro values has been reset"), 0x80); -#endif - gyroYawZero = (l2capinbuf[15] | ((l2capinbuf[18] & 0xFC) << 6)); - gyroRollZero = (l2capinbuf[16] | ((l2capinbuf[19] & 0xFC) << 6)); - gyroPitchZero = (l2capinbuf[17] | ((l2capinbuf[20] & 0xFC) << 6)); - - rollGyroScale = 500; // You might need to adjust these - pitchGyroScale = 400; - yawGyroScale = 415; - - gyroYaw = 0; - gyroRoll = 0; - gyroPitch = 0; - - motionValuesReset = true; - timer = micros(); - } - } - } else { - if(nunchuckConnected) { - hatValues[HatX] = l2capinbuf[15]; - hatValues[HatY] = l2capinbuf[16]; - accXnunchuck = ((l2capinbuf[17] << 2) | (l2capinbuf[20] & 0x10 >> 3)) - 416; - accYnunchuck = ((l2capinbuf[18] << 2) | (l2capinbuf[20] & 0x20 >> 4)) - 416; - accZnunchuck = (((l2capinbuf[19] & 0xFE) << 2) | (l2capinbuf[20] & 0xC0 >> 5)) - 416; - } - //else if(classicControllerConnected) { } - } - if(l2capinbuf[19] & 0x01) { - if(!extensionConnected) { - extensionConnected = true; - unknownExtensionConnected = true; -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nExtension connected to Motion Plus"), 0x80); -#endif - } - } else { - if(extensionConnected && !unknownExtensionConnected) { - extensionConnected = false; - unknownExtensionConnected = true; -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nExtension disconnected from Motion Plus"), 0x80); -#endif - nunchuckConnected = false; // There is no extension connected to the Motion Plus if this report is sent - } - } - - } else if(nunchuckConnected) { - hatValues[HatX] = l2capinbuf[15]; - hatValues[HatY] = l2capinbuf[16]; - accXnunchuck = ((l2capinbuf[17] << 2) | (l2capinbuf[20] & 0x0C >> 2)) - 416; - accYnunchuck = ((l2capinbuf[18] << 2) | (l2capinbuf[20] & 0x30 >> 4)) - 416; - accZnunchuck = ((l2capinbuf[19] << 2) | (l2capinbuf[20] & 0xC0 >> 6)) - 416; - } else if(wiiUProControllerConnected) { - hatValues[LeftHatX] = (l2capinbuf[15] | l2capinbuf[16] << 8); - hatValues[RightHatX] = (l2capinbuf[17] | l2capinbuf[18] << 8); - hatValues[LeftHatY] = (l2capinbuf[19] | l2capinbuf[20] << 8); - hatValues[RightHatY] = (l2capinbuf[21] | l2capinbuf[22] << 8); - } -#endif - break; -#ifdef DEBUG_USB_HOST - default: - Notify(PSTR("\r\nUnknown Report type: "), 0x80); - D_PrintHex (l2capinbuf[9], 0x80); - break; -#endif - } - } - } - L2CAP_task(); - } -} - -void WII::L2CAP_task() { - switch(l2cap_state) { - /* These states are used if the Wiimote is the host */ - case L2CAP_CONTROL_SUCCESS: - if(l2cap_check_flag(L2CAP_FLAG_CONFIG_CONTROL_SUCCESS)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nHID Control Successfully Configured"), 0x80); -#endif - l2cap_state = L2CAP_INTERRUPT_SETUP; - } - break; - - case L2CAP_INTERRUPT_SETUP: - if(l2cap_check_flag(L2CAP_FLAG_CONNECTION_INTERRUPT_REQUEST)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nHID Interrupt Incoming Connection Request"), 0x80); -#endif - pBtd->l2cap_connection_response(hci_handle, identifier, interrupt_dcid, interrupt_scid, PENDING); - delay(1); - pBtd->l2cap_connection_response(hci_handle, identifier, interrupt_dcid, interrupt_scid, SUCCESSFUL); - identifier++; - delay(1); - pBtd->l2cap_config_request(hci_handle, identifier, interrupt_scid); - - l2cap_state = L2CAP_INTERRUPT_CONFIG_REQUEST; - } - break; - - /* These states are used if the Arduino is the host */ - case L2CAP_CONTROL_CONNECT_REQUEST: - if(l2cap_check_flag(L2CAP_FLAG_CONTROL_CONNECTED)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSend HID Control Config Request"), 0x80); -#endif - identifier++; - pBtd->l2cap_config_request(hci_handle, identifier, control_scid); - l2cap_state = L2CAP_CONTROL_CONFIG_REQUEST; - } - break; - - case L2CAP_CONTROL_CONFIG_REQUEST: - if(l2cap_check_flag(L2CAP_FLAG_CONFIG_CONTROL_SUCCESS)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSend HID Interrupt Connection Request"), 0x80); -#endif - identifier++; - pBtd->l2cap_connection_request(hci_handle, identifier, interrupt_dcid, HID_INTR_PSM); - l2cap_state = L2CAP_INTERRUPT_CONNECT_REQUEST; - } - break; - - case L2CAP_INTERRUPT_CONNECT_REQUEST: - if(l2cap_check_flag(L2CAP_FLAG_INTERRUPT_CONNECTED)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSend HID Interrupt Config Request"), 0x80); -#endif - identifier++; - pBtd->l2cap_config_request(hci_handle, identifier, interrupt_scid); - l2cap_state = L2CAP_INTERRUPT_CONFIG_REQUEST; - } - break; - - case L2CAP_INTERRUPT_CONFIG_REQUEST: - if(l2cap_check_flag(L2CAP_FLAG_CONFIG_INTERRUPT_SUCCESS)) { // Now the HID channels is established -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nHID Channels Established"), 0x80); -#endif - pBtd->connectToWii = false; - pBtd->pairWithWii = false; - stateCounter = 0; - l2cap_state = WII_CHECK_MOTION_PLUS_STATE; - } - break; - - /* The next states are in run() */ - - case L2CAP_INTERRUPT_DISCONNECT: - if(l2cap_check_flag(L2CAP_FLAG_DISCONNECT_INTERRUPT_RESPONSE) && ((long)(millis() - timer) >= 0L)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nDisconnected Interrupt Channel"), 0x80); -#endif - identifier++; - pBtd->l2cap_disconnection_request(hci_handle, identifier, control_scid, control_dcid); - l2cap_state = L2CAP_CONTROL_DISCONNECT; - } - break; - - case L2CAP_CONTROL_DISCONNECT: - if(l2cap_check_flag(L2CAP_FLAG_DISCONNECT_CONTROL_RESPONSE)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nDisconnected Control Channel"), 0x80); -#endif - pBtd->hci_disconnect(hci_handle); - hci_handle = -1; // Reset handle - l2cap_event_flag = 0; // Reset flags - l2cap_state = L2CAP_WAIT; - } - break; - } -} - -void WII::Run() { - if(l2cap_state == L2CAP_INTERRUPT_DISCONNECT && ((long)(millis() - timer) >= 0L)) - L2CAP_task(); // Call the rest of the disconnection routine after we have waited long enough - - switch(l2cap_state) { - case L2CAP_WAIT: - if(pBtd->connectToWii && !pBtd->l2capConnectionClaimed && !wiimoteConnected && !activeConnection) { - pBtd->l2capConnectionClaimed = true; - activeConnection = true; - motionPlusInside = pBtd->motionPlusInside; -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSend HID Control Connection Request"), 0x80); -#endif - hci_handle = pBtd->hci_handle; // Store the HCI Handle for the connection - l2cap_event_flag = 0; // Reset flags - identifier = 0; - pBtd->l2cap_connection_request(hci_handle, identifier, control_dcid, HID_CTRL_PSM); - l2cap_state = L2CAP_CONTROL_CONNECT_REQUEST; - } else if(l2cap_check_flag(L2CAP_FLAG_CONNECTION_CONTROL_REQUEST)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nHID Control Incoming Connection Request"), 0x80); -#endif - pBtd->l2cap_connection_response(hci_handle, identifier, control_dcid, control_scid, PENDING); - delay(1); - pBtd->l2cap_connection_response(hci_handle, identifier, control_dcid, control_scid, SUCCESSFUL); - identifier++; - delay(1); - pBtd->l2cap_config_request(hci_handle, identifier, control_scid); - l2cap_state = L2CAP_CONTROL_SUCCESS; - } - break; - - case WII_CHECK_MOTION_PLUS_STATE: -#ifdef DEBUG_USB_HOST - if(stateCounter == 0) // Only print onnce - Notify(PSTR("\r\nChecking if a Motion Plus is connected"), 0x80); -#endif - stateCounter++; - if(stateCounter % 200 == 0) - checkMotionPresent(); // Check if there is a motion plus connected - if(wii_check_flag(WII_FLAG_MOTION_PLUS_CONNECTED)) { - stateCounter = 0; - l2cap_state = WII_INIT_MOTION_PLUS_STATE; - timer = micros(); - - if(unknownExtensionConnected) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nA extension is also connected"), 0x80); -#endif - activateNunchuck = true; // For we will just set this to true as this the only extension supported so far - } - - } else if(stateCounter == 601) { // We will try three times to check for the motion plus -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nNo Motion Plus was detected"), 0x80); -#endif - stateCounter = 0; - l2cap_state = WII_CHECK_EXTENSION_STATE; - } - break; - - case WII_CHECK_EXTENSION_STATE: // This is used to check if there is anything plugged in to the extension port -#ifdef DEBUG_USB_HOST - if(stateCounter == 0) // Only print onnce - Notify(PSTR("\r\nChecking if there is any extension connected"), 0x80); -#endif - stateCounter++; // We use this counter as there has to be a short delay between the commands - if(stateCounter == 1) - statusRequest(); // See if a new device has connected - if(stateCounter == 100) { - if(unknownExtensionConnected) // Check if there is a extension is connected to the port - initExtension1(); - else - stateCounter = 499; - } else if(stateCounter == 200) - initExtension2(); - else if(stateCounter == 300) { - readExtensionType(); - unknownExtensionConnected = false; - } else if(stateCounter == 400) { - if(wii_check_flag(WII_FLAG_CALIBRATE_BALANCE_BOARD)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nReading Wii Balance Board calibration values"), 0x80); -#endif - readWiiBalanceBoardCalibration(); - } else - stateCounter = 499; - } else if(stateCounter == 500) { - stateCounter = 0; - l2cap_state = TURN_ON_LED; - } - break; - - case WII_INIT_MOTION_PLUS_STATE: - stateCounter++; - if(stateCounter == 1) - initMotionPlus(); - else if(stateCounter == 100) - activateMotionPlus(); - else if(stateCounter == 200) - readExtensionType(); // Check if it has been activated - else if(stateCounter == 300) { - stateCounter = 0; - unknownExtensionConnected = false; // The motion plus will send a status report when it's activated, we will set this to false so it doesn't reinitialize the Motion Plus - l2cap_state = TURN_ON_LED; - } - break; - - case TURN_ON_LED: - if(wii_check_flag(WII_FLAG_NUNCHUCK_CONNECTED)) - nunchuckConnected = true; - wiimoteConnected = true; - onInit(); - l2cap_state = L2CAP_DONE; - break; - - case L2CAP_DONE: - if(unknownExtensionConnected) { -#ifdef DEBUG_USB_HOST - if(stateCounter == 0) // Only print once - Notify(PSTR("\r\nChecking extension port"), 0x80); -#endif - stateCounter++; // We will use this counter as there has to be a short delay between the commands - if(stateCounter == 50) - statusRequest(); - else if(stateCounter == 100) - initExtension1(); - else if(stateCounter == 150) - if((extensionConnected && motionPlusConnected) || (unknownExtensionConnected && !motionPlusConnected)) - initExtension2(); - else - stateCounter = 299; // There is no extension connected - else if(stateCounter == 200) - readExtensionType(); - else if(stateCounter == 250) { - if(wii_check_flag(WII_FLAG_NUNCHUCK_CONNECTED)) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nNunchuck was reconnected"), 0x80); -#endif - activateNunchuck = true; - nunchuckConnected = true; - } - if(!motionPlusConnected) - stateCounter = 449; - } else if(stateCounter == 300) { - if(motionPlusConnected) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nReactivating the Motion Plus"), 0x80); -#endif - initMotionPlus(); - } else - stateCounter = 449; - } else if(stateCounter == 350) - activateMotionPlus(); - else if(stateCounter == 400) - readExtensionType(); // Check if it has been activated - else if(stateCounter == 450) { - onInit(); - stateCounter = 0; - unknownExtensionConnected = false; - } - } else - stateCounter = 0; - break; - } -} - -/************************************************************/ -/* HID Commands */ -/************************************************************/ - -void WII::HID_Command(uint8_t* data, uint8_t nbytes) { - if(motionPlusInside) - pBtd->L2CAP_Command(hci_handle, data, nbytes, interrupt_scid[0], interrupt_scid[1]); // It's the new Wiimote with the Motion Plus Inside or Wii U Pro controller - else - pBtd->L2CAP_Command(hci_handle, data, nbytes, control_scid[0], control_scid[1]); -} - -void WII::setAllOff() { - HIDBuffer[1] = 0x11; - HIDBuffer[2] = 0x00; - HID_Command(HIDBuffer, 3); -} - -void WII::setRumbleOff() { - HIDBuffer[1] = 0x11; - HIDBuffer[2] &= ~0x01; // Bit 0 control the rumble - HID_Command(HIDBuffer, 3); -} - -void WII::setRumbleOn() { - HIDBuffer[1] = 0x11; - HIDBuffer[2] |= 0x01; // Bit 0 control the rumble - HID_Command(HIDBuffer, 3); -} - -void WII::setRumbleToggle() { - HIDBuffer[1] = 0x11; - HIDBuffer[2] ^= 0x01; // Bit 0 control the rumble - HID_Command(HIDBuffer, 3); -} - -void WII::setLedRaw(uint8_t value) { - HIDBuffer[1] = 0x11; - HIDBuffer[2] = value | (HIDBuffer[2] & 0x01); // Keep the rumble bit - HID_Command(HIDBuffer, 3); -} - -void WII::setLedOff(LEDEnum a) { - HIDBuffer[1] = 0x11; - HIDBuffer[2] &= ~(pgm_read_byte(&WII_LEDS[(uint8_t)a])); - HID_Command(HIDBuffer, 3); -} - -void WII::setLedOn(LEDEnum a) { - if(a == OFF) - setLedRaw(0); - else { - HIDBuffer[1] = 0x11; - HIDBuffer[2] |= pgm_read_byte(&WII_LEDS[(uint8_t)a]); - HID_Command(HIDBuffer, 3); - } -} - -void WII::setLedToggle(LEDEnum a) { - HIDBuffer[1] = 0x11; - HIDBuffer[2] ^= pgm_read_byte(&WII_LEDS[(uint8_t)a]); - HID_Command(HIDBuffer, 3); -} - -void WII::setLedStatus() { - HIDBuffer[1] = 0x11; - HIDBuffer[2] = (HIDBuffer[2] & 0x01); // Keep the rumble bit - if(wiimoteConnected) - HIDBuffer[2] |= 0x10; // If it's connected LED1 will light up - if(motionPlusConnected) - HIDBuffer[2] |= 0x20; // If it's connected LED2 will light up - if(nunchuckConnected) - HIDBuffer[2] |= 0x40; // If it's connected LED3 will light up - - HID_Command(HIDBuffer, 3); -} - -uint8_t WII::getBatteryLevel() { - checkBatteryLevel = true; // This is needed so the library knows that the status response is a response to this function - statusRequest(); // This will update the battery level - return batteryLevel; -}; - -void WII::setReportMode(bool continuous, uint8_t mode) { - uint8_t cmd_buf[4]; - cmd_buf[0] = 0xA2; // HID BT DATA_request (0xA0) | Report Type (Output 0x02) - cmd_buf[1] = 0x12; - if(continuous) - cmd_buf[2] = 0x04 | (HIDBuffer[2] & 0x01); // Keep the rumble bit - else - cmd_buf[2] = 0x00 | (HIDBuffer[2] & 0x01); // Keep the rumble bit - cmd_buf[3] = mode; - HID_Command(cmd_buf, 4); -} - -void WII::statusRequest() { - uint8_t cmd_buf[3]; - cmd_buf[0] = 0xA2; // HID BT DATA_request (0xA0) | Report Type (Output 0x02) - cmd_buf[1] = 0x15; - cmd_buf[2] = (HIDBuffer[2] & 0x01); // Keep the rumble bit - HID_Command(cmd_buf, 3); -} - -/************************************************************/ -/* Memmory Commands */ -/************************************************************/ - -void WII::writeData(uint32_t offset, uint8_t size, uint8_t* data) { - uint8_t cmd_buf[23]; - cmd_buf[0] = 0xA2; // HID BT DATA_request (0xA0) | Report Type (Output 0x02) - cmd_buf[1] = 0x16; // Write data - cmd_buf[2] = 0x04 | (HIDBuffer[2] & 0x01); // Write to memory, clear bit 2 to write to EEPROM - cmd_buf[3] = (uint8_t)((offset & 0xFF0000) >> 16); - cmd_buf[4] = (uint8_t)((offset & 0xFF00) >> 8); - cmd_buf[5] = (uint8_t)(offset & 0xFF); - cmd_buf[6] = size; - uint8_t i = 0; - for(; i < size; i++) - cmd_buf[7 + i] = data[i]; - for(; i < 16; i++) // Set the rest to zero - cmd_buf[7 + i] = 0x00; - HID_Command(cmd_buf, 23); -} - -void WII::initExtension1() { - uint8_t buf[1]; - buf[0] = 0x55; - writeData(0xA400F0, 1, buf); -} - -void WII::initExtension2() { - uint8_t buf[1]; - buf[0] = 0x00; - writeData(0xA400FB, 1, buf); -} - -void WII::initMotionPlus() { - uint8_t buf[1]; - buf[0] = 0x55; - writeData(0xA600F0, 1, buf); -} - -void WII::activateMotionPlus() { - uint8_t buf[1]; - if(pBtd->wiiUProController) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nActivating Wii U Pro Controller"), 0x80); -#endif - buf[0] = 0x00; // It seems like you can send anything but 0x04, 0x05, and 0x07 - } else if(activateNunchuck) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nActivating Motion Plus in pass-through mode"), 0x80); -#endif - buf[0] = 0x05; // Activate nunchuck pass-through mode - }//else if(classicControllerConnected && extensionConnected) - //buf[0] = 0x07; - else { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nActivating Motion Plus in normal mode"), 0x80); -#endif - buf[0] = 0x04; // Don't use any extension - } - writeData(0xA600FE, 1, buf); -} - -void WII::readData(uint32_t offset, uint16_t size, bool EEPROM) { - uint8_t cmd_buf[8]; - cmd_buf[0] = 0xA2; // HID BT DATA_request (0xA0) | Report Type (Output 0x02) - cmd_buf[1] = 0x17; // Read data - if(EEPROM) - cmd_buf[2] = 0x00 | (HIDBuffer[2] & 0x01); // Read from EEPROM - else - cmd_buf[2] = 0x04 | (HIDBuffer[2] & 0x01); // Read from memory - cmd_buf[3] = (uint8_t)((offset & 0xFF0000) >> 16); - cmd_buf[4] = (uint8_t)((offset & 0xFF00) >> 8); - cmd_buf[5] = (uint8_t)(offset & 0xFF); - cmd_buf[6] = (uint8_t)((size & 0xFF00) >> 8); - cmd_buf[7] = (uint8_t)(size & 0xFF); - - HID_Command(cmd_buf, 8); -} - -void WII::readExtensionType() { - readData(0xA400FA, 6, false); -} - -void WII::readCalData() { - readData(0x0016, 8, true); -} - -void WII::checkMotionPresent() { - readData(0xA600FA, 6, false); -} - -void WII::readWiiBalanceBoardCalibration() { - readData(0xA40024, 24, false); -} - -/************************************************************/ -/* WII Commands */ -/************************************************************/ - -bool WII::getButtonPress(ButtonEnum b) { // Return true when a button is pressed - if(wiiUProControllerConnected) - return (ButtonState & pgm_read_dword(&WII_PROCONTROLLER_BUTTONS[(uint8_t)b])); - else - return (ButtonState & pgm_read_dword(&WII_BUTTONS[(uint8_t)b])); -} - -bool WII::getButtonClick(ButtonEnum b) { // Only return true when a button is clicked - uint32_t button; - if(wiiUProControllerConnected) - button = pgm_read_dword(&WII_PROCONTROLLER_BUTTONS[(uint8_t)b]); - else - button = pgm_read_dword(&WII_BUTTONS[(uint8_t)b]); - bool click = (ButtonClickState & button); - ButtonClickState &= ~button; // clear "click" event - return click; -} - -uint8_t WII::getAnalogHat(HatEnum a) { - if(!nunchuckConnected) - return 127; // Return center position - else { - uint8_t output = hatValues[(uint8_t)a]; - if(output == 0xFF || output == 0x00) // The joystick will only read 255 or 0 when the cable is unplugged or initializing, so we will just return the center position - return 127; - else - return output; - } -} - -uint16_t WII::getAnalogHat(AnalogHatEnum a) { - if(!wiiUProControllerConnected) - return 2000; - else { - uint16_t output = hatValues[(uint8_t)a]; - if(output == 0x00) // The joystick will only read 0 when it is first initializing, so we will just return the center position - return 2000; - else - return output; - } -} - -void WII::onInit() { - if(pFuncOnInit) - pFuncOnInit(); // Call the user function - else - setLedStatus(); -} - -/************************************************************/ -/* Wii Balance Board Commands */ -/************************************************************/ - -float WII::getWeight(BalanceBoardEnum pos) { - // Use interpolating between two points - based on: https://github.com/skorokithakis/gr8w8upd8m8/blob/master/gr8w8upd8m8.py - // wiiBalanceBoardCal[pos][0] is calibration values for 0 kg - // wiiBalanceBoardCal[pos][1] is calibration values for 17 kg - // wiiBalanceBoardCal[pos][2] is calibration values for 34 kg - if(wiiBalanceBoardRaw[pos] < wiiBalanceBoardCal[0][pos]) - return 0.0f; // Below 0 kg - else if(wiiBalanceBoardRaw[pos] < wiiBalanceBoardCal[1][pos]) // Between 0 and 17 kg - return 17.0f * (float)(wiiBalanceBoardRaw[pos] - wiiBalanceBoardCal[0][pos]) / (float)(wiiBalanceBoardCal[1][pos] - wiiBalanceBoardCal[0][pos]); - else // More than 17 kg - return 17.0f + 17.0f * (float)(wiiBalanceBoardRaw[pos] - wiiBalanceBoardCal[1][pos]) / (float)(wiiBalanceBoardCal[2][pos] - wiiBalanceBoardCal[1][pos]); -}; - -float WII::getTotalWeight() { - return getWeight(TopRight) + getWeight(BotRight) + getWeight(TopLeft) + getWeight(BotLeft); -}; - -/************************************************************/ -/* The following functions are for the IR camera */ -/************************************************************/ - -#ifdef WIICAMERA - -void WII::IRinitialize() { // Turns on and initialises the IR camera - - enableIRCamera1(); -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nEnable IR Camera1 Complete"), 0x80); -#endif - delay(80); - - enableIRCamera2(); -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nEnable IR Camera2 Complete"), 0x80); -#endif - delay(80); - - write0x08Value(); -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nWrote hex number 0x08"), 0x80); -#endif - delay(80); - - writeSensitivityBlock1(); -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nWrote Sensitivity Block 1"), 0x80); -#endif - delay(80); - - writeSensitivityBlock2(); -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nWrote Sensitivity Block 2"), 0x80); -#endif - delay(80); - - uint8_t mode_num = 0x03; - setWiiModeNumber(mode_num); // Change input for whatever mode you want i.e. 0x01, 0x03, or 0x05 -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSet Wii Mode Number To 0x"), 0x80); - D_PrintHex (mode_num, 0x80); -#endif - delay(80); - - write0x08Value(); -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nWrote Hex Number 0x08"), 0x80); -#endif - delay(80); - - setReportMode(false, 0x33); - //setReportMode(false, 0x3f); // For full reporting mode, doesn't work yet -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nSet Report Mode to 0x33"), 0x80); -#endif - delay(80); - - statusRequest(); // Used to update wiiState - call isIRCameraEnabled() afterwards to check if it actually worked -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nIR Initialized"), 0x80); -#endif -} - -void WII::enableIRCamera1() { - uint8_t cmd_buf[3]; - cmd_buf[0] = 0xA2; // HID BT DATA_request (0xA0) | Report Type (Output 0x02) - cmd_buf[1] = 0x13; // Output report 13 - cmd_buf[2] = 0x04 | (HIDBuffer[2] & 0x01); // Keep the rumble bit and sets bit 2 - HID_Command(cmd_buf, 3); -} - -void WII::enableIRCamera2() { - uint8_t cmd_buf[3]; - cmd_buf[0] = 0xA2; // HID BT DATA_request (0xA0) | Report Type (Output 0x02) - cmd_buf[1] = 0x1A; // Output report 1A - cmd_buf[2] = 0x04 | (HIDBuffer[2] & 0x01); // Keep the rumble bit and sets bit 2 - HID_Command(cmd_buf, 3); -} - -void WII::writeSensitivityBlock1() { - uint8_t buf[9]; - buf[0] = 0x00; - buf[1] = 0x00; - buf[2] = 0x00; - buf[3] = 0x00; - buf[4] = 0x00; - buf[5] = 0x00; - buf[6] = 0x90; - buf[7] = 0x00; - buf[8] = 0x41; - - writeData(0xB00000, 9, buf); -} - -void WII::writeSensitivityBlock2() { - uint8_t buf[2]; - buf[0] = 0x40; - buf[1] = 0x00; - - writeData(0xB0001A, 2, buf); -} - -void WII::write0x08Value() { - uint8_t cmd = 0x08; - writeData(0xb00030, 1, &cmd); -} - -void WII::setWiiModeNumber(uint8_t mode_number) { // mode_number in hex i.e. 0x03 for extended mode - writeData(0xb00033, 1, &mode_number); -} -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/Wii.h b/protocol/usb_hid/USB_Host_Shield_2.0/Wii.h deleted file mode 100755 index 960f2273..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/Wii.h +++ /dev/null @@ -1,518 +0,0 @@ -/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - - IR camera support added by Allan Glover (adglover9.81@gmail.com) and Kristian Lauszus - */ - -#ifndef _wii_h_ -#define _wii_h_ - -#include "BTD.h" -#include "controllerEnums.h" - -/* Wii event flags */ -#define WII_FLAG_MOTION_PLUS_CONNECTED (1 << 0) -#define WII_FLAG_NUNCHUCK_CONNECTED (1 << 1) -#define WII_FLAG_CALIBRATE_BALANCE_BOARD (1 << 2) - -#define wii_check_flag(flag) (wii_event_flag & (flag)) -#define wii_set_flag(flag) (wii_event_flag |= (flag)) -#define wii_clear_flag(flag) (wii_event_flag &= ~(flag)) - -/** Enum used to read the joystick on the Nunchuck. */ -enum HatEnum { - /** Read the x-axis on the Nunchuck joystick. */ - HatX = 0, - /** Read the y-axis on the Nunchuck joystick. */ - HatY = 1, -}; - -/** Enum used to read the weight on Wii Balance Board. */ -enum BalanceBoardEnum { - TopRight = 0, - BotRight = 1, - TopLeft = 2, - BotLeft = 3, -}; - -/** - * This BluetoothService class implements support for the Wiimote including the Nunchuck and Motion Plus extension. - * - * It also support the Wii U Pro Controller. - */ -class WII : public BluetoothService { -public: - /** - * Constructor for the WII class. - * @param p Pointer to BTD class instance. - * @param pair Set this to true in order to pair with the Wiimote. If the argument is omitted then it won't pair with it. - * One can use ::PAIR to set it to true. - */ - WII(BTD *p, bool pair = false); - - /** @name BluetoothService implementation */ - /** Used this to disconnect any of the controllers. */ - void disconnect(); - /**@}*/ - - /** @name Wii Controller functions */ - /** - * getButtonPress(Button b) will return true as long as the button is held down. - * - * While getButtonClick(Button b) will only return it once. - * - * So you instance if you need to increase a variable once you would use getButtonClick(Button b), - * but if you need to drive a robot forward you would use getButtonPress(Button b). - * @param b ::ButtonEnum to read. - * @return getButtonPress(ButtonEnum b) will return a true as long as a button is held down, while getButtonClick(ButtonEnum b) will return true once for each button press. - */ - bool getButtonPress(ButtonEnum b); - bool getButtonClick(ButtonEnum b); - /**@}*/ - - /** @name Wii Controller functions */ - - /** Call this to start the paring sequence with a controller */ - void pair(void) { - if(pBtd) - pBtd->pairWithWiimote(); - }; - /** - * Used to read the joystick of the Nunchuck. - * @param a Either ::HatX or ::HatY. - * @return Return the analog value in the range from approximately 25-230. - */ - uint8_t getAnalogHat(HatEnum a); - /** - * Used to read the joystick of the Wii U Pro Controller. - * @param a Either ::LeftHatX, ::LeftHatY, ::RightHatX or ::RightHatY. - * @return Return the analog value in the range from approximately 800-3200. - */ - uint16_t getAnalogHat(AnalogHatEnum a); - - /** - * Pitch calculated from the Wiimote. A complimentary filter is used if the Motion Plus is connected. - * @return Pitch in the range from 0-360. - */ - double getPitch() { - if(motionPlusConnected) - return compPitch; - return getWiimotePitch(); - }; - - /** - * Roll calculated from the Wiimote. A complimentary filter is used if the Motion Plus is connected. - * @return Roll in the range from 0-360. - */ - double getRoll() { - if(motionPlusConnected) - return compRoll; - return getWiimoteRoll(); - }; - - /** - * This is the yaw calculated by the gyro. - * - * NOTE: This angle will drift a lot and is only available if the Motion Plus extension is connected. - * @return The angle calculated using the gyro. - */ - double getYaw() { - return gyroYaw; - }; - - /** Used to set all LEDs and rumble off. */ - void setAllOff(); - /** Turn off rumble. */ - void setRumbleOff(); - /** Turn on rumble. */ - void setRumbleOn(); - /** Toggle rumble. */ - void setRumbleToggle(); - - /** - * Set LED value without using the ::LEDEnum. - * @param value See: ::LEDEnum. - */ - void setLedRaw(uint8_t value); - - /** Turn all LEDs off. */ - void setLedOff() { - setLedRaw(0); - }; - /** - * Turn the specific ::LEDEnum off. - * @param a The ::LEDEnum to turn off. - */ - void setLedOff(LEDEnum a); - /** - * Turn the specific ::LEDEnum on. - * @param a The ::LEDEnum to turn on. - */ - void setLedOn(LEDEnum a); - /** - * Toggle the specific ::LEDEnum. - * @param a The ::LEDEnum to toggle. - */ - void setLedToggle(LEDEnum a); - /** - * This will set the LEDs, so the user can see which connections are active. - * - * The first ::LEDEnum indicate that the Wiimote is connected, - * the second ::LEDEnum indicate indicate that a Motion Plus is also connected - * the third ::LEDEnum will indicate that a Nunchuck controller is also connected. - */ - void setLedStatus(); - - /** - * Return the battery level of the Wiimote. - * @return The battery level in the range 0-255. - */ - uint8_t getBatteryLevel(); - - /** - * Return the Wiimote state. - * @return See: http://wiibrew.org/wiki/Wiimote#0x20:_Status. - */ - uint8_t getWiiState() { - return wiiState; - }; - /**@}*/ - - /**@{*/ - /** Variable used to indicate if a Wiimote is connected. */ - bool wiimoteConnected; - /** Variable used to indicate if a Nunchuck controller is connected. */ - bool nunchuckConnected; - /** Variable used to indicate if a Nunchuck controller is connected. */ - bool motionPlusConnected; - /** Variable used to indicate if a Wii U Pro controller is connected. */ - bool wiiUProControllerConnected; - /** Variable used to indicate if a Wii Balance Board is connected. */ - bool wiiBalanceBoardConnected; - /**@}*/ - - /* IMU Data, might be usefull if you need to do something more advanced than just calculating the angle */ - - /**@{*/ - - /** Pitch and roll calculated from the accelerometer inside the Wiimote. */ - double getWiimotePitch() { - return (atan2(accYwiimote, accZwiimote) + PI) * RAD_TO_DEG; - }; - - double getWiimoteRoll() { - return (atan2(accXwiimote, accZwiimote) + PI) * RAD_TO_DEG; - }; - /**@}*/ - - /**@{*/ - - /** Pitch and roll calculated from the accelerometer inside the Nunchuck. */ - double getNunchuckPitch() { - return (atan2(accYnunchuck, accZnunchuck) + PI) * RAD_TO_DEG; - }; - - double getNunchuckRoll() { - return (atan2(accXnunchuck, accZnunchuck) + PI) * RAD_TO_DEG; - }; - /**@}*/ - - /**@{*/ - /** Accelerometer values used to calculate pitch and roll. */ - int16_t accXwiimote, accYwiimote, accZwiimote; - int16_t accXnunchuck, accYnunchuck, accZnunchuck; - /**@}*/ - - /* Variables for the gyro inside the Motion Plus */ - /** This is the pitch calculated by the gyro - use this to tune WII#pitchGyroScale. */ - double gyroPitch; - /** This is the roll calculated by the gyro - use this to tune WII#rollGyroScale. */ - double gyroRoll; - /** This is the yaw calculated by the gyro - use this to tune WII#yawGyroScale. */ - double gyroYaw; - - /**@{*/ - /** The speed in deg/s from the gyro. */ - double pitchGyroSpeed; - double rollGyroSpeed; - double yawGyroSpeed; - /**@}*/ - - /**@{*/ - /** You might need to fine-tune these values. */ - uint16_t pitchGyroScale; - uint16_t rollGyroScale; - uint16_t yawGyroScale; - /**@}*/ - - /**@{*/ - /** Raw value read directly from the Motion Plus. */ - int16_t gyroYawRaw; - int16_t gyroRollRaw; - int16_t gyroPitchRaw; - /**@}*/ - - /**@{*/ - /** These values are set when the controller is first initialized. */ - int16_t gyroYawZero; - int16_t gyroRollZero; - int16_t gyroPitchZero; - /**@}*/ - - /** @name Wii Balance Board functions */ - - /** - * Used to get the weight at the specific position on the Wii Balance Board. - * @param ::BalanceBoardEnum to read from. - * @return Returns the weight in kg. - */ - float getWeight(BalanceBoardEnum pos); - - /** - * Used to get total weight on the Wii Balance Board. - * @returnReturns the weight in kg. - */ - float getTotalWeight(); - - /** - * Used to get the raw reading at the specific position on the Wii Balance Board. - * @param ::BalanceBoardEnum to read from. - * @return Returns the raw reading. - */ - uint16_t getWeightRaw(BalanceBoardEnum pos) { - return wiiBalanceBoardRaw[pos]; - }; - /**@}*/ - -#ifdef WIICAMERA - /** @name Wiimote IR camera functions - * You will have to set ::ENABLE_WII_IR_CAMERA in settings.h to 1 in order use the IR camera. - */ - /** Initialises the camera as per the steps from: http://wiibrew.org/wiki/Wiimote#IR_Camera */ - void IRinitialize(); - - /** - * IR object 1 x-position read from the Wii IR camera. - * @return The x-position of the object in the range 0-1023. - */ - uint16_t getIRx1() { - return IR_object_x1; - }; - - /** - * IR object 1 y-position read from the Wii IR camera. - * @return The y-position of the object in the range 0-767. - */ - uint16_t getIRy1() { - return IR_object_y1; - }; - - /** - * IR object 1 size read from the Wii IR camera. - * @return The size of the object in the range 0-15. - */ - uint8_t getIRs1() { - return IR_object_s1; - }; - - /** - * IR object 2 x-position read from the Wii IR camera. - * @return The x-position of the object in the range 0-1023. - */ - uint16_t getIRx2() { - return IR_object_x2; - }; - - /** - * IR object 2 y-position read from the Wii IR camera. - * @return The y-position of the object in the range 0-767. - */ - uint16_t getIRy2() { - return IR_object_y2; - }; - - /** - * IR object 2 size read from the Wii IR camera. - * @return The size of the object in the range 0-15. - */ - uint8_t getIRs2() { - return IR_object_s2; - }; - - /** - * IR object 3 x-position read from the Wii IR camera. - * @return The x-position of the object in the range 0-1023. - */ - uint16_t getIRx3() { - return IR_object_x3; - }; - - /** - * IR object 3 y-position read from the Wii IR camera. - * @return The y-position of the object in the range 0-767. - */ - uint16_t getIRy3() { - return IR_object_y3; - }; - - /** - * IR object 3 size read from the Wii IR camera. - * @return The size of the object in the range 0-15. - */ - uint8_t getIRs3() { - return IR_object_s3; - }; - - /** - * IR object 4 x-position read from the Wii IR camera. - * @return The x-position of the object in the range 0-1023. - */ - uint16_t getIRx4() { - return IR_object_x4; - }; - - /** - * IR object 4 y-position read from the Wii IR camera. - * @return The y-position of the object in the range 0-767. - */ - uint16_t getIRy4() { - return IR_object_y4; - }; - - /** - * IR object 4 size read from the Wii IR camera. - * @return The size of the object in the range 0-15. - */ - uint8_t getIRs4() { - return IR_object_s4; - }; - - /** - * Use this to check if the camera is enabled or not. - * If not call WII#IRinitialize to initialize the IR camera. - * @return True if it's enabled, false if not. - */ - bool isIRCameraEnabled() { - return (wiiState & 0x08); - }; - /**@}*/ -#endif - -protected: - /** @name BluetoothService implementation */ - /** - * Used to pass acldata to the services. - * @param ACLData Incoming acldata. - */ - void ACLData(uint8_t* ACLData); - /** Used to run part of the state machine. */ - void Run(); - /** Use this to reset the service. */ - void Reset(); - /** - * Called when the controller is successfully initialized. - * Use attachOnInit(void (*funcOnInit)(void)) to call your own function. - * This is useful for instance if you want to set the LEDs in a specific way. - */ - void onInit(); - /**@}*/ - -private: - - void L2CAP_task(); // L2CAP state machine - - /* Variables filled from HCI event management */ - bool activeConnection; // Used to indicate if it's already has established a connection - - /* Variables used by high level L2CAP task */ - uint8_t l2cap_state; - uint8_t wii_event_flag; // Used for Wii flags - - uint32_t ButtonState; - uint32_t OldButtonState; - uint32_t ButtonClickState; - uint16_t hatValues[4]; - - uint8_t HIDBuffer[3]; // Used to store HID commands - - uint16_t stateCounter; - bool unknownExtensionConnected; - bool extensionConnected; - bool checkBatteryLevel; // Set to true when getBatteryLevel() is called otherwise if should be false - bool motionPlusInside; // True if it's a new Wiimote with the Motion Plus extension build into it - - /* L2CAP Channels */ - uint8_t control_scid[2]; // L2CAP source CID for HID_Control - uint8_t control_dcid[2]; // 0x0060 - uint8_t interrupt_scid[2]; // L2CAP source CID for HID_Interrupt - uint8_t interrupt_dcid[2]; // 0x0061 - - /* HID Commands */ - void HID_Command(uint8_t* data, uint8_t nbytes); - void setReportMode(bool continuous, uint8_t mode); - - void writeData(uint32_t offset, uint8_t size, uint8_t* data); - void initExtension1(); - void initExtension2(); - - void statusRequest(); // Used to update the Wiimote state and battery level - - void readData(uint32_t offset, uint16_t size, bool EEPROM); - void readExtensionType(); - void readCalData(); - void readWiiBalanceBoardCalibration(); // Used by the library to read the Wii Balance Board calibration values - - void checkMotionPresent(); // Used to see if a Motion Plus is connected to the Wiimote - void initMotionPlus(); - void activateMotionPlus(); - - uint16_t wiiBalanceBoardRaw[4]; // Wii Balance Board raw values - uint16_t wiiBalanceBoardCal[3][4]; // Wii Balance Board calibration values - - double compPitch; // Fusioned angle using a complimentary filter if the Motion Plus is connected - double compRoll; // Fusioned angle using a complimentary filter if the Motion Plus is connected - - bool activateNunchuck; - bool motionValuesReset; // This bool is true when the gyro values has been reset - uint32_t timer; - - uint8_t wiiState; // Stores the value in l2capinbuf[12] - (0x01: Battery is nearly empty), (0x02: An Extension Controller is connected), (0x04: Speaker enabled), (0x08: IR enabled), (0x10: LED1, 0x20: LED2, 0x40: LED3, 0x80: LED4) - uint8_t batteryLevel; - -#ifdef WIICAMERA - /* Private function and variables for the readings from the IR Camera */ - void enableIRCamera1(); // Sets bit 2 of output report 13 - void enableIRCamera2(); // Sets bit 2 of output report 1A - void writeSensitivityBlock1(); - void writeSensitivityBlock2(); - void write0x08Value(); - void setWiiModeNumber(uint8_t mode_number); - - uint16_t IR_object_x1; // IR x position 10 bits - uint16_t IR_object_y1; // IR y position 10 bits - uint8_t IR_object_s1; // IR size value - uint16_t IR_object_x2; - uint16_t IR_object_y2; - uint8_t IR_object_s2; - uint16_t IR_object_x3; // IR x position 10 bits - uint16_t IR_object_y3; // IR y position 10 bits - uint8_t IR_object_s3; // IR size value - uint16_t IR_object_x4; - uint16_t IR_object_y4; - uint8_t IR_object_s4; -#endif -}; -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/WiiCameraReadme.md b/protocol/usb_hid/USB_Host_Shield_2.0/WiiCameraReadme.md deleted file mode 100644 index 8577d73f..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/WiiCameraReadme.md +++ /dev/null @@ -1,13 +0,0 @@ -Please see for the complete capabilities of the Wii camera. The IR camera code was written based on the above website and with support from Kristian Lauszus. - -This library is large, if you run into memory problems when uploading to the Arduino, disable serial debugging. - -To enable the IR camera code, simply set ```ENABLE_WII_IR_CAMERA``` to 1 in [settings.h](settings.h). - -This library implements the following settings: - -* Report sensitivity mode: 00 00 00 00 00 00 90 00 41 40 00 Suggested by inio (high sensitivity) -* Data Format: Extended mode (0x03). Full mode is not working yet. The output reports 0x3e and 0x3f need tampering with - * In this mode the camera outputs x and y coordinates and a size dimension for the 4 brightest points. - -Again, read through to get an understanding of the camera and its settings. diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/XBOXOLD.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/XBOXOLD.cpp deleted file mode 100644 index 78e6e9a5..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/XBOXOLD.cpp +++ /dev/null @@ -1,337 +0,0 @@ -/* Copyright (C) 2013 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#include "XBOXOLD.h" -// To enable serial debugging see "settings.h" -//#define EXTRADEBUG // Uncomment to get even more debugging data -//#define PRINTREPORT // Uncomment to print the report send by the Xbox controller - -/** Buttons on the controllers */ -const uint8_t XBOXOLD_BUTTONS[] PROGMEM = { - 0x01, // UP - 0x08, // RIGHT - 0x02, // DOWN - 0x04, // LEFT - - 0x20, // BACK - 0x10, // START - 0x40, // L3 - 0x80, // R3 - - // A, B, X, Y, BLACK, WHITE, L1, and R1 are analog buttons - 4, // BLACK - 5, // WHTIE - 6, // L1 - 7, // R1 - - 1, // B - 0, // A - 2, // X - 3, // Y -}; - -XBOXOLD::XBOXOLD(USB *p) : -pUsb(p), // pointer to USB class instance - mandatory -bAddress(0), // device address - mandatory -bPollEnable(false) { // don't start polling before dongle is connected - for(uint8_t i = 0; i < XBOX_MAX_ENDPOINTS; i++) { - epInfo[i].epAddr = 0; - epInfo[i].maxPktSize = (i) ? 0 : 8; - epInfo[i].epAttribs = 0; - epInfo[i].bmNakPower = (i) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER; - } - - if(pUsb) // register in USB subsystem - pUsb->RegisterDeviceClass(this); //set devConfig[] entry -} - -uint8_t XBOXOLD::Init(uint8_t parent, uint8_t port, bool lowspeed) { - uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)]; - USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); - uint8_t rcode; - UsbDevice *p = NULL; - EpInfo *oldep_ptr = NULL; - uint16_t PID; - uint16_t VID; - - // get memory address of USB device address pool - AddressPool &addrPool = pUsb->GetAddressPool(); -#ifdef EXTRADEBUG - Notify(PSTR("\r\nXBOXUSB Init"), 0x80); -#endif - // check if address has already been assigned to an instance - if(bAddress) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nAddress in use"), 0x80); -#endif - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - } - - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - - if(!p) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nAddress not found"), 0x80); -#endif - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - } - - if(!p->epinfo) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nepinfo is null"), 0x80); -#endif - return USB_ERROR_EPINFO_IS_NULL; - } - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - - p->lowspeed = lowspeed; - - // Get device descriptor - rcode = pUsb->getDevDescr(0, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*)buf); // Get device descriptor - addr, ep, nbytes, data - // Restore p->epinfo - p->epinfo = oldep_ptr; - - if(rcode) - goto FailGetDevDescr; - - VID = udd->idVendor; - PID = udd->idProduct; - - if((VID != XBOX_VID && VID != MADCATZ_VID && VID != JOYTECH_VID) || (PID != XBOX_OLD_PID1 && PID != XBOX_OLD_PID2 && PID != XBOX_OLD_PID3 && PID != XBOX_OLD_PID4)) // Check if VID and PID match - goto FailUnknownDevice; - - // Allocate new address according to device class - bAddress = addrPool.AllocAddress(parent, false, port); - - if(!bAddress) - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - - // Extract Max Packet Size from device descriptor - epInfo[0].maxPktSize = udd->bMaxPacketSize0; - - // Assign new address to the device - rcode = pUsb->setAddr(0, 0, bAddress); - if(rcode) { - p->lowspeed = false; - addrPool.FreeAddress(bAddress); - bAddress = 0; -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nsetAddr: "), 0x80); - D_PrintHex (rcode, 0x80); -#endif - return rcode; - } -#ifdef EXTRADEBUG - Notify(PSTR("\r\nAddr: "), 0x80); - D_PrintHex (bAddress, 0x80); -#endif - //delay(300); // Spec says you should wait at least 200ms - - p->lowspeed = false; - - //get pointer to assigned address record - p = addrPool.GetUsbDevicePtr(bAddress); - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - p->lowspeed = lowspeed; - - // Assign epInfo to epinfo pointer - only EP0 is known - rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo); - if(rcode) - goto FailSetDevTblEntry; - - /* The application will work in reduced host mode, so we can save program and data - memory space. After verifying the VID we will use known values for the - configuration values for device, interface, endpoints and HID for the XBOX controllers */ - - /* Initialize data structures for endpoints of device */ - epInfo[ XBOX_INPUT_PIPE ].epAddr = 0x01; // XBOX report endpoint - epInfo[ XBOX_INPUT_PIPE ].epAttribs = USB_TRANSFER_TYPE_INTERRUPT; - epInfo[ XBOX_INPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints - epInfo[ XBOX_INPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE; - epInfo[ XBOX_INPUT_PIPE ].bmSndToggle = 0; - epInfo[ XBOX_INPUT_PIPE ].bmRcvToggle = 0; - epInfo[ XBOX_OUTPUT_PIPE ].epAddr = 0x02; // XBOX output endpoint - epInfo[ XBOX_OUTPUT_PIPE ].epAttribs = USB_TRANSFER_TYPE_INTERRUPT; - epInfo[ XBOX_OUTPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints - epInfo[ XBOX_OUTPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE; - epInfo[ XBOX_OUTPUT_PIPE ].bmSndToggle = 0; - epInfo[ XBOX_OUTPUT_PIPE ].bmRcvToggle = 0; - - rcode = pUsb->setEpInfoEntry(bAddress, 3, epInfo); - if(rcode) - goto FailSetDevTblEntry; - - delay(200); // Give time for address change - - rcode = pUsb->setConf(bAddress, epInfo[ XBOX_CONTROL_PIPE ].epAddr, 1); - if(rcode) - goto FailSetConfDescr; - -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nXbox Controller Connected\r\n"), 0x80); -#endif - if(pFuncOnInit) - pFuncOnInit(); // Call the user function - XboxConnected = true; - bPollEnable = true; - return 0; // Successful configuration - - /* Diagnostic messages */ -FailGetDevDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetDevDescr(); - goto Fail; -#endif - -FailSetDevTblEntry: -#ifdef DEBUG_USB_HOST - NotifyFailSetDevTblEntry(); - goto Fail; -#endif - -FailSetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailSetConfDescr(); -#endif - goto Fail; - -FailUnknownDevice: -#ifdef DEBUG_USB_HOST - NotifyFailUnknownDevice(VID, PID); -#endif - rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - -Fail: -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nXbox Init Failed, error code: "), 0x80); - NotifyFail(rcode); -#endif - Release(); - return rcode; -} - -/* Performs a cleanup after failed Init() attempt */ -uint8_t XBOXOLD::Release() { - XboxConnected = false; - pUsb->GetAddressPool().FreeAddress(bAddress); - bAddress = 0; - bPollEnable = false; - return 0; -} - -uint8_t XBOXOLD::Poll() { - if(!bPollEnable) - return 0; - uint16_t BUFFER_SIZE = EP_MAXPKTSIZE; - pUsb->inTransfer(bAddress, epInfo[ XBOX_INPUT_PIPE ].epAddr, &BUFFER_SIZE, readBuf); // input on endpoint 1 - readReport(); -#ifdef PRINTREPORT - printReport(BUFFER_SIZE); // Uncomment "#define PRINTREPORT" to print the report send by the Xbox controller -#endif - return 0; -} - -void XBOXOLD::readReport() { - ButtonState = readBuf[2]; - - for(uint8_t i = 0; i < sizeof (buttonValues); i++) - buttonValues[i] = readBuf[i + 4]; // A, B, X, Y, BLACK, WHITE, L1, and R1 - - hatValue[LeftHatX] = (int16_t)(((uint16_t)readBuf[12] << 8) | readBuf[13]); - hatValue[LeftHatY] = (int16_t)(((uint16_t)readBuf[14] << 8) | readBuf[15]); - hatValue[RightHatX] = (int16_t)(((uint16_t)readBuf[16] << 8) | readBuf[17]); - hatValue[RightHatY] = (int16_t)(((uint16_t)readBuf[18] << 8) | readBuf[19]); - - //Notify(PSTR("\r\nButtonState"), 0x80); - //PrintHex(ButtonState, 0x80); - - if(ButtonState != OldButtonState || memcmp(buttonValues, oldButtonValues, sizeof (buttonValues)) != 0) { - ButtonClickState = ButtonState & ~OldButtonState; // Update click state variable - OldButtonState = ButtonState; - - for(uint8_t i = 0; i < sizeof (buttonValues); i++) { - if(oldButtonValues[i] == 0 && buttonValues[i] != 0) - buttonClicked[i] = true; // Update A, B, X, Y, BLACK, WHITE, L1, and R1 click state - oldButtonValues[i] = buttonValues[i]; - } - } -} - -void XBOXOLD::printReport(uint16_t length) { //Uncomment "#define PRINTREPORT" to print the report send by the Xbox controller -#ifdef PRINTREPORT - if(readBuf == NULL) - return; - for(uint8_t i = 0; i < length; i++) { - D_PrintHex (readBuf[i], 0x80); - Notify(PSTR(" "), 0x80); - } - Notify(PSTR("\r\n"), 0x80); -#endif -} - -uint8_t XBOXOLD::getButtonPress(ButtonEnum b) { - uint8_t button = pgm_read_byte(&XBOXOLD_BUTTONS[(uint8_t)b]); - if(b == A || b == B || b == X || b == Y || b == BLACK || b == WHITE || b == L1 || b == R1) // A, B, X, Y, BLACK, WHITE, L1, and R1 are analog buttons - return buttonValues[button]; // Analog buttons - return (ButtonState & button); // Digital buttons -} - -bool XBOXOLD::getButtonClick(ButtonEnum b) { - uint8_t button = pgm_read_byte(&XBOXOLD_BUTTONS[(uint8_t)b]); - if(b == A || b == B || b == X || b == Y || b == BLACK || b == WHITE || b == L1 || b == R1) { // A, B, X, Y, BLACK, WHITE, L1, and R1 are analog buttons - if(buttonClicked[button]) { - buttonClicked[button] = false; - return true; - } - return false; - } - - bool click = (ButtonClickState & button); - ButtonClickState &= ~button; // clear "click" event - return click; -} - -int16_t XBOXOLD::getAnalogHat(AnalogHatEnum a) { - return hatValue[a]; -} - -/* Xbox Controller commands */ -void XBOXOLD::XboxCommand(uint8_t* data, uint16_t nbytes) { - //bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x00), Report Type (Output 0x02), interface (0x00), datalength, datalength, data) - pUsb->ctrlReq(bAddress, epInfo[XBOX_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL); -} - -void XBOXOLD::setRumbleOn(uint8_t lValue, uint8_t rValue) { - uint8_t writeBuf[6]; - - writeBuf[0] = 0x00; - writeBuf[1] = 0x06; - writeBuf[2] = 0x00; - writeBuf[3] = rValue; // small weight - writeBuf[4] = 0x00; - writeBuf[5] = lValue; // big weight - - XboxCommand(writeBuf, 6); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/XBOXOLD.h b/protocol/usb_hid/USB_Host_Shield_2.0/XBOXOLD.h deleted file mode 100644 index 9a36b5cc..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/XBOXOLD.h +++ /dev/null @@ -1,185 +0,0 @@ -/* Copyright (C) 2013 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#ifndef _xboxold_h_ -#define _xboxold_h_ - -#include "Usb.h" -#include "hid.h" -#include "controllerEnums.h" - -/* Data Xbox taken from descriptors */ -#define EP_MAXPKTSIZE 32 // Max size for data via USB - -/* Names we give to the 3 Xbox pipes */ -#define XBOX_CONTROL_PIPE 0 -#define XBOX_INPUT_PIPE 1 -#define XBOX_OUTPUT_PIPE 2 - -// PID and VID of the different devices -#define XBOX_VID 0x045E // Microsoft Corporation -#define MADCATZ_VID 0x1BAD // For unofficial Mad Catz controllers -#define JOYTECH_VID 0x162E // For unofficial Joytech controllers - -#define XBOX_OLD_PID1 0x0202 // Original Microsoft Xbox controller (US) -#define XBOX_OLD_PID2 0x0285 // Original Microsoft Xbox controller (Japan) -#define XBOX_OLD_PID3 0x0287 // Microsoft Microsoft Xbox Controller S -#define XBOX_OLD_PID4 0x0289 // Smaller Microsoft Xbox controller (US) - -#define XBOX_MAX_ENDPOINTS 3 - -/** This class implements support for a the original Xbox controller via USB. */ -class XBOXOLD : public USBDeviceConfig { -public: - /** - * Constructor for the XBOXOLD class. - * @param pUsb Pointer to USB class instance. - */ - XBOXOLD(USB *pUsb); - - /** @name USBDeviceConfig implementation */ - /** - * Initialize the Xbox Controller. - * @param parent Hub number. - * @param port Port number on the hub. - * @param lowspeed Speed of the device. - * @return 0 on success. - */ - uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - /** - * Release the USB device. - * @return 0 on success. - */ - uint8_t Release(); - /** - * Poll the USB Input endpoins and run the state machines. - * @return 0 on success. - */ - uint8_t Poll(); - - /** - * Get the device address. - * @return The device address. - */ - virtual uint8_t GetAddress() { - return bAddress; - }; - - /** - * Used to check if the controller has been initialized. - * @return True if it's ready. - */ - virtual bool isReady() { - return bPollEnable; - }; - - /** - * Used by the USB core to check what this driver support. - * @param vid The device's VID. - * @param pid The device's PID. - * @return Returns true if the device's VID and PID matches this driver. - */ - virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { - return ((vid == XBOX_VID || vid == MADCATZ_VID || vid == JOYTECH_VID) && (pid == XBOX_OLD_PID1 || pid == XBOX_OLD_PID2 || pid == XBOX_OLD_PID3 || pid == XBOX_OLD_PID4)); - }; - /**@}*/ - - /** @name Xbox Controller functions */ - /** - * getButtonPress(ButtonEnum b) will return true as long as the button is held down. - * - * While getButtonClick(ButtonEnum b) will only return it once. - * - * So you instance if you need to increase a variable once you would use getButtonClick(ButtonEnum b), - * but if you need to drive a robot forward you would use getButtonPress(ButtonEnum b). - * @param b ::ButtonEnum to read. - * @return getButtonClick(ButtonEnum b) will return a bool, while getButtonPress(ButtonEnum b) will return a byte if reading ::L2 or ::R2. - */ - uint8_t getButtonPress(ButtonEnum b); - bool getButtonClick(ButtonEnum b); - /**@}*/ - - /** @name Xbox Controller functions */ - /** - * Return the analog value from the joysticks on the controller. - * @param a Either ::LeftHatX, ::LeftHatY, ::RightHatX or ::RightHatY. - * @return Returns a signed 16-bit integer. - */ - int16_t getAnalogHat(AnalogHatEnum a); - - /** Turn rumble off the controller. */ - void setRumbleOff() { - setRumbleOn(0, 0); - }; - /** - * Turn rumble on. - * @param lValue Left motor (big weight) inside the controller. - * @param rValue Right motor (small weight) inside the controller. - */ - void setRumbleOn(uint8_t lValue, uint8_t rValue); - - /** - * Used to call your own function when the controller is successfully initialized. - * @param funcOnInit Function to call. - */ - void attachOnInit(void (*funcOnInit)(void)) { - pFuncOnInit = funcOnInit; - }; - /**@}*/ - - /** True if a Xbox controller is connected. */ - bool XboxConnected; - -protected: - /** Pointer to USB class instance. */ - USB *pUsb; - /** Device address. */ - uint8_t bAddress; - /** Endpoint info structure. */ - EpInfo epInfo[XBOX_MAX_ENDPOINTS]; - -private: - /** - * Called when the controller is successfully initialized. - * Use attachOnInit(void (*funcOnInit)(void)) to call your own function. - * This is useful for instance if you want to set the LEDs in a specific way. - */ - void (*pFuncOnInit)(void); // Pointer to function called in onInit() - - bool bPollEnable; - - /* Variables to store the digital buttons */ - uint8_t ButtonState; - uint8_t OldButtonState; - uint8_t ButtonClickState; - - /* Variables to store the analog buttons */ - uint8_t buttonValues[8]; // A, B, X, Y, BLACK, WHITE, L1, and R1 - uint8_t oldButtonValues[8]; - bool buttonClicked[8]; - - int16_t hatValue[4]; // Joystick values - - uint8_t readBuf[EP_MAXPKTSIZE]; // General purpose buffer for input data - - void readReport(); // Read incoming data - void printReport(uint16_t length); // Print incoming date - - /* Private commands */ - void XboxCommand(uint8_t* data, uint16_t nbytes); -}; -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/XBOXONE.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/XBOXONE.cpp deleted file mode 100644 index 2159c052..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/XBOXONE.cpp +++ /dev/null @@ -1,374 +0,0 @@ -/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. - Copyright (C) 2015 guruthree - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - - guruthree - Web : https://github.com/guruthree/ - */ - -#include "XBOXONE.h" -// To enable serial debugging see "settings.h" -//#define EXTRADEBUG // Uncomment to get even more debugging data -//#define PRINTREPORT // Uncomment to print the report send by the Xbox ONE Controller - -XBOXONE::XBOXONE(USB *p) : -pUsb(p), // pointer to USB class instance - mandatory -bAddress(0), // device address - mandatory -bPollEnable(false) { // don't start polling before dongle is connected - for(uint8_t i = 0; i < XBOX_MAX_ENDPOINTS; i++) { - epInfo[i].epAddr = 0; - epInfo[i].maxPktSize = (i) ? 0 : 8; - epInfo[i].epAttribs = 0; - epInfo[i].bmNakPower = (i) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER; - } - - if(pUsb) // register in USB subsystem - pUsb->RegisterDeviceClass(this); //set devConfig[] entry -} - -uint8_t XBOXONE::Init(uint8_t parent, uint8_t port, bool lowspeed) { - uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)]; - USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); - uint8_t rcode; - UsbDevice *p = NULL; - EpInfo *oldep_ptr = NULL; - uint16_t PID; - uint16_t VID; - - // get memory address of USB device address pool - AddressPool &addrPool = pUsb->GetAddressPool(); -#ifdef EXTRADEBUG - Notify(PSTR("\r\nXBOXONE Init"), 0x80); -#endif - // check if address has already been assigned to an instance - if(bAddress) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nAddress in use"), 0x80); -#endif - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - } - - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - - if(!p) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nAddress not found"), 0x80); -#endif - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - } - - if(!p->epinfo) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nepinfo is null"), 0x80); -#endif - return USB_ERROR_EPINFO_IS_NULL; - } - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - - p->lowspeed = lowspeed; - - // Get device descriptor - rcode = pUsb->getDevDescr(0, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*)buf); // Get device descriptor - addr, ep, nbytes, data - // Restore p->epinfo - p->epinfo = oldep_ptr; - - if(rcode) - goto FailGetDevDescr; - - VID = udd->idVendor; - PID = udd->idProduct; - - if(!VIDPIDOK(VID, PID)) // Check VID - goto FailUnknownDevice; - - // Allocate new address according to device class - bAddress = addrPool.AllocAddress(parent, false, port); - - if(!bAddress) - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - - // Extract Max Packet Size from device descriptor - epInfo[0].maxPktSize = udd->bMaxPacketSize0; - - // Assign new address to the device - rcode = pUsb->setAddr(0, 0, bAddress); - if(rcode) { - p->lowspeed = false; - addrPool.FreeAddress(bAddress); - bAddress = 0; -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nsetAddr: "), 0x80); - D_PrintHex (rcode, 0x80); -#endif - return rcode; - } -#ifdef EXTRADEBUG - Notify(PSTR("\r\nAddr: "), 0x80); - D_PrintHex (bAddress, 0x80); -#endif - //delay(300); // Spec says you should wait at least 200ms - - p->lowspeed = false; - - //get pointer to assigned address record - p = addrPool.GetUsbDevicePtr(bAddress); - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - p->lowspeed = lowspeed; - - // Assign epInfo to epinfo pointer - only EP0 is known - rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo); - if(rcode) - goto FailSetDevTblEntry; - - /* The application will work in reduced host mode, so we can save program and data - memory space. After verifying the VID we will use known values for the - configuration values for device, interface, endpoints and HID for the XBOXONE Controllers */ - - /* Initialize data structures for endpoints of device */ - epInfo[ XBOX_OUTPUT_PIPE ].epAddr = 0x01; // XBOX one output endpoint - epInfo[ XBOX_OUTPUT_PIPE ].epAttribs = USB_TRANSFER_TYPE_INTERRUPT; - epInfo[ XBOX_OUTPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints - epInfo[ XBOX_OUTPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE; - epInfo[ XBOX_OUTPUT_PIPE ].bmSndToggle = 0; - epInfo[ XBOX_OUTPUT_PIPE ].bmRcvToggle = 0; - epInfo[ XBOX_INPUT_PIPE ].epAddr = 0x01; // XBOX one input endpoint - epInfo[ XBOX_INPUT_PIPE ].epAttribs = USB_TRANSFER_TYPE_INTERRUPT; - epInfo[ XBOX_INPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints - epInfo[ XBOX_INPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE; - epInfo[ XBOX_INPUT_PIPE ].bmSndToggle = 0; - epInfo[ XBOX_INPUT_PIPE ].bmRcvToggle = 0; - - rcode = pUsb->setEpInfoEntry(bAddress, 3, epInfo); - if(rcode) - goto FailSetDevTblEntry; - - delay(200); // Give time for address change - - rcode = pUsb->setConf(bAddress, epInfo[ XBOX_CONTROL_PIPE ].epAddr, 1); - if(rcode) - goto FailSetConfDescr; - -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nXbox One Controller Connected\r\n"), 0x80); -#endif - - delay(200); // let things settle - - // initialize the controller for input - writeBuf[0] = 0x05; - writeBuf[1] = 0x20; - rcode = XboxCommand(writeBuf, 2); - if (rcode) - goto Fail; - - onInit(); - XboxOneConnected = true; - bPollEnable = true; - return 0; // Successful configuration - - /* Diagnostic messages */ -FailGetDevDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetDevDescr(); - goto Fail; -#endif - -FailSetDevTblEntry: -#ifdef DEBUG_USB_HOST - NotifyFailSetDevTblEntry(); - goto Fail; -#endif - -FailSetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailSetConfDescr(); -#endif - goto Fail; - -FailUnknownDevice: -#ifdef DEBUG_USB_HOST - NotifyFailUnknownDevice(VID, PID); -#endif - rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - -Fail: -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nXbox One Init Failed, error code: "), 0x80); - NotifyFail(rcode); -#endif - Release(); - return rcode; -} - -/* Performs a cleanup after failed Init() attempt */ -uint8_t XBOXONE::Release() { - XboxOneConnected = false; - pUsb->GetAddressPool().FreeAddress(bAddress); - bAddress = 0; - bPollEnable = false; -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nXbox One Controller Disconnected\r\n"), 0x80); -#endif - return 0; -} - -uint8_t XBOXONE::Poll() { - if(!bPollEnable) - return 0; - uint16_t BUFFER_SIZE = EP_MAXPKTSIZE; - uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[ XBOX_INPUT_PIPE ].epAddr, &BUFFER_SIZE, readBuf); - if (!rcode) { - readReport(); -#ifdef PRINTREPORT - printReport(); // Uncomment "#define PRINTREPORT" to print the report send by the Xbox ONE Controller -#endif - } -#ifdef DEBUG_USB_HOST - else if (rcode != 0x04) { // not a matter of no update to send - Notify(PSTR("\r\nXbox One Poll Failed, error code: "), 0x80); - NotifyFail(rcode); - } -#endif - return rcode; -} - -void XBOXONE::readReport() { - if(readBuf == NULL) - return; - if(readBuf[0] == 0x07) { - // The XBOX button has a separate message - if(readBuf[4] == 1) - ButtonState |= XBOX_BUTTONS[XBOX]; - else - ButtonState &= ~XBOX_BUTTONS[XBOX]; - } - if(readBuf[0] != 0x20) { // Check if it's the correct report, otherwise return - the controller also sends different status reports -#ifdef EXTRADEBUG - Notify(PSTR("\r\nXbox Poll: "), 0x80); - D_PrintHex (readBuf[0], 0x80); // 0x03 is a heart beat report! -#endif - return; - } - - uint16_t xbox = ButtonState & XBOX_BUTTONS[XBOX]; // Since the XBOX button is separate, save it and add it back in - // xbox button from before, dpad, abxy, start/back, sync, stick click, shoulder buttons - ButtonState = xbox | (((uint16_t)readBuf[5] & 0xF) << 8) | (readBuf[4] & 0xF0) | (((uint16_t)readBuf[4] & 0x0C) << 10) | ((readBuf[4] & 0x01) << 3) | (((uint16_t)readBuf[5] & 0xC0) << 8) | ((readBuf[5] & 0x30) >> 4); - - triggerValue[0] = (uint16_t)(((uint16_t)readBuf[7] << 8) | readBuf[6]); - triggerValue[1] = (uint16_t)(((uint16_t)readBuf[9] << 8) | readBuf[8]); - - hatValue[LeftHatX] = (int16_t)(((uint16_t)readBuf[11] << 8) | readBuf[10]); - hatValue[LeftHatY] = (int16_t)(((uint16_t)readBuf[13] << 8) | readBuf[12]); - hatValue[RightHatX] = (int16_t)(((uint16_t)readBuf[15] << 8) | readBuf[14]); - hatValue[RightHatY] = (int16_t)(((uint16_t)readBuf[17] << 8) | readBuf[16]); - - //Notify(PSTR("\r\nButtonState"), 0x80); - //PrintHex(ButtonState, 0x80); - - if(ButtonState != OldButtonState) { - ButtonClickState = ButtonState & ~OldButtonState; // Update click state variable - OldButtonState = ButtonState; - } - - // Handle click detection for triggers - if(triggerValue[0] != 0 && triggerValueOld[0] == 0) - L2Clicked = true; - triggerValueOld[0] = triggerValue[0]; - if(triggerValue[1] != 0 && triggerValueOld[1] == 0) - R2Clicked = true; - triggerValueOld[1] = triggerValue[1]; -} - -void XBOXONE::printReport() { //Uncomment "#define PRINTREPORT" to print the report send by the Xbox ONE Controller -#ifdef PRINTREPORT - if(readBuf == NULL) - return; - for(uint8_t i = 0; i < XBOX_REPORT_BUFFER_SIZE; i++) { - D_PrintHex (readBuf[i], 0x80); - Notify(PSTR(" "), 0x80); - } - Notify(PSTR("\r\n"), 0x80); -#endif -} - -uint16_t XBOXONE::getButtonPress(ButtonEnum b) { - if(b == L2) // These are analog buttons - return triggerValue[0]; - else if(b == R2) - return triggerValue[1]; - return (bool)(ButtonState & ((uint16_t)pgm_read_word(&XBOX_BUTTONS[(uint8_t)b]))); -} - -bool XBOXONE::getButtonClick(ButtonEnum b) { - if(b == L2) { - if(L2Clicked) { - L2Clicked = false; - return true; - } - return false; - } else if(b == R2) { - if(R2Clicked) { - R2Clicked = false; - return true; - } - return false; - } - uint16_t button = pgm_read_word(&XBOX_BUTTONS[(uint8_t)b]); - bool click = (ButtonClickState & button); - ButtonClickState &= ~button; // clear "click" event - return click; -} - -int16_t XBOXONE::getAnalogHat(AnalogHatEnum a) { - return hatValue[a]; -} - -/* Xbox Controller commands */ -uint8_t XBOXONE::XboxCommand(uint8_t* data, uint16_t nbytes) { - uint8_t rcode = pUsb->outTransfer(bAddress, epInfo[ XBOX_OUTPUT_PIPE ].epAddr, nbytes, data); -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nXboxCommand, Return: "), 0x80); - D_PrintHex (rcode, 0x80); -#endif - return rcode; -} - -void XBOXONE::onInit() { - // a short buzz to show the controller is active - writeBuf[0] = 0x09; - writeBuf[1] = 0x08; - writeBuf[2] = 0x00; - writeBuf[3] = 0x09; - writeBuf[4] = 0x00; - writeBuf[5] = 0x0f; - writeBuf[6] = 0x04; - writeBuf[7] = 0x04; - writeBuf[8] = 0x20; - writeBuf[9] = 0x20; - writeBuf[10] = 0x80; - XboxCommand(writeBuf, 11); - - if(pFuncOnInit) - pFuncOnInit(); // Call the user function -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/XBOXONE.h b/protocol/usb_hid/USB_Host_Shield_2.0/XBOXONE.h deleted file mode 100644 index 11710fcf..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/XBOXONE.h +++ /dev/null @@ -1,172 +0,0 @@ -/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. - Copyright (C) 2015 guruthree - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - - guruthree - Web : https://github.com/guruthree/ - */ - - -#ifndef _xboxone_h_ -#define _xboxone_h_ - -#include "Usb.h" -#include "xboxEnums.h" - -/* Data Xbox ONE taken from descriptors */ -#define EP_MAXPKTSIZE 32 // max size for data via USB - -/* Names we give to the 3 XboxONE pipes */ -#define XBOX_CONTROL_PIPE 0 -#define XBOX_OUTPUT_PIPE 1 -#define XBOX_INPUT_PIPE 2 - -// PID and VID of the different devices -#define XBOX_VID 0x045E // Microsoft Corporation -#define XBOX_ONE_PID 0x02D1 // Microsoft One Wired controller - -#define XBOX_REPORT_BUFFER_SIZE 14 // Size of the input report buffer - -#define XBOX_MAX_ENDPOINTS 3 - -/** This class implements support for a Xbox ONE controller connected via USB. */ -class XBOXONE : public USBDeviceConfig { -public: - /** - * Constructor for the XBOXONE class. - * @param pUsb Pointer to USB class instance. - */ - XBOXONE(USB *pUsb); - - /** @name USBDeviceConfig implementation */ - /** - * Initialize the Xbox Controller. - * @param parent Hub number. - * @param port Port number on the hub. - * @param lowspeed Speed of the device. - * @return 0 on success. - */ - virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - /** - * Release the USB device. - * @return 0 on success. - */ - virtual uint8_t Release(); - /** - * Poll the USB Input endpoins and run the state machines. - * @return 0 on success. - */ - virtual uint8_t Poll(); - - /** - * Get the device address. - * @return The device address. - */ - virtual uint8_t GetAddress() { - return bAddress; - }; - - /** - * Used to check if the controller has been initialized. - * @return True if it's ready. - */ - virtual bool isReady() { - return bPollEnable; - }; - - /** - * Used by the USB core to check what this driver support. - * @param vid The device's VID. - * @param pid The device's PID. - * @return Returns true if the device's VID and PID matches this driver. - */ - virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { - return (vid == XBOX_VID && pid == XBOX_ONE_PID); - }; - /**@}*/ - - /** @name Xbox Controller functions */ - /** - * getButtonPress(ButtonEnum b) will return true as long as the button is held down. - * - * While getButtonClick(ButtonEnum b) will only return it once. - * - * So you instance if you need to increase a variable once you would use getButtonClick(ButtonEnum b), - * but if you need to drive a robot forward you would use getButtonPress(ButtonEnum b). - * @param b ::ButtonEnum to read. - * @return getButtonClick(ButtonEnum b) will return a bool, while getButtonPress(ButtonEnum b) will return a word if reading ::L2 or ::R2. - */ - uint16_t getButtonPress(ButtonEnum b); - bool getButtonClick(ButtonEnum b); - - /** - * Return the analog value from the joysticks on the controller. - * @param a Either ::LeftHatX, ::LeftHatY, ::RightHatX or ::RightHatY. - * @return Returns a signed 16-bit integer. - */ - int16_t getAnalogHat(AnalogHatEnum a); - - /** - * Used to call your own function when the controller is successfully initialized. - * @param funcOnInit Function to call. - */ - void attachOnInit(void (*funcOnInit)(void)) { - pFuncOnInit = funcOnInit; - }; - /**@}*/ - - /** True if a Xbox ONE controller is connected. */ - bool XboxOneConnected; - -protected: - /** Pointer to USB class instance. */ - USB *pUsb; - /** Device address. */ - uint8_t bAddress; - /** Endpoint info structure. */ - EpInfo epInfo[XBOX_MAX_ENDPOINTS]; - -private: - /** - * Called when the controller is successfully initialized. - * Use attachOnInit(void (*funcOnInit)(void)) to call your own function. - */ - void onInit(); - void (*pFuncOnInit)(void); // Pointer to function called in onInit() - - bool bPollEnable; - - /* Variables to store the buttons */ - uint16_t ButtonState; - uint16_t OldButtonState; - uint16_t ButtonClickState; - int16_t hatValue[4]; - uint16_t triggerValue[2]; - uint16_t triggerValueOld[2]; - - bool L2Clicked; // These buttons are analog, so we use we use these bools to check if they where clicked or not - bool R2Clicked; - - uint8_t readBuf[EP_MAXPKTSIZE]; // General purpose buffer for input data - uint8_t writeBuf[12]; // General purpose buffer for output data - - void readReport(); // read incoming data - void printReport(); // print incoming date - Uncomment for debugging - - /* Private commands */ - uint8_t XboxCommand(uint8_t* data, uint16_t nbytes); -}; -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/XBOXRECV.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/XBOXRECV.cpp deleted file mode 100644 index 41f1ff58..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/XBOXRECV.cpp +++ /dev/null @@ -1,583 +0,0 @@ -/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - - getBatteryLevel and checkStatus functions made by timstamp.co.uk found using BusHound from Perisoft.net - */ - -#include "XBOXRECV.h" -// To enable serial debugging see "settings.h" -//#define EXTRADEBUG // Uncomment to get even more debugging data -//#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller - -XBOXRECV::XBOXRECV(USB *p) : -pUsb(p), // pointer to USB class instance - mandatory -bAddress(0), // device address - mandatory -bPollEnable(false) { // don't start polling before dongle is connected - for(uint8_t i = 0; i < XBOX_MAX_ENDPOINTS; i++) { - epInfo[i].epAddr = 0; - epInfo[i].maxPktSize = (i) ? 0 : 8; - epInfo[i].epAttribs = 0; - epInfo[i].bmNakPower = (i) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER; - } - - if(pUsb) // register in USB subsystem - pUsb->RegisterDeviceClass(this); //set devConfig[] entry -} - -uint8_t XBOXRECV::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) { - const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR); - uint8_t buf[constBufSize]; - USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); - uint8_t rcode; - UsbDevice *p = NULL; - EpInfo *oldep_ptr = NULL; - uint16_t PID, VID; - - AddressPool &addrPool = pUsb->GetAddressPool(); // Get memory address of USB device address pool -#ifdef EXTRADEBUG - Notify(PSTR("\r\nXBOXRECV Init"), 0x80); -#endif - - if(bAddress) { // Check if address has already been assigned to an instance -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nAddress in use"), 0x80); -#endif - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - } - - p = addrPool.GetUsbDevicePtr(0); // Get pointer to pseudo device with address 0 assigned - - if(!p) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nAddress not found"), 0x80); -#endif - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - } - - if(!p->epinfo) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nepinfo is null"), 0x80); -#endif - return USB_ERROR_EPINFO_IS_NULL; - } - - oldep_ptr = p->epinfo; // Save old pointer to EP_RECORD of address 0 - p->epinfo = epInfo; // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->lowspeed = lowspeed; - - rcode = pUsb->getDevDescr(0, 0, constBufSize, (uint8_t*)buf); // Get device descriptor - addr, ep, nbytes, data - - p->epinfo = oldep_ptr; // Restore p->epinfo - - if(rcode) - goto FailGetDevDescr; - - VID = udd->idVendor; - PID = udd->idProduct; - - if((VID != XBOX_VID && VID != MADCATZ_VID && VID != JOYTECH_VID) || (PID != XBOX_WIRELESS_RECEIVER_PID && PID != XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID)) { // Check if it's a Xbox receiver using the Vendor ID and Product ID -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nYou'll need a wireless receiver for this libary to work"), 0x80); -#endif - goto FailUnknownDevice; - } - - bAddress = addrPool.AllocAddress(parent, false, port); // Allocate new address according to device class - - if(!bAddress) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nOut of address space"), 0x80); -#endif - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - } - - epInfo[0].maxPktSize = udd->bMaxPacketSize0; // Extract Max Packet Size from device descriptor - - delay(20); // Wait a little before resetting device - - return USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET; - - /* Diagnostic messages */ -FailGetDevDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetDevDescr(rcode); -#endif - if(rcode != hrJERR) - rcode = USB_ERROR_FailGetDevDescr; - goto Fail; - -FailUnknownDevice: -#ifdef DEBUG_USB_HOST - NotifyFailUnknownDevice(VID, PID); -#endif - rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - -Fail: -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80); - NotifyFail(rcode); -#endif - Release(); - return rcode; -}; - -uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) { - uint8_t rcode; - - AddressPool &addrPool = pUsb->GetAddressPool(); -#ifdef EXTRADEBUG - Notify(PSTR("\r\nBTD Init"), 0x80); -#endif - UsbDevice *p = addrPool.GetUsbDevicePtr(bAddress); // Get pointer to assigned address record - - if(!p) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nAddress not found"), 0x80); -#endif - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - } - - delay(300); // Assign new address to the device - - rcode = pUsb->setAddr(0, 0, bAddress); // Assign new address to the device - if(rcode) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nsetAddr: "), 0x80); - D_PrintHex (rcode, 0x80); -#endif - p->lowspeed = false; - goto Fail; - } -#ifdef EXTRADEBUG - Notify(PSTR("\r\nAddr: "), 0x80); - D_PrintHex (bAddress, 0x80); -#endif - - p->lowspeed = false; - - p = addrPool.GetUsbDevicePtr(bAddress); // Get pointer to assigned address record - if(!p) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nAddress not found"), 0x80); -#endif - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - } - - p->lowspeed = lowspeed; - - rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo); // Assign epInfo to epinfo pointer - only EP0 is known - if(rcode) - goto FailSetDevTblEntry; - - /* The application will work in reduced host mode, so we can save program and data - memory space. After verifying the VID we will use known values for the - configuration values for device, interface, endpoints and HID for the XBOX360 Wireless receiver */ - - /* Initialize data structures for endpoints of device */ - epInfo[ XBOX_INPUT_PIPE_1 ].epAddr = 0x01; // XBOX 360 report endpoint - poll interval 1ms - epInfo[ XBOX_INPUT_PIPE_1 ].epAttribs = USB_TRANSFER_TYPE_INTERRUPT; - epInfo[ XBOX_INPUT_PIPE_1 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints - epInfo[ XBOX_INPUT_PIPE_1 ].maxPktSize = EP_MAXPKTSIZE; - epInfo[ XBOX_INPUT_PIPE_1 ].bmSndToggle = 0; - epInfo[ XBOX_INPUT_PIPE_1 ].bmRcvToggle = 0; - epInfo[ XBOX_OUTPUT_PIPE_1 ].epAddr = 0x01; // XBOX 360 output endpoint - poll interval 8ms - epInfo[ XBOX_OUTPUT_PIPE_1 ].epAttribs = USB_TRANSFER_TYPE_INTERRUPT; - epInfo[ XBOX_OUTPUT_PIPE_1 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints - epInfo[ XBOX_OUTPUT_PIPE_1 ].maxPktSize = EP_MAXPKTSIZE; - epInfo[ XBOX_OUTPUT_PIPE_1 ].bmSndToggle = 0; - epInfo[ XBOX_OUTPUT_PIPE_1 ].bmRcvToggle = 0; - - epInfo[ XBOX_INPUT_PIPE_2 ].epAddr = 0x03; // XBOX 360 report endpoint - poll interval 1ms - epInfo[ XBOX_INPUT_PIPE_2 ].epAttribs = USB_TRANSFER_TYPE_INTERRUPT; - epInfo[ XBOX_INPUT_PIPE_2 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints - epInfo[ XBOX_INPUT_PIPE_2 ].maxPktSize = EP_MAXPKTSIZE; - epInfo[ XBOX_INPUT_PIPE_2 ].bmSndToggle = 0; - epInfo[ XBOX_INPUT_PIPE_2 ].bmRcvToggle = 0; - epInfo[ XBOX_OUTPUT_PIPE_2 ].epAddr = 0x03; // XBOX 360 output endpoint - poll interval 8ms - epInfo[ XBOX_OUTPUT_PIPE_2 ].epAttribs = USB_TRANSFER_TYPE_INTERRUPT; - epInfo[ XBOX_OUTPUT_PIPE_2 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints - epInfo[ XBOX_OUTPUT_PIPE_2 ].maxPktSize = EP_MAXPKTSIZE; - epInfo[ XBOX_OUTPUT_PIPE_2 ].bmSndToggle = 0; - epInfo[ XBOX_OUTPUT_PIPE_2 ].bmRcvToggle = 0; - - epInfo[ XBOX_INPUT_PIPE_3 ].epAddr = 0x05; // XBOX 360 report endpoint - poll interval 1ms - epInfo[ XBOX_INPUT_PIPE_3 ].epAttribs = USB_TRANSFER_TYPE_INTERRUPT; - epInfo[ XBOX_INPUT_PIPE_3 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints - epInfo[ XBOX_INPUT_PIPE_3 ].maxPktSize = EP_MAXPKTSIZE; - epInfo[ XBOX_INPUT_PIPE_3 ].bmSndToggle = 0; - epInfo[ XBOX_INPUT_PIPE_3 ].bmRcvToggle = 0; - epInfo[ XBOX_OUTPUT_PIPE_3 ].epAddr = 0x05; // XBOX 360 output endpoint - poll interval 8ms - epInfo[ XBOX_OUTPUT_PIPE_3 ].epAttribs = USB_TRANSFER_TYPE_INTERRUPT; - epInfo[ XBOX_OUTPUT_PIPE_3 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints - epInfo[ XBOX_OUTPUT_PIPE_3 ].maxPktSize = EP_MAXPKTSIZE; - epInfo[ XBOX_OUTPUT_PIPE_3 ].bmSndToggle = 0; - epInfo[ XBOX_OUTPUT_PIPE_3 ].bmRcvToggle = 0; - - epInfo[ XBOX_INPUT_PIPE_4 ].epAddr = 0x07; // XBOX 360 report endpoint - poll interval 1ms - epInfo[ XBOX_INPUT_PIPE_4 ].epAttribs = USB_TRANSFER_TYPE_INTERRUPT; - epInfo[ XBOX_INPUT_PIPE_4 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints - epInfo[ XBOX_INPUT_PIPE_4 ].maxPktSize = EP_MAXPKTSIZE; - epInfo[ XBOX_INPUT_PIPE_4 ].bmSndToggle = 0; - epInfo[ XBOX_INPUT_PIPE_4 ].bmRcvToggle = 0; - epInfo[ XBOX_OUTPUT_PIPE_4 ].epAddr = 0x07; // XBOX 360 output endpoint - poll interval 8ms - epInfo[ XBOX_OUTPUT_PIPE_4 ].epAttribs = USB_TRANSFER_TYPE_INTERRUPT; - epInfo[ XBOX_OUTPUT_PIPE_4 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints - epInfo[ XBOX_OUTPUT_PIPE_4 ].maxPktSize = EP_MAXPKTSIZE; - epInfo[ XBOX_OUTPUT_PIPE_4 ].bmSndToggle = 0; - epInfo[ XBOX_OUTPUT_PIPE_4 ].bmRcvToggle = 0; - - rcode = pUsb->setEpInfoEntry(bAddress, 9, epInfo); - if(rcode) - goto FailSetDevTblEntry; - - delay(200); //Give time for address change - - rcode = pUsb->setConf(bAddress, epInfo[ XBOX_CONTROL_PIPE ].epAddr, 1); - if(rcode) - goto FailSetConfDescr; - -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nXbox Wireless Receiver Connected\r\n"), 0x80); -#endif - XboxReceiverConnected = true; - bPollEnable = true; - checkStatusTimer = 0; // Reset timer - return 0; // Successful configuration - - /* Diagnostic messages */ -FailSetDevTblEntry: -#ifdef DEBUG_USB_HOST - NotifyFailSetDevTblEntry(); - goto Fail; -#endif - -FailSetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailSetConfDescr(); -#endif - -Fail: -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80); - NotifyFail(rcode); -#endif - Release(); - return rcode; -} - -/* Performs a cleanup after failed Init() attempt */ -uint8_t XBOXRECV::Release() { - XboxReceiverConnected = false; - for(uint8_t i = 0; i < 4; i++) - Xbox360Connected[i] = 0x00; - pUsb->GetAddressPool().FreeAddress(bAddress); - bAddress = 0; - bPollEnable = false; - return 0; -} - -uint8_t XBOXRECV::Poll() { - if(!bPollEnable) - return 0; - if(!checkStatusTimer || ((millis() - checkStatusTimer) > 3000)) { // Run checkStatus every 3 seconds - checkStatusTimer = millis(); - checkStatus(); - } - - uint8_t inputPipe; - uint16_t bufferSize; - for(uint8_t i = 0; i < 4; i++) { - if(i == 0) - inputPipe = XBOX_INPUT_PIPE_1; - else if(i == 1) - inputPipe = XBOX_INPUT_PIPE_2; - else if(i == 2) - inputPipe = XBOX_INPUT_PIPE_3; - else - inputPipe = XBOX_INPUT_PIPE_4; - - bufferSize = EP_MAXPKTSIZE; // This is the maximum number of bytes we want to receive - pUsb->inTransfer(bAddress, epInfo[ inputPipe ].epAddr, &bufferSize, readBuf); - if(bufferSize > 0) { // The number of received bytes -#ifdef EXTRADEBUG - Notify(PSTR("Bytes Received: "), 0x80); - D_PrintHex (bufferSize, 0x80); - Notify(PSTR("\r\n"), 0x80); -#endif - readReport(i); -#ifdef PRINTREPORT - printReport(i, bufferSize); // Uncomment "#define PRINTREPORT" to print the report send by the Xbox 360 Controller -#endif - } - } - return 0; -} - -void XBOXRECV::readReport(uint8_t controller) { - if(readBuf == NULL) - return; - // This report is send when a controller is connected and disconnected - if(readBuf[0] == 0x08 && readBuf[1] != Xbox360Connected[controller]) { - Xbox360Connected[controller] = readBuf[1]; -#ifdef DEBUG_USB_HOST - Notify(PSTR("Controller "), 0x80); - Notify(controller, 0x80); -#endif - if(Xbox360Connected[controller]) { -#ifdef DEBUG_USB_HOST - const char* str = 0; - switch(readBuf[1]) { - case 0x80: str = PSTR(" as controller\r\n"); - break; - case 0x40: str = PSTR(" as headset\r\n"); - break; - case 0xC0: str = PSTR(" as controller+headset\r\n"); - break; - } - Notify(PSTR(": connected"), 0x80); - Notify(str, 0x80); -#endif - onInit(controller); - } -#ifdef DEBUG_USB_HOST - else - Notify(PSTR(": disconnected\r\n"), 0x80); -#endif - return; - } - // Controller status report - if(readBuf[1] == 0x00 && readBuf[3] & 0x13 && readBuf[4] >= 0x22) { - controllerStatus[controller] = ((uint16_t)readBuf[3] << 8) | readBuf[4]; - return; - } - if(readBuf[1] != 0x01) // Check if it's the correct report - the receiver also sends different status reports - return; - - // A controller must be connected if it's sending data - if(!Xbox360Connected[controller]) - Xbox360Connected[controller] |= 0x80; - - ButtonState[controller] = (uint32_t)(readBuf[9] | ((uint16_t)readBuf[8] << 8) | ((uint32_t)readBuf[7] << 16) | ((uint32_t)readBuf[6] << 24)); - - hatValue[controller][LeftHatX] = (int16_t)(((uint16_t)readBuf[11] << 8) | readBuf[10]); - hatValue[controller][LeftHatY] = (int16_t)(((uint16_t)readBuf[13] << 8) | readBuf[12]); - hatValue[controller][RightHatX] = (int16_t)(((uint16_t)readBuf[15] << 8) | readBuf[14]); - hatValue[controller][RightHatY] = (int16_t)(((uint16_t)readBuf[17] << 8) | readBuf[16]); - - //Notify(PSTR("\r\nButtonState: "), 0x80); - //PrintHex(ButtonState[controller], 0x80); - - if(ButtonState[controller] != OldButtonState[controller]) { - buttonStateChanged[controller] = true; - ButtonClickState[controller] = (ButtonState[controller] >> 16) & ((~OldButtonState[controller]) >> 16); // Update click state variable, but don't include the two trigger buttons L2 and R2 - if(((uint8_t)OldButtonState[controller]) == 0 && ((uint8_t)ButtonState[controller]) != 0) // The L2 and R2 buttons are special as they are analog buttons - R2Clicked[controller] = true; - if((uint8_t)(OldButtonState[controller] >> 8) == 0 && (uint8_t)(ButtonState[controller] >> 8) != 0) - L2Clicked[controller] = true; - OldButtonState[controller] = ButtonState[controller]; - } -} - -void XBOXRECV::printReport(uint8_t controller, uint8_t nBytes) { //Uncomment "#define PRINTREPORT" to print the report send by the Xbox 360 Controller -#ifdef PRINTREPORT - if(readBuf == NULL) - return; - Notify(PSTR("Controller "), 0x80); - Notify(controller, 0x80); - Notify(PSTR(": "), 0x80); - for(uint8_t i = 0; i < nBytes; i++) { - D_PrintHex (readBuf[i], 0x80); - Notify(PSTR(" "), 0x80); - } - Notify(PSTR("\r\n"), 0x80); -#endif -} - -uint8_t XBOXRECV::getButtonPress(ButtonEnum b, uint8_t controller) { - if(b == L2) // These are analog buttons - return (uint8_t)(ButtonState[controller] >> 8); - else if(b == R2) - return (uint8_t)ButtonState[controller]; - return (bool)(ButtonState[controller] & ((uint32_t)pgm_read_word(&XBOX_BUTTONS[(uint8_t)b]) << 16)); -} - -bool XBOXRECV::getButtonClick(ButtonEnum b, uint8_t controller) { - if(b == L2) { - if(L2Clicked[controller]) { - L2Clicked[controller] = false; - return true; - } - return false; - } else if(b == R2) { - if(R2Clicked[controller]) { - R2Clicked[controller] = false; - return true; - } - return false; - } - uint16_t button = pgm_read_word(&XBOX_BUTTONS[(uint8_t)b]); - bool click = (ButtonClickState[controller] & button); - ButtonClickState[controller] &= ~button; // clear "click" event - return click; -} - -int16_t XBOXRECV::getAnalogHat(AnalogHatEnum a, uint8_t controller) { - return hatValue[controller][a]; -} - -bool XBOXRECV::buttonChanged(uint8_t controller) { - bool state = buttonStateChanged[controller]; - buttonStateChanged[controller] = false; - return state; -} - -/* -ControllerStatus Breakdown -ControllerStatus[controller] & 0x0001 // 0 -ControllerStatus[controller] & 0x0002 // normal batteries, no rechargeable battery pack -ControllerStatus[controller] & 0x0004 // controller starting up / settling -ControllerStatus[controller] & 0x0008 // headset adapter plugged in, but no headphones connected (mute?) -ControllerStatus[controller] & 0x0010 // 0 -ControllerStatus[controller] & 0x0020 // 1 -ControllerStatus[controller] & 0x0040 // battery level (high bit) -ControllerStatus[controller] & 0x0080 // battery level (low bit) -ControllerStatus[controller] & 0x0100 // 1 -ControllerStatus[controller] & 0x0200 // 1 -ControllerStatus[controller] & 0x0400 // headset adapter plugged in -ControllerStatus[controller] & 0x0800 // 0 -ControllerStatus[controller] & 0x1000 // 1 -ControllerStatus[controller] & 0x2000 // 0 -ControllerStatus[controller] & 0x4000 // 0 -ControllerStatus[controller] & 0x8000 // 0 - */ -uint8_t XBOXRECV::getBatteryLevel(uint8_t controller) { - return ((controllerStatus[controller] & 0x00C0) >> 6); -} - -void XBOXRECV::XboxCommand(uint8_t controller, uint8_t* data, uint16_t nbytes) { -#ifdef EXTRADEBUG - uint8_t rcode; -#endif - uint8_t outputPipe; - switch(controller) { - case 0: outputPipe = XBOX_OUTPUT_PIPE_1; - break; - case 1: outputPipe = XBOX_OUTPUT_PIPE_2; - break; - case 2: outputPipe = XBOX_OUTPUT_PIPE_3; - break; - case 3: outputPipe = XBOX_OUTPUT_PIPE_4; - break; - default: - return; - } -#ifdef EXTRADEBUG - rcode = -#endif - pUsb->outTransfer(bAddress, epInfo[ outputPipe ].epAddr, nbytes, data); -#ifdef EXTRADEBUG - if(rcode) - Notify(PSTR("Error sending Xbox message\r\n"), 0x80); -#endif -} - -void XBOXRECV::disconnect(uint8_t controller) { - writeBuf[0] = 0x00; - writeBuf[1] = 0x00; - writeBuf[2] = 0x08; - writeBuf[3] = 0xC0; - - XboxCommand(controller, writeBuf, 4); -} - -void XBOXRECV::setLedRaw(uint8_t value, uint8_t controller) { - writeBuf[0] = 0x00; - writeBuf[1] = 0x00; - writeBuf[2] = 0x08; - writeBuf[3] = value | 0x40; - - XboxCommand(controller, writeBuf, 4); -} - -void XBOXRECV::setLedOn(LEDEnum led, uint8_t controller) { - if(led == OFF) - setLedRaw(0, controller); - else if(led != ALL) // All LEDs can't be on a the same time - setLedRaw(pgm_read_byte(&XBOX_LEDS[(uint8_t)led]) + 4, controller); -} - -void XBOXRECV::setLedBlink(LEDEnum led, uint8_t controller) { - setLedRaw(pgm_read_byte(&XBOX_LEDS[(uint8_t)led]), controller); -} - -void XBOXRECV::setLedMode(LEDModeEnum ledMode, uint8_t controller) { // This function is used to do some speciel LED stuff the controller supports - setLedRaw((uint8_t)ledMode, controller); -} - -/* PC runs this at interval of approx 2 seconds -Thanks to BusHound from Perisoft.net for the Windows USB Analysis output -Found by timstamp.co.uk - */ -void XBOXRECV::checkStatus() { - if(!bPollEnable) - return; - // Get controller info - writeBuf[0] = 0x08; - writeBuf[1] = 0x00; - writeBuf[2] = 0x0f; - writeBuf[3] = 0xc0; - for(uint8_t i = 0; i < 4; i++) { - XboxCommand(i, writeBuf, 4); - } - // Get battery status - writeBuf[0] = 0x00; - writeBuf[1] = 0x00; - writeBuf[2] = 0x00; - writeBuf[3] = 0x40; - for(uint8_t i = 0; i < 4; i++) { - if(Xbox360Connected[i]) - XboxCommand(i, writeBuf, 4); - } -} - -void XBOXRECV::setRumbleOn(uint8_t lValue, uint8_t rValue, uint8_t controller) { - writeBuf[0] = 0x00; - writeBuf[1] = 0x01; - writeBuf[2] = 0x0f; - writeBuf[3] = 0xc0; - writeBuf[4] = 0x00; - writeBuf[5] = lValue; // big weight - writeBuf[6] = rValue; // small weight - - XboxCommand(controller, writeBuf, 7); -} - -void XBOXRECV::onInit(uint8_t controller) { - if(pFuncOnInit) - pFuncOnInit(); // Call the user function - else { - LEDEnum led; - if(controller == 0) - led = LED1; - else if(controller == 1) - led = LED2; - else if(controller == 2) - led = LED3; - else - led = LED4; - setLedOn(led, controller); - } -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/XBOXRECV.h b/protocol/usb_hid/USB_Host_Shield_2.0/XBOXRECV.h deleted file mode 100644 index 4f921465..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/XBOXRECV.h +++ /dev/null @@ -1,276 +0,0 @@ -/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - - getBatteryLevel and checkStatus functions made by timstamp.co.uk found using BusHound from Perisoft.net - */ - -#ifndef _xboxrecv_h_ -#define _xboxrecv_h_ - -#include "Usb.h" -#include "xboxEnums.h" - -/* Data Xbox 360 taken from descriptors */ -#define EP_MAXPKTSIZE 32 // max size for data via USB - -/* Names we give to the 9 Xbox360 pipes */ -#define XBOX_CONTROL_PIPE 0 -#define XBOX_INPUT_PIPE_1 1 -#define XBOX_OUTPUT_PIPE_1 2 -#define XBOX_INPUT_PIPE_2 3 -#define XBOX_OUTPUT_PIPE_2 4 -#define XBOX_INPUT_PIPE_3 5 -#define XBOX_OUTPUT_PIPE_3 6 -#define XBOX_INPUT_PIPE_4 7 -#define XBOX_OUTPUT_PIPE_4 8 - -// PID and VID of the different devices -#define XBOX_VID 0x045E // Microsoft Corporation -#define MADCATZ_VID 0x1BAD // For unofficial Mad Catz receivers -#define JOYTECH_VID 0x162E // For unofficial Joytech controllers - -#define XBOX_WIRELESS_RECEIVER_PID 0x0719 // Microsoft Wireless Gaming Receiver -#define XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID 0x0291 // Third party Wireless Gaming Receiver - -#define XBOX_MAX_ENDPOINTS 9 - -/** - * This class implements support for a Xbox Wireless receiver. - * - * Up to four controllers can connect to one receiver, if more is needed one can use a second receiver via the USBHub class. - */ -class XBOXRECV : public USBDeviceConfig { -public: - /** - * Constructor for the XBOXRECV class. - * @param pUsb Pointer to USB class instance. - */ - XBOXRECV(USB *pUsb); - - /** @name USBDeviceConfig implementation */ - /** - * Address assignment and basic initilization is done here. - * @param parent Hub number. - * @param port Port number on the hub. - * @param lowspeed Speed of the device. - * @return 0 on success. - */ - uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed); - /** - * Initialize the Xbox wireless receiver. - * @param parent Hub number. - * @param port Port number on the hub. - * @param lowspeed Speed of the device. - * @return 0 on success. - */ - uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - /** - * Release the USB device. - * @return 0 on success. - */ - uint8_t Release(); - /** - * Poll the USB Input endpoins and run the state machines. - * @return 0 on success. - */ - uint8_t Poll(); - - /** - * Get the device address. - * @return The device address. - */ - virtual uint8_t GetAddress() { - return bAddress; - }; - - /** - * Used to check if the controller has been initialized. - * @return True if it's ready. - */ - virtual bool isReady() { - return bPollEnable; - }; - - /** - * Used by the USB core to check what this driver support. - * @param vid The device's VID. - * @param pid The device's PID. - * @return Returns true if the device's VID and PID matches this driver. - */ - virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { - return ((vid == XBOX_VID || vid == MADCATZ_VID || vid == JOYTECH_VID) && (pid == XBOX_WIRELESS_RECEIVER_PID || pid == XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID)); - }; - /**@}*/ - - /** @name Xbox Controller functions */ - /** - * getButtonPress(uint8_t controller, ButtonEnum b) will return true as long as the button is held down. - * - * While getButtonClick(uint8_t controller, ButtonEnum b) will only return it once. - * - * So you instance if you need to increase a variable once you would use getButtonClick(uint8_t controller, ButtonEnum b), - * but if you need to drive a robot forward you would use getButtonPress(uint8_t controller, ButtonEnum b). - * @param b ::ButtonEnum to read. - * @param controller The controller to read from. Default to 0. - * @return getButtonClick(uint8_t controller, ButtonEnum b) will return a bool, while getButtonPress(uint8_t controller, ButtonEnum b) will return a byte if reading ::L2 or ::R2. - */ - uint8_t getButtonPress(ButtonEnum b, uint8_t controller = 0); - bool getButtonClick(ButtonEnum b, uint8_t controller = 0); - /**@}*/ - - /** @name Xbox Controller functions */ - /** - * Return the analog value from the joysticks on the controller. - * @param a Either ::LeftHatX, ::LeftHatY, ::RightHatX or ::RightHatY. - * @param controller The controller to read from. Default to 0. - * @return Returns a signed 16-bit integer. - */ - int16_t getAnalogHat(AnalogHatEnum a, uint8_t controller = 0); - - /** - * Used to disconnect any of the controllers. - * @param controller The controller to disconnect. Default to 0. - */ - void disconnect(uint8_t controller = 0); - - /** - * Turn rumble off and all the LEDs on the specific controller. - * @param controller The controller to write to. Default to 0. - */ - void setAllOff(uint8_t controller = 0) { - setRumbleOn(0, 0, controller); - setLedOff(controller); - }; - - /** - * Turn rumble off the specific controller. - * @param controller The controller to write to. Default to 0. - */ - void setRumbleOff(uint8_t controller = 0) { - setRumbleOn(0, 0, controller); - }; - /** - * Turn rumble on. - * @param lValue Left motor (big weight) inside the controller. - * @param rValue Right motor (small weight) inside the controller. - * @param controller The controller to write to. Default to 0. - */ - void setRumbleOn(uint8_t lValue, uint8_t rValue, uint8_t controller = 0); - /** - * Set LED value. Without using the ::LEDEnum or ::LEDModeEnum. - * @param value See: - * setLedOff(uint8_t controller), setLedOn(uint8_t controller, LED l), - * setLedBlink(uint8_t controller, LED l), and setLedMode(uint8_t controller, LEDMode lm). - * @param controller The controller to write to. Default to 0. - */ - void setLedRaw(uint8_t value, uint8_t controller = 0); - - /** - * Turn all LEDs off the specific controller. - * @param controller The controller to write to. Default to 0. - */ - void setLedOff(uint8_t controller = 0) { - setLedRaw(0, controller); - }; - /** - * Turn on a LED by using ::LEDEnum. - * @param l ::OFF, ::LED1, ::LED2, ::LED3 and ::LED4 is supported by the Xbox controller. - * @param controller The controller to write to. Default to 0. - */ - void setLedOn(LEDEnum l, uint8_t controller = 0); - /** - * Turn on a LED by using ::LEDEnum. - * @param l ::ALL, ::LED1, ::LED2, ::LED3 and ::LED4 is supported by the Xbox controller. - * @param controller The controller to write to. Default to 0. - */ - void setLedBlink(LEDEnum l, uint8_t controller = 0); - /** - * Used to set special LED modes supported by the Xbox controller. - * @param lm See ::LEDModeEnum. - * @param controller The controller to write to. Default to 0. - */ - void setLedMode(LEDModeEnum lm, uint8_t controller = 0); - /** - * Used to get the battery level from the controller. - * @param controller The controller to read from. Default to 0. - * @return Returns the battery level as an integer in the range of 0-3. - */ - uint8_t getBatteryLevel(uint8_t controller = 0); - /** - * Used to check if a button has changed. - * @param controller The controller to read from. Default to 0. - * @return True if a button has changed. - */ - bool buttonChanged(uint8_t controller = 0); - - /** - * Used to call your own function when the controller is successfully initialized. - * @param funcOnInit Function to call. - */ - void attachOnInit(void (*funcOnInit)(void)) { - pFuncOnInit = funcOnInit; - }; - /**@}*/ - - /** True if a wireless receiver is connected. */ - bool XboxReceiverConnected; - /** Variable used to indicate if the XBOX 360 controller is successfully connected. */ - uint8_t Xbox360Connected[4]; - -protected: - /** Pointer to USB class instance. */ - USB *pUsb; - /** Device address. */ - uint8_t bAddress; - /** Endpoint info structure. */ - EpInfo epInfo[XBOX_MAX_ENDPOINTS]; - -private: - /** - * Called when the controller is successfully initialized. - * Use attachOnInit(void (*funcOnInit)(void)) to call your own function. - * This is useful for instance if you want to set the LEDs in a specific way. - * @param controller The initialized controller. - */ - void onInit(uint8_t controller); - void (*pFuncOnInit)(void); // Pointer to function called in onInit() - - bool bPollEnable; - - /* Variables to store the buttons */ - uint32_t ButtonState[4]; - uint32_t OldButtonState[4]; - uint16_t ButtonClickState[4]; - int16_t hatValue[4][4]; - uint16_t controllerStatus[4]; - bool buttonStateChanged[4]; // True if a button has changed - - bool L2Clicked[4]; // These buttons are analog, so we use we use these bools to check if they where clicked or not - bool R2Clicked[4]; - - uint32_t checkStatusTimer; // Timing for checkStatus() signals - - uint8_t readBuf[EP_MAXPKTSIZE]; // General purpose buffer for input data - uint8_t writeBuf[7]; // General purpose buffer for output data - - void readReport(uint8_t controller); // read incoming data - void printReport(uint8_t controller, uint8_t nBytes); // print incoming date - Uncomment for debugging - - /* Private commands */ - void XboxCommand(uint8_t controller, uint8_t* data, uint16_t nbytes); - void checkStatus(); -}; -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/XBOXUSB.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/XBOXUSB.cpp deleted file mode 100644 index ddece21b..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/XBOXUSB.cpp +++ /dev/null @@ -1,361 +0,0 @@ -/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#include "XBOXUSB.h" -// To enable serial debugging see "settings.h" -//#define EXTRADEBUG // Uncomment to get even more debugging data -//#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller - -XBOXUSB::XBOXUSB(USB *p) : -pUsb(p), // pointer to USB class instance - mandatory -bAddress(0), // device address - mandatory -bPollEnable(false) { // don't start polling before dongle is connected - for(uint8_t i = 0; i < XBOX_MAX_ENDPOINTS; i++) { - epInfo[i].epAddr = 0; - epInfo[i].maxPktSize = (i) ? 0 : 8; - epInfo[i].epAttribs = 0; - epInfo[i].bmNakPower = (i) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER; - } - - if(pUsb) // register in USB subsystem - pUsb->RegisterDeviceClass(this); //set devConfig[] entry -} - -uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) { - uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)]; - USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); - uint8_t rcode; - UsbDevice *p = NULL; - EpInfo *oldep_ptr = NULL; - uint16_t PID; - uint16_t VID; - - // get memory address of USB device address pool - AddressPool &addrPool = pUsb->GetAddressPool(); -#ifdef EXTRADEBUG - Notify(PSTR("\r\nXBOXUSB Init"), 0x80); -#endif - // check if address has already been assigned to an instance - if(bAddress) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nAddress in use"), 0x80); -#endif - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - } - - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - - if(!p) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nAddress not found"), 0x80); -#endif - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - } - - if(!p->epinfo) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nepinfo is null"), 0x80); -#endif - return USB_ERROR_EPINFO_IS_NULL; - } - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - - p->lowspeed = lowspeed; - - // Get device descriptor - rcode = pUsb->getDevDescr(0, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*)buf); // Get device descriptor - addr, ep, nbytes, data - // Restore p->epinfo - p->epinfo = oldep_ptr; - - if(rcode) - goto FailGetDevDescr; - - VID = udd->idVendor; - PID = udd->idProduct; - - if(VID != XBOX_VID && VID != MADCATZ_VID && VID != JOYTECH_VID && VID != GAMESTOP_VID) // Check VID - goto FailUnknownDevice; - if(PID == XBOX_WIRELESS_PID) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nYou have plugged in a wireless Xbox 360 controller - it doesn't support USB communication"), 0x80); -#endif - goto FailUnknownDevice; - } else if(PID == XBOX_WIRELESS_RECEIVER_PID || PID == XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID) { -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nThis library only supports Xbox 360 controllers via USB"), 0x80); -#endif - goto FailUnknownDevice; - } else if(PID != XBOX_WIRED_PID && PID != MADCATZ_WIRED_PID && PID != GAMESTOP_WIRED_PID && PID != AFTERGLOW_WIRED_PID && PID != JOYTECH_WIRED_PID) // Check PID - goto FailUnknownDevice; - - // Allocate new address according to device class - bAddress = addrPool.AllocAddress(parent, false, port); - - if(!bAddress) - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - - // Extract Max Packet Size from device descriptor - epInfo[0].maxPktSize = udd->bMaxPacketSize0; - - // Assign new address to the device - rcode = pUsb->setAddr(0, 0, bAddress); - if(rcode) { - p->lowspeed = false; - addrPool.FreeAddress(bAddress); - bAddress = 0; -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nsetAddr: "), 0x80); - D_PrintHex (rcode, 0x80); -#endif - return rcode; - } -#ifdef EXTRADEBUG - Notify(PSTR("\r\nAddr: "), 0x80); - D_PrintHex (bAddress, 0x80); -#endif - //delay(300); // Spec says you should wait at least 200ms - - p->lowspeed = false; - - //get pointer to assigned address record - p = addrPool.GetUsbDevicePtr(bAddress); - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - p->lowspeed = lowspeed; - - // Assign epInfo to epinfo pointer - only EP0 is known - rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo); - if(rcode) - goto FailSetDevTblEntry; - - /* The application will work in reduced host mode, so we can save program and data - memory space. After verifying the VID we will use known values for the - configuration values for device, interface, endpoints and HID for the XBOX360 Controllers */ - - /* Initialize data structures for endpoints of device */ - epInfo[ XBOX_INPUT_PIPE ].epAddr = 0x01; // XBOX 360 report endpoint - epInfo[ XBOX_INPUT_PIPE ].epAttribs = USB_TRANSFER_TYPE_INTERRUPT; - epInfo[ XBOX_INPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints - epInfo[ XBOX_INPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE; - epInfo[ XBOX_INPUT_PIPE ].bmSndToggle = 0; - epInfo[ XBOX_INPUT_PIPE ].bmRcvToggle = 0; - epInfo[ XBOX_OUTPUT_PIPE ].epAddr = 0x02; // XBOX 360 output endpoint - epInfo[ XBOX_OUTPUT_PIPE ].epAttribs = USB_TRANSFER_TYPE_INTERRUPT; - epInfo[ XBOX_OUTPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints - epInfo[ XBOX_OUTPUT_PIPE ].maxPktSize = EP_MAXPKTSIZE; - epInfo[ XBOX_OUTPUT_PIPE ].bmSndToggle = 0; - epInfo[ XBOX_OUTPUT_PIPE ].bmRcvToggle = 0; - - rcode = pUsb->setEpInfoEntry(bAddress, 3, epInfo); - if(rcode) - goto FailSetDevTblEntry; - - delay(200); // Give time for address change - - rcode = pUsb->setConf(bAddress, epInfo[ XBOX_CONTROL_PIPE ].epAddr, 1); - if(rcode) - goto FailSetConfDescr; - -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nXbox 360 Controller Connected\r\n"), 0x80); -#endif - onInit(); - Xbox360Connected = true; - bPollEnable = true; - return 0; // Successful configuration - - /* Diagnostic messages */ -FailGetDevDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetDevDescr(); - goto Fail; -#endif - -FailSetDevTblEntry: -#ifdef DEBUG_USB_HOST - NotifyFailSetDevTblEntry(); - goto Fail; -#endif - -FailSetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailSetConfDescr(); -#endif - goto Fail; - -FailUnknownDevice: -#ifdef DEBUG_USB_HOST - NotifyFailUnknownDevice(VID, PID); -#endif - rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - -Fail: -#ifdef DEBUG_USB_HOST - Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80); - NotifyFail(rcode); -#endif - Release(); - return rcode; -} - -/* Performs a cleanup after failed Init() attempt */ -uint8_t XBOXUSB::Release() { - Xbox360Connected = false; - pUsb->GetAddressPool().FreeAddress(bAddress); - bAddress = 0; - bPollEnable = false; - return 0; -} - -uint8_t XBOXUSB::Poll() { - if(!bPollEnable) - return 0; - uint16_t BUFFER_SIZE = EP_MAXPKTSIZE; - pUsb->inTransfer(bAddress, epInfo[ XBOX_INPUT_PIPE ].epAddr, &BUFFER_SIZE, readBuf); // input on endpoint 1 - readReport(); -#ifdef PRINTREPORT - printReport(); // Uncomment "#define PRINTREPORT" to print the report send by the Xbox 360 Controller -#endif - return 0; -} - -void XBOXUSB::readReport() { - if(readBuf == NULL) - return; - if(readBuf[0] != 0x00 || readBuf[1] != 0x14) { // Check if it's the correct report - the controller also sends different status reports - return; - } - - ButtonState = (uint32_t)(readBuf[5] | ((uint16_t)readBuf[4] << 8) | ((uint32_t)readBuf[3] << 16) | ((uint32_t)readBuf[2] << 24)); - - hatValue[LeftHatX] = (int16_t)(((uint16_t)readBuf[7] << 8) | readBuf[6]); - hatValue[LeftHatY] = (int16_t)(((uint16_t)readBuf[9] << 8) | readBuf[8]); - hatValue[RightHatX] = (int16_t)(((uint16_t)readBuf[11] << 8) | readBuf[10]); - hatValue[RightHatY] = (int16_t)(((uint16_t)readBuf[13] << 8) | readBuf[12]); - - //Notify(PSTR("\r\nButtonState"), 0x80); - //PrintHex(ButtonState, 0x80); - - if(ButtonState != OldButtonState) { - ButtonClickState = (ButtonState >> 16) & ((~OldButtonState) >> 16); // Update click state variable, but don't include the two trigger buttons L2 and R2 - if(((uint8_t)OldButtonState) == 0 && ((uint8_t)ButtonState) != 0) // The L2 and R2 buttons are special as they are analog buttons - R2Clicked = true; - if((uint8_t)(OldButtonState >> 8) == 0 && (uint8_t)(ButtonState >> 8) != 0) - L2Clicked = true; - OldButtonState = ButtonState; - } -} - -void XBOXUSB::printReport() { //Uncomment "#define PRINTREPORT" to print the report send by the Xbox 360 Controller -#ifdef PRINTREPORT - if(readBuf == NULL) - return; - for(uint8_t i = 0; i < XBOX_REPORT_BUFFER_SIZE; i++) { - D_PrintHex (readBuf[i], 0x80); - Notify(PSTR(" "), 0x80); - } - Notify(PSTR("\r\n"), 0x80); -#endif -} - -uint8_t XBOXUSB::getButtonPress(ButtonEnum b) { - if(b == L2) // These are analog buttons - return (uint8_t)(ButtonState >> 8); - else if(b == R2) - return (uint8_t)ButtonState; - return (bool)(ButtonState & ((uint32_t)pgm_read_word(&XBOX_BUTTONS[(uint8_t)b]) << 16)); -} - -bool XBOXUSB::getButtonClick(ButtonEnum b) { - if(b == L2) { - if(L2Clicked) { - L2Clicked = false; - return true; - } - return false; - } else if(b == R2) { - if(R2Clicked) { - R2Clicked = false; - return true; - } - return false; - } - uint16_t button = pgm_read_word(&XBOX_BUTTONS[(uint8_t)b]); - bool click = (ButtonClickState & button); - ButtonClickState &= ~button; // clear "click" event - return click; -} - -int16_t XBOXUSB::getAnalogHat(AnalogHatEnum a) { - return hatValue[a]; -} - -/* Xbox Controller commands */ -void XBOXUSB::XboxCommand(uint8_t* data, uint16_t nbytes) { - //bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x00), Report Type (Output 0x02), interface (0x00), datalength, datalength, data) - pUsb->ctrlReq(bAddress, epInfo[XBOX_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL); -} - -void XBOXUSB::setLedRaw(uint8_t value) { - writeBuf[0] = 0x01; - writeBuf[1] = 0x03; - writeBuf[2] = value; - - XboxCommand(writeBuf, 3); -} - -void XBOXUSB::setLedOn(LEDEnum led) { - if(led == OFF) - setLedRaw(0); - else if(led != ALL) // All LEDs can't be on a the same time - setLedRaw(pgm_read_byte(&XBOX_LEDS[(uint8_t)led]) + 4); -} - -void XBOXUSB::setLedBlink(LEDEnum led) { - setLedRaw(pgm_read_byte(&XBOX_LEDS[(uint8_t)led])); -} - -void XBOXUSB::setLedMode(LEDModeEnum ledMode) { // This function is used to do some special LED stuff the controller supports - setLedRaw((uint8_t)ledMode); -} - -void XBOXUSB::setRumbleOn(uint8_t lValue, uint8_t rValue) { - writeBuf[0] = 0x00; - writeBuf[1] = 0x08; - writeBuf[2] = 0x00; - writeBuf[3] = lValue; // big weight - writeBuf[4] = rValue; // small weight - writeBuf[5] = 0x00; - writeBuf[6] = 0x00; - writeBuf[7] = 0x00; - - XboxCommand(writeBuf, 8); -} - -void XBOXUSB::onInit() { - if(pFuncOnInit) - pFuncOnInit(); // Call the user function - else - setLedOn(LED1); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/XBOXUSB.h b/protocol/usb_hid/USB_Host_Shield_2.0/XBOXUSB.h deleted file mode 100644 index 1ab37851..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/XBOXUSB.h +++ /dev/null @@ -1,225 +0,0 @@ -/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#ifndef _xboxusb_h_ -#define _xboxusb_h_ - -#include "Usb.h" -#include "hid.h" -#include "xboxEnums.h" - -/* Data Xbox 360 taken from descriptors */ -#define EP_MAXPKTSIZE 32 // max size for data via USB - -/* Names we give to the 3 Xbox360 pipes */ -#define XBOX_CONTROL_PIPE 0 -#define XBOX_INPUT_PIPE 1 -#define XBOX_OUTPUT_PIPE 2 - -// PID and VID of the different devices -#define XBOX_VID 0x045E // Microsoft Corporation -#define MADCATZ_VID 0x1BAD // For unofficial Mad Catz controllers -#define JOYTECH_VID 0x162E // For unofficial Joytech controllers -#define GAMESTOP_VID 0x0E6F // Gamestop controller - -#define XBOX_WIRED_PID 0x028E // Microsoft 360 Wired controller -#define XBOX_WIRELESS_PID 0x028F // Wireless controller only support charging -#define XBOX_WIRELESS_RECEIVER_PID 0x0719 // Microsoft Wireless Gaming Receiver -#define XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID 0x0291 // Third party Wireless Gaming Receiver -#define MADCATZ_WIRED_PID 0xF016 // Mad Catz wired controller -#define JOYTECH_WIRED_PID 0xBEEF // For Joytech wired controller -#define GAMESTOP_WIRED_PID 0x0401 // Gamestop wired controller -#define AFTERGLOW_WIRED_PID 0x0213 // Afterglow wired controller - it uses the same VID as a Gamestop controller - -#define XBOX_REPORT_BUFFER_SIZE 14 // Size of the input report buffer - -#define XBOX_MAX_ENDPOINTS 3 - -/** This class implements support for a Xbox wired controller via USB. */ -class XBOXUSB : public USBDeviceConfig { -public: - /** - * Constructor for the XBOXUSB class. - * @param pUsb Pointer to USB class instance. - */ - XBOXUSB(USB *pUsb); - - /** @name USBDeviceConfig implementation */ - /** - * Initialize the Xbox Controller. - * @param parent Hub number. - * @param port Port number on the hub. - * @param lowspeed Speed of the device. - * @return 0 on success. - */ - uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - /** - * Release the USB device. - * @return 0 on success. - */ - uint8_t Release(); - /** - * Poll the USB Input endpoins and run the state machines. - * @return 0 on success. - */ - uint8_t Poll(); - - /** - * Get the device address. - * @return The device address. - */ - virtual uint8_t GetAddress() { - return bAddress; - }; - - /** - * Used to check if the controller has been initialized. - * @return True if it's ready. - */ - virtual bool isReady() { - return bPollEnable; - }; - - /** - * Used by the USB core to check what this driver support. - * @param vid The device's VID. - * @param pid The device's PID. - * @return Returns true if the device's VID and PID matches this driver. - */ - virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { - return ((vid == XBOX_VID || vid == MADCATZ_VID || vid == JOYTECH_VID || vid == GAMESTOP_VID) && (pid == XBOX_WIRED_PID || pid == MADCATZ_WIRED_PID || pid == GAMESTOP_WIRED_PID || pid == AFTERGLOW_WIRED_PID || pid == JOYTECH_WIRED_PID)); - }; - /**@}*/ - - /** @name Xbox Controller functions */ - /** - * getButtonPress(ButtonEnum b) will return true as long as the button is held down. - * - * While getButtonClick(ButtonEnum b) will only return it once. - * - * So you instance if you need to increase a variable once you would use getButtonClick(ButtonEnum b), - * but if you need to drive a robot forward you would use getButtonPress(ButtonEnum b). - * @param b ::ButtonEnum to read. - * @return getButtonClick(ButtonEnum b) will return a bool, while getButtonPress(ButtonEnum b) will return a byte if reading ::L2 or ::R2. - */ - uint8_t getButtonPress(ButtonEnum b); - bool getButtonClick(ButtonEnum b); - /**@}*/ - - /** @name Xbox Controller functions */ - /** - * Return the analog value from the joysticks on the controller. - * @param a Either ::LeftHatX, ::LeftHatY, ::RightHatX or ::RightHatY. - * @return Returns a signed 16-bit integer. - */ - int16_t getAnalogHat(AnalogHatEnum a); - - /** Turn rumble off and all the LEDs on the controller. */ - void setAllOff() { - setRumbleOn(0, 0); - setLedRaw(0); - }; - - /** Turn rumble off the controller. */ - void setRumbleOff() { - setRumbleOn(0, 0); - }; - /** - * Turn rumble on. - * @param lValue Left motor (big weight) inside the controller. - * @param rValue Right motor (small weight) inside the controller. - */ - void setRumbleOn(uint8_t lValue, uint8_t rValue); - /** - * Set LED value. Without using the ::LEDEnum or ::LEDModeEnum. - * @param value See: - * setLedOff(), setLedOn(LEDEnum l), - * setLedBlink(LEDEnum l), and setLedMode(LEDModeEnum lm). - */ - void setLedRaw(uint8_t value); - - /** Turn all LEDs off the controller. */ - void setLedOff() { - setLedRaw(0); - }; - /** - * Turn on a LED by using ::LEDEnum. - * @param l ::OFF, ::LED1, ::LED2, ::LED3 and ::LED4 is supported by the Xbox controller. - */ - void setLedOn(LEDEnum l); - /** - * Turn on a LED by using ::LEDEnum. - * @param l ::ALL, ::LED1, ::LED2, ::LED3 and ::LED4 is supported by the Xbox controller. - */ - void setLedBlink(LEDEnum l); - /** - * Used to set special LED modes supported by the Xbox controller. - * @param lm See ::LEDModeEnum. - */ - void setLedMode(LEDModeEnum lm); - - /** - * Used to call your own function when the controller is successfully initialized. - * @param funcOnInit Function to call. - */ - void attachOnInit(void (*funcOnInit)(void)) { - pFuncOnInit = funcOnInit; - }; - /**@}*/ - - /** True if a Xbox 360 controller is connected. */ - bool Xbox360Connected; - -protected: - /** Pointer to USB class instance. */ - USB *pUsb; - /** Device address. */ - uint8_t bAddress; - /** Endpoint info structure. */ - EpInfo epInfo[XBOX_MAX_ENDPOINTS]; - -private: - /** - * Called when the controller is successfully initialized. - * Use attachOnInit(void (*funcOnInit)(void)) to call your own function. - * This is useful for instance if you want to set the LEDs in a specific way. - */ - void onInit(); - void (*pFuncOnInit)(void); // Pointer to function called in onInit() - - bool bPollEnable; - - /* Variables to store the buttons */ - uint32_t ButtonState; - uint32_t OldButtonState; - uint16_t ButtonClickState; - int16_t hatValue[4]; - uint16_t controllerStatus; - - bool L2Clicked; // These buttons are analog, so we use we use these bools to check if they where clicked or not - bool R2Clicked; - - uint8_t readBuf[EP_MAXPKTSIZE]; // General purpose buffer for input data - uint8_t writeBuf[8]; // General purpose buffer for output data - - void readReport(); // read incoming data - void printReport(); // print incoming date - Uncomment for debugging - - /* Private commands */ - void XboxCommand(uint8_t* data, uint16_t nbytes); -}; -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/address.h b/protocol/usb_hid/USB_Host_Shield_2.0/address.h deleted file mode 100644 index c3e1b314..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/address.h +++ /dev/null @@ -1,282 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#if !defined(_usb_h_) || defined(__ADDRESS_H__) -#error "Never include address.h directly; include Usb.h instead" -#else -#define __ADDRESS_H__ - - - -/* NAK powers. To save space in endpoint data structure, amount of retries before giving up and returning 0x4 is stored in */ -/* bmNakPower as a power of 2. The actual nak_limit is then calculated as nak_limit = ( 2^bmNakPower - 1) */ -#define USB_NAK_MAX_POWER 15 //NAK binary order maximum value -#define USB_NAK_DEFAULT 14 //default 32K-1 NAKs before giving up -#define USB_NAK_NOWAIT 1 //Single NAK stops transfer -#define USB_NAK_NONAK 0 //Do not count NAKs, stop retrying after USB Timeout - -struct EpInfo { - uint8_t epAddr; // Endpoint address - uint8_t maxPktSize; // Maximum packet size - - union { - uint8_t epAttribs; - - struct { - uint8_t bmSndToggle : 1; // Send toggle, when zero bmSNDTOG0, bmSNDTOG1 otherwise - uint8_t bmRcvToggle : 1; // Send toggle, when zero bmRCVTOG0, bmRCVTOG1 otherwise - uint8_t bmNakPower : 6; // Binary order for NAK_LIMIT value - } __attribute__((packed)); - }; -} __attribute__((packed)); - -// 7 6 5 4 3 2 1 0 -// --------------------------------- -// | | H | P | P | P | A | A | A | -// --------------------------------- -// -// H - if 1 the address is a hub address -// P - parent hub address -// A - device address / port number in case of hub -// - -struct UsbDeviceAddress { - - union { - - struct { - uint8_t bmAddress : 3; // device address/port number - uint8_t bmParent : 3; // parent hub address - uint8_t bmHub : 1; // hub flag - uint8_t bmReserved : 1; // reserved, must be zero - } __attribute__((packed)); - uint8_t devAddress; - }; -} __attribute__((packed)); - -#define bmUSB_DEV_ADDR_ADDRESS 0x07 -#define bmUSB_DEV_ADDR_PARENT 0x38 -#define bmUSB_DEV_ADDR_HUB 0x40 - -struct UsbDevice { - EpInfo *epinfo; // endpoint info pointer - UsbDeviceAddress address; - uint8_t epcount; // number of endpoints - bool lowspeed; // indicates if a device is the low speed one - // uint8_t devclass; // device class -} __attribute__((packed)); - -class AddressPool { -public: - virtual UsbDevice* GetUsbDevicePtr(uint8_t addr) = 0; - virtual uint8_t AllocAddress(uint8_t parent, bool is_hub = false, uint8_t port = 0) = 0; - virtual void FreeAddress(uint8_t addr) = 0; -}; - -typedef void (*UsbDeviceHandleFunc)(UsbDevice *pdev); - -#define ADDR_ERROR_INVALID_INDEX 0xFF -#define ADDR_ERROR_INVALID_ADDRESS 0xFF - -template -class AddressPoolImpl : public AddressPool { - EpInfo dev0ep; //Endpoint data structure used during enumeration for uninitialized device - - uint8_t hubCounter; // hub counter is kept - // in order to avoid hub address duplication - - UsbDevice thePool[MAX_DEVICES_ALLOWED]; - - // Initializes address pool entry - - void InitEntry(uint8_t index) { - thePool[index].address.devAddress = 0; - thePool[index].epcount = 1; - thePool[index].lowspeed = 0; - thePool[index].epinfo = &dev0ep; - }; - - // Returns thePool index for a given address - - uint8_t FindAddressIndex(uint8_t address = 0) { - for(uint8_t i = 1; i < MAX_DEVICES_ALLOWED; i++) { - if(thePool[i].address.devAddress == address) - return i; - } - return 0; - }; - - // Returns thePool child index for a given parent - - uint8_t FindChildIndex(UsbDeviceAddress addr, uint8_t start = 1) { - for(uint8_t i = (start < 1 || start >= MAX_DEVICES_ALLOWED) ? 1 : start; i < MAX_DEVICES_ALLOWED; i++) { - if(thePool[i].address.bmParent == addr.bmAddress) - return i; - } - return 0; - }; - - // Frees address entry specified by index parameter - - void FreeAddressByIndex(uint8_t index) { - // Zero field is reserved and should not be affected - if(index == 0) - return; - - UsbDeviceAddress uda = thePool[index].address; - // If a hub was switched off all port addresses should be freed - if(uda.bmHub == 1) { - for(uint8_t i = 1; (i = FindChildIndex(uda, i));) - FreeAddressByIndex(i); - - // If the hub had the last allocated address, hubCounter should be decremented - if(hubCounter == uda.bmAddress) - hubCounter--; - } - InitEntry(index); - } - - // Initializes the whole address pool at once - - void InitAllAddresses() { - for(uint8_t i = 1; i < MAX_DEVICES_ALLOWED; i++) - InitEntry(i); - - hubCounter = 0; - }; - -public: - - AddressPoolImpl() : hubCounter(0) { - // Zero address is reserved - InitEntry(0); - - thePool[0].address.devAddress = 0; - thePool[0].epinfo = &dev0ep; - dev0ep.epAddr = 0; - dev0ep.maxPktSize = 8; - dev0ep.epAttribs = 0; //set DATA0/1 toggles to 0 - dev0ep.bmNakPower = USB_NAK_MAX_POWER; - - InitAllAddresses(); - }; - - // Returns a pointer to a specified address entry - - virtual UsbDevice* GetUsbDevicePtr(uint8_t addr) { - if(!addr) - return thePool; - - uint8_t index = FindAddressIndex(addr); - - return (!index) ? NULL : thePool + index; - }; - - // Performs an operation specified by pfunc for each addressed device - - void ForEachUsbDevice(UsbDeviceHandleFunc pfunc) { - if(!pfunc) - return; - - for(uint8_t i = 1; i < MAX_DEVICES_ALLOWED; i++) - if(thePool[i].address.devAddress) - pfunc(thePool + i); - }; - - // Allocates new address - - virtual uint8_t AllocAddress(uint8_t parent, bool is_hub = false, uint8_t port = 0) { - /* if (parent != 0 && port == 0) - USB_HOST_SERIAL.println("PRT:0"); */ - UsbDeviceAddress _parent; - _parent.devAddress = parent; - if(_parent.bmReserved || port > 7) - //if(parent > 127 || port > 7) - return 0; - - if(is_hub && hubCounter == 7) - return 0; - - // finds first empty address entry starting from one - uint8_t index = FindAddressIndex(0); - - if(!index) // if empty entry is not found - return 0; - - if(_parent.devAddress == 0) { - if(is_hub) { - thePool[index].address.devAddress = 0x41; - hubCounter++; - } else - thePool[index].address.devAddress = 1; - - return thePool[index].address.devAddress; - } - - UsbDeviceAddress addr; - addr.devAddress = 0; // Ensure all bits are zero - addr.bmParent = _parent.bmAddress; - if(is_hub) { - addr.bmHub = 1; - addr.bmAddress = ++hubCounter; - } else { - addr.bmHub = 0; - addr.bmAddress = port; - } - thePool[index].address = addr; - /* - USB_HOST_SERIAL.print("Addr:"); - USB_HOST_SERIAL.print(addr.bmHub, HEX); - USB_HOST_SERIAL.print("."); - USB_HOST_SERIAL.print(addr.bmParent, HEX); - USB_HOST_SERIAL.print("."); - USB_HOST_SERIAL.println(addr.bmAddress, HEX); - */ - return thePool[index].address.devAddress; - }; - - // Empties pool entry - - virtual void FreeAddress(uint8_t addr) { - // if the root hub is disconnected all the addresses should be initialized - if(addr == 0x41) { - InitAllAddresses(); - return; - } - uint8_t index = FindAddressIndex(addr); - FreeAddressByIndex(index); - }; - - // Returns number of hubs attached - // It can be rather helpfull to find out if there are hubs attached than getting the exact number of hubs. - //uint8_t GetNumHubs() - //{ - // return hubCounter; - //}; - //uint8_t GetNumDevices() - //{ - // uint8_t counter = 0; - - // for (uint8_t i=1; iRegisterDeviceClass(this); //set devConfig[] entry - } -} - -uint8_t ADK::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) { - return Init(parent, port, lowspeed); // Just call Init. Yes, really! -} - -/* Connection initialization of an Android phone */ -uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) { - uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)]; - USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); - uint8_t rcode; - uint8_t num_of_conf; // number of configurations - UsbDevice *p = NULL; - EpInfo *oldep_ptr = NULL; - - // get memory address of USB device address pool - AddressPool &addrPool = pUsb->GetAddressPool(); - - USBTRACE("\r\nADK Init"); - - // check if address has already been assigned to an instance - if(bAddress) { - USBTRACE("\r\nAddress in use"); - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - } - - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - - if(!p) { - USBTRACE("\r\nAddress not found"); - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - } - - if(!p->epinfo) { - USBTRACE("epinfo is null\r\n"); - return USB_ERROR_EPINFO_IS_NULL; - } - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - - p->lowspeed = lowspeed; - - // Get device descriptor - rcode = pUsb->getDevDescr(0, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*)buf); - - // Restore p->epinfo - p->epinfo = oldep_ptr; - - if(rcode) { - goto FailGetDevDescr; - } - - // Allocate new address according to device class - bAddress = addrPool.AllocAddress(parent, false, port); - - // Extract Max Packet Size from device descriptor - epInfo[0].maxPktSize = udd->bMaxPacketSize0; - - // Assign new address to the device - rcode = pUsb->setAddr(0, 0, bAddress); - if(rcode) { - p->lowspeed = false; - addrPool.FreeAddress(bAddress); - bAddress = 0; - //USBTRACE2("setAddr:",rcode); - return rcode; - }//if (rcode... - - //USBTRACE2("\r\nAddr:", bAddress); - // Spec says you should wait at least 200ms. - //delay(300); - - p->lowspeed = false; - - //get pointer to assigned address record - p = addrPool.GetUsbDevicePtr(bAddress); - if(!p) { - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - } - - p->lowspeed = lowspeed; - - // Assign epInfo to epinfo pointer - only EP0 is known - rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo); - if(rcode) { - goto FailSetDevTblEntry; - } - - //check if ADK device is already in accessory mode; if yes, configure and exit - if(udd->idVendor == ADK_VID && - (udd->idProduct == ADK_PID || udd->idProduct == ADB_PID)) { - USBTRACE("\r\nAcc.mode device detected"); - /* go through configurations, find first bulk-IN, bulk-OUT EP, fill epInfo and quit */ - num_of_conf = udd->bNumConfigurations; - - //USBTRACE2("\r\nNC:",num_of_conf); - for(uint8_t i = 0; i < num_of_conf; i++) { - ConfigDescParser < 0, 0, 0, 0 > confDescrParser(this); - delay(1); - rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser); -#if defined(XOOM) - //added by Jaylen Scott Vanorden - if(rcode) { - USBTRACE2("\r\nGot 1st bad code for config: ", rcode); - // Try once more - rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser); - } -#endif - if(rcode) { - goto FailGetConfDescr; - } - if(bNumEP > 2) { - break; - } - } // for (uint8_t i=0; isetEpInfoEntry(bAddress, 3, epInfo); - if(rcode) { - goto FailSetDevTblEntry; - } - } - - // Set Configuration Value - rcode = pUsb->setConf(bAddress, 0, bConfNum); - if(rcode) { - goto FailSetConfDescr; - } - /* print endpoint structure */ - /* - USBTRACE("\r\nEndpoint Structure:"); - USBTRACE("\r\nEP0:"); - USBTRACE2("\r\nAddr: ", epInfo[0].epAddr); - USBTRACE2("\r\nMax.pkt.size: ", epInfo[0].maxPktSize); - USBTRACE2("\r\nAttr: ", epInfo[0].epAttribs); - USBTRACE("\r\nEpout:"); - USBTRACE2("\r\nAddr: ", epInfo[epDataOutIndex].epAddr); - USBTRACE2("\r\nMax.pkt.size: ", epInfo[epDataOutIndex].maxPktSize); - USBTRACE2("\r\nAttr: ", epInfo[epDataOutIndex].epAttribs); - USBTRACE("\r\nEpin:"); - USBTRACE2("\r\nAddr: ", epInfo[epDataInIndex].epAddr); - USBTRACE2("\r\nMax.pkt.size: ", epInfo[epDataInIndex].maxPktSize); - USBTRACE2("\r\nAttr: ", epInfo[epDataInIndex].epAttribs); - */ - - USBTRACE("\r\nConfiguration successful"); - ready = true; - return 0; //successful configuration - }//if( buf->idVendor == ADK_VID... - - //probe device - get accessory protocol revision - { - uint16_t adkproto = -1; - delay(1); - rcode = getProto((uint8_t*) & adkproto); -#if defined(XOOM) - //added by Jaylen Scott Vanorden - if(rcode) { - USBTRACE2("\r\nGot 1st bad code for proto: ", rcode); - // Try once more - rcode = getProto((uint8_t*) & adkproto); - } -#endif - if(rcode) { - goto FailGetProto; //init fails - } - USBTRACE2("\r\nADK protocol rev. ", adkproto); - } - - delay(100); - - //sending ID strings - sendStr(ACCESSORY_STRING_MANUFACTURER, manufacturer); - delay(10); - sendStr(ACCESSORY_STRING_MODEL, model); - delay(10); - sendStr(ACCESSORY_STRING_DESCRIPTION, description); - delay(10); - sendStr(ACCESSORY_STRING_VERSION, version); - delay(10); - sendStr(ACCESSORY_STRING_URI, uri); - delay(10); - sendStr(ACCESSORY_STRING_SERIAL, serial); - - delay(100); - - //switch to accessory mode - //the Android phone will reset - rcode = switchAcc(); - if(rcode) { - goto FailSwAcc; //init fails - } - rcode = USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET; - delay(100); // Give Android a chance to do its reset. This is a guess, and possibly could be lower. - goto SwAttempt; //switch to accessory mode attempted - - /* diagnostic messages */ -FailGetDevDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetDevDescr(rcode); - goto Fail; -#endif - -FailSetDevTblEntry: -#ifdef DEBUG_USB_HOST - NotifyFailSetDevTblEntry(rcode); - goto Fail; -#endif - -FailGetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetConfDescr(rcode); - goto Fail; -#endif - -FailSetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailSetConfDescr(rcode); - goto Fail; -#endif - -FailGetProto: -#ifdef DEBUG_USB_HOST - USBTRACE("\r\ngetProto:"); - goto Fail; -#endif - -FailSwAcc: -#ifdef DEBUG_USB_HOST - USBTRACE("\r\nswAcc:"); - goto Fail; -#endif - - //FailOnInit: - // USBTRACE("OnInit:"); - // goto Fail; - // -SwAttempt: -#ifdef DEBUG_USB_HOST - USBTRACE("\r\nAccessory mode switch attempt"); -Fail: -#endif - //USBTRACE2("\r\nADK Init Failed, error code: ", rcode); - //NotifyFail(rcode); - Release(); - return rcode; -} - -/* Extracts bulk-IN and bulk-OUT endpoint information from config descriptor */ -void ADK::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) { - //ErrorMessage(PSTR("Conf.Val"), conf); - //ErrorMessage(PSTR("Iface Num"), iface); - //ErrorMessage(PSTR("Alt.Set"), alt); - - //added by Yuuichi Akagawa - if(bNumEP == 3) { - return; - } - - bConfNum = conf; - - if((pep->bmAttributes & 0x02) == 2) { - uint8_t index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; - // Fill in the endpoint info structure - epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F); - epInfo[index].maxPktSize = (uint8_t)pep->wMaxPacketSize; - - bNumEP++; - - //PrintEndpointDescriptor(pep); - } -} - -/* Performs a cleanup after failed Init() attempt */ -uint8_t ADK::Release() { - pUsb->GetAddressPool().FreeAddress(bAddress); - - bNumEP = 1; //must have to be reset to 1 - - bAddress = 0; - ready = false; - return 0; -} - -uint8_t ADK::RcvData(uint16_t *bytes_rcvd, uint8_t *dataptr) { - //USBTRACE2("\r\nAddr: ", bAddress ); - //USBTRACE2("\r\nEP: ",epInfo[epDataInIndex].epAddr); - return pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, bytes_rcvd, dataptr); -} - -uint8_t ADK::SndData(uint16_t nbytes, uint8_t *dataptr) { - return pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, nbytes, dataptr); -} - -void ADK::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) { - Notify(PSTR("Endpoint descriptor:"), 0x80); - Notify(PSTR("\r\nLength:\t\t"), 0x80); - D_PrintHex (ep_ptr->bLength, 0x80); - Notify(PSTR("\r\nType:\t\t"), 0x80); - D_PrintHex (ep_ptr->bDescriptorType, 0x80); - Notify(PSTR("\r\nAddress:\t"), 0x80); - D_PrintHex (ep_ptr->bEndpointAddress, 0x80); - Notify(PSTR("\r\nAttributes:\t"), 0x80); - D_PrintHex (ep_ptr->bmAttributes, 0x80); - Notify(PSTR("\r\nMaxPktSize:\t"), 0x80); - D_PrintHex (ep_ptr->wMaxPacketSize, 0x80); - Notify(PSTR("\r\nPoll Intrv:\t"), 0x80); - D_PrintHex (ep_ptr->bInterval, 0x80); - Notify(PSTR("\r\n"), 0x80); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/adk.h b/protocol/usb_hid/USB_Host_Shield_2.0/adk.h deleted file mode 100644 index 4a2920b8..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/adk.h +++ /dev/null @@ -1,140 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -/* Google ADK interface support header */ - -#if !defined(_ADK_H_) -#define _ADK_H_ - -#include "Usb.h" - -#define ADK_VID 0x18D1 -#define ADK_PID 0x2D00 -#define ADB_PID 0x2D01 - -#define XOOM //enables repeating getProto() and getConf() attempts -//necessary for slow devices such as Motorola XOOM -//defined by default, can be commented out to save memory - -/* requests */ - -#define ADK_GETPROTO 51 //check USB accessory protocol version -#define ADK_SENDSTR 52 //send identifying string -#define ADK_ACCSTART 53 //start device in accessory mode - -#define bmREQ_ADK_GET USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_VENDOR|USB_SETUP_RECIPIENT_DEVICE -#define bmREQ_ADK_SEND USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_VENDOR|USB_SETUP_RECIPIENT_DEVICE - -#define ACCESSORY_STRING_MANUFACTURER 0 -#define ACCESSORY_STRING_MODEL 1 -#define ACCESSORY_STRING_DESCRIPTION 2 -#define ACCESSORY_STRING_VERSION 3 -#define ACCESSORY_STRING_URI 4 -#define ACCESSORY_STRING_SERIAL 5 - -#define ADK_MAX_ENDPOINTS 3 //endpoint 0, bulk_IN, bulk_OUT - -class ADK; - -class ADK : public USBDeviceConfig, public UsbConfigXtracter { -private: - /* ID strings */ - const char* manufacturer; - const char* model; - const char* description; - const char* version; - const char* uri; - const char* serial; - - /* ADK proprietary requests */ - uint8_t getProto(uint8_t* adkproto); - uint8_t sendStr(uint8_t index, const char* str); - uint8_t switchAcc(void); - -protected: - static const uint8_t epDataInIndex; // DataIn endpoint index - static const uint8_t epDataOutIndex; // DataOUT endpoint index - - /* mandatory members */ - USB *pUsb; - uint8_t bAddress; - uint8_t bConfNum; // configuration number - - uint8_t bNumEP; // total number of EP in the configuration - bool ready; - - /* Endpoint data structure */ - EpInfo epInfo[ADK_MAX_ENDPOINTS]; - - void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); - -public: - ADK(USB *pUsb, const char* manufacturer, - const char* model, - const char* description, - const char* version, - const char* uri, - const char* serial); - - // Methods for receiving and sending data - uint8_t RcvData(uint16_t *nbytesptr, uint8_t *dataptr); - uint8_t SndData(uint16_t nbytes, uint8_t *dataptr); - - - // USBDeviceConfig implementation - uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed); - uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - uint8_t Release(); - - virtual uint8_t Poll() { - return 0; - }; - - virtual uint8_t GetAddress() { - return bAddress; - }; - - virtual bool isReady() { - return ready; - }; - - virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { - return (vid == ADK_VID && (pid == ADK_PID || pid == ADB_PID)); - }; - - //UsbConfigXtracter implementation - void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); -}; //class ADK : public USBDeviceConfig ... - -/* get ADK protocol version */ - -/* returns 2 bytes in *adkproto */ -inline uint8_t ADK::getProto(uint8_t* adkproto) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_ADK_GET, ADK_GETPROTO, 0, 0, 0, 2, 2, adkproto, NULL)); -} - -/* send ADK string */ -inline uint8_t ADK::sendStr(uint8_t index, const char* str) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_ADK_SEND, ADK_SENDSTR, 0, 0, index, strlen(str) + 1, strlen(str) + 1, (uint8_t*)str, NULL)); -} - -/* switch to accessory mode */ -inline uint8_t ADK::switchAcc(void) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_ADK_SEND, ADK_ACCSTART, 0, 0, 0, 0, 0, NULL, NULL)); -} - -#endif // _ADK_H_ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/avrpins.h b/protocol/usb_hid/USB_Host_Shield_2.0/avrpins.h deleted file mode 100644 index 4e60e3a2..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/avrpins.h +++ /dev/null @@ -1,1130 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -/* derived from Konstantin Chizhov's AVR port templates */ - -#if !defined(_usb_h_) || defined(_avrpins_h_) -#error "Never include avrpins.h directly; include Usb.h instead" -#else -#define _avrpins_h_ - -#if defined(__AVR__) - -// pointers are 16 bits on AVR -#define pgm_read_pointer(p) pgm_read_word(p) - -// Support for these boards needs to be manually activated in settings.h or in a makefile -#if !defined(BOARD_MEGA_ADK) && defined(__AVR_ATmega2560__) && (USE_UHS_MEGA_ADK || defined(ARDUINO_AVR_ADK)) -#define BOARD_MEGA_ADK -#elif !defined(BOARD_BLACK_WIDDOW) && USE_UHS_BLACK_WIDDOW -#define BOARD_BLACK_WIDDOW -#endif - -#ifdef PORTA -#define USE_PORTA -#endif -#ifdef PORTB -#define USE_PORTB -#endif -#ifdef PORTC -#define USE_PORTC -#endif -#ifdef PORTD -#define USE_PORTD -#endif -#ifdef PORTE -#define USE_PORTE -#endif -#ifdef PORTF -#define USE_PORTF -#endif -#ifdef PORTG -#define USE_PORTG -#endif -#ifdef PORTH -#define USE_PORTH -#endif -#ifdef PORTJ -#define USE_PORTJ -#endif -#ifdef PORTK -#define USE_PORTK -#endif -#ifdef PORTL -#define USE_PORTL -#endif -#ifdef PORTQ -#define USE_PORTQ -#endif -#ifdef PORTR -#define USE_PORTR -#endif - -#ifdef TCCR0A -#define USE_TCCR0A -#endif -#ifdef TCCR1A -#define USE_TCCR1A -#endif -#ifdef TCCR2A -#define USE_TCCR2A -#endif - -//Port definitions for AtTiny, AtMega families. - -#define MAKE_PORT(portName, ddrName, pinName, className, ID) \ - class className{\ - public:\ - typedef uint8_t DataT;\ - public:\ - static void Write(DataT value){portName = value;}\ - static void ClearAndSet(DataT clearMask, DataT value){portName = (portName & ~clearMask) | value;}\ - static DataT Read(){return portName;}\ - static void DirWrite(DataT value){ddrName = value;}\ - static DataT DirRead(){return ddrName;}\ - static void Set(DataT value){portName |= value;}\ - static void Clear(DataT value){portName &= ~value;}\ - static void Toggle(DataT value){portName ^= value;}\ - static void DirSet(DataT value){ddrName |= value;}\ - static void DirClear(DataT value){ddrName &= ~value;}\ - static void DirToggle(DataT value){ddrName ^= value;}\ - static DataT PinRead(){return pinName;}\ - enum{Id = ID};\ - enum{Width=sizeof(DataT)*8};\ - }; - -// TCCR registers to set/clear Arduino PWM -#define MAKE_TCCR(TccrName, className) \ - class className{\ - public:\ - typedef uint8_t DataT;\ - public:\ - static void Write(DataT value){TccrName = value;}\ - static void ClearAndSet(DataT clearMask, DataT value){TccrName = (TccrName & ~clearMask) | value;}\ - static DataT Read(){return TccrName;}\ - static void Set(DataT value){TccrName |= value;}\ - static void Clear(DataT value){TccrName &= ~value;}\ - static void Toggle(DataT value){TccrName ^= value;}\ - enum{Width=sizeof(DataT)*8};\ - }; - -#ifdef USE_PORTA - -MAKE_PORT(PORTA, DDRA, PINA, Porta, 'A') -#endif -#ifdef USE_PORTB -MAKE_PORT(PORTB, DDRB, PINB, Portb, 'B') -#endif -#ifdef USE_PORTC -MAKE_PORT(PORTC, DDRC, PINC, Portc, 'C') -#endif -#ifdef USE_PORTD -MAKE_PORT(PORTD, DDRD, PIND, Portd, 'D') -#endif -#ifdef USE_PORTE -MAKE_PORT(PORTE, DDRE, PINE, Porte, 'E') -#endif -#ifdef USE_PORTF -MAKE_PORT(PORTF, DDRF, PINF, Portf, 'F') -#endif -#ifdef USE_PORTG -MAKE_PORT(PORTG, DDRG, PING, Portg, 'G') -#endif -#ifdef USE_PORTH -MAKE_PORT(PORTH, DDRH, PINH, Porth, 'H') -#endif -#ifdef USE_PORTJ -MAKE_PORT(PORTJ, DDRJ, PINJ, Portj, 'J') -#endif -#ifdef USE_PORTK -MAKE_PORT(PORTK, DDRK, PINK, Portk, 'K') -#endif -#ifdef USE_PORTL -MAKE_PORT(PORTL, DDRL, PINL, Portl, 'L') -#endif -#ifdef USE_PORTQ -MAKE_PORT(PORTQ, DDRQ, PINQ, Portq, 'Q') -#endif -#ifdef USE_PORTR -MAKE_PORT(PORTR, DDRR, PINR, Portr, 'R') -#endif - -#ifdef USE_TCCR0A -MAKE_TCCR(TCCR0A, Tccr0a) -#endif -#ifdef USE_TCCR1A -MAKE_TCCR(TCCR1A, Tccr1a) -#endif -#ifdef USE_TCCR2A -MAKE_TCCR(TCCR2A, Tccr2a) -#endif - -// this class represents one pin in a IO port. -// It is fully static. -template -class TPin { - // BOOST_STATIC_ASSERT(PIN < PORT::Width); -public: - typedef PORT Port; - - enum { - Number = PIN - }; - - static void Set() { - PORT::Set(1 << PIN); - } - - static void Set(uint8_t val) { - if(val) - Set(); - else Clear(); - } - - static void SetDir(uint8_t val) { - if(val) - SetDirWrite(); - else SetDirRead(); - } - - static void Clear() { - PORT::Clear(1 << PIN); - } - - static void Toggle() { - PORT::Toggle(1 << PIN); - } - - static void SetDirRead() { - PORT::DirClear(1 << PIN); - } - - static void SetDirWrite() { - PORT::DirSet(1 << PIN); - } - - static uint8_t IsSet() { - return PORT::PinRead() & (uint8_t)(1 << PIN); - } - - static void WaiteForSet() { - while(IsSet() == 0) { - } - } - - static void WaiteForClear() { - while(IsSet()) { - } - } -}; //class TPin... - -// this class represents one bit in TCCR port. -// used to set/clear TCCRx bits -// It is fully static. - -template -class TCom { - // BOOST_STATIC_ASSERT(PIN < PORT::Width); -public: - typedef TCCR Tccr; - - enum { - Com = COM - }; - - static void Set() { - TCCR::Set(1 << COM); - } - - static void Clear() { - TCCR::Clear(1 << COM); - } - - static void Toggle() { - TCCR::Toggle(1 << COM); - } -}; //class TCom... - -//Short pin definitions -#ifdef USE_PORTA -typedef TPin Pa0; -typedef TPin Pa1; -typedef TPin Pa2; -typedef TPin Pa3; -typedef TPin Pa4; -typedef TPin Pa5; -typedef TPin Pa6; -typedef TPin Pa7; -#endif - -#ifdef USE_PORTB -typedef TPin Pb0; -typedef TPin Pb1; -typedef TPin Pb2; -typedef TPin Pb3; -typedef TPin Pb4; -typedef TPin Pb5; -typedef TPin Pb6; -typedef TPin Pb7; -#endif - -#ifdef USE_PORTC -typedef TPin Pc0; -typedef TPin Pc1; -typedef TPin Pc2; -typedef TPin Pc3; -typedef TPin Pc4; -typedef TPin Pc5; -typedef TPin Pc6; -typedef TPin Pc7; -#endif - -#ifdef USE_PORTD -typedef TPin Pd0; -typedef TPin Pd1; -typedef TPin Pd2; -typedef TPin Pd3; -typedef TPin Pd4; -typedef TPin Pd5; -typedef TPin Pd6; -typedef TPin Pd7; -#endif - -#ifdef USE_PORTE -typedef TPin Pe0; -typedef TPin Pe1; -typedef TPin Pe2; -typedef TPin Pe3; -typedef TPin Pe4; -typedef TPin Pe5; -typedef TPin Pe6; -typedef TPin Pe7; -#endif - -#ifdef USE_PORTF -typedef TPin Pf0; -typedef TPin Pf1; -typedef TPin Pf2; -typedef TPin Pf3; -typedef TPin Pf4; -typedef TPin Pf5; -typedef TPin Pf6; -typedef TPin Pf7; -#endif - -#ifdef USE_PORTG -typedef TPin Pg0; -typedef TPin Pg1; -typedef TPin Pg2; -typedef TPin Pg3; -typedef TPin Pg4; -typedef TPin Pg5; -typedef TPin Pg6; -typedef TPin Pg7; -#endif - -#ifdef USE_PORTH -typedef TPin Ph0; -typedef TPin Ph1; -typedef TPin Ph2; -typedef TPin Ph3; -typedef TPin Ph4; -typedef TPin Ph5; -typedef TPin Ph6; -typedef TPin Ph7; -#endif - -#ifdef USE_PORTJ -typedef TPin Pj0; -typedef TPin Pj1; -typedef TPin Pj2; -typedef TPin Pj3; -typedef TPin Pj4; -typedef TPin Pj5; -typedef TPin Pj6; -typedef TPin Pj7; -#endif - -#ifdef USE_PORTK -typedef TPin Pk0; -typedef TPin Pk1; -typedef TPin Pk2; -typedef TPin Pk3; -typedef TPin Pk4; -typedef TPin Pk5; -typedef TPin Pk6; -typedef TPin Pk7; -#endif - -#ifdef USE_PORTL -typedef TPin Pl0; -typedef TPin Pl1; -typedef TPin Pl2; -typedef TPin Pl3; -typedef TPin Pl4; -typedef TPin Pl5; -typedef TPin Pl6; -typedef TPin Pl7; -#endif - -#ifdef USE_PORTQ -typedef TPin Pq0; -typedef TPin Pq1; -typedef TPin Pq2; -typedef TPin Pq3; -typedef TPin Pq4; -typedef TPin Pq5; -typedef TPin Pq6; -typedef TPin Pq7; -#endif - -#ifdef USE_PORTR -typedef TPin Pr0; -typedef TPin Pr1; -typedef TPin Pr2; -typedef TPin Pr3; -typedef TPin Pr4; -typedef TPin Pr5; -typedef TPin Pr6; -typedef TPin Pr7; -#endif - -#ifdef USE_TCCR0A -typedef TCom Tc0a; //P6 -typedef TCom Tc0b; //P5 -#endif - -#ifdef USE_TCCR1A -typedef TCom Tc1a; //P9 -typedef TCom Tc1b; //P10 -#endif - -#ifdef USE_TCCR2A -typedef TCom Tc2a; //P11 -typedef TCom Tc2b; //P3 -#endif - -template -class Tp_Tc { -public: - - static void SetDir(uint8_t val) { - if(val) - SetDirWrite(); - else SetDirRead(); - } - - static void SetDirRead() { - Tp_pin::SetDirRead(); //set pin direction - Tc_bit::Clear(); //disconnect pin from PWM - } - - static void SetDirWrite() { - Tp_pin::SetDirWrite(); - Tc_bit::Clear(); - } -}; - -/* pin definitions for cases where it's necessary to clear compare output mode bits */ - -//typedef Tp_Tc P3; //Arduino pin 3 -//typedef Tp_Tc P5; //Arduino pin 5 -//typedef Tp_Tc P6; //Arduino pin 6 -//typedef Tp_Tc P9; //Arduino pin 9 -//typedef Tp_Tc P10; //Arduino pin 10 -//typedef Tp_Tc P11; //Arduino pin 11 - -/* Arduino pin definitions */ -#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) -// "Mega" Arduino pin numbers - -#define P0 Pe0 -#define P1 Pe1 -#define P2 Pe4 -#define P3 Pe5 -#define P4 Pg5 -#define P5 Pe3 -#define P6 Ph3 -#define P7 Ph4 - -#define P8 Ph5 -#define P9 Ph6 -#define P10 Pb4 -#define P11 Pb5 -#define P12 Pb6 -#define P13 Pb7 - -#define P14 Pj1 -#define P15 Pj0 -#define P16 Ph1 -#define P17 Ph0 -#define P18 Pd3 -#define P19 Pd2 -#define P20 Pd1 -#define P21 Pd0 - -#define P22 Pa0 -#define P23 Pa1 -#define P24 Pa2 -#define P25 Pa3 -#define P26 Pa4 -#define P27 Pa5 -#define P28 Pa6 -#define P29 Pa7 -#define P30 Pc7 -#define P31 Pc6 -#define P32 Pc5 -#define P33 Pc4 -#define P34 Pc3 -#define P35 Pc2 -#define P36 Pc1 -#define P37 Pc0 - -#define P38 Pd7 -#define P39 Pg2 -#define P40 Pg1 -#define P41 Pg0 -#define P42 Pl7 -#define P43 Pl6 -#define P44 Pl5 -#define P45 Pl4 -#define P46 Pl3 -#define P47 Pl2 -#define P48 Pl1 -#define P49 Pl0 -#define P50 Pb3 -#define P51 Pb2 -#define P52 Pb1 -#define P53 Pb0 - -#ifdef BOARD_MEGA_ADK // These pins are not broken out on the Arduino ADK -#define P54 Pe6 // INT on Arduino ADK -#define P55 Pj2 // MAX_RESET on Arduino ADK -#endif - -// "Mega" pin numbers - -#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) -// "Classic" Arduino pin numbers - -#define P0 Pd0 -#define P1 Pd1 -#define P2 Pd2 -#define P3 Pd3 -#define P4 Pd4 -#define P5 Pd5 -#define P6 Pd6 -#define P7 Pd7 - -#define P8 Pb0 -#define P9 Pb1 -#define P10 Pb2 -#define P11 Pb3 -#define P12 Pb4 -#define P13 Pb5 - -#define P14 Pc0 -#define P15 Pc1 -#define P16 Pc2 -#define P17 Pc3 -#define P18 Pc4 -#define P19 Pc5 - -// "Classic" Arduino pin numbers - -#elif defined(CORE_TEENSY) && defined(__AVR_ATmega32U4__) -// Teensy 2.0 pin numbers -// http://www.pjrc.com/teensy/pinout.html -#define P0 Pb0 -#define P1 Pb1 -#define P2 Pb2 -#define P3 Pb3 -#define P4 Pb7 -#define P5 Pd0 -#define P6 Pd1 -#define P7 Pd2 -#define P8 Pd3 -#define P9 Pc6 -#define P10 Pc7 -#define P11 Pd6 -#define P12 Pd7 -#define P13 Pb4 -#define P14 Pb5 -#define P15 Pb6 -#define P16 Pf7 -#define P17 Pf6 -#define P18 Pf5 -#define P19 Pf4 -#define P20 Pf1 -#define P21 Pf0 -#define P22 Pd4 -#define P23 Pd5 -#define P24 Pe6 -// Teensy 2.0 - -#elif defined(__AVR_ATmega32U4__) -// Arduino Leonardo pin numbers - -#define P0 Pd2 // D0 - PD2 -#define P1 Pd3 // D1 - PD3 -#define P2 Pd1 // D2 - PD1 -#define P3 Pd0 // D3 - PD0 -#define P4 Pd4 // D4 - PD4 -#define P5 Pc6 // D5 - PC6 -#define P6 Pd7 // D6 - PD7 -#define P7 Pe6 // D7 - PE6 - -#define P8 Pb4 // D8 - PB4 -#define P9 Pb5 // D9 - PB5 -#define P10 Pb6 // D10 - PB6 -#define P11 Pb7 // D11 - PB7 -#define P12 Pd6 // D12 - PD6 -#define P13 Pc7 // D13 - PC7 - -#define P14 Pb3 // D14 - MISO - PB3 -#define P15 Pb1 // D15 - SCK - PB1 -#define P16 Pb2 // D16 - MOSI - PB2 -#define P17 Pb0 // D17 - SS - PB0 - -#define P18 Pf7 // D18 - A0 - PF7 -#define P19 Pf6 // D19 - A1 - PF6 -#define P20 Pf5 // D20 - A2 - PF5 -#define P21 Pf4 // D21 - A3 - PF4 -#define P22 Pf1 // D22 - A4 - PF1 -#define P23 Pf0 // D23 - A5 - PF0 - -#define P24 Pd4 // D24 / D4 - A6 - PD4 -#define P25 Pd7 // D25 / D6 - A7 - PD7 -#define P26 Pb4 // D26 / D8 - A8 - PB4 -#define P27 Pb5 // D27 / D9 - A9 - PB5 -#define P28 Pb6 // D28 / D10 - A10 - PB6 -#define P29 Pd6 // D29 / D12 - A11 - PD6 - -// Arduino Leonardo pin numbers - -#elif defined(CORE_TEENSY) && (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)) -// Teensy++ 1.0 and 2.0 pin numbers -// http://www.pjrc.com/teensy/pinout.html -#define P0 Pd0 -#define P1 Pd1 -#define P2 Pd2 -#define P3 Pd3 -#define P4 Pd4 -#define P5 Pd5 -#define P6 Pd6 -#define P7 Pd7 -#define P8 Pe0 -#define P9 Pe1 -#define P10 Pc0 -#define P11 Pc1 -#define P12 Pc2 -#define P13 Pc3 -#define P14 Pc4 -#define P15 Pc5 -#define P16 Pc6 -#define P17 Pc7 -#define P18 Pe6 -#define P19 Pe7 -#define P20 Pb0 -#define P21 Pb1 -#define P22 Pb2 -#define P23 Pb3 -#define P24 Pb4 -#define P25 Pb5 -#define P26 Pb6 -#define P27 Pb7 -#define P28 Pa0 -#define P29 Pa1 -#define P30 Pa2 -#define P31 Pa3 -#define P32 Pa4 -#define P33 Pa5 -#define P34 Pa6 -#define P35 Pa7 -#define P36 Pe4 -#define P37 Pe5 -#define P38 Pf0 -#define P39 Pf1 -#define P40 Pf2 -#define P41 Pf3 -#define P42 Pf4 -#define P43 Pf5 -#define P44 Pf6 -#define P45 Pf7 -// Teensy++ 1.0 and 2.0 - -#elif defined(ARDUINO_AVR_BALANDUINO) && (defined(__AVR_ATmega644__) || defined(__AVR_ATmega1284P__)) -// Balanduino pin numbers -// http://balanduino.net/ -#define P0 Pd0 /* 0 - PD0 */ -#define P1 Pd1 /* 1 - PD1 */ - -#if BALANDUINO_REVISION < 13 - #define P2 Pb2 /* 2 - PB2 */ - #define P3 Pd6 /* 3 - PD6 */ - #define P4 Pd7 /* 4 - PD7 */ - #define P5 Pb3 /* 5 - PB3 */ -#else - #define P2 Pd2 /* 2 - PD2 */ - #define P3 Pd3 /* 3 - PD3 */ - #define P4 Pd6 /* 4 - PD6 */ - #define P5 Pd7 /* 5 - PD7 */ -#endif - -#define P6 Pb4 /* 6 - PB4 */ -#define P7 Pa0 /* 7 - PA0 */ -#define P8 Pa1 /* 8 - PA1 */ -#define P9 Pa2 /* 9 - PA2 */ -#define P10 Pa3 /* 10 - PA3 */ -#define P11 Pa4 /* 11 - PA4 */ -#define P12 Pa5 /* 12 - PA5 */ -#define P13 Pc1 /* 13 - PC1 */ -#define P14 Pc0 /* 14 - PC0 */ - -#if BALANDUINO_REVISION < 13 - #define P15 Pd2 /* 15 - PD2 */ - #define P16 Pd3 /* 16 - PD3 */ -#else - #define P15 Pb2 /* 15 - PB2 */ - #define P16 Pb3 /* 16 - PB2 */ -#endif - -#define P17 Pd4 /* 17 - PD4 */ -#define P18 Pd5 /* 18 - PD5 */ -#define P19 Pc2 /* 19 - PC2 */ -#define P20 Pc3 /* 20 - PC3 */ -#define P21 Pc4 /* 21 - PC4 */ -#define P22 Pc5 /* 22 - PC5 */ -#define P23 Pc6 /* 23 - PC6 */ -#define P24 Pc7 /* 24 - PC7 */ -#define P25 Pb0 /* 25 - PB0 */ -#define P26 Pb1 /* 26 - PB1 */ -#define P27 Pb5 /* 27 - PB5 */ -#define P28 Pb6 /* 28 - PB6 */ -#define P29 Pb7 /* 29 - PB7 */ -#define P30 Pa6 /* 30 - PA6 */ -#define P31 Pa7 /* 31 - PA7 */ -// Balanduino - -#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) -// Sanguino pin numbers -// Homepage: http://sanguino.cc/hardware -// Hardware add-on: https://github.com/Lauszus/Sanguino -#define P0 Pb0 -#define P1 Pb1 -#define P2 Pb2 -#define P3 Pb3 -#define P4 Pb4 -#define P5 Pb5 -#define P6 Pb6 -#define P7 Pb7 -#define P8 Pd0 -#define P9 Pd1 -#define P10 Pd2 -#define P11 Pd3 -#define P12 Pd4 -#define P13 Pd5 -#define P14 Pd6 -#define P15 Pd7 -#define P16 Pc0 -#define P17 Pc1 -#define P18 Pc2 -#define P19 Pc3 -#define P20 Pc4 -#define P21 Pc5 -#define P22 Pc6 -#define P23 Pc7 -#define P24 Pa0 -#define P25 Pa1 -#define P26 Pa2 -#define P27 Pa3 -#define P28 Pa4 -#define P29 Pa5 -#define P30 Pa6 -#define P31 Pa7 -// Sanguino - -#else -#error "Please define board in avrpins.h" - -#endif // Arduino pin definitions - -#elif defined(__arm__) - -// pointers are 32 bits on ARM -#define pgm_read_pointer(p) pgm_read_dword(p) - -#if defined(CORE_TEENSY) && (defined(__MK20DX128__) || defined(__MK20DX256__)) - -#include "core_pins.h" -#include "avr_emulation.h" - -#define GPIO_BITBAND_ADDR(reg, bit) (((uint32_t)&(reg) - 0x40000000) * 32 + (bit) * 4 + 0x42000000) -#define GPIO_BITBAND_PTR(reg, bit) ((uint8_t *)GPIO_BITBAND_ADDR((reg), (bit))) - -#define MAKE_PIN(className, baseReg, pinNum, configReg) \ -class className { \ -public: \ - static void Set() { \ - *GPIO_BITBAND_PTR(baseReg, pinNum) = 1; \ - } \ - static void Clear() { \ - *GPIO_BITBAND_PTR(baseReg, pinNum) = 0; \ - } \ - static void SetDirRead() { \ - configReg = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1); \ - *(GPIO_BITBAND_PTR(baseReg, pinNum) + 640) = 0; \ - } \ - static void SetDirWrite() { \ - configReg = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1); \ - *(GPIO_BITBAND_PTR(baseReg, pinNum) + 640) = 1; \ - } \ - static uint8_t IsSet() { \ - return *(GPIO_BITBAND_PTR(baseReg, pinNum) + 512); \ - } \ -}; - -MAKE_PIN(P0, CORE_PIN0_PORTREG, CORE_PIN0_BIT, CORE_PIN0_CONFIG); -MAKE_PIN(P1, CORE_PIN1_PORTREG, CORE_PIN1_BIT, CORE_PIN1_CONFIG); -MAKE_PIN(P2, CORE_PIN2_PORTREG, CORE_PIN2_BIT, CORE_PIN2_CONFIG); -MAKE_PIN(P3, CORE_PIN3_PORTREG, CORE_PIN3_BIT, CORE_PIN3_CONFIG); -MAKE_PIN(P4, CORE_PIN4_PORTREG, CORE_PIN4_BIT, CORE_PIN4_CONFIG); -MAKE_PIN(P5, CORE_PIN5_PORTREG, CORE_PIN5_BIT, CORE_PIN5_CONFIG); -MAKE_PIN(P6, CORE_PIN6_PORTREG, CORE_PIN6_BIT, CORE_PIN6_CONFIG); -MAKE_PIN(P7, CORE_PIN7_PORTREG, CORE_PIN7_BIT, CORE_PIN7_CONFIG); -MAKE_PIN(P8, CORE_PIN8_PORTREG, CORE_PIN8_BIT, CORE_PIN8_CONFIG); -MAKE_PIN(P9, CORE_PIN9_PORTREG, CORE_PIN9_BIT, CORE_PIN9_CONFIG); -MAKE_PIN(P10, CORE_PIN10_PORTREG, CORE_PIN10_BIT, CORE_PIN10_CONFIG); -MAKE_PIN(P11, CORE_PIN11_PORTREG, CORE_PIN11_BIT, CORE_PIN11_CONFIG); -MAKE_PIN(P12, CORE_PIN12_PORTREG, CORE_PIN12_BIT, CORE_PIN12_CONFIG); -MAKE_PIN(P13, CORE_PIN13_PORTREG, CORE_PIN13_BIT, CORE_PIN13_CONFIG); -MAKE_PIN(P14, CORE_PIN14_PORTREG, CORE_PIN14_BIT, CORE_PIN14_CONFIG); -MAKE_PIN(P15, CORE_PIN15_PORTREG, CORE_PIN15_BIT, CORE_PIN15_CONFIG); -MAKE_PIN(P16, CORE_PIN16_PORTREG, CORE_PIN16_BIT, CORE_PIN16_CONFIG); -MAKE_PIN(P17, CORE_PIN17_PORTREG, CORE_PIN17_BIT, CORE_PIN17_CONFIG); -MAKE_PIN(P18, CORE_PIN18_PORTREG, CORE_PIN18_BIT, CORE_PIN18_CONFIG); -MAKE_PIN(P19, CORE_PIN19_PORTREG, CORE_PIN19_BIT, CORE_PIN19_CONFIG); -MAKE_PIN(P20, CORE_PIN20_PORTREG, CORE_PIN20_BIT, CORE_PIN20_CONFIG); -MAKE_PIN(P21, CORE_PIN21_PORTREG, CORE_PIN21_BIT, CORE_PIN21_CONFIG); -MAKE_PIN(P22, CORE_PIN22_PORTREG, CORE_PIN22_BIT, CORE_PIN22_CONFIG); -MAKE_PIN(P23, CORE_PIN23_PORTREG, CORE_PIN23_BIT, CORE_PIN23_CONFIG); -MAKE_PIN(P24, CORE_PIN24_PORTREG, CORE_PIN24_BIT, CORE_PIN24_CONFIG); -MAKE_PIN(P25, CORE_PIN25_PORTREG, CORE_PIN25_BIT, CORE_PIN25_CONFIG); -MAKE_PIN(P26, CORE_PIN26_PORTREG, CORE_PIN26_BIT, CORE_PIN26_CONFIG); -MAKE_PIN(P27, CORE_PIN27_PORTREG, CORE_PIN27_BIT, CORE_PIN27_CONFIG); -MAKE_PIN(P28, CORE_PIN28_PORTREG, CORE_PIN28_BIT, CORE_PIN28_CONFIG); -MAKE_PIN(P29, CORE_PIN29_PORTREG, CORE_PIN29_BIT, CORE_PIN29_CONFIG); -MAKE_PIN(P30, CORE_PIN30_PORTREG, CORE_PIN30_BIT, CORE_PIN30_CONFIG); -MAKE_PIN(P31, CORE_PIN31_PORTREG, CORE_PIN31_BIT, CORE_PIN31_CONFIG); -MAKE_PIN(P32, CORE_PIN32_PORTREG, CORE_PIN32_BIT, CORE_PIN32_CONFIG); -MAKE_PIN(P33, CORE_PIN33_PORTREG, CORE_PIN33_BIT, CORE_PIN33_CONFIG); - -#undef MAKE_PIN - -#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) - -// SetDirRead: -// Disable interrupts -// Disable the pull up resistor -// Set to INPUT -// Enable PIO - -// SetDirWrite: -// Disable interrupts -// Disable the pull up resistor -// Set to OUTPUT -// Enable PIO - -#define MAKE_PIN(className, pio, pinMask) \ -class className { \ -public: \ - static void Set() { \ - pio->PIO_SODR = pinMask; \ - } \ - static void Clear() { \ - pio->PIO_CODR = pinMask; \ - } \ - static void SetDirRead() { \ - pio->PIO_IDR = pinMask ; \ - pio->PIO_PUDR = pinMask; \ - pio->PIO_ODR = pinMask; \ - pio->PIO_PER = pinMask; \ - } \ - static void SetDirWrite() { \ - pio->PIO_IDR = pinMask ; \ - pio->PIO_PUDR = pinMask; \ - pio->PIO_OER = pinMask; \ - pio->PIO_PER = pinMask; \ - } \ - static uint8_t IsSet() { \ - return pio->PIO_PDSR & pinMask; \ - } \ -}; - -// See: http://arduino.cc/en/Hacking/PinMappingSAM3X and variant.cpp - -MAKE_PIN(P0, PIOA, PIO_PA8); -MAKE_PIN(P1, PIOA, PIO_PA9); -MAKE_PIN(P2, PIOB, PIO_PB25); -MAKE_PIN(P3, PIOC, PIO_PC28); -MAKE_PIN(P4, PIOC, PIO_PC26); -MAKE_PIN(P5, PIOC, PIO_PC25); -MAKE_PIN(P6, PIOC, PIO_PC24); -MAKE_PIN(P7, PIOC, PIO_PC23); -MAKE_PIN(P8, PIOC, PIO_PC22); -MAKE_PIN(P9, PIOC, PIO_PC21); -MAKE_PIN(P10, PIOC, PIO_PC29); -MAKE_PIN(P11, PIOD, PIO_PD7); -MAKE_PIN(P12, PIOD, PIO_PD8); -MAKE_PIN(P13, PIOB, PIO_PB27); -MAKE_PIN(P14, PIOD, PIO_PD4); -MAKE_PIN(P15, PIOD, PIO_PD5); -MAKE_PIN(P16, PIOA, PIO_PA13); -MAKE_PIN(P17, PIOA, PIO_PA12); -MAKE_PIN(P18, PIOA, PIO_PA11); -MAKE_PIN(P19, PIOA, PIO_PA10); -MAKE_PIN(P20, PIOB, PIO_PB12); -MAKE_PIN(P21, PIOB, PIO_PB13); -MAKE_PIN(P22, PIOB, PIO_PB26); -MAKE_PIN(P23, PIOA, PIO_PA14); -MAKE_PIN(P24, PIOA, PIO_PA15); -MAKE_PIN(P25, PIOD, PIO_PD0); -MAKE_PIN(P26, PIOD, PIO_PD1); -MAKE_PIN(P27, PIOD, PIO_PD2); -MAKE_PIN(P28, PIOD, PIO_PD3); -MAKE_PIN(P29, PIOD, PIO_PD6); -MAKE_PIN(P30, PIOD, PIO_PD9); -MAKE_PIN(P31, PIOA, PIO_PA7); -MAKE_PIN(P32, PIOD, PIO_PD10); -MAKE_PIN(P33, PIOC, PIO_PC1); -MAKE_PIN(P34, PIOC, PIO_PC2); -MAKE_PIN(P35, PIOC, PIO_PC3); -MAKE_PIN(P36, PIOC, PIO_PC4); -MAKE_PIN(P37, PIOC, PIO_PC5); -MAKE_PIN(P38, PIOC, PIO_PC6); -MAKE_PIN(P39, PIOC, PIO_PC7); -MAKE_PIN(P40, PIOC, PIO_PC8); -MAKE_PIN(P41, PIOC, PIO_PC9); -MAKE_PIN(P42, PIOA, PIO_PA19); -MAKE_PIN(P43, PIOA, PIO_PA20); -MAKE_PIN(P44, PIOC, PIO_PC19); -MAKE_PIN(P45, PIOC, PIO_PC18); -MAKE_PIN(P46, PIOC, PIO_PC17); -MAKE_PIN(P47, PIOC, PIO_PC16); -MAKE_PIN(P48, PIOC, PIO_PC15); -MAKE_PIN(P49, PIOC, PIO_PC14); -MAKE_PIN(P50, PIOC, PIO_PC13); -MAKE_PIN(P51, PIOC, PIO_PC12); -MAKE_PIN(P52, PIOB, PIO_PB21); -MAKE_PIN(P53, PIOB, PIO_PB14); -MAKE_PIN(P54, PIOA, PIO_PA16); -MAKE_PIN(P55, PIOA, PIO_PA24); -MAKE_PIN(P56, PIOA, PIO_PA23); -MAKE_PIN(P57, PIOA, PIO_PA22); -MAKE_PIN(P58, PIOA, PIO_PA6); -MAKE_PIN(P59, PIOA, PIO_PA4); -MAKE_PIN(P60, PIOA, PIO_PA3); -MAKE_PIN(P61, PIOA, PIO_PA2); -MAKE_PIN(P62, PIOB, PIO_PB17); -MAKE_PIN(P63, PIOB, PIO_PB18); -MAKE_PIN(P64, PIOB, PIO_PB19); -MAKE_PIN(P65, PIOB, PIO_PB20); -MAKE_PIN(P66, PIOB, PIO_PB15); -MAKE_PIN(P67, PIOB, PIO_PB16); -MAKE_PIN(P68, PIOA, PIO_PA1); -MAKE_PIN(P69, PIOA, PIO_PA0); -MAKE_PIN(P70, PIOA, PIO_PA17); -MAKE_PIN(P71, PIOA, PIO_PA18); -MAKE_PIN(P72, PIOC, PIO_PC30); -MAKE_PIN(P73, PIOA, PIO_PA21); -MAKE_PIN(P74, PIOA, PIO_PA25); // MISO -MAKE_PIN(P75, PIOA, PIO_PA26); // MOSI -MAKE_PIN(P76, PIOA, PIO_PA27); // CLK -MAKE_PIN(P77, PIOA, PIO_PA28); -MAKE_PIN(P78, PIOB, PIO_PB23); // Unconnected - -#undef MAKE_PIN - -#elif defined(RBL_NRF51822) - -#define MAKE_PIN(className, pin) \ -class className { \ -public: \ - static void Set() { \ - nrf_gpio_pin_set(pin); \ - } \ - static void Clear() { \ - nrf_gpio_pin_clear(pin); \ - } \ - static void SetDirRead() { \ - nrf_gpio_cfg_input(pin, NRF_GPIO_PIN_NOPULL); \ - } \ - static void SetDirWrite() { \ - nrf_gpio_cfg_output(pin); \ - } \ - static uint8_t IsSet() { \ - return (uint8_t)nrf_gpio_pin_read(pin); \ - } \ -}; - -// See: pin_transform.c in RBL nRF51822 SDK -MAKE_PIN(P0, Pin_nRF51822_to_Arduino(D0)); -MAKE_PIN(P1, Pin_nRF51822_to_Arduino(D1)); -MAKE_PIN(P2, Pin_nRF51822_to_Arduino(D2)); -MAKE_PIN(P3, Pin_nRF51822_to_Arduino(D3)); -MAKE_PIN(P4, Pin_nRF51822_to_Arduino(D4)); -MAKE_PIN(P5, Pin_nRF51822_to_Arduino(D5)); -MAKE_PIN(P6, Pin_nRF51822_to_Arduino(D6)); -MAKE_PIN(P7, Pin_nRF51822_to_Arduino(D7)); -MAKE_PIN(P8, Pin_nRF51822_to_Arduino(D8)); -MAKE_PIN(P9, Pin_nRF51822_to_Arduino(D9)); // INT -MAKE_PIN(P10, Pin_nRF51822_to_Arduino(D10)); // SS -MAKE_PIN(P11, Pin_nRF51822_to_Arduino(D11)); -MAKE_PIN(P12, Pin_nRF51822_to_Arduino(D12)); -MAKE_PIN(P13, Pin_nRF51822_to_Arduino(D13)); -MAKE_PIN(P14, Pin_nRF51822_to_Arduino(D14)); -MAKE_PIN(P15, Pin_nRF51822_to_Arduino(D15)); -MAKE_PIN(P17, Pin_nRF51822_to_Arduino(D17)); // MISO -MAKE_PIN(P18, Pin_nRF51822_to_Arduino(D18)); // MOSI -MAKE_PIN(P16, Pin_nRF51822_to_Arduino(D16)); // CLK -MAKE_PIN(P19, Pin_nRF51822_to_Arduino(D19)); -MAKE_PIN(P20, Pin_nRF51822_to_Arduino(D20)); -MAKE_PIN(P21, Pin_nRF51822_to_Arduino(D21)); -MAKE_PIN(P22, Pin_nRF51822_to_Arduino(D22)); -MAKE_PIN(P23, Pin_nRF51822_to_Arduino(D23)); -MAKE_PIN(P24, Pin_nRF51822_to_Arduino(D24)); - -#undef MAKE_PIN - -#else -#error "Please define board in avrpins.h" - -#endif - -#elif defined(__ARDUINO_X86__) // Intel Galileo, Intel Galileo 2 and Intel Edison - -#include - -// Pointers are 32 bits on x86 -#define pgm_read_pointer(p) pgm_read_dword(p) - -#if PLATFORM_ID == 0xE1 // Edison platform id -#define pinToFastPin(pin) 1 // As far as I can tell all pins can be used as fast pins -#endif - -// Pin 2 and 3 on the Intel Galileo supports a higher rate, -// so it is recommended to use one of these as the SS pin. - -#define MAKE_PIN(className, pin) \ -class className { \ -public: \ - static void Set() { \ - fastDigitalWrite(pin, HIGH); \ - } \ - static void Clear() { \ - fastDigitalWrite(pin, LOW); \ - } \ - static void SetDirRead() { \ - if (pinToFastPin(pin)) \ - pinMode(pin, INPUT_FAST); \ - else \ - pinMode(pin, INPUT); \ - } \ - static void SetDirWrite() { \ - if (pinToFastPin(pin)) \ - pinMode(pin, OUTPUT_FAST); \ - else \ - pinMode(pin, OUTPUT); \ - } \ - static uint8_t IsSet() { \ - return fastDigitalRead(pin); \ - } \ -}; - -MAKE_PIN(P0, 0); -MAKE_PIN(P1, 1); -MAKE_PIN(P2, 2); -MAKE_PIN(P3, 3); -MAKE_PIN(P4, 4); -MAKE_PIN(P5, 5); -MAKE_PIN(P6, 6); -MAKE_PIN(P7, 7); -MAKE_PIN(P8, 8); -MAKE_PIN(P9, 9); -MAKE_PIN(P10, 10); -MAKE_PIN(P11, 11); -MAKE_PIN(P12, 12); -MAKE_PIN(P13, 13); -MAKE_PIN(P14, 14); // A0 -MAKE_PIN(P15, 15); // A1 -MAKE_PIN(P16, 16); // A2 -MAKE_PIN(P17, 17); // A3 -MAKE_PIN(P18, 18); // A4 -MAKE_PIN(P19, 19); // A5 - -#undef MAKE_PIN - -#elif defined(__MIPSEL__) -// MIPSEL (MIPS architecture using a little endian byte order) - -// MIPS size_t = 4 -#define pgm_read_pointer(p) pgm_read_dword(p) - -#define MAKE_PIN(className, pin) \ -class className { \ -public: \ - static void Set() { \ - digitalWrite(pin, HIGH);\ - } \ - static void Clear() { \ - digitalWrite(pin, LOW); \ - } \ - static void SetDirRead() { \ - pinMode(pin, INPUT); \ - } \ - static void SetDirWrite() { \ - pinMode(pin, OUTPUT); \ - } \ - static uint8_t IsSet() { \ - return digitalRead(pin); \ - } \ -}; - -// 0 .. 13 - Digital pins -MAKE_PIN(P0, 0); // RX -MAKE_PIN(P1, 1); // TX -MAKE_PIN(P2, 2); // -MAKE_PIN(P3, 3); // -MAKE_PIN(P4, 4); // -MAKE_PIN(P5, 5); // -MAKE_PIN(P6, 6); // -MAKE_PIN(P7, 7); // -MAKE_PIN(P8, 8); // -MAKE_PIN(P9, 9); // -MAKE_PIN(P10, 10); // -MAKE_PIN(P11, 11); // -MAKE_PIN(P12, 12); // -MAKE_PIN(P13, 13); // - -#undef MAKE_PIN - -#else -#error "Please define board in avrpins.h" - -#endif - -#endif //_avrpins_h_ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/cdc_XR21B1411.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/cdc_XR21B1411.cpp deleted file mode 100644 index 74df8c3b..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/cdc_XR21B1411.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#include "cdc_XR21B1411.h" - -XR21B1411::XR21B1411(USB *p, CDCAsyncOper *pasync) : -ACM(p, pasync) { - // Is this needed?? - _enhanced_status = enhanced_features(); // Set up features -} - -uint8_t XR21B1411::Init(uint8_t parent, uint8_t port, bool lowspeed) { - const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR); - - uint8_t buf[constBufSize]; - USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); - - uint8_t rcode; - UsbDevice *p = NULL; - EpInfo *oldep_ptr = NULL; - uint8_t num_of_conf; // number of configurations - - AddressPool &addrPool = pUsb->GetAddressPool(); - - USBTRACE("XR Init\r\n"); - - if(bAddress) - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - if(!p->epinfo) { - USBTRACE("epinfo\r\n"); - return USB_ERROR_EPINFO_IS_NULL; - } - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - - p->lowspeed = lowspeed; - - // Get device descriptor - rcode = pUsb->getDevDescr(0, 0, constBufSize, (uint8_t*)buf); - - // Restore p->epinfo - p->epinfo = oldep_ptr; - - if(rcode) - goto FailGetDevDescr; - - // Allocate new address according to device class - bAddress = addrPool.AllocAddress(parent, false, port); - - if(!bAddress) - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - - // Extract Max Packet Size from the device descriptor - epInfo[0].maxPktSize = udd->bMaxPacketSize0; - - // Assign new address to the device - rcode = pUsb->setAddr(0, 0, bAddress); - - if(rcode) { - p->lowspeed = false; - addrPool.FreeAddress(bAddress); - bAddress = 0; - USBTRACE2("setAddr:", rcode); - return rcode; - } - - USBTRACE2("Addr:", bAddress); - - p->lowspeed = false; - - p = addrPool.GetUsbDevicePtr(bAddress); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - p->lowspeed = lowspeed; - - num_of_conf = udd->bNumConfigurations; - - if((((udd->idVendor != 0x2890U) || (udd->idProduct != 0x0201U)) && ((udd->idVendor != 0x04e2U) || (udd->idProduct != 0x1411U)))) - return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - - // Assign epInfo to epinfo pointer - rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo); - - if(rcode) - goto FailSetDevTblEntry; - - USBTRACE2("NC:", num_of_conf); - - for(uint8_t i = 0; i < num_of_conf; i++) { - ConfigDescParser< USB_CLASS_COM_AND_CDC_CTRL, - CDC_SUBCLASS_ACM, - CDC_PROTOCOL_ITU_T_V_250, - CP_MASK_COMPARE_CLASS | - CP_MASK_COMPARE_SUBCLASS | - CP_MASK_COMPARE_PROTOCOL > CdcControlParser(this); - - ConfigDescParser CdcDataParser(this); - - rcode = pUsb->getConfDescr(bAddress, 0, i, &CdcControlParser); - - if(rcode) - goto FailGetConfDescr; - - rcode = pUsb->getConfDescr(bAddress, 0, i, &CdcDataParser); - - if(rcode) - goto FailGetConfDescr; - - if(bNumEP > 1) - break; - } // for - - if(bNumEP < 4) - return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - - // Assign epInfo to epinfo pointer - rcode = pUsb->setEpInfoEntry(bAddress, bNumEP, epInfo); - - USBTRACE2("Conf:", bConfNum); - - // Set Configuration Value - rcode = pUsb->setConf(bAddress, 0, bConfNum); - - if(rcode) - goto FailSetConfDescr; - - // Set up features status - _enhanced_status = enhanced_features(); - half_duplex(false); - autoflowRTS(false); - autoflowDSR(false); - autoflowXON(false); - wide(false); // Always false, because this is only available in custom mode. - - rcode = pAsync->OnInit(this); - - if(rcode) - goto FailOnInit; - - USBTRACE("XR configured\r\n"); - - ready = true; - - //bPollEnable = true; - - //USBTRACE("Poll enabled\r\n"); - return 0; - -FailGetDevDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetDevDescr(); - goto Fail; -#endif - -FailSetDevTblEntry: -#ifdef DEBUG_USB_HOST - NotifyFailSetDevTblEntry(); - goto Fail; -#endif - -FailGetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetConfDescr(); - goto Fail; -#endif - -FailSetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailSetConfDescr(); - goto Fail; -#endif - -FailOnInit: -#ifdef DEBUG_USB_HOST - USBTRACE("OnInit:"); -#endif - -#ifdef DEBUG_USB_HOST -Fail: - NotifyFail(rcode); -#endif - Release(); - return rcode; -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/cdc_XR21B1411.h b/protocol/usb_hid/USB_Host_Shield_2.0/cdc_XR21B1411.h deleted file mode 100644 index c3262754..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/cdc_XR21B1411.h +++ /dev/null @@ -1,272 +0,0 @@ -/* Copyright (C) 2015 Andrew J. Kroll - and - Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(__CDC_XR21B1411_H__) -#define __CDC_XR21B1411_H__ - -#include "cdcacm.h" - -#define XR_REG_CUSTOM_DRIVER (0x020DU) // DRIVER SELECT -#define XR_REG_CUSTOM_DRIVER_ACTIVE (0x0001U) // 0: CDC 1: CUSTOM - -#define XR_REG_ACM_FLOW_CTL (0x0216U) // FLOW CONTROL REGISTER CDCACM MODE -#define XR_REG_FLOW_CTL (0x0C06U) // FLOW CONTROL REGISTER CUSTOM MODE -#define XR_REG_FLOW_CTL_HALF_DPLX (0x0008U) // 0:FULL DUPLEX 1:HALF DUPLEX -#define XR_REG_FLOW_CTL_MODE_MASK (0x0007U) // MODE BITMASK -#define XR_REG_FLOW_CTL_NONE (0x0000U) // NO FLOW CONTROL -#define XR_REG_FLOW_CTL_HW (0x0001U) // HARDWARE FLOW CONTROL -#define XR_REG_FLOW_CTL_SW (0x0002U) // SOFTWARE FLOW CONTROL -#define XR_REG_FLOW_CTL_MMMRX (0x0003U) // MULTIDROP RX UPON ADDRESS MATCH -#define XR_REG_FLOW_CTL_MMMRXTX (0x0004U) // MULTIDROP RX/TX UPON ADDRESS MATCH - -#define XR_REG_ACM_GPIO_MODE (0x0217U) // GPIO MODE REGISTER IN CDCACM MODE -#define XR_REG_GPIO_MODE (0x0C0CU) // GPIO MODE REGISTER IN CUSTOM MODE -#define XR_REG_GPIO_MODE_GPIO (0x0000U) // ALL GPIO PINS ACM PROGRAMMABLE -#define XR_REG_GPIO_MODE_FC_RTSCTS (0x0001U) // AUTO RTSCTS HW FC (GPIO 4/5) -#define XR_REG_GPIO_MODE_FC_DTRDSR (0x0002U) // AUTO DTRDSR HW FC (GPIO 2/3) -#define XR_REG_GPIO_MODE_ATE (0x0003U) // AUTO TRANSCEIVER ENABLE DURING TX (GPIO 5) -#define XR_REG_GPIO_MODE_ATE_ADDRESS (0x0004U) // AUTO TRANSCEIVER ENABLE ON ADDRESS MATCH (GPIO 5) - -#define XR_REG_ACM_GPIO_DIR (0x0218U) // GPIO DIRECTION REGISTER CDCACM MODE, 0:IN 1:OUT -#define XR_REG_GPIO_DIR (0x0C0DU) // GPIO DIRECTION REGISTER CUSTOM MODE, 0:IN 1:OUT - -#define XR_REG_ACM_GPIO_INT (0x0219U) // GPIO PIN CHANGE INTERRUPT ENABLE CDCACM MODE, 0: ENABLED 1: DISABLED -#define XR_REG_GPIO_INT (0x0C11U) // GPIO PIN CHANGE INTERRUPT ENABLE CUSTOM MODE, 0: ENABLED 1: DISABLED -#define XR_REG_GPIO_MASK (0x001FU) // GPIO REGISTERS BITMASK - -#define XR_REG_UART_ENABLE (0x0C00U) // UART I/O ENABLE REGISTER -#define XR_REG_UART_ENABLE_RX (0x0002U) // 0:DISABLED 1:ENABLED -#define XR_REG_UART_ENABLE_TX (0x0001U) // 0:DISABLED 1:ENABLED - -#define XR_REG_ERROR_STATUS (0x0C09U) // ERROR STATUS REGISTER -#define XR_REG_ERROR_STATUS_MASK (0x00F8U) // ERROR STATUS BITMASK -#define XR_REG_ERROR_STATUS_ERROR (0x0078U) // ERROR STATUS ERROR BITMASK -#define XR_REG_ERROR_STATUS_BREAK (0x0008U) // BREAK ERROR HAS BEEN DETECTED -#define XR_REG_ERROR_STATUS_FRAME (0x0010U) // FRAMING ERROR HAS BEEN DETECTED -#define XR_REG_ERROR_STATUS_PARITY (0x0020U) // PARITY ERROR HAS BEEN DETECTED -#define XR_REG_ERROR_STATUS_OVERRUN (0x0040U) // RX OVERRUN ERROR HAS BEEN DETECTED -#define XR_REG_ERROR_STATUS_BREAK_STATUS (0x0080U) // BREAK CONDITION IS CURRENTLY BEING DETECTED - -#define XR_REG_TX_BREAK (0x0C0AU) // TRANSMIT BREAK. 0X0001-0XFFE TIME IN MS, 0X0000 STOP, 0X0FFF BREAK ON - -#define XR_REG_XCVR_EN_DELAY (0x0C0BU) // TURN-ARROUND DELAY IN BIT-TIMES 0X0000-0X000F - -#define XR_REG_GPIO_SET (0x0C0EU) // 1:SET GPIO PIN - -#define XR_REG_GPIO_CLR (0x0C0FU) // 1:CLEAR GPIO PIN - -#define XR_REG_GPIO_STATUS (0x0C10U) // READ GPIO PINS - -#define XR_REG_CUSTOMISED_INT (0x0C12U) // 0:STANDARD 1:CUSTOM SEE DATA SHEET - -#define XR_REG_PIN_PULLUP_ENABLE (0x0C14U) // 0:DISABLE 1:ENABLE, BITS 0-5:GPIO, 6:RX 7:TX - -#define XR_REG_PIN_PULLDOWN_ENABLE (0x0C15U) // 0:DISABLE 1:ENABLE, BITS 0-5:GPIO, 6:RX 7:TX - -#define XR_REG_LOOPBACK (0x0C16U) // 0:DISABLE 1:ENABLE, SEE DATA SHEET - -#define XR_REG_RX_FIFO_LATENCY (0x0CC2U) // FIFO LATENCY REGISTER -#define XR_REG_RX_FIFO_LATENCY_ENABLE (0x0001U) // - -#define XR_REG_WIDE_MODE (0x0D02U) -#define XR_REG_WIDE_MODE_ENABLE (0x0001U) - -#define XR_REG_XON_CHAR (0x0C07U) -#define XR_REG_XOFF_CHAR (0x0C08U) - -#define XR_REG_TX_FIFO_RESET (0x0C80U) // 1: RESET, SELF-CLEARING -#define XR_REG_TX_FIFO_COUNT (0x0C81U) // READ-ONLY -#define XR_REG_RX_FIFO_RESET (0x0CC0U) // 1: RESET, SELF-CLEARING -#define XR_REG_RX_FIFO_COUNT (0x0CC1U) // READ-ONLY - -#define XR_WRITE_REQUEST_TYPE (0x40U) - -#define XR_READ_REQUEST_TYPE (0xC0U) - -#define XR_MAX_ENDPOINTS 4 - -class XR21B1411 : public ACM { -protected: - -public: - XR21B1411(USB *pusb, CDCAsyncOper *pasync); - - /** - * Used by the USB core to check what this driver support. - * @param vid The device's VID. - * @param pid The device's PID. - * @return Returns true if the device's VID and PID matches this driver. - */ - virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { - return (((vid == 0x2890U) && (pid == 0x0201U)) || ((vid == 0x04e2U) && (pid == 0x1411U))); - }; - - uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - - virtual tty_features enhanced_features(void) { - tty_features rv; - rv.enhanced = true; - rv.autoflow_RTS = true; - rv.autoflow_DSR = true; - rv.autoflow_XON = true; - rv.half_duplex = true; - rv.wide = true; - return rv; - }; - - uint8_t read_register(uint16_t reg, uint16_t *val) { - return (pUsb->ctrlReq(bAddress, 0, XR_READ_REQUEST_TYPE, 1, 0, 0, reg, 2, 2, (uint8_t *)val, NULL)); - } - - uint8_t write_register(uint16_t reg, uint16_t val) { - return (pUsb->ctrlReq(bAddress, 0, XR_WRITE_REQUEST_TYPE, 0, BGRAB0(val), BGRAB1(val), reg, 0, 0, NULL, NULL)); - } - - - //////////////////////////////////////////////////////////////////////// - // The following methods set the CDC-ACM defaults. - //////////////////////////////////////////////////////////////////////// - - virtual void autoflowRTS(bool s) { - uint16_t val; - uint8_t rval; - rval = read_register(XR_REG_ACM_FLOW_CTL, &val); - if(!rval) { - if(s) { - val &= XR_REG_FLOW_CTL_HALF_DPLX; - val |= XR_REG_FLOW_CTL_HW; - } else { - val &= XR_REG_FLOW_CTL_HALF_DPLX; - } - rval = write_register(XR_REG_ACM_FLOW_CTL, val); - if(!rval) { - rval = write_register(XR_REG_ACM_GPIO_MODE, XR_REG_GPIO_MODE_GPIO); - if(!rval) { - // ACM commands apply the new settings. - LINE_CODING LCT; - rval = GetLineCoding(&LCT); - if(!rval) { - rval = SetLineCoding(&LCT); - if(!rval) { - _enhanced_status.autoflow_XON = false; - _enhanced_status.autoflow_DSR = false; - _enhanced_status.autoflow_RTS = s; - } - } - } - } - } - }; - - virtual void autoflowDSR(bool s) { - uint16_t val; - uint8_t rval; - rval = read_register(XR_REG_ACM_FLOW_CTL, &val); - if(!rval) { - if(s) { - val &= XR_REG_FLOW_CTL_HALF_DPLX; - val |= XR_REG_FLOW_CTL_HW; - } else { - val &= XR_REG_FLOW_CTL_HALF_DPLX; - } - rval = write_register(XR_REG_ACM_FLOW_CTL, val); - if(!rval) { - if(s) { - rval = write_register(XR_REG_ACM_GPIO_MODE, XR_REG_GPIO_MODE_FC_DTRDSR); - } else { - rval = write_register(XR_REG_ACM_GPIO_MODE, XR_REG_GPIO_MODE_GPIO); - } - if(!rval) { - // ACM commands apply the new settings. - LINE_CODING LCT; - rval = GetLineCoding(&LCT); - if(!rval) { - rval = SetLineCoding(&LCT); - if(!rval) { - _enhanced_status.autoflow_XON = false; - _enhanced_status.autoflow_RTS = false; - _enhanced_status.autoflow_DSR = s; - } - } - } - } - } - }; - - virtual void autoflowXON(bool s) { - // NOTE: hardware defaults to the normal XON/XOFF - uint16_t val; - uint8_t rval; - rval = read_register(XR_REG_ACM_FLOW_CTL, &val); - if(!rval) { - if(s) { - val &= XR_REG_FLOW_CTL_HALF_DPLX; - val |= XR_REG_FLOW_CTL_SW; - } else { - val &= XR_REG_FLOW_CTL_HALF_DPLX; - } - rval = write_register(XR_REG_ACM_FLOW_CTL, val); - if(!rval) { - rval = write_register(XR_REG_ACM_GPIO_MODE, XR_REG_GPIO_MODE_GPIO); - if(!rval) { - // ACM commands apply the new settings. - LINE_CODING LCT; - rval = GetLineCoding(&LCT); - if(!rval) { - rval = SetLineCoding(&LCT); - if(!rval) { - _enhanced_status.autoflow_RTS = false; - _enhanced_status.autoflow_DSR = false; - _enhanced_status.autoflow_XON = s; - } - } - } - } - } - }; - - virtual void half_duplex(bool s) { - uint16_t val; - uint8_t rval; - rval = read_register(XR_REG_ACM_FLOW_CTL, &val); - if(!rval) { - if(s) { - val |= XR_REG_FLOW_CTL_HALF_DPLX; - } else { - val &= XR_REG_FLOW_CTL_MODE_MASK; - } - rval = write_register(XR_REG_ACM_FLOW_CTL, val); - if(!rval) { - // ACM commands apply the new settings. - LINE_CODING LCT; - rval = GetLineCoding(&LCT); - if(!rval) { - rval = SetLineCoding(&LCT); - if(!rval) { - _enhanced_status.half_duplex = s; - } - } - } - } - }; - - - -}; - -#endif // __CDCPROLIFIC_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/cdcacm.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/cdcacm.cpp deleted file mode 100644 index 2cd2c9a8..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/cdcacm.cpp +++ /dev/null @@ -1,331 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#include "cdcacm.h" - -const uint8_t ACM::epDataInIndex = 1; -const uint8_t ACM::epDataOutIndex = 2; -const uint8_t ACM::epInterruptInIndex = 3; - -ACM::ACM(USB *p, CDCAsyncOper *pasync) : -pUsb(p), -pAsync(pasync), -bAddress(0), -bControlIface(0), -bDataIface(0), -bNumEP(1), -qNextPollTime(0), -bPollEnable(false), -ready(false) { - _enhanced_status = enhanced_features(); // Set up features - for(uint8_t i = 0; i < ACM_MAX_ENDPOINTS; i++) { - epInfo[i].epAddr = 0; - epInfo[i].maxPktSize = (i) ? 0 : 8; - epInfo[i].epAttribs = 0; - epInfo[i].bmNakPower = (i == epDataInIndex) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER; - - } - if(pUsb) - pUsb->RegisterDeviceClass(this); -} - -uint8_t ACM::Init(uint8_t parent, uint8_t port, bool lowspeed) { - - const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR); - - uint8_t buf[constBufSize]; - USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); - - uint8_t rcode; - UsbDevice *p = NULL; - EpInfo *oldep_ptr = NULL; - uint8_t num_of_conf; // number of configurations - - AddressPool &addrPool = pUsb->GetAddressPool(); - - USBTRACE("ACM Init\r\n"); - - if(bAddress) - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - if(!p->epinfo) { - USBTRACE("epinfo\r\n"); - return USB_ERROR_EPINFO_IS_NULL; - } - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - - p->lowspeed = lowspeed; - - // Get device descriptor - rcode = pUsb->getDevDescr(0, 0, constBufSize, (uint8_t*)buf); - - // Restore p->epinfo - p->epinfo = oldep_ptr; - - if(rcode) - goto FailGetDevDescr; - - // Allocate new address according to device class - bAddress = addrPool.AllocAddress(parent, false, port); - - if(!bAddress) - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - - // Extract Max Packet Size from the device descriptor - epInfo[0].maxPktSize = udd->bMaxPacketSize0; - - // Assign new address to the device - rcode = pUsb->setAddr(0, 0, bAddress); - - if(rcode) { - p->lowspeed = false; - addrPool.FreeAddress(bAddress); - bAddress = 0; - USBTRACE2("setAddr:", rcode); - return rcode; - } - - USBTRACE2("Addr:", bAddress); - - p->lowspeed = false; - - p = addrPool.GetUsbDevicePtr(bAddress); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - p->lowspeed = lowspeed; - - num_of_conf = udd->bNumConfigurations; - - // Assign epInfo to epinfo pointer - rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo); - - if(rcode) - goto FailSetDevTblEntry; - - USBTRACE2("NC:", num_of_conf); - - for(uint8_t i = 0; i < num_of_conf; i++) { - ConfigDescParser< USB_CLASS_COM_AND_CDC_CTRL, - CDC_SUBCLASS_ACM, - CDC_PROTOCOL_ITU_T_V_250, - CP_MASK_COMPARE_CLASS | - CP_MASK_COMPARE_SUBCLASS | - CP_MASK_COMPARE_PROTOCOL > CdcControlParser(this); - - ConfigDescParser CdcDataParser(this); - - rcode = pUsb->getConfDescr(bAddress, 0, i, &CdcControlParser); - - if(rcode) - goto FailGetConfDescr; - - rcode = pUsb->getConfDescr(bAddress, 0, i, &CdcDataParser); - - if(rcode) - goto FailGetConfDescr; - - if(bNumEP > 1) - break; - } // for - - if(bNumEP < 4) - return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - - // Assign epInfo to epinfo pointer - rcode = pUsb->setEpInfoEntry(bAddress, bNumEP, epInfo); - - USBTRACE2("Conf:", bConfNum); - - // Set Configuration Value - rcode = pUsb->setConf(bAddress, 0, bConfNum); - - if(rcode) - goto FailSetConfDescr; - - // Set up features status - _enhanced_status = enhanced_features(); - half_duplex(false); - autoflowRTS(false); - autoflowDSR(false); - autoflowXON(false); - wide(false); // Always false, because this is only available in custom mode. - rcode = pAsync->OnInit(this); - - if(rcode) - goto FailOnInit; - - USBTRACE("ACM configured\r\n"); - - ready = true; - - //bPollEnable = true; - - //USBTRACE("Poll enabled\r\n"); - return 0; - -FailGetDevDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetDevDescr(); - goto Fail; -#endif - -FailSetDevTblEntry: -#ifdef DEBUG_USB_HOST - NotifyFailSetDevTblEntry(); - goto Fail; -#endif - -FailGetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetConfDescr(); - goto Fail; -#endif - -FailSetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailSetConfDescr(); - goto Fail; -#endif - -FailOnInit: -#ifdef DEBUG_USB_HOST - USBTRACE("OnInit:"); -#endif - -#ifdef DEBUG_USB_HOST -Fail: - NotifyFail(rcode); -#endif - Release(); - return rcode; -} - -void ACM::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) { - //ErrorMessage (PSTR("Conf.Val"), conf); - //ErrorMessage (PSTR("Iface Num"), iface); - //ErrorMessage (PSTR("Alt.Set"), alt); - - bConfNum = conf; - - uint8_t index; - - if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) - index = epInterruptInIndex; - else - if((pep->bmAttributes & 0x02) == 2) - index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; - else - return; - - // Fill in the endpoint info structure - epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F); - epInfo[index].maxPktSize = (uint8_t)pep->wMaxPacketSize; - epInfo[index].epAttribs = 0; - - bNumEP++; - - PrintEndpointDescriptor(pep); -} - -uint8_t ACM::Release() { - ready = false; - pUsb->GetAddressPool().FreeAddress(bAddress); - - bControlIface = 0; - bDataIface = 0; - bNumEP = 1; - - bAddress = 0; - qNextPollTime = 0; - bPollEnable = false; - return 0; -} - -uint8_t ACM::Poll() { - uint8_t rcode = 0; - - if(!bPollEnable) - return 0; - - return rcode; -} - -uint8_t ACM::RcvData(uint16_t *bytes_rcvd, uint8_t *dataptr) { - return pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, bytes_rcvd, dataptr); -} - -uint8_t ACM::SndData(uint16_t nbytes, uint8_t *dataptr) { - return pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, nbytes, dataptr); -} - -uint8_t ACM::SetCommFeature(uint16_t fid, uint8_t nbytes, uint8_t *dataptr) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_CDCOUT, CDC_SET_COMM_FEATURE, (fid & 0xff), (fid >> 8), bControlIface, nbytes, nbytes, dataptr, NULL)); -} - -uint8_t ACM::GetCommFeature(uint16_t fid, uint8_t nbytes, uint8_t *dataptr) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_CDCIN, CDC_GET_COMM_FEATURE, (fid & 0xff), (fid >> 8), bControlIface, nbytes, nbytes, dataptr, NULL)); -} - -uint8_t ACM::ClearCommFeature(uint16_t fid) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_CDCOUT, CDC_CLEAR_COMM_FEATURE, (fid & 0xff), (fid >> 8), bControlIface, 0, 0, NULL, NULL)); -} - -uint8_t ACM::SetLineCoding(const LINE_CODING *dataptr) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_CDCOUT, CDC_SET_LINE_CODING, 0x00, 0x00, bControlIface, sizeof (LINE_CODING), sizeof (LINE_CODING), (uint8_t*)dataptr, NULL)); -} - -uint8_t ACM::GetLineCoding(LINE_CODING *dataptr) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_CDCIN, CDC_GET_LINE_CODING, 0x00, 0x00, bControlIface, sizeof (LINE_CODING), sizeof (LINE_CODING), (uint8_t*)dataptr, NULL)); -} - -uint8_t ACM::SetControlLineState(uint8_t state) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_CDCOUT, CDC_SET_CONTROL_LINE_STATE, state, 0, bControlIface, 0, 0, NULL, NULL)); -} - -uint8_t ACM::SendBreak(uint16_t duration) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_CDCOUT, CDC_SEND_BREAK, (duration & 0xff), (duration >> 8), bControlIface, 0, 0, NULL, NULL)); -} - -void ACM::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) { - Notify(PSTR("Endpoint descriptor:"), 0x80); - Notify(PSTR("\r\nLength:\t\t"), 0x80); - D_PrintHex (ep_ptr->bLength, 0x80); - Notify(PSTR("\r\nType:\t\t"), 0x80); - D_PrintHex (ep_ptr->bDescriptorType, 0x80); - Notify(PSTR("\r\nAddress:\t"), 0x80); - D_PrintHex (ep_ptr->bEndpointAddress, 0x80); - Notify(PSTR("\r\nAttributes:\t"), 0x80); - D_PrintHex (ep_ptr->bmAttributes, 0x80); - Notify(PSTR("\r\nMaxPktSize:\t"), 0x80); - D_PrintHex (ep_ptr->wMaxPacketSize, 0x80); - Notify(PSTR("\r\nPoll Intrv:\t"), 0x80); - D_PrintHex (ep_ptr->bInterval, 0x80); - Notify(PSTR("\r\n"), 0x80); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/cdcacm.h b/protocol/usb_hid/USB_Host_Shield_2.0/cdcacm.h deleted file mode 100644 index 2a38524d..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/cdcacm.h +++ /dev/null @@ -1,252 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(__CDCACM_H__) -#define __CDCACM_H__ - -#include "Usb.h" - -#define bmREQ_CDCOUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE -#define bmREQ_CDCIN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE - -// CDC Subclass Constants -#define CDC_SUBCLASS_DLCM 0x01 // Direct Line Control Model -#define CDC_SUBCLASS_ACM 0x02 // Abstract Control Model -#define CDC_SUBCLASS_TCM 0x03 // Telephone Control Model -#define CDC_SUBCLASS_MCCM 0x04 // Multi Channel Control Model -#define CDC_SUBCLASS_CAPI 0x05 // CAPI Control Model -#define CDC_SUBCLASS_ETHERNET 0x06 // Ethernet Network Control Model -#define CDC_SUBCLASS_ATM 0x07 // ATM Network Control Model -#define CDC_SUBCLASS_WIRELESS_HANDSET 0x08 // Wireless Handset Control Model -#define CDC_SUBCLASS_DEVICE_MANAGEMENT 0x09 // Device Management -#define CDC_SUBCLASS_MOBILE_DIRECT_LINE 0x0A // Mobile Direct Line Model -#define CDC_SUBCLASS_OBEX 0x0B // OBEX -#define CDC_SUBCLASS_ETHERNET_EMU 0x0C // Ethernet Emulation Model - -// Communication Interface Class Control Protocol Codes -#define CDC_PROTOCOL_ITU_T_V_250 0x01 // AT Commands defined by ITU-T V.250 -#define CDC_PROTOCOL_PCCA_101 0x02 // AT Commands defined by PCCA-101 -#define CDC_PROTOCOL_PCCA_101_O 0x03 // AT Commands defined by PCCA-101 & Annex O -#define CDC_PROTOCOL_GSM_7_07 0x04 // AT Commands defined by GSM 7.07 -#define CDC_PROTOCOL_3GPP_27_07 0x05 // AT Commands defined by 3GPP 27.007 -#define CDC_PROTOCOL_C_S0017_0 0x06 // AT Commands defined by TIA for CDMA -#define CDC_PROTOCOL_USB_EEM 0x07 // Ethernet Emulation Model - -// CDC Commands defined by CDC 1.2 -#define CDC_SEND_ENCAPSULATED_COMMAND 0x00 -#define CDC_GET_ENCAPSULATED_RESPONSE 0x01 - -// CDC Commands defined by PSTN 1.2 -#define CDC_SET_COMM_FEATURE 0x02 -#define CDC_GET_COMM_FEATURE 0x03 -#define CDC_CLEAR_COMM_FEATURE 0x04 -#define CDC_SET_AUX_LINE_STATE 0x10 -#define CDC_SET_HOOK_STATE 0x11 -#define CDC_PULSE_SETUP 0x12 -#define CDC_SEND_PULSE 0x13 -#define CDC_SET_PULSE_TIME 0x14 -#define CDC_RING_AUX_JACK 0x15 -#define CDC_SET_LINE_CODING 0x20 -#define CDC_GET_LINE_CODING 0x21 -#define CDC_SET_CONTROL_LINE_STATE 0x22 -#define CDC_SEND_BREAK 0x23 -#define CDC_SET_RINGER_PARMS 0x30 -#define CDC_GET_RINGER_PARMS 0x31 -#define CDC_SET_OPERATION_PARMS 0x32 -#define CDC_GET_OPERATION_PARMS 0x33 -#define CDC_SET_LINE_PARMS 0x34 -#define CDC_GET_LINE_PARMS 0x35 -#define CDC_DIAL_DIGITS 0x36 - -//Class-Specific Notification Codes -#define NETWORK_CONNECTION 0x00 -#define RESPONSE_AVAILABLE 0x01 -#define AUX_JACK_HOOK_STATE 0x08 -#define RING_DETECT 0x09 -#define SERIAL_STATE 0x20 -#define CALL_STATE_CHANGE 0x28 -#define LINE_STATE_CHANGE 0x29 -#define CONNECTION_SPEED_CHANGE 0x2a - -// CDC Functional Descriptor Structures - -typedef struct { - uint8_t bFunctionLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubtype; - uint8_t bmCapabilities; - uint8_t bDataInterface; -} CALL_MGMNT_FUNC_DESCR; - -typedef struct { - uint8_t bFunctionLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubtype; - uint8_t bmCapabilities; -} ACM_FUNC_DESCR, DLM_FUNC_DESCR, TEL_OPER_MODES_FUNC_DESCR, -TEL_CALL_STATE_REP_CPBL_FUNC_DESCR; - -typedef struct { - uint8_t bFunctionLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubtype; - uint8_t bRingerVolSteps; - uint8_t bNumRingerPatterns; -} TEL_RINGER_FUNC_DESCR; - -typedef struct { - uint32_t dwDTERate; // Data Terminal Rate in bits per second - uint8_t bCharFormat; // 0 - 1 stop bit, 1 - 1.5 stop bits, 2 - 2 stop bits - uint8_t bParityType; // 0 - None, 1 - Odd, 2 - Even, 3 - Mark, 4 - Space - uint8_t bDataBits; // Data bits (5, 6, 7, 8 or 16) -} LINE_CODING; - -typedef struct { - uint8_t bmRequestType; // 0xa1 for class-specific notifications - uint8_t bNotification; - uint16_t wValue; - uint16_t wIndex; - uint16_t wLength; - uint16_t bmState; //UART state bitmap for SERIAL_STATE, other notifications variable length -} CLASS_NOTIFICATION; - -class ACM; - -class CDCAsyncOper { -public: - - virtual uint8_t OnInit(ACM *pacm) { - return 0; - }; - //virtual void OnDataRcvd(ACM *pacm, uint8_t nbytes, uint8_t *dataptr) = 0; - //virtual void OnDisconnected(ACM *pacm) = 0; -}; - -/** - * This structure is used to report the extended capabilities of the connected device. - * It is also used to report the current status. - * Regular CDC-ACM reports all as false. - */ -typedef struct { - - union { - uint8_t tty; - - struct { - bool enhanced : 1; // Do we have the ability to set/clear any features? - // Status and 8th bit in data stream. - // Presence only indicates feature is available, but this isn't used for CDC-ACM. - bool wide : 1; - bool autoflow_RTS : 1; // Has autoflow on RTS/CTS - bool autoflow_DSR : 1; // Has autoflow on DTR/DSR - bool autoflow_XON : 1; // Has autoflow XON/XOFF - bool half_duplex : 1; // Has half-duplex capability. - } __attribute__((packed)); - }; -} tty_features; - -#define ACM_MAX_ENDPOINTS 4 - -class ACM : public USBDeviceConfig, public UsbConfigXtracter { -protected: - static const uint8_t epDataInIndex; // DataIn endpoint index - static const uint8_t epDataOutIndex; // DataOUT endpoint index - static const uint8_t epInterruptInIndex; // InterruptIN endpoint index - - USB *pUsb; - CDCAsyncOper *pAsync; - uint8_t bAddress; - uint8_t bConfNum; // configuration number - uint8_t bControlIface; // Control interface value - uint8_t bDataIface; // Data interface value - uint8_t bNumEP; // total number of EP in the configuration - uint32_t qNextPollTime; // next poll time - volatile bool bPollEnable; // poll enable flag - volatile bool ready; //device ready indicator - tty_features _enhanced_status; // current status - - EpInfo epInfo[ACM_MAX_ENDPOINTS]; - - void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); - -public: - ACM(USB *pusb, CDCAsyncOper *pasync); - - uint8_t SetCommFeature(uint16_t fid, uint8_t nbytes, uint8_t *dataptr); - uint8_t GetCommFeature(uint16_t fid, uint8_t nbytes, uint8_t *dataptr); - uint8_t ClearCommFeature(uint16_t fid); - uint8_t SetLineCoding(const LINE_CODING *dataptr); - uint8_t GetLineCoding(LINE_CODING *dataptr); - uint8_t SetControlLineState(uint8_t state); - uint8_t SendBreak(uint16_t duration); - uint8_t GetNotif(uint16_t *bytes_rcvd, uint8_t *dataptr); - - // Methods for receiving and sending data - uint8_t RcvData(uint16_t *nbytesptr, uint8_t *dataptr); - uint8_t SndData(uint16_t nbytes, uint8_t *dataptr); - - // USBDeviceConfig implementation - uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - uint8_t Release(); - uint8_t Poll(); - - bool available(void) { - return false; - }; - - virtual uint8_t GetAddress() { - return bAddress; - }; - - virtual bool isReady() { - return ready; - }; - - virtual tty_features enhanced_status(void) { - return _enhanced_status; - }; - - virtual tty_features enhanced_features(void) { - tty_features rv; - rv.enhanced = false; - rv.autoflow_RTS = false; - rv.autoflow_DSR = false; - rv.autoflow_XON = false; - rv.half_duplex = false; - rv.wide = false; - return rv; - }; - - virtual void autoflowRTS(bool s) { - }; - - virtual void autoflowDSR(bool s) { - }; - - virtual void autoflowXON(bool s) { - }; - - virtual void half_duplex(bool s) { - }; - - virtual void wide(bool s) { - }; - - // UsbConfigXtracter implementation - void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); -}; - -#endif // __CDCACM_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/cdcftdi.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/cdcftdi.cpp deleted file mode 100644 index 80d21d16..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/cdcftdi.cpp +++ /dev/null @@ -1,334 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#include "cdcftdi.h" - -const uint8_t FTDI::epDataInIndex = 1; -const uint8_t FTDI::epDataOutIndex = 2; -const uint8_t FTDI::epInterruptInIndex = 3; - -FTDI::FTDI(USB *p, FTDIAsyncOper *pasync) : -pAsync(pasync), -pUsb(p), -bAddress(0), -bNumEP(1), -wFTDIType(0) { - for(uint8_t i = 0; i < FTDI_MAX_ENDPOINTS; i++) { - epInfo[i].epAddr = 0; - epInfo[i].maxPktSize = (i) ? 0 : 8; - epInfo[i].epAttribs = 0; - epInfo[i].bmNakPower = (i==epDataInIndex) ? USB_NAK_NOWAIT: USB_NAK_MAX_POWER; - } - if(pUsb) - pUsb->RegisterDeviceClass(this); -} - -uint8_t FTDI::Init(uint8_t parent, uint8_t port, bool lowspeed) { - const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR); - - uint8_t buf[constBufSize]; - USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); - uint8_t rcode; - UsbDevice *p = NULL; - EpInfo *oldep_ptr = NULL; - - uint8_t num_of_conf; // number of configurations - - AddressPool &addrPool = pUsb->GetAddressPool(); - - USBTRACE("FTDI Init\r\n"); - - if(bAddress) - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - if(!p->epinfo) { - USBTRACE("epinfo\r\n"); - return USB_ERROR_EPINFO_IS_NULL; - } - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - - p->lowspeed = lowspeed; - - // Get device descriptor - rcode = pUsb->getDevDescr(0, 0, sizeof (USB_DEVICE_DESCRIPTOR), buf); - - // Restore p->epinfo - p->epinfo = oldep_ptr; - - if(rcode) - goto FailGetDevDescr; - if(udd->idVendor != FTDI_VID || udd->idProduct != FTDI_PID) - return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - - // Save type of FTDI chip - wFTDIType = udd->bcdDevice; - - // Allocate new address according to device class - bAddress = addrPool.AllocAddress(parent, false, port); - - if(!bAddress) - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - - // Extract Max Packet Size from the device descriptor - epInfo[0].maxPktSize = udd->bMaxPacketSize0; - - // Assign new address to the device - rcode = pUsb->setAddr(0, 0, bAddress); - - if(rcode) { - p->lowspeed = false; - addrPool.FreeAddress(bAddress); - bAddress = 0; - USBTRACE2("setAddr:", rcode); - return rcode; - } - - USBTRACE2("Addr:", bAddress); - - p->lowspeed = false; - - p = addrPool.GetUsbDevicePtr(bAddress); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - p->lowspeed = lowspeed; - - num_of_conf = udd->bNumConfigurations; - - // Assign epInfo to epinfo pointer - rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo); - - if(rcode) - goto FailSetDevTblEntry; - - USBTRACE2("NC:", num_of_conf); - - for(uint8_t i = 0; i < num_of_conf; i++) { - HexDumper HexDump; - ConfigDescParser < 0xFF, 0xFF, 0xFF, CP_MASK_COMPARE_ALL> confDescrParser(this); - - rcode = pUsb->getConfDescr(bAddress, 0, i, &HexDump); - - if(rcode) - goto FailGetConfDescr; - - rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser); - - if(rcode) - goto FailGetConfDescr; - - if(bNumEP > 1) - break; - } // for - - if(bNumEP < 2) - return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - - USBTRACE2("NumEP:", bNumEP); - - // Assign epInfo to epinfo pointer - rcode = pUsb->setEpInfoEntry(bAddress, bNumEP, epInfo); - - USBTRACE2("Conf:", bConfNum); - - // Set Configuration Value - rcode = pUsb->setConf(bAddress, 0, bConfNum); - - if(rcode) - goto FailSetConfDescr; - - rcode = pAsync->OnInit(this); - - if(rcode) - goto FailOnInit; - - USBTRACE("FTDI configured\r\n"); - - bPollEnable = true; - return 0; - -FailGetDevDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetDevDescr(); - goto Fail; -#endif - -FailSetDevTblEntry: -#ifdef DEBUG_USB_HOST - NotifyFailSetDevTblEntry(); - goto Fail; -#endif - -FailGetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetConfDescr(); - goto Fail; -#endif - -FailSetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailSetConfDescr(); - goto Fail; -#endif - -FailOnInit: -#ifdef DEBUG_USB_HOST - USBTRACE("OnInit:"); - -Fail: - NotifyFail(rcode); -#endif - Release(); - return rcode; -} - -void FTDI::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) { - ErrorMessage (PSTR("Conf.Val"), conf); - ErrorMessage (PSTR("Iface Num"), iface); - ErrorMessage (PSTR("Alt.Set"), alt); - - bConfNum = conf; - - uint8_t index; - - if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) - index = epInterruptInIndex; - else - if((pep->bmAttributes & 0x02) == 2) - index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; - else - return; - - // Fill in the endpoint info structure - epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F); - epInfo[index].maxPktSize = (uint8_t)pep->wMaxPacketSize; - epInfo[index].epAttribs = 0; - - bNumEP++; - - PrintEndpointDescriptor(pep); -} - -uint8_t FTDI::Release() { - pUsb->GetAddressPool().FreeAddress(bAddress); - - bAddress = 0; - bNumEP = 1; - qNextPollTime = 0; - bPollEnable = false; - return pAsync->OnRelease(this); -} - -uint8_t FTDI::Poll() { - uint8_t rcode = 0; - - //if (!bPollEnable) - // return 0; - - //if (qNextPollTime <= millis()) - //{ - // USB_HOST_SERIAL.println(bAddress, HEX); - - // qNextPollTime = millis() + 100; - //} - return rcode; -} - -uint8_t FTDI::SetBaudRate(uint32_t baud) { - uint16_t baud_value, baud_index = 0; - uint32_t divisor3; - - divisor3 = 48000000 / 2 / baud; // divisor shifted 3 bits to the left - - if(wFTDIType == FT232AM) { - if((divisor3 & 0x7) == 7) - divisor3++; // round x.7/8 up to x+1 - - baud_value = divisor3 >> 3; - divisor3 &= 0x7; - - if(divisor3 == 1) baud_value |= 0xc000; - else // 0.125 - if(divisor3 >= 4) baud_value |= 0x4000; - else // 0.5 - if(divisor3 != 0) baud_value |= 0x8000; // 0.25 - if(baud_value == 1) baud_value = 0; /* special case for maximum baud rate */ - } else { - static const unsigned char divfrac [8] = {0, 3, 2, 0, 1, 1, 2, 3}; - static const unsigned char divindex[8] = {0, 0, 0, 1, 0, 1, 1, 1}; - - baud_value = divisor3 >> 3; - baud_value |= divfrac [divisor3 & 0x7] << 14; - baud_index = divindex[divisor3 & 0x7]; - - /* Deal with special cases for highest baud rates. */ - if(baud_value == 1) baud_value = 0; - else // 1.0 - if(baud_value == 0x4001) baud_value = 1; // 1.5 - } - USBTRACE2("baud_value:", baud_value); - USBTRACE2("baud_index:", baud_index); - return pUsb->ctrlReq(bAddress, 0, bmREQ_FTDI_OUT, FTDI_SIO_SET_BAUD_RATE, baud_value & 0xff, baud_value >> 8, baud_index, 0, 0, NULL, NULL); -} - -uint8_t FTDI::SetModemControl(uint16_t signal) { - return pUsb->ctrlReq(bAddress, 0, bmREQ_FTDI_OUT, FTDI_SIO_MODEM_CTRL, signal & 0xff, signal >> 8, 0, 0, 0, NULL, NULL); -} - -uint8_t FTDI::SetFlowControl(uint8_t protocol, uint8_t xon, uint8_t xoff) { - return pUsb->ctrlReq(bAddress, 0, bmREQ_FTDI_OUT, FTDI_SIO_SET_FLOW_CTRL, xon, xoff, protocol << 8, 0, 0, NULL, NULL); -} - -uint8_t FTDI::SetData(uint16_t databm) { - return pUsb->ctrlReq(bAddress, 0, bmREQ_FTDI_OUT, FTDI_SIO_SET_DATA, databm & 0xff, databm >> 8, 0, 0, 0, NULL, NULL); -} - -uint8_t FTDI::RcvData(uint16_t *bytes_rcvd, uint8_t *dataptr) { - return pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, bytes_rcvd, dataptr); -} - -uint8_t FTDI::SndData(uint16_t nbytes, uint8_t *dataptr) { - return pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, nbytes, dataptr); -} - -void FTDI::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) { - Notify(PSTR("Endpoint descriptor:"), 0x80); - Notify(PSTR("\r\nLength:\t\t"), 0x80); - D_PrintHex (ep_ptr->bLength, 0x80); - Notify(PSTR("\r\nType:\t\t"), 0x80); - D_PrintHex (ep_ptr->bDescriptorType, 0x80); - Notify(PSTR("\r\nAddress:\t"), 0x80); - D_PrintHex (ep_ptr->bEndpointAddress, 0x80); - Notify(PSTR("\r\nAttributes:\t"), 0x80); - D_PrintHex (ep_ptr->bmAttributes, 0x80); - Notify(PSTR("\r\nMaxPktSize:\t"), 0x80); - D_PrintHex (ep_ptr->wMaxPacketSize, 0x80); - Notify(PSTR("\r\nPoll Intrv:\t"), 0x80); - D_PrintHex (ep_ptr->bInterval, 0x80); - Notify(PSTR("\r\n"), 0x80); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/cdcftdi.h b/protocol/usb_hid/USB_Host_Shield_2.0/cdcftdi.h deleted file mode 100644 index b7312526..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/cdcftdi.h +++ /dev/null @@ -1,145 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(__CDCFTDI_H__) -#define __CDCFTDI_H__ - -#include "Usb.h" - -#define bmREQ_FTDI_OUT 0x40 -#define bmREQ_FTDI_IN 0xc0 - -//#define bmREQ_FTDI_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE -//#define bmREQ_FTDI_IN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE - -#define FTDI_VID 0x0403 // FTDI VID -#define FTDI_PID 0x6001 // FTDI PID - -#define FT232AM 0x0200 -#define FT232BM 0x0400 -#define FT2232 0x0500 -#define FT232R 0x0600 - -// Commands -#define FTDI_SIO_RESET 0 /* Reset the port */ -#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ -#define FTDI_SIO_SET_FLOW_CTRL 2 /* Set flow control register */ -#define FTDI_SIO_SET_BAUD_RATE 3 /* Set baud rate */ -#define FTDI_SIO_SET_DATA 4 /* Set the data characteristics of the port */ -#define FTDI_SIO_GET_MODEM_STATUS 5 /* Retrieve current value of modem status register */ -#define FTDI_SIO_SET_EVENT_CHAR 6 /* Set the event character */ -#define FTDI_SIO_SET_ERROR_CHAR 7 /* Set the error character */ - -#define FTDI_SIO_RESET_SIO 0 -#define FTDI_SIO_RESET_PURGE_RX 1 -#define FTDI_SIO_RESET_PURGE_TX 2 - -#define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8 ) -#define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8 ) -#define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8 ) -#define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8 ) -#define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8 ) -#define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11) -#define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11) -#define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11) -#define FTDI_SIO_SET_BREAK (0x1 << 14) - -#define FTDI_SIO_SET_DTR_MASK 0x1 -#define FTDI_SIO_SET_DTR_HIGH ( 1 | ( FTDI_SIO_SET_DTR_MASK << 8)) -#define FTDI_SIO_SET_DTR_LOW ( 0 | ( FTDI_SIO_SET_DTR_MASK << 8)) -#define FTDI_SIO_SET_RTS_MASK 0x2 -#define FTDI_SIO_SET_RTS_HIGH ( 2 | ( FTDI_SIO_SET_RTS_MASK << 8 )) -#define FTDI_SIO_SET_RTS_LOW ( 0 | ( FTDI_SIO_SET_RTS_MASK << 8 )) - -#define FTDI_SIO_DISABLE_FLOW_CTRL 0x0 -#define FTDI_SIO_RTS_CTS_HS (0x1 << 8) -#define FTDI_SIO_DTR_DSR_HS (0x2 << 8) -#define FTDI_SIO_XON_XOFF_HS (0x4 << 8) - -#define FTDI_SIO_CTS_MASK 0x10 -#define FTDI_SIO_DSR_MASK 0x20 -#define FTDI_SIO_RI_MASK 0x40 -#define FTDI_SIO_RLSD_MASK 0x80 - -class FTDI; - -class FTDIAsyncOper { -public: - - virtual uint8_t OnInit(FTDI *pftdi) { - return 0; - }; - - virtual uint8_t OnRelease(FTDI *pftdi) { - return 0; - }; -}; - - -// Only single port chips are currently supported by the library, -// so only three endpoints are allocated. -#define FTDI_MAX_ENDPOINTS 3 - -class FTDI : public USBDeviceConfig, public UsbConfigXtracter { - static const uint8_t epDataInIndex; // DataIn endpoint index - static const uint8_t epDataOutIndex; // DataOUT endpoint index - static const uint8_t epInterruptInIndex; // InterruptIN endpoint index - - FTDIAsyncOper *pAsync; - USB *pUsb; - uint8_t bAddress; - uint8_t bConfNum; // configuration number - uint8_t bNumIface; // number of interfaces in the configuration - uint8_t bNumEP; // total number of EP in the configuration - uint32_t qNextPollTime; // next poll time - bool bPollEnable; // poll enable flag - uint16_t wFTDIType; // Type of FTDI chip - - EpInfo epInfo[FTDI_MAX_ENDPOINTS]; - - void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); - -public: - FTDI(USB *pusb, FTDIAsyncOper *pasync); - - uint8_t SetBaudRate(uint32_t baud); - uint8_t SetModemControl(uint16_t control); - uint8_t SetFlowControl(uint8_t protocol, uint8_t xon = 0x11, uint8_t xoff = 0x13); - uint8_t SetData(uint16_t databm); - - // Methods for recieving and sending data - uint8_t RcvData(uint16_t *bytes_rcvd, uint8_t *dataptr); - uint8_t SndData(uint16_t nbytes, uint8_t *dataptr); - - // USBDeviceConfig implementation - uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - uint8_t Release(); - uint8_t Poll(); - - virtual uint8_t GetAddress() { - return bAddress; - }; - - // UsbConfigXtracter implementation - void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); - - virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) { - return (vid == FTDI_VID && pid == FTDI_PID); - } - -}; - -#endif // __CDCFTDI_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/cdcprolific.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/cdcprolific.cpp deleted file mode 100644 index eceb1df9..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/cdcprolific.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#include "cdcprolific.h" - -PL2303::PL2303(USB *p, CDCAsyncOper *pasync) : -ACM(p, pasync), -wPLType(0) { -} - -uint8_t PL2303::Init(uint8_t parent, uint8_t port, bool lowspeed) { - const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR); - - uint8_t buf[constBufSize]; - USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); - uint8_t rcode; - UsbDevice *p = NULL; - EpInfo *oldep_ptr = NULL; - uint8_t num_of_conf; // number of configurations -#ifdef PL2303_COMPAT - enum pl2303_type pltype = unknown; -#endif - - AddressPool &addrPool = pUsb->GetAddressPool(); - - USBTRACE("PL Init\r\n"); - - if(bAddress) - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - if(!p->epinfo) { - USBTRACE("epinfo\r\n"); - return USB_ERROR_EPINFO_IS_NULL; - } - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - - p->lowspeed = lowspeed; - - // Get device descriptor - rcode = pUsb->getDevDescr(0, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*)buf); - - // Restore p->epinfo - p->epinfo = oldep_ptr; - - if(rcode) - goto FailGetDevDescr; - - if(udd->idVendor != PL_VID && CHECK_PID(udd->idProduct)) - return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - - /* determine chip variant */ -#ifdef PL2303_COMPAT - if(udd->bDeviceClass == 0x02 ) - pltype = type_0; - else if(udd->bMaxPacketSize0 == 0x40 ) - pltype = rev_HX; - else if(udd->bDeviceClass == 0x00) - pltype = type_1; - else if(udd->bDeviceClass == 0xff) - pltype = type_1; -#endif - - // Save type of PL chip - wPLType = udd->bcdDevice; - - // Allocate new address according to device class - bAddress = addrPool.AllocAddress(parent, false, port); - - if(!bAddress) - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - - // Extract Max Packet Size from the device descriptor - epInfo[0].maxPktSize = udd->bMaxPacketSize0; - - // Assign new address to the device - rcode = pUsb->setAddr(0, 0, bAddress); - - if(rcode) { - p->lowspeed = false; - addrPool.FreeAddress(bAddress); - bAddress = 0; - USBTRACE2("setAddr:", rcode); - return rcode; - } - - USBTRACE2("Addr:", bAddress); - - p->lowspeed = false; - - p = addrPool.GetUsbDevicePtr(bAddress); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - p->lowspeed = lowspeed; - - num_of_conf = udd->bNumConfigurations; - - // Assign epInfo to epinfo pointer - rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo); - - if(rcode) - goto FailSetDevTblEntry; - - USBTRACE2("NC:", num_of_conf); - - for(uint8_t i = 0; i < num_of_conf; i++) { - HexDumper HexDump; - ConfigDescParser < 0xFF, 0, 0, CP_MASK_COMPARE_CLASS> confDescrParser(this); - - rcode = pUsb->getConfDescr(bAddress, 0, i, &HexDump); - - if(rcode) - goto FailGetConfDescr; - - rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser); - - if(rcode) - goto FailGetConfDescr; - - if(bNumEP > 1) - break; - } // for - - if(bNumEP < 2) - return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - - // Assign epInfo to epinfo pointer - rcode = pUsb->setEpInfoEntry(bAddress, bNumEP, epInfo); - - USBTRACE2("Conf:", bConfNum); - - // Set Configuration Value - rcode = pUsb->setConf(bAddress, 0, bConfNum); - - if(rcode) - goto FailSetConfDescr; - -#ifdef PL2303_COMPAT - /* Shamanic dance - sending Prolific init data as-is */ - vendorRead( 0x84, 0x84, 0, buf ); - vendorWrite( 0x04, 0x04, 0 ); - vendorRead( 0x84, 0x84, 0, buf ); - vendorRead( 0x83, 0x83, 0, buf ); - vendorRead( 0x84, 0x84, 0, buf ); - vendorWrite( 0x04, 0x04, 1 ); - vendorRead( 0x84, 0x84, 0, buf); - vendorRead( 0x83, 0x83, 0, buf); - vendorWrite( 0, 0, 1 ); - vendorWrite( 1, 0, 0 ); - if( pltype == rev_HX ) { - vendorWrite( 2, 0, 0x44 ); - vendorWrite( 0x06, 0x06, 0 ); // From W7 init - } - else { - vendorWrite( 2, 0, 0x24 ); - } - /* Shamanic dance end */ -#endif - /* Calling post-init callback */ - rcode = pAsync->OnInit(this); - - if(rcode) - goto FailOnInit; - - USBTRACE("PL configured\r\n"); - - //bPollEnable = true; - ready = true; - return 0; - -FailGetDevDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetDevDescr(); - goto Fail; -#endif - -FailSetDevTblEntry: -#ifdef DEBUG_USB_HOST - NotifyFailSetDevTblEntry(); - goto Fail; -#endif - -FailGetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetConfDescr(); - goto Fail; -#endif - -FailSetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailSetConfDescr(); - goto Fail; -#endif - -FailOnInit: -#ifdef DEBUG_USB_HOST - USBTRACE("OnInit:"); -#endif - -#ifdef DEBUG_USB_HOST -Fail: - NotifyFail(rcode); -#endif - Release(); - return rcode; -} - -//uint8_t PL::Poll() -//{ -// uint8_t rcode = 0; -// -// //if (!bPollEnable) -// // return 0; -// -// //if (qNextPollTime <= millis()) -// //{ -// // USB_HOST_SERIAL.println(bAddress, HEX); -// -// // qNextPollTime = millis() + 100; -// //} -// return rcode; -//} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/cdcprolific.h b/protocol/usb_hid/USB_Host_Shield_2.0/cdcprolific.h deleted file mode 100644 index 49914664..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/cdcprolific.h +++ /dev/null @@ -1,159 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(__CDCPROLIFIC_H__) -#define __CDCPROLIFIC_H__ - -#include "cdcacm.h" - -//#define PL2303_COMPAT // Uncomment it if you have compatibility problems - -#define PL_VID 0x067B -#define CHECK_PID(pid) ( pid != 0x2303 && pid != 0x0609 ) - -//#define PL_PID 0x0609 - -#define PROLIFIC_REV_H 0x0202 -#define PROLIFIC_REV_X 0x0300 -#define PROLIFIC_REV_HX_CHIP_D 0x0400 -#define PROLIFIC_REV_1 0x0001 - -#define kXOnChar '\x11' -#define kXOffChar '\x13' - -#define SPECIAL_SHIFT (5) -#define SPECIAL_MASK ((1<ctrlReq(bAddress, 0, VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, val_lo, val_hi, index, 1, 1, buf, NULL )); -} - -/* vendor write request */ -inline uint8_t PL2303::vendorWrite( uint8_t val_lo, uint8_t val_hi, uint8_t index ) -{ - return( pUsb->ctrlReq(bAddress, 0, VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, val_lo, val_hi, index, 0, 0, NULL, NULL )); -} -#endif - -#endif // __CDCPROLIFIC_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/confdescparser.h b/protocol/usb_hid/USB_Host_Shield_2.0/confdescparser.h deleted file mode 100644 index a6806f2e..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/confdescparser.h +++ /dev/null @@ -1,213 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(_usb_h_) || defined(__CONFDESCPARSER_H__) -#error "Never include confdescparser.h directly; include Usb.h instead" -#else - -#define __CONFDESCPARSER_H__ - -class UsbConfigXtracter { -public: - //virtual void ConfigXtract(const USB_CONFIGURATION_DESCRIPTOR *conf) = 0; - //virtual void InterfaceXtract(uint8_t conf, const USB_INTERFACE_DESCRIPTOR *iface) = 0; - - virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep) { - }; -}; - -#define CP_MASK_COMPARE_CLASS 1 -#define CP_MASK_COMPARE_SUBCLASS 2 -#define CP_MASK_COMPARE_PROTOCOL 4 -#define CP_MASK_COMPARE_ALL 7 - -// Configuration Descriptor Parser Class Template - -template -class ConfigDescParser : public USBReadParser { - UsbConfigXtracter *theXtractor; - MultiValueBuffer theBuffer; - MultiByteValueParser valParser; - ByteSkipper theSkipper; - uint8_t varBuffer[16 /*sizeof(USB_CONFIGURATION_DESCRIPTOR)*/]; - - uint8_t stateParseDescr; // ParseDescriptor state - - uint8_t dscrLen; // Descriptor length - uint8_t dscrType; // Descriptor type - - bool isGoodInterface; // Apropriate interface flag - uint8_t confValue; // Configuration value - uint8_t protoValue; // Protocol value - uint8_t ifaceNumber; // Interface number - uint8_t ifaceAltSet; // Interface alternate settings - - bool UseOr; - bool ParseDescriptor(uint8_t **pp, uint16_t *pcntdn); - void PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc); - -public: - - void SetOR(void) { - UseOr = true; - } - ConfigDescParser(UsbConfigXtracter *xtractor); - void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset); -}; - -template -ConfigDescParser::ConfigDescParser(UsbConfigXtracter *xtractor) : -theXtractor(xtractor), -stateParseDescr(0), -dscrLen(0), -dscrType(0), -UseOr(false) { - theBuffer.pValue = varBuffer; - valParser.Initialize(&theBuffer); - theSkipper.Initialize(&theBuffer); -}; - -template -void ConfigDescParser::Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset) { - uint16_t cntdn = (uint16_t)len; - uint8_t *p = (uint8_t*)pbuf; - - while(cntdn) - if(!ParseDescriptor(&p, &cntdn)) - return; -} - -/* Parser for the configuration descriptor. Takes values for class, subclass, protocol fields in interface descriptor and - compare masks for them. When the match is found, calls EndpointXtract passing buffer containing endpoint descriptor */ -template -bool ConfigDescParser::ParseDescriptor(uint8_t **pp, uint16_t *pcntdn) { - USB_CONFIGURATION_DESCRIPTOR* ucd = reinterpret_cast(varBuffer); - USB_INTERFACE_DESCRIPTOR* uid = reinterpret_cast(varBuffer); - switch(stateParseDescr) { - case 0: - theBuffer.valueSize = 2; - valParser.Initialize(&theBuffer); - stateParseDescr = 1; - case 1: - if(!valParser.Parse(pp, pcntdn)) - return false; - dscrLen = *((uint8_t*)theBuffer.pValue); - dscrType = *((uint8_t*)theBuffer.pValue + 1); - stateParseDescr = 2; - case 2: - // This is a sort of hack. Assuming that two bytes are all ready in the buffer - // the pointer is positioned two bytes ahead in order for the rest of descriptor - // to be read right after the size and the type fields. - // This should be used carefully. varBuffer should be used directly to handle data - // in the buffer. - theBuffer.pValue = varBuffer + 2; - stateParseDescr = 3; - case 3: - switch(dscrType) { - case USB_DESCRIPTOR_INTERFACE: - isGoodInterface = false; - case USB_DESCRIPTOR_CONFIGURATION: - theBuffer.valueSize = sizeof (USB_CONFIGURATION_DESCRIPTOR) - 2; - break; - case USB_DESCRIPTOR_ENDPOINT: - theBuffer.valueSize = sizeof (USB_ENDPOINT_DESCRIPTOR) - 2; - break; - case HID_DESCRIPTOR_HID: - theBuffer.valueSize = dscrLen - 2; - break; - } - valParser.Initialize(&theBuffer); - stateParseDescr = 4; - case 4: - switch(dscrType) { - case USB_DESCRIPTOR_CONFIGURATION: - if(!valParser.Parse(pp, pcntdn)) - return false; - confValue = ucd->bConfigurationValue; - break; - case USB_DESCRIPTOR_INTERFACE: - if(!valParser.Parse(pp, pcntdn)) - return false; - if((MASK & CP_MASK_COMPARE_CLASS) && uid->bInterfaceClass != CLASS_ID) - break; - if((MASK & CP_MASK_COMPARE_SUBCLASS) && uid->bInterfaceSubClass != SUBCLASS_ID) - break; - if(UseOr) { - if((!((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol))) - break; - } else { - if((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol != PROTOCOL_ID) - break; - } - isGoodInterface = true; - ifaceNumber = uid->bInterfaceNumber; - ifaceAltSet = uid->bAlternateSetting; - protoValue = uid->bInterfaceProtocol; - break; - case USB_DESCRIPTOR_ENDPOINT: - if(!valParser.Parse(pp, pcntdn)) - return false; - if(isGoodInterface) - if(theXtractor) - theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (USB_ENDPOINT_DESCRIPTOR*)varBuffer); - break; - //case HID_DESCRIPTOR_HID: - // if (!valParser.Parse(pp, pcntdn)) - // return false; - // PrintHidDescriptor((const USB_HID_DESCRIPTOR*)varBuffer); - // break; - default: - if(!theSkipper.Skip(pp, pcntdn, dscrLen - 2)) - return false; - } - theBuffer.pValue = varBuffer; - stateParseDescr = 0; - } - return true; -} - -template -void ConfigDescParser::PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc) { - Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80); - Notify(PSTR("bDescLength:\t\t"), 0x80); - PrintHex (pDesc->bLength, 0x80); - - Notify(PSTR("\r\nbDescriptorType:\t"), 0x80); - PrintHex (pDesc->bDescriptorType, 0x80); - - Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80); - PrintHex (pDesc->bcdHID, 0x80); - - Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80); - PrintHex (pDesc->bCountryCode, 0x80); - - Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80); - PrintHex (pDesc->bNumDescriptors, 0x80); - - for(uint8_t i = 0; i < pDesc->bNumDescriptors; i++) { - HID_CLASS_DESCRIPTOR_LEN_AND_TYPE *pLT = (HID_CLASS_DESCRIPTOR_LEN_AND_TYPE*)&(pDesc->bDescrType); - - Notify(PSTR("\r\nbDescrType:\t\t"), 0x80); - PrintHex (pLT[i].bDescrType, 0x80); - - Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80); - PrintHex (pLT[i].wDescriptorLength, 0x80); - } - Notify(PSTR("\r\n"), 0x80); -} - - -#endif // __CONFDESCPARSER_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/controllerEnums.h b/protocol/usb_hid/USB_Host_Shield_2.0/controllerEnums.h deleted file mode 100644 index 0169c763..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/controllerEnums.h +++ /dev/null @@ -1,204 +0,0 @@ -/* Copyright (C) 2013 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#ifndef _controllerenums_h -#define _controllerenums_h - -/** - * This header file is used to store different enums for the controllers, - * This is necessary so all the different libraries can be used at once. - */ - -/** Enum used to turn on the LEDs on the different controllers. */ -enum LEDEnum { - OFF = 0, - LED1 = 1, - LED2 = 2, - LED3 = 3, - LED4 = 4, - - LED5 = 5, - LED6 = 6, - LED7 = 7, - LED8 = 8, - LED9 = 9, - LED10 = 10, - /** Used to blink all LEDs on the Xbox controller */ - ALL = 5, -}; - -/** Used to set the colors of the Move and PS4 controller. */ -enum ColorsEnum { - /** r = 255, g = 0, b = 0 */ - Red = 0xFF0000, - /** r = 0, g = 255, b = 0 */ - Green = 0xFF00, - /** r = 0, g = 0, b = 255 */ - Blue = 0xFF, - - /** r = 255, g = 235, b = 4 */ - Yellow = 0xFFEB04, - /** r = 0, g = 255, b = 255 */ - Lightblue = 0xFFFF, - /** r = 255, g = 0, b = 255 */ - Purble = 0xFF00FF, - - /** r = 255, g = 255, b = 255 */ - White = 0xFFFFFF, - /** r = 0, g = 0, b = 0 */ - Off = 0x00, -}; - -enum RumbleEnum { - RumbleHigh = 0x10, - RumbleLow = 0x20, -}; - -/** This enum is used to read all the different buttons on the different controllers */ -enum ButtonEnum { - /**@{*/ - /** These buttons are available on all the the controllers */ - UP = 0, - RIGHT = 1, - DOWN = 2, - LEFT = 3, - /**@}*/ - - /**@{*/ - /** Wii buttons */ - PLUS = 5, - TWO = 6, - ONE = 7, - MINUS = 8, - HOME = 9, - Z = 10, - C = 11, - B = 12, - A = 13, - /**@}*/ - - /**@{*/ - /** These are only available on the Wii U Pro Controller */ - L = 16, - R = 17, - ZL = 18, - ZR = 19, - /**@}*/ - - /**@{*/ - /** PS3 controllers buttons */ - SELECT = 4, - START = 5, - L3 = 6, - R3 = 7, - - L2 = 8, - R2 = 9, - L1 = 10, - R1 = 11, - TRIANGLE = 12, - CIRCLE = 13, - CROSS = 14, - SQUARE = 15, - - PS = 16, - - MOVE = 17, // Covers 12 bits - we only need to read the top 8 - T = 18, // Covers 12 bits - we only need to read the top 8 - /**@}*/ - - /** PS4 controllers buttons - SHARE and OPTIONS are present instead of SELECT and START */ - SHARE = 4, - OPTIONS = 5, - TOUCHPAD = 17, - /**@}*/ - - /**@{*/ - /** Xbox buttons */ - BACK = 4, - X = 14, - Y = 15, - XBOX = 16, - SYNC = 17, - BLACK = 8, // Available on the original Xbox controller - WHITE = 9, // Available on the original Xbox controller - /**@}*/ - - /** PS Buzz controllers */ - RED = 0, - YELLOW = 1, - GREEN = 2, - ORANGE = 3, - BLUE = 4, - /**@}*/ -}; - -/** Joysticks on the PS3 and Xbox controllers. */ -enum AnalogHatEnum { - /** Left joystick x-axis */ - LeftHatX = 0, - /** Left joystick y-axis */ - LeftHatY = 1, - /** Right joystick x-axis */ - RightHatX = 2, - /** Right joystick y-axis */ - RightHatY = 3, -}; - -/** - * Sensors inside the Sixaxis Dualshock 3, Move controller and PS4 controller. - * Note: that the location is shifted 9 when it's connected via USB on the PS3 controller. - */ -enum SensorEnum { - /** Accelerometer values */ - aX = 50, aY = 52, aZ = 54, - /** Gyro z-axis */ - gZ = 56, - gX, gY, // These are not available on the PS3 controller - - /** Accelerometer x-axis */ - aXmove = 28, - /** Accelerometer z-axis */ - aZmove = 30, - /** Accelerometer y-axis */ - aYmove = 32, - - /** Gyro x-axis */ - gXmove = 40, - /** Gyro z-axis */ - gZmove = 42, - /** Gyro y-axis */ - gYmove = 44, - - /** Temperature sensor */ - tempMove = 46, - - /** Magnetometer x-axis */ - mXmove = 47, - /** Magnetometer z-axis */ - mZmove = 49, - /** Magnetometer y-axis */ - mYmove = 50, -}; - -/** Used to get the angle calculated using the PS3 controller and PS4 controller. */ -enum AngleEnum { - Pitch = 0x01, - Roll = 0x02, -}; - -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/BTHID/BTHID.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/BTHID/BTHID.ino deleted file mode 100644 index 919a5646..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/BTHID/BTHID.ino +++ /dev/null @@ -1,55 +0,0 @@ -/* - Example sketch for the HID Bluetooth library - developed by Kristian Lauszus - For more information visit my blog: http://blog.tkjelectronics.dk/ or - send me an e-mail: kristianl@tkjelectronics.com - */ - -#include -#include -#include "KeyboardParser.h" -#include "MouseParser.h" - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -//USBHub Hub1(&Usb); // Some dongles have a hub inside -BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so - -/* You can create the instance of the class in two ways */ -// This will start an inquiry and then pair with your device - you only have to do this once -// If you are using a Bluetooth keyboard, then you should type in the password on the keypad and then press enter -BTHID bthid(&Btd, PAIR, "0000"); - -// After that you can simply create the instance like so and then press any button on the device -//BTHID hid(&Btd); - -KbdRptParser keyboardPrs; -MouseRptParser mousePrs; - -void setup() { - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); // Halt - } - - bthid.SetReportParser(KEYBOARD_PARSER_ID, (HIDReportParser*)&keyboardPrs); - bthid.SetReportParser(MOUSE_PARSER_ID, (HIDReportParser*)&mousePrs); - - // If "Boot Protocol Mode" does not work, then try "Report Protocol Mode" - // If that does not work either, then uncomment PRINTREPORT in BTHID.cpp to see the raw report - bthid.setProtocolMode(HID_BOOT_PROTOCOL); // Boot Protocol Mode - //bthid.setProtocolMode(HID_RPT_PROTOCOL); // Report Protocol Mode - - Serial.print(F("\r\nHID Bluetooth Library Started")); -} -void loop() { - Usb.Task(); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/BTHID/KeyboardParser.h b/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/BTHID/KeyboardParser.h deleted file mode 100644 index c5394331..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/BTHID/KeyboardParser.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef __kbdrptparser_h_ -#define __kbdrptparser_h_ - -class KbdRptParser : public KeyboardReportParser { - protected: - virtual uint8_t HandleLockingKeys(HID *hid, uint8_t key); - virtual void OnControlKeysChanged(uint8_t before, uint8_t after); - virtual void OnKeyDown(uint8_t mod, uint8_t key); - virtual void OnKeyUp(uint8_t mod, uint8_t key); - virtual void OnKeyPressed(uint8_t key); - - private: - void PrintKey(uint8_t mod, uint8_t key); -}; - -uint8_t KbdRptParser::HandleLockingKeys(HID *hid, uint8_t key) { - uint8_t old_keys = kbdLockingKeys.bLeds; - - switch (key) { - case UHS_HID_BOOT_KEY_NUM_LOCK: - Serial.println(F("Num lock")); - kbdLockingKeys.kbdLeds.bmNumLock = ~kbdLockingKeys.kbdLeds.bmNumLock; - break; - case UHS_HID_BOOT_KEY_CAPS_LOCK: - Serial.println(F("Caps lock")); - kbdLockingKeys.kbdLeds.bmCapsLock = ~kbdLockingKeys.kbdLeds.bmCapsLock; - break; - case UHS_HID_BOOT_KEY_SCROLL_LOCK: - Serial.println(F("Scroll lock")); - kbdLockingKeys.kbdLeds.bmScrollLock = ~kbdLockingKeys.kbdLeds.bmScrollLock; - break; - } - - if (old_keys != kbdLockingKeys.bLeds && hid) { - BTHID *pBTHID = reinterpret_cast (hid); // A cast the other way around is done in BTHID.cpp - pBTHID->setLeds(kbdLockingKeys.bLeds); // Update the LEDs on the keyboard - } - - return 0; -}; - -void KbdRptParser::PrintKey(uint8_t m, uint8_t key) { - MODIFIERKEYS mod; - *((uint8_t*)&mod) = m; - Serial.print((mod.bmLeftCtrl == 1) ? F("C") : F(" ")); - Serial.print((mod.bmLeftShift == 1) ? F("S") : F(" ")); - Serial.print((mod.bmLeftAlt == 1) ? F("A") : F(" ")); - Serial.print((mod.bmLeftGUI == 1) ? F("G") : F(" ")); - - Serial.print(F(" >")); - PrintHex(key, 0x80); - Serial.print(F("< ")); - - Serial.print((mod.bmRightCtrl == 1) ? F("C") : F(" ")); - Serial.print((mod.bmRightShift == 1) ? F("S") : F(" ")); - Serial.print((mod.bmRightAlt == 1) ? F("A") : F(" ")); - Serial.println((mod.bmRightGUI == 1) ? F("G") : F(" ")); -}; - -void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key) { - Serial.print(F("DN ")); - PrintKey(mod, key); - uint8_t c = OemToAscii(mod, key); - - if (c) - OnKeyPressed(c); -}; - -void KbdRptParser::OnControlKeysChanged(uint8_t before, uint8_t after) { - MODIFIERKEYS beforeMod; - *((uint8_t*)&beforeMod) = before; - - MODIFIERKEYS afterMod; - *((uint8_t*)&afterMod) = after; - - if (beforeMod.bmLeftCtrl != afterMod.bmLeftCtrl) - Serial.println(F("LeftCtrl changed")); - if (beforeMod.bmLeftShift != afterMod.bmLeftShift) - Serial.println(F("LeftShift changed")); - if (beforeMod.bmLeftAlt != afterMod.bmLeftAlt) - Serial.println(F("LeftAlt changed")); - if (beforeMod.bmLeftGUI != afterMod.bmLeftGUI) - Serial.println(F("LeftGUI changed")); - - if (beforeMod.bmRightCtrl != afterMod.bmRightCtrl) - Serial.println(F("RightCtrl changed")); - if (beforeMod.bmRightShift != afterMod.bmRightShift) - Serial.println(F("RightShift changed")); - if (beforeMod.bmRightAlt != afterMod.bmRightAlt) - Serial.println(F("RightAlt changed")); - if (beforeMod.bmRightGUI != afterMod.bmRightGUI) - Serial.println(F("RightGUI changed")); -}; - -void KbdRptParser::OnKeyUp(uint8_t mod, uint8_t key) { - Serial.print(F("UP ")); - PrintKey(mod, key); -}; - -void KbdRptParser::OnKeyPressed(uint8_t key) { - Serial.print(F("ASCII: ")); - Serial.println((char)key); -}; - -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/BTHID/MouseParser.h b/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/BTHID/MouseParser.h deleted file mode 100644 index a9245ded..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/BTHID/MouseParser.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef __mouserptparser_h__ -#define __mouserptparser_h__ - -class MouseRptParser : public MouseReportParser { - protected: - virtual void OnMouseMove(MOUSEINFO *mi); - virtual void OnLeftButtonUp(MOUSEINFO *mi); - virtual void OnLeftButtonDown(MOUSEINFO *mi); - virtual void OnRightButtonUp(MOUSEINFO *mi); - virtual void OnRightButtonDown(MOUSEINFO *mi); - virtual void OnMiddleButtonUp(MOUSEINFO *mi); - virtual void OnMiddleButtonDown(MOUSEINFO *mi); -}; - -void MouseRptParser::OnMouseMove(MOUSEINFO *mi) { - Serial.print(F("dx=")); - Serial.print(mi->dX, DEC); - Serial.print(F(" dy=")); - Serial.println(mi->dY, DEC); -}; - -void MouseRptParser::OnLeftButtonUp(MOUSEINFO *mi) { - Serial.println(F("L Butt Up")); -}; - -void MouseRptParser::OnLeftButtonDown(MOUSEINFO *mi) { - Serial.println(F("L Butt Dn")); -}; - -void MouseRptParser::OnRightButtonUp(MOUSEINFO *mi) { - Serial.println(F("R Butt Up")); -}; - -void MouseRptParser::OnRightButtonDown(MOUSEINFO *mi) { - Serial.println(F("R Butt Dn")); -}; - -void MouseRptParser::OnMiddleButtonUp(MOUSEINFO *mi) { - Serial.println(F("M Butt Up")); -}; - -void MouseRptParser::OnMiddleButtonDown(MOUSEINFO *mi) { - Serial.println(F("M Butt Dn")); -}; - -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/PS3BT/PS3BT.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/PS3BT/PS3BT.ino deleted file mode 100644 index b8967344..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/PS3BT/PS3BT.ino +++ /dev/null @@ -1,188 +0,0 @@ -/* - Example sketch for the PS3 Bluetooth library - developed by Kristian Lauszus - For more information visit my blog: http://blog.tkjelectronics.dk/ or - send me an e-mail: kristianl@tkjelectronics.com - */ - -#include -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -//USBHub Hub1(&Usb); // Some dongles have a hub inside - -BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so -/* You can create the instance of the class in two ways */ -PS3BT PS3(&Btd); // This will just create the instance -//PS3BT PS3(&Btd, 0x00, 0x15, 0x83, 0x3D, 0x0A, 0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch - -bool printTemperature; -bool printAngle; - -void setup() { - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); //halt - } - Serial.print(F("\r\nPS3 Bluetooth Library Started")); -} -void loop() { - Usb.Task(); - - if (PS3.PS3Connected || PS3.PS3NavigationConnected) { - if (PS3.getAnalogHat(LeftHatX) > 137 || PS3.getAnalogHat(LeftHatX) < 117 || PS3.getAnalogHat(LeftHatY) > 137 || PS3.getAnalogHat(LeftHatY) < 117 || PS3.getAnalogHat(RightHatX) > 137 || PS3.getAnalogHat(RightHatX) < 117 || PS3.getAnalogHat(RightHatY) > 137 || PS3.getAnalogHat(RightHatY) < 117) { - Serial.print(F("\r\nLeftHatX: ")); - Serial.print(PS3.getAnalogHat(LeftHatX)); - Serial.print(F("\tLeftHatY: ")); - Serial.print(PS3.getAnalogHat(LeftHatY)); - if (PS3.PS3Connected) { // The Navigation controller only have one joystick - Serial.print(F("\tRightHatX: ")); - Serial.print(PS3.getAnalogHat(RightHatX)); - Serial.print(F("\tRightHatY: ")); - Serial.print(PS3.getAnalogHat(RightHatY)); - } - } - - // Analog button values can be read from almost all buttons - if (PS3.getAnalogButton(L2) || PS3.getAnalogButton(R2)) { - Serial.print(F("\r\nL2: ")); - Serial.print(PS3.getAnalogButton(L2)); - if (PS3.PS3Connected) { - Serial.print(F("\tR2: ")); - Serial.print(PS3.getAnalogButton(R2)); - } - } - if (PS3.getButtonClick(PS)) { - Serial.print(F("\r\nPS")); - PS3.disconnect(); - } - else { - if (PS3.getButtonClick(TRIANGLE)) - Serial.print(F("\r\nTraingle")); - if (PS3.getButtonClick(CIRCLE)) - Serial.print(F("\r\nCircle")); - if (PS3.getButtonClick(CROSS)) - Serial.print(F("\r\nCross")); - if (PS3.getButtonClick(SQUARE)) - Serial.print(F("\r\nSquare")); - - if (PS3.getButtonClick(UP)) { - Serial.print(F("\r\nUp")); - if (PS3.PS3Connected) { - PS3.setLedOff(); - PS3.setLedOn(LED4); - } - } - if (PS3.getButtonClick(RIGHT)) { - Serial.print(F("\r\nRight")); - if (PS3.PS3Connected) { - PS3.setLedOff(); - PS3.setLedOn(LED1); - } - } - if (PS3.getButtonClick(DOWN)) { - Serial.print(F("\r\nDown")); - if (PS3.PS3Connected) { - PS3.setLedOff(); - PS3.setLedOn(LED2); - } - } - if (PS3.getButtonClick(LEFT)) { - Serial.print(F("\r\nLeft")); - if (PS3.PS3Connected) { - PS3.setLedOff(); - PS3.setLedOn(LED3); - } - } - - if (PS3.getButtonClick(L1)) - Serial.print(F("\r\nL1")); - if (PS3.getButtonClick(L3)) - Serial.print(F("\r\nL3")); - if (PS3.getButtonClick(R1)) - Serial.print(F("\r\nR1")); - if (PS3.getButtonClick(R3)) - Serial.print(F("\r\nR3")); - - if (PS3.getButtonClick(SELECT)) { - Serial.print(F("\r\nSelect - ")); - PS3.printStatusString(); - } - if (PS3.getButtonClick(START)) { - Serial.print(F("\r\nStart")); - printAngle = !printAngle; - } - } -#if 0 // Set this to 1 in order to see the angle of the controller - if (printAngle) { - Serial.print(F("\r\nPitch: ")); - Serial.print(PS3.getAngle(Pitch)); - Serial.print(F("\tRoll: ")); - Serial.print(PS3.getAngle(Roll)); - } -#endif - } -#if 0 // Set this to 1 in order to enable support for the Playstation Move controller - else if (PS3.PS3MoveConnected) { - if (PS3.getAnalogButton(T)) { - Serial.print(F("\r\nT: ")); - Serial.print(PS3.getAnalogButton(T)); - } - if (PS3.getButtonClick(PS)) { - Serial.print(F("\r\nPS")); - PS3.disconnect(); - } - else { - if (PS3.getButtonClick(SELECT)) { - Serial.print(F("\r\nSelect")); - printTemperature = !printTemperature; - } - if (PS3.getButtonClick(START)) { - Serial.print(F("\r\nStart")); - printAngle = !printAngle; - } - if (PS3.getButtonClick(TRIANGLE)) { - Serial.print(F("\r\nTriangle")); - PS3.moveSetBulb(Red); - } - if (PS3.getButtonClick(CIRCLE)) { - Serial.print(F("\r\nCircle")); - PS3.moveSetBulb(Green); - } - if (PS3.getButtonClick(SQUARE)) { - Serial.print(F("\r\nSquare")); - PS3.moveSetBulb(Blue); - } - if (PS3.getButtonClick(CROSS)) { - Serial.print(F("\r\nCross")); - PS3.moveSetBulb(Yellow); - } - if (PS3.getButtonClick(MOVE)) { - PS3.moveSetBulb(Off); - Serial.print(F("\r\nMove")); - Serial.print(F(" - ")); - PS3.printStatusString(); - } - } - if (printAngle) { - Serial.print(F("\r\nPitch: ")); - Serial.print(PS3.getAngle(Pitch)); - Serial.print(F("\tRoll: ")); - Serial.print(PS3.getAngle(Roll)); - } - else if (printTemperature) { - Serial.print(F("\r\nTemperature: ")); - Serial.print(PS3.getTemperature()); - } - } -#endif -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/PS3Multi/PS3Multi.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/PS3Multi/PS3Multi.ino deleted file mode 100644 index 5ebfd781..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/PS3Multi/PS3Multi.ino +++ /dev/null @@ -1,149 +0,0 @@ -/* - Example sketch for the PS3 Bluetooth library - developed by Kristian Lauszus - This example show how one can use multiple controllers with the library - For more information visit my blog: http://blog.tkjelectronics.dk/ or - send me an e-mail: kristianl@tkjelectronics.com - */ - -#include -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -//USBHub Hub1(&Usb); // Some dongles have a hub inside - -BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so -PS3BT *PS3[2]; // We will use this pointer to store the two instance, you can easily make it larger if you like, but it will use a lot of RAM! -const uint8_t length = sizeof(PS3) / sizeof(PS3[0]); // Get the lenght of the array -bool printAngle[length]; -bool oldControllerState[length]; - -void setup() { - for (uint8_t i = 0; i < length; i++) { - PS3[i] = new PS3BT(&Btd); // Create the instances - PS3[i]->attachOnInit(onInit); // onInit() is called upon a new connection - you can call the function whatever you like - } - - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); //halt - } - Serial.print(F("\r\nPS3 Bluetooth Library Started")); -} -void loop() { - Usb.Task(); - - for (uint8_t i = 0; i < length; i++) { - if (PS3[i]->PS3Connected || PS3[i]->PS3NavigationConnected) { - if (PS3[i]->getAnalogHat(LeftHatX) > 137 || PS3[i]->getAnalogHat(LeftHatX) < 117 || PS3[i]->getAnalogHat(LeftHatY) > 137 || PS3[i]->getAnalogHat(LeftHatY) < 117 || PS3[i]->getAnalogHat(RightHatX) > 137 || PS3[i]->getAnalogHat(RightHatX) < 117 || PS3[i]->getAnalogHat(RightHatY) > 137 || PS3[i]->getAnalogHat(RightHatY) < 117) { - Serial.print(F("\r\nLeftHatX: ")); - Serial.print(PS3[i]->getAnalogHat(LeftHatX)); - Serial.print(F("\tLeftHatY: ")); - Serial.print(PS3[i]->getAnalogHat(LeftHatY)); - if (PS3[i]->PS3Connected) { // The Navigation controller only have one joystick - Serial.print(F("\tRightHatX: ")); - Serial.print(PS3[i]->getAnalogHat(RightHatX)); - Serial.print(F("\tRightHatY: ")); - Serial.print(PS3[i]->getAnalogHat(RightHatY)); - } - } - //Analog button values can be read from almost all buttons - if (PS3[i]->getAnalogButton(L2) || PS3[i]->getAnalogButton(R2)) { - Serial.print(F("\r\nL2: ")); - Serial.print(PS3[i]->getAnalogButton(L2)); - if (PS3[i]->PS3Connected) { - Serial.print(F("\tR2: ")); - Serial.print(PS3[i]->getAnalogButton(R2)); - } - } - if (PS3[i]->getButtonClick(PS)) { - Serial.print(F("\r\nPS")); - PS3[i]->disconnect(); - oldControllerState[i] = false; // Reset value - } - else { - if (PS3[i]->getButtonClick(TRIANGLE)) - Serial.print(F("\r\nTraingle")); - if (PS3[i]->getButtonClick(CIRCLE)) - Serial.print(F("\r\nCircle")); - if (PS3[i]->getButtonClick(CROSS)) - Serial.print(F("\r\nCross")); - if (PS3[i]->getButtonClick(SQUARE)) - Serial.print(F("\r\nSquare")); - - if (PS3[i]->getButtonClick(UP)) { - Serial.print(F("\r\nUp")); - if (PS3[i]->PS3Connected) { - PS3[i]->setLedOff(); - PS3[i]->setLedOn(LED4); - } - } - if (PS3[i]->getButtonClick(RIGHT)) { - Serial.print(F("\r\nRight")); - if (PS3[i]->PS3Connected) { - PS3[i]->setLedOff(); - PS3[i]->setLedOn(LED1); - } - } - if (PS3[i]->getButtonClick(DOWN)) { - Serial.print(F("\r\nDown")); - if (PS3[i]->PS3Connected) { - PS3[i]->setLedOff(); - PS3[i]->setLedOn(LED2); - } - } - if (PS3[i]->getButtonClick(LEFT)) { - Serial.print(F("\r\nLeft")); - if (PS3[i]->PS3Connected) { - PS3[i]->setLedOff(); - PS3[i]->setLedOn(LED3); - } - } - - if (PS3[i]->getButtonClick(L1)) - Serial.print(F("\r\nL1")); - if (PS3[i]->getButtonClick(L3)) - Serial.print(F("\r\nL3")); - if (PS3[i]->getButtonClick(R1)) - Serial.print(F("\r\nR1")); - if (PS3[i]->getButtonClick(R3)) - Serial.print(F("\r\nR3")); - - if (PS3[i]->getButtonClick(SELECT)) { - Serial.print(F("\r\nSelect - ")); - PS3[i]->printStatusString(); - } - if (PS3[i]->getButtonClick(START)) { - Serial.print(F("\r\nStart")); - printAngle[i] = !printAngle[i]; - } - } - if (printAngle[i]) { - Serial.print(F("\r\nPitch: ")); - Serial.print(PS3[i]->getAngle(Pitch)); - Serial.print(F("\tRoll: ")); - Serial.print(PS3[i]->getAngle(Roll)); - } - } - /* I have removed the PS3 Move code as an Uno will run out of RAM if it's included */ - //else if(PS3[i]->PS3MoveConnected) { - } -} - -void onInit() { - for (uint8_t i = 0; i < length; i++) { - if ((PS3[i]->PS3Connected || PS3[i]->PS3NavigationConnected) && !oldControllerState[i]) { - oldControllerState[i] = true; // Used to check which is the new controller - PS3[i]->setLedOn((LEDEnum)(i + 1)); // Cast directly to LEDEnum - see: "controllerEnums.h" - } - } -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/PS3SPP/PS3SPP.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/PS3SPP/PS3SPP.ino deleted file mode 100644 index 8f234cbd..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/PS3SPP/PS3SPP.ino +++ /dev/null @@ -1,162 +0,0 @@ -/* - Example sketch for the Bluetooth library - developed by Kristian Lauszus - For more information visit my blog: http://blog.tkjelectronics.dk/ or - send me an e-mail: kristianl@tkjelectronics.com - - This example show how one can combine all the difference Bluetooth services in one single code. - Note: - You will need a Arduino Mega 1280/2560 to run this sketch, - as a normal Arduino (Uno, Duemilanove etc.) doesn't have enough SRAM and FLASH - */ - -#include -#include -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -//USBHub Hub1(&Usb); // Some dongles have a hub inside - -BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so - -/* You can create the instances of the bluetooth services in two ways */ -SPP SerialBT(&Btd); // This will set the name to the defaults: "Arduino" and the pin to "0000" -//SPP SerialBTBT(&Btd,"Lauszus's Arduino","0000"); // You can also set the name and pin like so -PS3BT PS3(&Btd); // This will just create the instance -//PS3BT PS3(&Btd, 0x00, 0x15, 0x83, 0x3D, 0x0A, 0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch - -bool firstMessage = true; -String output = ""; // We will store the data in this string - -void setup() { - Serial.begin(115200); // This wil lprint the debugging from the libraries -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); //halt - } - Serial.print(F("\r\nBluetooth Library Started")); - output.reserve(200); // Reserve 200 bytes for the output string -} -void loop() { - Usb.Task(); // The SPP data is actually not send until this is called, one could call SerialBT.send() directly as well - - if (SerialBT.connected) { - if (firstMessage) { - firstMessage = false; - SerialBT.println(F("Hello from Arduino")); // Send welcome message - } - if (Serial.available()) - SerialBT.write(Serial.read()); - if (SerialBT.available()) - Serial.write(SerialBT.read()); - } - else - firstMessage = true; - - if (PS3.PS3Connected || PS3.PS3NavigationConnected) { - output = ""; // Reset output string - if (PS3.getAnalogHat(LeftHatX) > 137 || PS3.getAnalogHat(LeftHatX) < 117 || PS3.getAnalogHat(LeftHatY) > 137 || PS3.getAnalogHat(LeftHatY) < 117 || PS3.getAnalogHat(RightHatX) > 137 || PS3.getAnalogHat(RightHatX) < 117 || PS3.getAnalogHat(RightHatY) > 137 || PS3.getAnalogHat(RightHatY) < 117) { - output += "LeftHatX: "; - output += PS3.getAnalogHat(LeftHatX); - output += "\tLeftHatY: "; - output += PS3.getAnalogHat(LeftHatY); - if (PS3.PS3Connected) { // The Navigation controller only have one joystick - output += "\tRightHatX: "; - output += PS3.getAnalogHat(RightHatX); - output += "\tRightHatY: "; - output += PS3.getAnalogHat(RightHatY); - } - } - //Analog button values can be read from almost all buttons - if (PS3.getAnalogButton(L2) || PS3.getAnalogButton(R2)) { - if (output != "") - output += "\r\n"; - output += "L2: "; - output += PS3.getAnalogButton(L2); - if (PS3.PS3Connected) { - output += "\tR2: "; - output += PS3.getAnalogButton(R2); - } - } - if (output != "") { - Serial.println(output); - if (SerialBT.connected) - SerialBT.println(output); - output = ""; // Reset output string - } - if (PS3.getButtonClick(PS)) { - output += " - PS"; - PS3.disconnect(); - } - else { - if (PS3.getButtonClick(TRIANGLE)) - output += " - Traingle"; - if (PS3.getButtonClick(CIRCLE)) - output += " - Circle"; - if (PS3.getButtonClick(CROSS)) - output += " - Cross"; - if (PS3.getButtonClick(SQUARE)) - output += " - Square"; - - if (PS3.getButtonClick(UP)) { - output += " - Up"; - if (PS3.PS3Connected) { - PS3.setLedOff(); - PS3.setLedOn(LED4); - } - } - if (PS3.getButtonClick(RIGHT)) { - output += " - Right"; - if (PS3.PS3Connected) { - PS3.setLedOff(); - PS3.setLedOn(LED1); - } - } - if (PS3.getButtonClick(DOWN)) { - output += " - Down"; - if (PS3.PS3Connected) { - PS3.setLedOff(); - PS3.setLedOn(LED2); - } - } - if (PS3.getButtonClick(LEFT)) { - output += " - Left"; - if (PS3.PS3Connected) { - PS3.setLedOff(); - PS3.setLedOn(LED3); - } - } - - if (PS3.getButtonClick(L1)) - output += " - L1"; - if (PS3.getButtonClick(L3)) - output += " - L3"; - if (PS3.getButtonClick(R1)) - output += " - R1"; - if (PS3.getButtonClick(R3)) - output += " - R3"; - - if (PS3.getButtonClick(SELECT)) { - output += " - Select"; - } - if (PS3.getButtonClick(START)) - output += " - Start"; - - if (output != "") { - String string = "PS3 Controller" + output; - Serial.println(string); - if (SerialBT.connected) - SerialBT.println(string); - } - } - delay(10); - } -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/PS4BT/PS4BT.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/PS4BT/PS4BT.ino deleted file mode 100644 index c3ba696b..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/PS4BT/PS4BT.ino +++ /dev/null @@ -1,146 +0,0 @@ -/* - Example sketch for the PS4 Bluetooth library - developed by Kristian Lauszus - For more information visit my blog: http://blog.tkjelectronics.dk/ or - send me an e-mail: kristianl@tkjelectronics.com - */ - -#include -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -//USBHub Hub1(&Usb); // Some dongles have a hub inside -BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so - -/* You can create the instance of the PS4BT class in two ways */ -// This will start an inquiry and then pair with the PS4 controller - you only have to do this once -// You will need to hold down the PS and Share button at the same time, the PS4 controller will then start to blink rapidly indicating that it is in paring mode -PS4BT PS4(&Btd, PAIR); - -// After that you can simply create the instance like so and then press the PS button on the device -//PS4BT PS4(&Btd); - -bool printAngle, printTouch; -uint8_t oldL2Value, oldR2Value; - -void setup() { - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); // Halt - } - Serial.print(F("\r\nPS4 Bluetooth Library Started")); -} -void loop() { - Usb.Task(); - - if (PS4.connected()) { - if (PS4.getAnalogHat(LeftHatX) > 137 || PS4.getAnalogHat(LeftHatX) < 117 || PS4.getAnalogHat(LeftHatY) > 137 || PS4.getAnalogHat(LeftHatY) < 117 || PS4.getAnalogHat(RightHatX) > 137 || PS4.getAnalogHat(RightHatX) < 117 || PS4.getAnalogHat(RightHatY) > 137 || PS4.getAnalogHat(RightHatY) < 117) { - Serial.print(F("\r\nLeftHatX: ")); - Serial.print(PS4.getAnalogHat(LeftHatX)); - Serial.print(F("\tLeftHatY: ")); - Serial.print(PS4.getAnalogHat(LeftHatY)); - Serial.print(F("\tRightHatX: ")); - Serial.print(PS4.getAnalogHat(RightHatX)); - Serial.print(F("\tRightHatY: ")); - Serial.print(PS4.getAnalogHat(RightHatY)); - } - - if (PS4.getAnalogButton(L2) || PS4.getAnalogButton(R2)) { // These are the only analog buttons on the PS4 controller - Serial.print(F("\r\nL2: ")); - Serial.print(PS4.getAnalogButton(L2)); - Serial.print(F("\tR2: ")); - Serial.print(PS4.getAnalogButton(R2)); - } - if (PS4.getAnalogButton(L2) != oldL2Value || PS4.getAnalogButton(R2) != oldR2Value) // Only write value if it's different - PS4.setRumbleOn(PS4.getAnalogButton(L2), PS4.getAnalogButton(R2)); - oldL2Value = PS4.getAnalogButton(L2); - oldR2Value = PS4.getAnalogButton(R2); - - if (PS4.getButtonClick(PS)) { - Serial.print(F("\r\nPS")); - PS4.disconnect(); - } - else { - if (PS4.getButtonClick(TRIANGLE)) { - Serial.print(F("\r\nTraingle")); - PS4.setRumbleOn(RumbleLow); - } - if (PS4.getButtonClick(CIRCLE)) { - Serial.print(F("\r\nCircle")); - PS4.setRumbleOn(RumbleHigh); - } - if (PS4.getButtonClick(CROSS)) { - Serial.print(F("\r\nCross")); - PS4.setLedFlash(10, 10); // Set it to blink rapidly - } - if (PS4.getButtonClick(SQUARE)) { - Serial.print(F("\r\nSquare")); - PS4.setLedFlash(0, 0); // Turn off blinking - } - - if (PS4.getButtonClick(UP)) { - Serial.print(F("\r\nUp")); - PS4.setLed(Red); - } if (PS4.getButtonClick(RIGHT)) { - Serial.print(F("\r\nRight")); - PS4.setLed(Blue); - } if (PS4.getButtonClick(DOWN)) { - Serial.print(F("\r\nDown")); - PS4.setLed(Yellow); - } if (PS4.getButtonClick(LEFT)) { - Serial.print(F("\r\nLeft")); - PS4.setLed(Green); - } - - if (PS4.getButtonClick(L1)) - Serial.print(F("\r\nL1")); - if (PS4.getButtonClick(L3)) - Serial.print(F("\r\nL3")); - if (PS4.getButtonClick(R1)) - Serial.print(F("\r\nR1")); - if (PS4.getButtonClick(R3)) - Serial.print(F("\r\nR3")); - - if (PS4.getButtonClick(SHARE)) - Serial.print(F("\r\nShare")); - if (PS4.getButtonClick(OPTIONS)) { - Serial.print(F("\r\nOptions")); - printAngle = !printAngle; - } - if (PS4.getButtonClick(TOUCHPAD)) { - Serial.print(F("\r\nTouchpad")); - printTouch = !printTouch; - } - - if (printAngle) { // Print angle calculated using the accelerometer only - Serial.print(F("\r\nPitch: ")); - Serial.print(PS4.getAngle(Pitch)); - Serial.print(F("\tRoll: ")); - Serial.print(PS4.getAngle(Roll)); - } - - if (printTouch) { // Print the x, y coordinates of the touchpad - if (PS4.isTouching(0) || PS4.isTouching(1)) // Print newline and carriage return if any of the fingers are touching the touchpad - Serial.print(F("\r\n")); - for (uint8_t i = 0; i < 2; i++) { // The touchpad track two fingers - if (PS4.isTouching(i)) { // Print the position of the finger if it is touching the touchpad - Serial.print(F("X")); Serial.print(i + 1); Serial.print(F(": ")); - Serial.print(PS4.getX(i)); - Serial.print(F("\tY")); Serial.print(i + 1); Serial.print(F(": ")); - Serial.print(PS4.getY(i)); - Serial.print(F("\t")); - } - } - } - } - } -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/SPP/SPP.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/SPP/SPP.ino deleted file mode 100644 index 8fb9c4ec..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/SPP/SPP.ino +++ /dev/null @@ -1,52 +0,0 @@ -/* - Example sketch for the RFCOMM/SPP Bluetooth library - developed by Kristian Lauszus - For more information visit my blog: http://blog.tkjelectronics.dk/ or - send me an e-mail: kristianl@tkjelectronics.com - */ - -#include -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -//USBHub Hub1(&Usb); // Some dongles have a hub inside - -BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so -/* You can create the instance of the class in two ways */ -SPP SerialBT(&Btd); // This will set the name to the defaults: "Arduino" and the pin to "0000" -//SPP SerialBT(&Btd, "Lauszus's Arduino", "1234"); // You can also set the name and pin like so - -bool firstMessage = true; - -void setup() { - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); //halt - } - Serial.print(F("\r\nSPP Bluetooth Library Started")); -} -void loop() { - Usb.Task(); // The SPP data is actually not send until this is called, one could call SerialBT.send() directly as well - - if (SerialBT.connected) { - if (firstMessage) { - firstMessage = false; - SerialBT.println(F("Hello from Arduino")); // Send welcome message - } - if (Serial.available()) - SerialBT.write(Serial.read()); - if (SerialBT.available()) - Serial.write(SerialBT.read()); - } - else - firstMessage = true; -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/SPPMulti/SPPMulti.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/SPPMulti/SPPMulti.ino deleted file mode 100644 index df521d8e..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/SPPMulti/SPPMulti.ino +++ /dev/null @@ -1,67 +0,0 @@ -/* - Example sketch for the RFCOMM/SPP Bluetooth library - developed by Kristian Lauszus - For more information visit my blog: http://blog.tkjelectronics.dk/ or - send me an e-mail: kristianl@tkjelectronics.com - */ - -#include -#include - -// Satisfy IDE, which only needs to see the include statment in the ino. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -//USBHub Hub1(&Usb); // Some dongles have a hub inside - -BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so - -const uint8_t length = 2; // Set the number of instances here -SPP *SerialBT[length]; // We will use this pointer to store the instances, you can easily make it larger if you like, but it will use a lot of RAM! - -bool firstMessage[length] = { true }; // Set all to true - -void setup() { - for (uint8_t i = 0; i < length; i++) - SerialBT[i] = new SPP(&Btd); // This will set the name to the default: "Arduino" and the pin to "0000" for all connections - - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); // Halt - } - Serial.print(F("\r\nSPP Bluetooth Library Started")); -} - -void loop() { - Usb.Task(); // The SPP data is actually not send until this is called, one could call SerialBT.send() directly as well - - for (uint8_t i = 0; i < length; i++) { - if (SerialBT[i]->connected) { - if (firstMessage[i]) { - firstMessage[i] = false; - SerialBT[i]->println(F("Hello from Arduino")); // Send welcome message - } - if (SerialBT[i]->available()) - Serial.write(SerialBT[i]->read()); - } - else - firstMessage[i] = true; - } - - // Set the connection you want to send to using the first character - // For instance "0Hello World" would send "Hello World" to connection 0 - if (Serial.available()) { - delay(10); // Wait for the rest of the data to arrive - uint8_t id = Serial.read() - '0'; // Convert from ASCII - if (id < length && SerialBT[id]->connected) { // Make sure that the id is valid and make sure that a device is actually connected - while (Serial.available()) // Check if data is available - SerialBT[id]->write(Serial.read()); // Send the data - } - } -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/Wii/Wii.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/Wii/Wii.ino deleted file mode 100644 index b1935681..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/Wii/Wii.ino +++ /dev/null @@ -1,118 +0,0 @@ -/* - Example sketch for the Wiimote Bluetooth library - developed by Kristian Lauszus - For more information visit my blog: http://blog.tkjelectronics.dk/ or - send me an e-mail: kristianl@tkjelectronics.com - */ - -#include -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -//USBHub Hub1(&Usb); // Some dongles have a hub inside - -BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so -/* You can create the instance of the class in two ways */ -WII Wii(&Btd, PAIR); // This will start an inquiry and then pair with your Wiimote - you only have to do this once -//WII Wii(&Btd); // After that you can simply create the instance like so and then press any button on the Wiimote - -bool printAngle; - -void setup() { - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); //halt - } - Serial.print(F("\r\nWiimote Bluetooth Library Started")); -} -void loop() { - Usb.Task(); - if (Wii.wiimoteConnected) { - if (Wii.getButtonClick(HOME)) { // You can use getButtonPress to see if the button is held down - Serial.print(F("\r\nHOME")); - Wii.disconnect(); - } - else { - if (Wii.getButtonClick(LEFT)) { - Wii.setLedOff(); - Wii.setLedOn(LED1); - Serial.print(F("\r\nLeft")); - } - if (Wii.getButtonClick(RIGHT)) { - Wii.setLedOff(); - Wii.setLedOn(LED3); - Serial.print(F("\r\nRight")); - } - if (Wii.getButtonClick(DOWN)) { - Wii.setLedOff(); - Wii.setLedOn(LED4); - Serial.print(F("\r\nDown")); - } - if (Wii.getButtonClick(UP)) { - Wii.setLedOff(); - Wii.setLedOn(LED2); - Serial.print(F("\r\nUp")); - } - - if (Wii.getButtonClick(PLUS)) - Serial.print(F("\r\nPlus")); - if (Wii.getButtonClick(MINUS)) - Serial.print(F("\r\nMinus")); - - if (Wii.getButtonClick(ONE)) - Serial.print(F("\r\nOne")); - if (Wii.getButtonClick(TWO)) - Serial.print(F("\r\nTwo")); - - if (Wii.getButtonClick(A)) { - printAngle = !printAngle; - Serial.print(F("\r\nA")); - } - if (Wii.getButtonClick(B)) { - Wii.setRumbleToggle(); - Serial.print(F("\r\nB")); - } - } -#if 0 // Set this to 1 in order to see the angle of the controllers - if (printAngle) { - Serial.print(F("\r\nPitch: ")); - Serial.print(Wii.getPitch()); - Serial.print(F("\tRoll: ")); - Serial.print(Wii.getRoll()); - if (Wii.motionPlusConnected) { - Serial.print(F("\tYaw: ")); - Serial.print(Wii.getYaw()); - } - if (Wii.nunchuckConnected) { - Serial.print(F("\tNunchuck Pitch: ")); - Serial.print(Wii.getNunchuckPitch()); - Serial.print(F("\tNunchuck Roll: ")); - Serial.print(Wii.getNunchuckRoll()); - } - } -#endif - } -#if 0 // Set this to 1 if you are using a Nunchuck controller - if (Wii.nunchuckConnected) { - if (Wii.getButtonClick(Z)) - Serial.print(F("\r\nZ")); - if (Wii.getButtonClick(C)) - Serial.print(F("\r\nC")); - if (Wii.getAnalogHat(HatX) > 137 || Wii.getAnalogHat(HatX) < 117 || Wii.getAnalogHat(HatY) > 137 || Wii.getAnalogHat(HatY) < 117) { - Serial.print(F("\r\nHatX: ")); - Serial.print(Wii.getAnalogHat(HatX)); - Serial.print(F("\tHatY: ")); - Serial.print(Wii.getAnalogHat(HatY)); - } - } -#endif -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/WiiBalanceBoard/WiiBalanceBoard.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/WiiBalanceBoard/WiiBalanceBoard.ino deleted file mode 100644 index 18c5b411..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/WiiBalanceBoard/WiiBalanceBoard.ino +++ /dev/null @@ -1,51 +0,0 @@ -/* - Example sketch for the Wii Balance Board Bluetooth library - developed by Kristian Lauszus - For more information visit my blog: http://blog.tkjelectronics.dk/ or - send me an e-mail: kristianl@tkjelectronics.com - */ - -#include -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -//USBHub Hub1(&Usb); // Some dongles have a hub inside - -BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so -/* You can create the instance of the class in two ways */ -WII Wii(&Btd, PAIR); // This will start an inquiry and then pair with your Wii Balance Board - you only have to do this once -//WII Wii(&Btd); // After that you can simply create the instance like so and then press the power button on the Wii Balance Board - -void setup() { - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); //halt - } - Serial.print(F("\r\nWii Balance Board Bluetooth Library Started")); -} -void loop() { - Usb.Task(); - if (Wii.wiiBalanceBoardConnected) { - Serial.print(F("\r\nWeight: ")); - for (uint8_t i = 0; i < 4; i++) { - Serial.print(Wii.getWeight((BalanceBoardEnum)i)); - Serial.print(F("\t")); - } - Serial.print(F("Total Weight: ")); - Serial.print(Wii.getTotalWeight()); - if (Wii.getButtonClick(A)) { - Serial.print(F("\r\nA")); - //Wii.setLedToggle(LED1); // The Wii Balance Board has one LED as well - Wii.disconnect(); - } - } -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/WiiIRCamera/WiiIRCamera.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/WiiIRCamera/WiiIRCamera.ino deleted file mode 100644 index 573b8bd4..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/WiiIRCamera/WiiIRCamera.ino +++ /dev/null @@ -1,133 +0,0 @@ -/* -Example sketch for the Wii libary showing the IR camera functionality. This example -is for the Bluetooth Wii library developed for the USB shield from Circuits@Home - -Created by Allan Glover and Kristian Lauszus. -Contact Kristian: http://blog.tkjelectronics.dk/ or send an email at kristianl@tkjelectronics.com. -Contact Allan at adglover9.81@gmail.com - -To test the Wiimote IR camera, you will need access to an IR source. Sunlight will work but is not ideal. -The simpleist solution is to use the Wii sensor bar, i.e. emitter bar, supplied by the Wii system. -Otherwise, wire up a IR LED yourself. -*/ - -#include -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -#ifndef WIICAMERA // Used to check if WIICAMERA is defined -#error "Please set ENABLE_WII_IR_CAMERA to 1 in settings.h" -#endif - -USB Usb; -//USBHub Hub1(&Usb); // Some dongles have a hub inside - -BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so -/* You can create the instance of the class in two ways */ -WII Wii(&Btd, PAIR); // This will start an inquiry and then pair with your Wiimote - you only have to do this once -//WII Wii(&Btd); // After the Wiimote pairs once with the line of code above, you can simply create the instance like so and re upload and then press any button on the Wiimote - -bool printAngle; -uint8_t printObjects; - -void setup() { - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); //halt - } - Serial.print(F("\r\nWiimote Bluetooth Library Started")); -} - -void loop() { - Usb.Task(); - if (Wii.wiimoteConnected) { - if (Wii.getButtonClick(HOME)) { // You can use getButtonPress to see if the button is held down - Serial.print(F("\r\nHOME")); - Wii.disconnect(); - } - else { - if (Wii.getButtonClick(ONE)) - Wii.IRinitialize(); // Run the initialisation sequence - if (Wii.getButtonClick(MINUS) || Wii.getButtonClick(PLUS)) { - if (!Wii.isIRCameraEnabled()) - Serial.print(F("\r\nEnable IR camera first")); - else { - if (Wii.getButtonPress(MINUS)) { // getButtonClick will only return true once - if (printObjects > 0) - printObjects--; - } - else { - if (printObjects < 4) - printObjects++; - } - Serial.print(F("\r\nTracking ")); - Serial.print(printObjects); - Serial.print(F(" objects")); - } - } - if (Wii.getButtonClick(A)) { - printAngle = !printAngle; - Serial.print(F("\r\nA")); - } - if (Wii.getButtonClick(B)) { - Serial.print(F("\r\nBattery level: ")); - Serial.print(Wii.getBatteryLevel()); // You can get the battery level as well - } - } - if (printObjects > 0) { - if (Wii.getIRx1() != 0x3FF || Wii.getIRy1() != 0x3FF || Wii.getIRs1() != 0) { // Only print if the IR camera is actually seeing something - Serial.print(F("\r\nx1: ")); - Serial.print(Wii.getIRx1()); - Serial.print(F("\ty1: ")); - Serial.print(Wii.getIRy1()); - Serial.print(F("\ts1:")); - Serial.print(Wii.getIRs1()); - } - if (printObjects > 1) { - if (Wii.getIRx2() != 0x3FF || Wii.getIRy2() != 0x3FF || Wii.getIRs2() != 0) { - Serial.print(F("\r\nx2: ")); - Serial.print(Wii.getIRx2()); - Serial.print(F("\ty2: ")); - Serial.print(Wii.getIRy2()); - Serial.print(F("\ts2:")); - Serial.print(Wii.getIRs2()); - } - if (printObjects > 2) { - if (Wii.getIRx3() != 0x3FF || Wii.getIRy3() != 0x3FF || Wii.getIRs3() != 0) { - Serial.print(F("\r\nx3: ")); - Serial.print(Wii.getIRx3()); - Serial.print(F("\ty3: ")); - Serial.print(Wii.getIRy3()); - Serial.print(F("\ts3:")); - Serial.print(Wii.getIRs3()); - } - if (printObjects > 3) { - if (Wii.getIRx4() != 0x3FF || Wii.getIRy4() != 0x3FF || Wii.getIRs4() != 0) { - Serial.print(F("\r\nx4: ")); - Serial.print(Wii.getIRx4()); - Serial.print(F("\ty4: ")); - Serial.print(Wii.getIRy4()); - Serial.print(F("\ts4:")); - Serial.print(Wii.getIRs4()); - } - } - } - } - } - if (printAngle) { // There is no extension bytes available, so the MotionPlus or Nunchuck can't be read - Serial.print(F("\r\nPitch: ")); - Serial.print(Wii.getPitch()); - Serial.print(F("\tRoll: ")); - Serial.print(Wii.getRoll()); - } - } -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/WiiMulti/WiiMulti.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/WiiMulti/WiiMulti.ino deleted file mode 100644 index 07c6f13d..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/WiiMulti/WiiMulti.ino +++ /dev/null @@ -1,132 +0,0 @@ -/* - Example sketch for the Wiimote Bluetooth library - developed by Kristian Lauszus - This example show how one can use multiple controllers with the library - For more information visit my blog: http://blog.tkjelectronics.dk/ or - send me an e-mail: kristianl@tkjelectronics.com - */ - -#include -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -//USBHub Hub1(&Usb); // Some dongles have a hub inside - -BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so -WII *Wii[2]; // We will use this pointer to store the two instance, you can easily make it larger if you like, but it will use a lot of RAM! -const uint8_t length = sizeof(Wii) / sizeof(Wii[0]); // Get the lenght of the array -bool printAngle[length]; -bool oldControllerState[length]; - -void setup() { - for (uint8_t i = 0; i < length; i++) { - Wii[i] = new WII(&Btd); // You will have to pair each controller with the dongle before you can define the instances like so, just add PAIR as the second argument - Wii[i]->attachOnInit(onInit); // onInit() is called upon a new connection - you can call the function whatever you like - } - - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); //halt - } - Serial.print(F("\r\nWiimote Bluetooth Library Started")); -} -void loop() { - Usb.Task(); - - for (uint8_t i = 0; i < length; i++) { - if (Wii[i]->wiimoteConnected) { - if (Wii[i]->getButtonClick(HOME)) { // You can use getButtonPress to see if the button is held down - Serial.print(F("\r\nHOME")); - Wii[i]->disconnect(); - oldControllerState[i] = false; // Reset value - } - else { - if (Wii[i]->getButtonClick(LEFT)) { - Wii[i]->setLedOff(); - Wii[i]->setLedOn(LED1); - Serial.print(F("\r\nLeft")); - } - if (Wii[i]->getButtonClick(RIGHT)) { - Wii[i]->setLedOff(); - Wii[i]->setLedOn(LED3); - Serial.print(F("\r\nRight")); - } - if (Wii[i]->getButtonClick(DOWN)) { - Wii[i]->setLedOff(); - Wii[i]->setLedOn(LED4); - Serial.print(F("\r\nDown")); - } - if (Wii[i]->getButtonClick(UP)) { - Wii[i]->setLedOff(); - Wii[i]->setLedOn(LED2); - Serial.print(F("\r\nUp")); - } - - if (Wii[i]->getButtonClick(PLUS)) - Serial.print(F("\r\nPlus")); - if (Wii[i]->getButtonClick(MINUS)) - Serial.print(F("\r\nMinus")); - - if (Wii[i]->getButtonClick(ONE)) - Serial.print(F("\r\nOne")); - if (Wii[i]->getButtonClick(TWO)) - Serial.print(F("\r\nTwo")); - - if (Wii[i]->getButtonClick(A)) { - printAngle[i] = !printAngle[i]; - Serial.print(F("\r\nA")); - } - if (Wii[i]->getButtonClick(B)) { - Wii[i]->setRumbleToggle(); - Serial.print(F("\r\nB")); - } - } - if (printAngle[i]) { - Serial.print(F("\r\nPitch: ")); - Serial.print(Wii[i]->getPitch()); - Serial.print(F("\tRoll: ")); - Serial.print(Wii[i]->getRoll()); - if (Wii[i]->motionPlusConnected) { - Serial.print(F("\tYaw: ")); - Serial.print(Wii[i]->getYaw()); - } - if (Wii[i]->nunchuckConnected) { - Serial.print(F("\tNunchuck Pitch: ")); - Serial.print(Wii[i]->getNunchuckPitch()); - Serial.print(F("\tNunchuck Roll: ")); - Serial.print(Wii[i]->getNunchuckRoll()); - } - } - } - if (Wii[i]->nunchuckConnected) { - if (Wii[i]->getButtonClick(Z)) - Serial.print(F("\r\nZ")); - if (Wii[i]->getButtonClick(C)) - Serial.print(F("\r\nC")); - if (Wii[i]->getAnalogHat(HatX) > 137 || Wii[i]->getAnalogHat(HatX) < 117 || Wii[i]->getAnalogHat(HatY) > 137 || Wii[i]->getAnalogHat(HatY) < 117) { - Serial.print(F("\r\nHatX: ")); - Serial.print(Wii[i]->getAnalogHat(HatX)); - Serial.print(F("\tHatY: ")); - Serial.print(Wii[i]->getAnalogHat(HatY)); - } - } - } -} - -void onInit() { - for (uint8_t i = 0; i < length; i++) { - if (Wii[i]->wiimoteConnected && !oldControllerState[i]) { - oldControllerState[i] = true; // Used to check which is the new controller - Wii[i]->setLedOn((LEDEnum)(i + 1)); // Cast directly to LEDEnum - see: "controllerEnums.h" - } - } -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/WiiUProController/WiiUProController.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/WiiUProController/WiiUProController.ino deleted file mode 100644 index ab35a274..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Bluetooth/WiiUProController/WiiUProController.ino +++ /dev/null @@ -1,104 +0,0 @@ -/* - Example sketch for the Wiimote Bluetooth library - developed by Kristian Lauszus - For more information visit my blog: http://blog.tkjelectronics.dk/ or - send me an e-mail: kristianl@tkjelectronics.com - */ - -#include -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -//USBHub Hub1(&Usb); // Some dongles have a hub inside - -BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so -/* You can create the instance of the class in two ways */ -WII Wii(&Btd, PAIR); // This will start an inquiry and then pair with your Wiimote - you only have to do this once -//WII Wii(&Btd); // After that you can simply create the instance like so and then press any button on the Wiimote - -void setup() { - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); //halt - } - Serial.print(F("\r\nWiimote Bluetooth Library Started")); -} -void loop() { - Usb.Task(); - if (Wii.wiiUProControllerConnected) { - if (Wii.getButtonClick(HOME)) { // You can use getButtonPress to see if the button is held down - Serial.print(F("\r\nHome")); - Wii.disconnect(); - } - else { - if (Wii.getButtonClick(LEFT)) { - Wii.setLedOff(); - Wii.setLedOn(LED1); - Serial.print(F("\r\nLeft")); - } - if (Wii.getButtonClick(RIGHT)) { - Wii.setLedOff(); - Wii.setLedOn(LED3); - Serial.print(F("\r\nRight")); - } - if (Wii.getButtonClick(DOWN)) { - Wii.setLedOff(); - Wii.setLedOn(LED4); - Serial.print(F("\r\nDown")); - } - if (Wii.getButtonClick(UP)) { - Wii.setLedOff(); - Wii.setLedOn(LED2); - Serial.print(F("\r\nUp")); - } - - if (Wii.getButtonClick(PLUS)) - Serial.print(F("\r\nPlus")); - if (Wii.getButtonClick(MINUS)) - Serial.print(F("\r\nMinus")); - - if (Wii.getButtonClick(A)) - Serial.print(F("\r\nA")); - if (Wii.getButtonClick(B)) { - Wii.setRumbleToggle(); - Serial.print(F("\r\nB")); - } - if (Wii.getButtonClick(X)) - Serial.print(F("\r\nX")); - if (Wii.getButtonClick(Y)) - Serial.print(F("\r\nY")); - - if (Wii.getButtonClick(L)) - Serial.print(F("\r\nL")); - if (Wii.getButtonClick(R)) - Serial.print(F("\r\nR")); - if (Wii.getButtonClick(ZL)) - Serial.print(F("\r\nZL")); - if (Wii.getButtonClick(ZR)) - Serial.print(F("\r\nZR")); - if (Wii.getButtonClick(L3)) - Serial.print(F("\r\nL3")); - if (Wii.getButtonClick(R3)) - Serial.print(F("\r\nR3")); - } - if (Wii.getAnalogHat(LeftHatX) > 2200 || Wii.getAnalogHat(LeftHatX) < 1800 || Wii.getAnalogHat(LeftHatY) > 2200 || Wii.getAnalogHat(LeftHatY) < 1800 || Wii.getAnalogHat(RightHatX) > 2200 || Wii.getAnalogHat(RightHatX) < 1800 || Wii.getAnalogHat(RightHatY) > 2200 || Wii.getAnalogHat(RightHatY) < 1800) { - Serial.print(F("\r\nLeftHatX: ")); - Serial.print(Wii.getAnalogHat(LeftHatX)); - Serial.print(F("\tLeftHatY: ")); - Serial.print(Wii.getAnalogHat(LeftHatY)); - Serial.print(F("\tRightHatX: ")); - Serial.print(Wii.getAnalogHat(RightHatX)); - Serial.print(F("\tRightHatY: ")); - Serial.print(Wii.getAnalogHat(RightHatY)); - } - } -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino deleted file mode 100644 index 48b33abf..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino +++ /dev/null @@ -1,129 +0,0 @@ -#include -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -class KbdRptParser : public KeyboardReportParser -{ - void PrintKey(uint8_t mod, uint8_t key); - - protected: - void OnControlKeysChanged(uint8_t before, uint8_t after); - - void OnKeyDown (uint8_t mod, uint8_t key); - void OnKeyUp (uint8_t mod, uint8_t key); - void OnKeyPressed(uint8_t key); -}; - -void KbdRptParser::PrintKey(uint8_t m, uint8_t key) -{ - MODIFIERKEYS mod; - *((uint8_t*)&mod) = m; - Serial.print((mod.bmLeftCtrl == 1) ? "C" : " "); - Serial.print((mod.bmLeftShift == 1) ? "S" : " "); - Serial.print((mod.bmLeftAlt == 1) ? "A" : " "); - Serial.print((mod.bmLeftGUI == 1) ? "G" : " "); - - Serial.print(" >"); - PrintHex(key, 0x80); - Serial.print("< "); - - Serial.print((mod.bmRightCtrl == 1) ? "C" : " "); - Serial.print((mod.bmRightShift == 1) ? "S" : " "); - Serial.print((mod.bmRightAlt == 1) ? "A" : " "); - Serial.println((mod.bmRightGUI == 1) ? "G" : " "); -}; - -void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key) -{ - Serial.print("DN "); - PrintKey(mod, key); - uint8_t c = OemToAscii(mod, key); - - if (c) - OnKeyPressed(c); -} - -void KbdRptParser::OnControlKeysChanged(uint8_t before, uint8_t after) { - - MODIFIERKEYS beforeMod; - *((uint8_t*)&beforeMod) = before; - - MODIFIERKEYS afterMod; - *((uint8_t*)&afterMod) = after; - - if (beforeMod.bmLeftCtrl != afterMod.bmLeftCtrl) { - Serial.println("LeftCtrl changed"); - } - if (beforeMod.bmLeftShift != afterMod.bmLeftShift) { - Serial.println("LeftShift changed"); - } - if (beforeMod.bmLeftAlt != afterMod.bmLeftAlt) { - Serial.println("LeftAlt changed"); - } - if (beforeMod.bmLeftGUI != afterMod.bmLeftGUI) { - Serial.println("LeftGUI changed"); - } - - if (beforeMod.bmRightCtrl != afterMod.bmRightCtrl) { - Serial.println("RightCtrl changed"); - } - if (beforeMod.bmRightShift != afterMod.bmRightShift) { - Serial.println("RightShift changed"); - } - if (beforeMod.bmRightAlt != afterMod.bmRightAlt) { - Serial.println("RightAlt changed"); - } - if (beforeMod.bmRightGUI != afterMod.bmRightGUI) { - Serial.println("RightGUI changed"); - } - -} - -void KbdRptParser::OnKeyUp(uint8_t mod, uint8_t key) -{ - Serial.print("UP "); - PrintKey(mod, key); -} - -void KbdRptParser::OnKeyPressed(uint8_t key) -{ - Serial.print("ASCII: "); - Serial.println((char)key); -}; - -USB Usb; -//USBHub Hub(&Usb); -HIDBoot HidKeyboard(&Usb); - -uint32_t next_time; - -KbdRptParser Prs; - -void setup() -{ - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSC did not start."); - - delay( 200 ); - - next_time = millis() + 5000; - - HidKeyboard.SetReportParser(0, (HIDReportParser*)&Prs); -} - -void loop() -{ - Usb.Task(); -} - diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootKbdAndMouse/USBHIDBootKbdAndMouse.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootKbdAndMouse/USBHIDBootKbdAndMouse.ino deleted file mode 100644 index 5fc8c96f..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootKbdAndMouse/USBHIDBootKbdAndMouse.ino +++ /dev/null @@ -1,178 +0,0 @@ -#include -#include - -// Satisfy IDE, which only needs to see the include statment in the ino. -#ifdef dobogusinclude -#include -#include -#endif - -class MouseRptParser : public MouseReportParser -{ - protected: - void OnMouseMove(MOUSEINFO *mi); - void OnLeftButtonUp(MOUSEINFO *mi); - void OnLeftButtonDown(MOUSEINFO *mi); - void OnRightButtonUp(MOUSEINFO *mi); - void OnRightButtonDown(MOUSEINFO *mi); - void OnMiddleButtonUp(MOUSEINFO *mi); - void OnMiddleButtonDown(MOUSEINFO *mi); -}; -void MouseRptParser::OnMouseMove(MOUSEINFO *mi) -{ - Serial.print("dx="); - Serial.print(mi->dX, DEC); - Serial.print(" dy="); - Serial.println(mi->dY, DEC); -}; -void MouseRptParser::OnLeftButtonUp (MOUSEINFO *mi) -{ - Serial.println("L Butt Up"); -}; -void MouseRptParser::OnLeftButtonDown (MOUSEINFO *mi) -{ - Serial.println("L Butt Dn"); -}; -void MouseRptParser::OnRightButtonUp (MOUSEINFO *mi) -{ - Serial.println("R Butt Up"); -}; -void MouseRptParser::OnRightButtonDown (MOUSEINFO *mi) -{ - Serial.println("R Butt Dn"); -}; -void MouseRptParser::OnMiddleButtonUp (MOUSEINFO *mi) -{ - Serial.println("M Butt Up"); -}; -void MouseRptParser::OnMiddleButtonDown (MOUSEINFO *mi) -{ - Serial.println("M Butt Dn"); -}; - -class KbdRptParser : public KeyboardReportParser -{ - void PrintKey(uint8_t mod, uint8_t key); - - protected: - void OnControlKeysChanged(uint8_t before, uint8_t after); - void OnKeyDown (uint8_t mod, uint8_t key); - void OnKeyUp (uint8_t mod, uint8_t key); - void OnKeyPressed(uint8_t key); -}; - -void KbdRptParser::PrintKey(uint8_t m, uint8_t key) -{ - MODIFIERKEYS mod; - *((uint8_t*)&mod) = m; - Serial.print((mod.bmLeftCtrl == 1) ? "C" : " "); - Serial.print((mod.bmLeftShift == 1) ? "S" : " "); - Serial.print((mod.bmLeftAlt == 1) ? "A" : " "); - Serial.print((mod.bmLeftGUI == 1) ? "G" : " "); - - Serial.print(" >"); - PrintHex(key, 0x80); - Serial.print("< "); - - Serial.print((mod.bmRightCtrl == 1) ? "C" : " "); - Serial.print((mod.bmRightShift == 1) ? "S" : " "); - Serial.print((mod.bmRightAlt == 1) ? "A" : " "); - Serial.println((mod.bmRightGUI == 1) ? "G" : " "); -}; - -void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key) -{ - Serial.print("DN "); - PrintKey(mod, key); - uint8_t c = OemToAscii(mod, key); - - if (c) - OnKeyPressed(c); -} - -void KbdRptParser::OnControlKeysChanged(uint8_t before, uint8_t after) { - - MODIFIERKEYS beforeMod; - *((uint8_t*)&beforeMod) = before; - - MODIFIERKEYS afterMod; - *((uint8_t*)&afterMod) = after; - - if (beforeMod.bmLeftCtrl != afterMod.bmLeftCtrl) { - Serial.println("LeftCtrl changed"); - } - if (beforeMod.bmLeftShift != afterMod.bmLeftShift) { - Serial.println("LeftShift changed"); - } - if (beforeMod.bmLeftAlt != afterMod.bmLeftAlt) { - Serial.println("LeftAlt changed"); - } - if (beforeMod.bmLeftGUI != afterMod.bmLeftGUI) { - Serial.println("LeftGUI changed"); - } - - if (beforeMod.bmRightCtrl != afterMod.bmRightCtrl) { - Serial.println("RightCtrl changed"); - } - if (beforeMod.bmRightShift != afterMod.bmRightShift) { - Serial.println("RightShift changed"); - } - if (beforeMod.bmRightAlt != afterMod.bmRightAlt) { - Serial.println("RightAlt changed"); - } - if (beforeMod.bmRightGUI != afterMod.bmRightGUI) { - Serial.println("RightGUI changed"); - } - -} - -void KbdRptParser::OnKeyUp(uint8_t mod, uint8_t key) -{ - Serial.print("UP "); - PrintKey(mod, key); -} - -void KbdRptParser::OnKeyPressed(uint8_t key) -{ - Serial.print("ASCII: "); - Serial.println((char)key); -}; - -USB Usb; -USBHub Hub(&Usb); - -HIDBoot < HID_PROTOCOL_KEYBOARD | HID_PROTOCOL_MOUSE > HidComposite(&Usb); -HIDBoot HidKeyboard(&Usb); -HIDBoot HidMouse(&Usb); - -//uint32_t next_time; - -KbdRptParser KbdPrs; -MouseRptParser MousePrs; - -void setup() -{ - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSC did not start."); - - delay( 200 ); - - //next_time = millis() + 5000; - - HidComposite.SetReportParser(0, (HIDReportParser*)&KbdPrs); - HidComposite.SetReportParser(1, (HIDReportParser*)&MousePrs); - HidKeyboard.SetReportParser(0, (HIDReportParser*)&KbdPrs); - HidMouse.SetReportParser(0, (HIDReportParser*)&MousePrs); -} - -void loop() -{ - Usb.Task(); -} - diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootMouse/USBHIDBootMouse.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootMouse/USBHIDBootMouse.ino deleted file mode 100644 index 53102512..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDBootMouse/USBHIDBootMouse.ino +++ /dev/null @@ -1,83 +0,0 @@ -#include -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -class MouseRptParser : public MouseReportParser -{ -protected: - void OnMouseMove (MOUSEINFO *mi); - void OnLeftButtonUp (MOUSEINFO *mi); - void OnLeftButtonDown (MOUSEINFO *mi); - void OnRightButtonUp (MOUSEINFO *mi); - void OnRightButtonDown (MOUSEINFO *mi); - void OnMiddleButtonUp (MOUSEINFO *mi); - void OnMiddleButtonDown (MOUSEINFO *mi); -}; -void MouseRptParser::OnMouseMove(MOUSEINFO *mi) -{ - Serial.print("dx="); - Serial.print(mi->dX, DEC); - Serial.print(" dy="); - Serial.println(mi->dY, DEC); -}; -void MouseRptParser::OnLeftButtonUp (MOUSEINFO *mi) -{ - Serial.println("L Butt Up"); -}; -void MouseRptParser::OnLeftButtonDown (MOUSEINFO *mi) -{ - Serial.println("L Butt Dn"); -}; -void MouseRptParser::OnRightButtonUp (MOUSEINFO *mi) -{ - Serial.println("R Butt Up"); -}; -void MouseRptParser::OnRightButtonDown (MOUSEINFO *mi) -{ - Serial.println("R Butt Dn"); -}; -void MouseRptParser::OnMiddleButtonUp (MOUSEINFO *mi) -{ - Serial.println("M Butt Up"); -}; -void MouseRptParser::OnMiddleButtonDown (MOUSEINFO *mi) -{ - Serial.println("M Butt Dn"); -}; - -USB Usb; -USBHub Hub(&Usb); -HIDBoot HidMouse(&Usb); - -uint32_t next_time; - -MouseRptParser Prs; - -void setup() -{ - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSC did not start."); - - delay( 200 ); - - next_time = millis() + 5000; - - HidMouse.SetReportParser(0,(HIDReportParser*)&Prs); -} - -void loop() -{ - Usb.Task(); -} - diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/USBHIDJoystick.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/USBHIDJoystick.ino deleted file mode 100644 index 956441d6..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/USBHIDJoystick.ino +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#include - -// Satisfy IDE, which only needs to see the include statment in the ino. -#ifdef dobogusinclude -#include -#include -#endif - -#include "hidjoystickrptparser.h" - -USB Usb; -USBHub Hub(&Usb); -HIDUniversal Hid(&Usb); -JoystickEvents JoyEvents; -JoystickReportParser Joy(&JoyEvents); - -void setup() { - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSC did not start."); - - delay(200); - - if (!Hid.SetReportParser(0, &Joy)) - ErrorMessage (PSTR("SetReportParser"), 1); -} - -void loop() { - Usb.Task(); -} - diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.cpp deleted file mode 100644 index 083b95ca..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "hidjoystickrptparser.h" - -JoystickReportParser::JoystickReportParser(JoystickEvents *evt) : -joyEvents(evt), -oldHat(0xDE), -oldButtons(0) { - for (uint8_t i = 0; i < RPT_GEMEPAD_LEN; i++) - oldPad[i] = 0xD; -} - -void JoystickReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) { - bool match = true; - - // Checking if there are changes in report since the method was last called - for (uint8_t i = 0; i < RPT_GEMEPAD_LEN; i++) - if (buf[i] != oldPad[i]) { - match = false; - break; - } - - // Calling Game Pad event handler - if (!match && joyEvents) { - joyEvents->OnGamePadChanged((const GamePadEventData*)buf); - - for (uint8_t i = 0; i < RPT_GEMEPAD_LEN; i++) oldPad[i] = buf[i]; - } - - uint8_t hat = (buf[5] & 0xF); - - // Calling Hat Switch event handler - if (hat != oldHat && joyEvents) { - joyEvents->OnHatSwitch(hat); - oldHat = hat; - } - - uint16_t buttons = (0x0000 | buf[6]); - buttons <<= 4; - buttons |= (buf[5] >> 4); - uint16_t changes = (buttons ^ oldButtons); - - // Calling Button Event Handler for every button changed - if (changes) { - for (uint8_t i = 0; i < 0x0C; i++) { - uint16_t mask = (0x0001 << i); - - if (((mask & changes) > 0) && joyEvents) - if ((buttons & mask) > 0) - joyEvents->OnButtonDn(i + 1); - else - joyEvents->OnButtonUp(i + 1); - } - oldButtons = buttons; - } -} - -void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt) { - Serial.print("X1: "); - PrintHex (evt->X, 0x80); - Serial.print("\tY1: "); - PrintHex (evt->Y, 0x80); - Serial.print("\tX2: "); - PrintHex (evt->Z1, 0x80); - Serial.print("\tY2: "); - PrintHex (evt->Z2, 0x80); - Serial.print("\tRz: "); - PrintHex (evt->Rz, 0x80); - Serial.println(""); -} - -void JoystickEvents::OnHatSwitch(uint8_t hat) { - Serial.print("Hat Switch: "); - PrintHex (hat, 0x80); - Serial.println(""); -} - -void JoystickEvents::OnButtonUp(uint8_t but_id) { - Serial.print("Up: "); - Serial.println(but_id, DEC); -} - -void JoystickEvents::OnButtonDn(uint8_t but_id) { - Serial.print("Dn: "); - Serial.println(but_id, DEC); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h b/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h deleted file mode 100644 index 733b8f8d..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h +++ /dev/null @@ -1,33 +0,0 @@ -#if !defined(__HIDJOYSTICKRPTPARSER_H__) -#define __HIDJOYSTICKRPTPARSER_H__ - -#include - -struct GamePadEventData { - uint8_t X, Y, Z1, Z2, Rz; -}; - -class JoystickEvents { -public: - virtual void OnGamePadChanged(const GamePadEventData *evt); - virtual void OnHatSwitch(uint8_t hat); - virtual void OnButtonUp(uint8_t but_id); - virtual void OnButtonDn(uint8_t but_id); -}; - -#define RPT_GEMEPAD_LEN 5 - -class JoystickReportParser : public HIDReportParser { - JoystickEvents *joyEvents; - - uint8_t oldPad[RPT_GEMEPAD_LEN]; - uint8_t oldHat; - uint16_t oldButtons; - -public: - JoystickReportParser(JoystickEvents *evt); - - virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); -}; - -#endif // __HIDJOYSTICKRPTPARSER_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHID_desc/USBHID_desc.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHID_desc/USBHID_desc.ino deleted file mode 100644 index 85cfc19a..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHID_desc/USBHID_desc.ino +++ /dev/null @@ -1,77 +0,0 @@ -#include -#include -#include -#include -#include "pgmstrings.h" - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -class HIDUniversal2 : public HIDUniversal -{ -public: - HIDUniversal2(USB *usb) : HIDUniversal(usb) {}; - -protected: - uint8_t OnInitSuccessful(); -}; - -uint8_t HIDUniversal2::OnInitSuccessful() -{ - uint8_t rcode; - - HexDumper Hex; - ReportDescParser Rpt; - - if ((rcode = GetReportDescr(0, &Hex))) - goto FailGetReportDescr1; - - if ((rcode = GetReportDescr(0, &Rpt))) - goto FailGetReportDescr2; - - return 0; - -FailGetReportDescr1: - USBTRACE("GetReportDescr1:"); - goto Fail; - -FailGetReportDescr2: - USBTRACE("GetReportDescr2:"); - goto Fail; - -Fail: - Serial.println(rcode, HEX); - Release(); - return rcode; -} - -USB Usb; -//USBHub Hub(&Usb); -HIDUniversal2 Hid(&Usb); -UniversalReportParser Uni; - -void setup() -{ - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSC did not start."); - - delay( 200 ); - - if (!Hid.SetReportParser(0, &Uni)) - ErrorMessage(PSTR("SetReportParser"), 1 ); -} - -void loop() -{ - Usb.Task(); -} - diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHID_desc/pgmstrings.h b/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHID_desc/pgmstrings.h deleted file mode 100644 index bdb0077e..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/USBHID_desc/pgmstrings.h +++ /dev/null @@ -1,52 +0,0 @@ -#if !defined(__PGMSTRINGS_H__) -#define __PGMSTRINGS_H__ - -#define LOBYTE(x) ((char*)(&(x)))[0] -#define HIBYTE(x) ((char*)(&(x)))[1] -#define BUFSIZE 256 //buffer size - - -/* Print strings in Program Memory */ -const char Gen_Error_str[] PROGMEM = "\r\nRequest error. Error code:\t"; -const char Dev_Header_str[] PROGMEM ="\r\nDevice descriptor: "; -const char Dev_Length_str[] PROGMEM ="\r\nDescriptor Length:\t"; -const char Dev_Type_str[] PROGMEM ="\r\nDescriptor type:\t"; -const char Dev_Version_str[] PROGMEM ="\r\nUSB version:\t\t"; -const char Dev_Class_str[] PROGMEM ="\r\nDevice class:\t\t"; -const char Dev_Subclass_str[] PROGMEM ="\r\nDevice Subclass:\t"; -const char Dev_Protocol_str[] PROGMEM ="\r\nDevice Protocol:\t"; -const char Dev_Pktsize_str[] PROGMEM ="\r\nMax.packet size:\t"; -const char Dev_Vendor_str[] PROGMEM ="\r\nVendor ID:\t\t"; -const char Dev_Product_str[] PROGMEM ="\r\nProduct ID:\t\t"; -const char Dev_Revision_str[] PROGMEM ="\r\nRevision ID:\t\t"; -const char Dev_Mfg_str[] PROGMEM ="\r\nMfg.string index:\t"; -const char Dev_Prod_str[] PROGMEM ="\r\nProd.string index:\t"; -const char Dev_Serial_str[] PROGMEM ="\r\nSerial number index:\t"; -const char Dev_Nconf_str[] PROGMEM ="\r\nNumber of conf.:\t"; -const char Conf_Trunc_str[] PROGMEM ="Total length truncated to 256 bytes"; -const char Conf_Header_str[] PROGMEM ="\r\nConfiguration descriptor:"; -const char Conf_Totlen_str[] PROGMEM ="\r\nTotal length:\t\t"; -const char Conf_Nint_str[] PROGMEM ="\r\nNum.intf:\t\t"; -const char Conf_Value_str[] PROGMEM ="\r\nConf.value:\t\t"; -const char Conf_String_str[] PROGMEM ="\r\nConf.string:\t\t"; -const char Conf_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; -const char Conf_Pwr_str[] PROGMEM ="\r\nMax.pwr:\t\t"; -const char Int_Header_str[] PROGMEM ="\r\n\r\nInterface descriptor:"; -const char Int_Number_str[] PROGMEM ="\r\nIntf.number:\t\t"; -const char Int_Alt_str[] PROGMEM ="\r\nAlt.:\t\t\t"; -const char Int_Endpoints_str[] PROGMEM ="\r\nEndpoints:\t\t"; -const char Int_Class_str[] PROGMEM ="\r\nIntf. Class:\t\t"; -const char Int_Subclass_str[] PROGMEM ="\r\nIntf. Subclass:\t\t"; -const char Int_Protocol_str[] PROGMEM ="\r\nIntf. Protocol:\t\t"; -const char Int_String_str[] PROGMEM ="\r\nIntf.string:\t\t"; -const char End_Header_str[] PROGMEM ="\r\n\r\nEndpoint descriptor:"; -const char End_Address_str[] PROGMEM ="\r\nEndpoint address:\t"; -const char End_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; -const char End_Pktsize_str[] PROGMEM ="\r\nMax.pkt size:\t\t"; -const char End_Interval_str[] PROGMEM ="\r\nPolling interval:\t"; -const char Unk_Header_str[] PROGMEM = "\r\nUnknown descriptor:"; -const char Unk_Length_str[] PROGMEM ="\r\nLength:\t\t"; -const char Unk_Type_str[] PROGMEM ="\r\nType:\t\t"; -const char Unk_Contents_str[] PROGMEM ="\r\nContents:\t"; - -#endif // __PGMSTRINGS_H__ \ No newline at end of file diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp.ino deleted file mode 100644 index 837d7f5a..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp.ino +++ /dev/null @@ -1,42 +0,0 @@ -/* Simplified Logitech Extreme 3D Pro Joystick Report Parser */ - -#include -#include -#include - -#include "le3dp_rptparser.h" - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -USBHub Hub(&Usb); -HIDUniversal Hid(&Usb); -JoystickEvents JoyEvents; -JoystickReportParser Joy(&JoyEvents); - -void setup() -{ - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSC did not start."); - - delay( 200 ); - - if (!Hid.SetReportParser(0, &Joy)) - ErrorMessage(PSTR("SetReportParser"), 1 ); -} - -void loop() -{ - Usb.Task(); -} - diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.cpp deleted file mode 100644 index baece13b..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "le3dp_rptparser.h" - -JoystickReportParser::JoystickReportParser(JoystickEvents *evt) : - joyEvents(evt) -{} - -void JoystickReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) -{ - bool match = true; - - // Checking if there are changes in report since the method was last called - for (uint8_t i=0; iOnGamePadChanged((const GamePadEventData*)buf); - - for (uint8_t i=0; i(evt->x, 0x80); - Serial.print(" Y: "); - PrintHex(evt->y, 0x80); - Serial.print(" Hat Switch: "); - PrintHex(evt->hat, 0x80); - Serial.print(" Twist: "); - PrintHex(evt->twist, 0x80); - Serial.print(" Slider: "); - PrintHex(evt->slider, 0x80); - Serial.print(" Buttons A: "); - PrintHex(evt->buttons_a, 0x80); - Serial.print(" Buttons B: "); - PrintHex(evt->buttons_b, 0x80); - Serial.println(""); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.h b/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.h deleted file mode 100644 index 2400364e..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.h +++ /dev/null @@ -1,42 +0,0 @@ -#if !defined(__HIDJOYSTICKRPTPARSER_H__) -#define __HIDJOYSTICKRPTPARSER_H__ - -#include - -struct GamePadEventData -{ - union { //axes and hut switch - uint32_t axes; - struct { - uint32_t x : 10; - uint32_t y : 10; - uint32_t hat : 4; - uint32_t twist : 8; - }; - }; - uint8_t buttons_a; - uint8_t slider; - uint8_t buttons_b; -}; - -class JoystickEvents -{ -public: - virtual void OnGamePadChanged(const GamePadEventData *evt); -}; - -#define RPT_GAMEPAD_LEN sizeof(GamePadEventData)/sizeof(uint8_t) - -class JoystickReportParser : public HIDReportParser -{ - JoystickEvents *joyEvents; - - uint8_t oldPad[RPT_GAMEPAD_LEN]; - -public: - JoystickReportParser(JoystickEvents *evt); - - virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); -}; - -#endif // __HIDJOYSTICKRPTPARSER_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale.ino deleted file mode 100644 index f26ff964..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale.ino +++ /dev/null @@ -1,51 +0,0 @@ -/* Digital Scale Output. Written for Stamps.com Model 510 */ -/* 5lb Digital Scale; any HID scale with Usage page 0x8d should work */ - -#include -#include -#include - -#include "scale_rptparser.h" - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -USBHub Hub(&Usb); -HIDUniversal Hid(&Usb); -Max_LCD LCD(&Usb); -ScaleEvents ScaleEvents(&LCD); -ScaleReportParser Scale(&ScaleEvents); - -void setup() -{ - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSC did not start."); - - // set up the LCD's number of rows and columns: - LCD.begin(16, 2); - LCD.clear(); - LCD.home(); - LCD.setCursor(0,0); - LCD.write('R'); - - delay( 200 ); - - if (!Hid.SetReportParser(0, &Scale)) - ErrorMessage(PSTR("SetReportParser"), 1 ); -} - -void loop() -{ - Usb.Task(); -} - diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.cpp deleted file mode 100644 index 01ed980c..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* Parser for standard HID scale (usage page 0x8d) data input report (ID 3) */ -#include "scale_rptparser.h" - -const char* UNITS[13] = { - "units", // unknown unit - "mg", // milligram - "g", // gram - "kg", // kilogram - "cd", // carat - "taels", // lian - "gr", // grain - "dwt", // pennyweight - "tonnes", // metric tons - "tons", // avoir ton - "ozt", // troy ounce - "oz", // ounce - "lbs" // pound -}; - -ScaleReportParser::ScaleReportParser(ScaleEvents *evt) : - scaleEvents(evt) -{} - -void ScaleReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) -{ - bool match = true; - - // Checking if there are changes in report since the method was last called - for (uint8_t i=0; iOnScaleChanged((const ScaleEventData*)buf); - - for (uint8_t i=0; iwrite( *str++ ); - - } -} - -void ScaleEvents::OnScaleChanged(const ScaleEventData *evt) -{ - - pLcd->clear(); - pLcd->home(); - pLcd->setCursor(0,0); - - if( evt->reportID != 3 ) { - - const char inv_report[]="Invalid report!"; - - Serial.println(inv_report); - LcdPrint(inv_report); - - return; - - }//if( evt->reportID != 3... - - switch( evt->status ) { - - case REPORT_FAULT: - Serial.println(F("Report fault")); - break; - - case ZEROED: - Serial.println(F("Scale zero set")); - break; - - case WEIGHING: { - - const char progress[] = "Weighing..."; - Serial.println(progress); - LcdPrint(progress); - break; - } - - case WEIGHT_VALID: { - - char buf[10]; - double weight = evt->weight * pow( 10, evt->exp ); - - - - Serial.print(F("Weight: ")); - Serial.print( weight ); - Serial.print(F(" ")); - Serial.println( UNITS[ evt->unit ]); - - LcdPrint("Weight: "); - dtostrf( weight, 4, 2, buf ); - LcdPrint( buf ); - LcdPrint( UNITS[ evt->unit ]); - - break; - - }//case WEIGHT_VALID... - - case WEIGHT_NEGATIVE: { - - const char negweight[] = "Negative weight"; - Serial.println(negweight); - LcdPrint(negweight); - break; - } - - case OVERWEIGHT: { - - const char overweight[] = "Max.weight reached"; - Serial.println(overweight); - LcdPrint( overweight ); - break; - } - - case CALIBRATE_ME: - - Serial.println(F("Scale calibration required")); - break; - - case ZERO_ME: - - Serial.println(F("Scale zeroing required")); - break; - - default: - - Serial.print(F("Undefined status code: ")); - Serial.println( evt->status ); - break; - - }//switch( evt->status... - -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h b/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h deleted file mode 100644 index 57fbb033..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h +++ /dev/null @@ -1,55 +0,0 @@ -#if !defined(__SCALERPTPARSER_H__) -#define __SCALERPTPARSER_H__ - -#include -#include - -/* Scale status constants */ -#define REPORT_FAULT 0x01 -#define ZEROED 0x02 -#define WEIGHING 0x03 -#define WEIGHT_VALID 0x04 -#define WEIGHT_NEGATIVE 0x05 -#define OVERWEIGHT 0x06 -#define CALIBRATE_ME 0x07 -#define ZERO_ME 0x08 - -/* input data report */ -struct ScaleEventData -{ - uint8_t reportID; //must be 3 - uint8_t status; - uint8_t unit; - int8_t exp; //scale factor for the weight - uint16_t weight; // -}; - -class ScaleEvents -{ - - Max_LCD* pLcd; - - void LcdPrint( const char* str ); - -public: - - ScaleEvents( Max_LCD* pLCD ); - - virtual void OnScaleChanged(const ScaleEventData *evt); -}; - -#define RPT_SCALE_LEN sizeof(ScaleEventData)/sizeof(uint8_t) - -class ScaleReportParser : public HIDReportParser -{ - ScaleEvents *scaleEvents; - - uint8_t oldScale[RPT_SCALE_LEN]; - -public: - ScaleReportParser(ScaleEvents *evt); - - virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); -}; - -#endif // __SCALERPTPARSER_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/PS3USB/PS3USB.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/PS3USB/PS3USB.ino deleted file mode 100644 index a53dcfbe..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/PS3USB/PS3USB.ino +++ /dev/null @@ -1,148 +0,0 @@ -/* - Example sketch for the PS3 USB library - developed by Kristian Lauszus - For more information visit my blog: http://blog.tkjelectronics.dk/ or - send me an e-mail: kristianl@tkjelectronics.com - */ - -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -/* You can create the instance of the class in two ways */ -PS3USB PS3(&Usb); // This will just create the instance -//PS3USB PS3(&Usb,0x00,0x15,0x83,0x3D,0x0A,0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch - -bool printAngle; -uint8_t state = 0; - -void setup() { - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); //halt - } - Serial.print(F("\r\nPS3 USB Library Started")); -} -void loop() { - Usb.Task(); - - if (PS3.PS3Connected || PS3.PS3NavigationConnected) { - if (PS3.getAnalogHat(LeftHatX) > 137 || PS3.getAnalogHat(LeftHatX) < 117 || PS3.getAnalogHat(LeftHatY) > 137 || PS3.getAnalogHat(LeftHatY) < 117 || PS3.getAnalogHat(RightHatX) > 137 || PS3.getAnalogHat(RightHatX) < 117 || PS3.getAnalogHat(RightHatY) > 137 || PS3.getAnalogHat(RightHatY) < 117) { - Serial.print(F("\r\nLeftHatX: ")); - Serial.print(PS3.getAnalogHat(LeftHatX)); - Serial.print(F("\tLeftHatY: ")); - Serial.print(PS3.getAnalogHat(LeftHatY)); - if (PS3.PS3Connected) { // The Navigation controller only have one joystick - Serial.print(F("\tRightHatX: ")); - Serial.print(PS3.getAnalogHat(RightHatX)); - Serial.print(F("\tRightHatY: ")); - Serial.print(PS3.getAnalogHat(RightHatY)); - } - } - // Analog button values can be read from almost all buttons - if (PS3.getAnalogButton(L2) || PS3.getAnalogButton(R2)) { - Serial.print(F("\r\nL2: ")); - Serial.print(PS3.getAnalogButton(L2)); - if (!PS3.PS3NavigationConnected) { - Serial.print(F("\tR2: ")); - Serial.print(PS3.getAnalogButton(R2)); - } - } - if (PS3.getButtonClick(PS)) - Serial.print(F("\r\nPS")); - - if (PS3.getButtonClick(TRIANGLE)) - Serial.print(F("\r\nTraingle")); - if (PS3.getButtonClick(CIRCLE)) - Serial.print(F("\r\nCircle")); - if (PS3.getButtonClick(CROSS)) - Serial.print(F("\r\nCross")); - if (PS3.getButtonClick(SQUARE)) - Serial.print(F("\r\nSquare")); - - if (PS3.getButtonClick(UP)) { - Serial.print(F("\r\nUp")); - PS3.setLedOff(); - PS3.setLedOn(LED4); - } - if (PS3.getButtonClick(RIGHT)) { - Serial.print(F("\r\nRight")); - PS3.setLedOff(); - PS3.setLedOn(LED1); - } - if (PS3.getButtonClick(DOWN)) { - Serial.print(F("\r\nDown")); - PS3.setLedOff(); - PS3.setLedOn(LED2); - } - if (PS3.getButtonClick(LEFT)) { - Serial.print(F("\r\nLeft")); - PS3.setLedOff(); - PS3.setLedOn(LED3); - } - - if (PS3.getButtonClick(L1)) - Serial.print(F("\r\nL1")); - if (PS3.getButtonClick(L3)) - Serial.print(F("\r\nL3")); - if (PS3.getButtonClick(R1)) - Serial.print(F("\r\nR1")); - if (PS3.getButtonClick(R3)) - Serial.print(F("\r\nR3")); - - if (PS3.getButtonClick(SELECT)) { - Serial.print(F("\r\nSelect - ")); - PS3.printStatusString(); - } - if (PS3.getButtonClick(START)) { - Serial.print(F("\r\nStart")); - printAngle = !printAngle; - } - if (printAngle) { - Serial.print(F("\r\nPitch: ")); - Serial.print(PS3.getAngle(Pitch)); - Serial.print(F("\tRoll: ")); - Serial.print(PS3.getAngle(Roll)); - } - } - else if (PS3.PS3MoveConnected) { // One can only set the color of the bulb, set the rumble, set and get the bluetooth address and calibrate the magnetometer via USB - if (state == 0) { - PS3.moveSetRumble(0); - PS3.moveSetBulb(Off); - } else if (state == 1) { - PS3.moveSetRumble(75); - PS3.moveSetBulb(Red); - } else if (state == 2) { - PS3.moveSetRumble(125); - PS3.moveSetBulb(Green); - } else if (state == 3) { - PS3.moveSetRumble(150); - PS3.moveSetBulb(Blue); - } else if (state == 4) { - PS3.moveSetRumble(175); - PS3.moveSetBulb(Yellow); - } else if (state == 5) { - PS3.moveSetRumble(200); - PS3.moveSetBulb(Lightblue); - } else if (state == 6) { - PS3.moveSetRumble(225); - PS3.moveSetBulb(Purble); - } else if (state == 7) { - PS3.moveSetRumble(250); - PS3.moveSetBulb(White); - } - - state++; - if (state > 7) - state = 0; - delay(1000); - } -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/PS4USB/PS4USB.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/PS4USB/PS4USB.ino deleted file mode 100644 index d0d76790..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/PS4USB/PS4USB.ino +++ /dev/null @@ -1,133 +0,0 @@ -/* - Example sketch for the PS4 USB library - developed by Kristian Lauszus - For more information visit my blog: http://blog.tkjelectronics.dk/ or - send me an e-mail: kristianl@tkjelectronics.com - */ - -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -PS4USB PS4(&Usb); - -bool printAngle, printTouch; -uint8_t oldL2Value, oldR2Value; - -void setup() { - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); // Halt - } - Serial.print(F("\r\nPS4 USB Library Started")); -} - -void loop() { - Usb.Task(); - - if (PS4.connected()) { - if (PS4.getAnalogHat(LeftHatX) > 137 || PS4.getAnalogHat(LeftHatX) < 117 || PS4.getAnalogHat(LeftHatY) > 137 || PS4.getAnalogHat(LeftHatY) < 117 || PS4.getAnalogHat(RightHatX) > 137 || PS4.getAnalogHat(RightHatX) < 117 || PS4.getAnalogHat(RightHatY) > 137 || PS4.getAnalogHat(RightHatY) < 117) { - Serial.print(F("\r\nLeftHatX: ")); - Serial.print(PS4.getAnalogHat(LeftHatX)); - Serial.print(F("\tLeftHatY: ")); - Serial.print(PS4.getAnalogHat(LeftHatY)); - Serial.print(F("\tRightHatX: ")); - Serial.print(PS4.getAnalogHat(RightHatX)); - Serial.print(F("\tRightHatY: ")); - Serial.print(PS4.getAnalogHat(RightHatY)); - } - - if (PS4.getAnalogButton(L2) || PS4.getAnalogButton(R2)) { // These are the only analog buttons on the PS4 controller - Serial.print(F("\r\nL2: ")); - Serial.print(PS4.getAnalogButton(L2)); - Serial.print(F("\tR2: ")); - Serial.print(PS4.getAnalogButton(R2)); - } - if (PS4.getAnalogButton(L2) != oldL2Value || PS4.getAnalogButton(R2) != oldR2Value) // Only write value if it's different - PS4.setRumbleOn(PS4.getAnalogButton(L2), PS4.getAnalogButton(R2)); - oldL2Value = PS4.getAnalogButton(L2); - oldR2Value = PS4.getAnalogButton(R2); - - if (PS4.getButtonClick(PS)) - Serial.print(F("\r\nPS")); - if (PS4.getButtonClick(TRIANGLE)) { - Serial.print(F("\r\nTraingle")); - PS4.setRumbleOn(RumbleLow); - } - if (PS4.getButtonClick(CIRCLE)) { - Serial.print(F("\r\nCircle")); - PS4.setRumbleOn(RumbleHigh); - } - if (PS4.getButtonClick(CROSS)) { - Serial.print(F("\r\nCross")); - PS4.setLedFlash(10, 10); // Set it to blink rapidly - } - if (PS4.getButtonClick(SQUARE)) { - Serial.print(F("\r\nSquare")); - PS4.setLedFlash(0, 0); // Turn off blinking - } - - if (PS4.getButtonClick(UP)) { - Serial.print(F("\r\nUp")); - PS4.setLed(Red); - } if (PS4.getButtonClick(RIGHT)) { - Serial.print(F("\r\nRight")); - PS4.setLed(Blue); - } if (PS4.getButtonClick(DOWN)) { - Serial.print(F("\r\nDown")); - PS4.setLed(Yellow); - } if (PS4.getButtonClick(LEFT)) { - Serial.print(F("\r\nLeft")); - PS4.setLed(Green); - } - - if (PS4.getButtonClick(L1)) - Serial.print(F("\r\nL1")); - if (PS4.getButtonClick(L3)) - Serial.print(F("\r\nL3")); - if (PS4.getButtonClick(R1)) - Serial.print(F("\r\nR1")); - if (PS4.getButtonClick(R3)) - Serial.print(F("\r\nR3")); - - if (PS4.getButtonClick(SHARE)) - Serial.print(F("\r\nShare")); - if (PS4.getButtonClick(OPTIONS)) { - Serial.print(F("\r\nOptions")); - printAngle = !printAngle; - } - if (PS4.getButtonClick(TOUCHPAD)) { - Serial.print(F("\r\nTouchpad")); - printTouch = !printTouch; - } - - if (printAngle) { // Print angle calculated using the accelerometer only - Serial.print(F("\r\nPitch: ")); - Serial.print(PS4.getAngle(Pitch)); - Serial.print(F("\tRoll: ")); - Serial.print(PS4.getAngle(Roll)); - } - - if (printTouch) { // Print the x, y coordinates of the touchpad - if (PS4.isTouching(0) || PS4.isTouching(1)) // Print newline and carriage return if any of the fingers are touching the touchpad - Serial.print(F("\r\n")); - for (uint8_t i = 0; i < 2; i++) { // The touchpad track two fingers - if (PS4.isTouching(i)) { // Print the position of the finger if it is touching the touchpad - Serial.print(F("X")); Serial.print(i + 1); Serial.print(F(": ")); - Serial.print(PS4.getX(i)); - Serial.print(F("\tY")); Serial.print(i + 1); Serial.print(F(": ")); - Serial.print(PS4.getY(i)); - Serial.print(F("\t")); - } - } - } - } -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/PSBuzz/PSBuzz.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/PSBuzz/PSBuzz.ino deleted file mode 100644 index 6ee462c1..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/PSBuzz/PSBuzz.ino +++ /dev/null @@ -1,49 +0,0 @@ -/* - Example sketch for the Playstation Buzz library - developed by Kristian Lauszus - For more information visit my blog: http://blog.tkjelectronics.dk/ or - send me an e-mail: kristianl@tkjelectronics.com - */ - -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -PSBuzz Buzz(&Usb); - -void setup() { - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); // Halt - } - Serial.println(F("\r\nPS Buzz Library Started")); -} - -void loop() { - Usb.Task(); - - if (Buzz.connected()) { - for (uint8_t i = 0; i < 4; i++) { - if (Buzz.getButtonClick(RED, i)) { - Buzz.setLedToggle(i); // Toggle the LED - Serial.println(F("RED")); - } - if (Buzz.getButtonClick(YELLOW, i)) - Serial.println(F("YELLOW")); - if (Buzz.getButtonClick(GREEN, i)) - Serial.println(F("GREEN")); - if (Buzz.getButtonClick(ORANGE, i)) - Serial.println(F("ORANGE")); - if (Buzz.getButtonClick(BLUE, i)) - Serial.println(F("BLUE")); - } - } -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/USB_desc/USB_desc.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/USB_desc/USB_desc.ino deleted file mode 100644 index acfe57d3..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/USB_desc/USB_desc.ino +++ /dev/null @@ -1,349 +0,0 @@ -#include - -#include "pgmstrings.h" - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -//USBHub Hub1(&Usb); -//USBHub Hub2(&Usb); -//USBHub Hub3(&Usb); -//USBHub Hub4(&Usb); -//USBHub Hub5(&Usb); -//USBHub Hub6(&Usb); -//USBHub Hub7(&Usb); - -uint32_t next_time; - -void PrintAllAddresses(UsbDevice *pdev) -{ - UsbDeviceAddress adr; - adr.devAddress = pdev->address.devAddress; - Serial.print("\r\nAddr:"); - Serial.print(adr.devAddress, HEX); - Serial.print("("); - Serial.print(adr.bmHub, HEX); - Serial.print("."); - Serial.print(adr.bmParent, HEX); - Serial.print("."); - Serial.print(adr.bmAddress, HEX); - Serial.println(")"); -} - -void PrintAddress(uint8_t addr) -{ - UsbDeviceAddress adr; - adr.devAddress = addr; - Serial.print("\r\nADDR:\t"); - Serial.println(adr.devAddress, HEX); - Serial.print("DEV:\t"); - Serial.println(adr.bmAddress, HEX); - Serial.print("PRNT:\t"); - Serial.println(adr.bmParent, HEX); - Serial.print("HUB:\t"); - Serial.println(adr.bmHub, HEX); -} - -void setup() -{ - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSC did not start."); - - delay( 200 ); - - next_time = millis() + 10000; -} - -byte getdevdescr( byte addr, byte &num_conf ); - -void PrintDescriptors(uint8_t addr) -{ - uint8_t rcode = 0; - byte num_conf = 0; - - rcode = getdevdescr( (byte)addr, num_conf ); - if ( rcode ) - { - printProgStr(Gen_Error_str); - print_hex( rcode, 8 ); - } - Serial.print("\r\n"); - - for (int i = 0; i < num_conf; i++) - { - rcode = getconfdescr( addr, i ); // get configuration descriptor - if ( rcode ) - { - printProgStr(Gen_Error_str); - print_hex(rcode, 8); - } - Serial.println("\r\n"); - } -} - -void PrintAllDescriptors(UsbDevice *pdev) -{ - Serial.println("\r\n"); - print_hex(pdev->address.devAddress, 8); - Serial.println("\r\n--"); - PrintDescriptors( pdev->address.devAddress ); -} - -void loop() -{ - Usb.Task(); - - if ( Usb.getUsbTaskState() == USB_STATE_RUNNING ) - { - //if (millis() >= next_time) - { - Usb.ForEachUsbDevice(&PrintAllDescriptors); - Usb.ForEachUsbDevice(&PrintAllAddresses); - - while ( 1 ); //stop - } - } -} - -byte getdevdescr( byte addr, byte &num_conf ) -{ - USB_DEVICE_DESCRIPTOR buf; - byte rcode; - rcode = Usb.getDevDescr( addr, 0, 0x12, ( uint8_t *)&buf ); - if ( rcode ) { - return ( rcode ); - } - printProgStr(Dev_Header_str); - printProgStr(Dev_Length_str); - print_hex( buf.bLength, 8 ); - printProgStr(Dev_Type_str); - print_hex( buf.bDescriptorType, 8 ); - printProgStr(Dev_Version_str); - print_hex( buf.bcdUSB, 16 ); - printProgStr(Dev_Class_str); - print_hex( buf.bDeviceClass, 8 ); - printProgStr(Dev_Subclass_str); - print_hex( buf.bDeviceSubClass, 8 ); - printProgStr(Dev_Protocol_str); - print_hex( buf.bDeviceProtocol, 8 ); - printProgStr(Dev_Pktsize_str); - print_hex( buf.bMaxPacketSize0, 8 ); - printProgStr(Dev_Vendor_str); - print_hex( buf.idVendor, 16 ); - printProgStr(Dev_Product_str); - print_hex( buf.idProduct, 16 ); - printProgStr(Dev_Revision_str); - print_hex( buf.bcdDevice, 16 ); - printProgStr(Dev_Mfg_str); - print_hex( buf.iManufacturer, 8 ); - printProgStr(Dev_Prod_str); - print_hex( buf.iProduct, 8 ); - printProgStr(Dev_Serial_str); - print_hex( buf.iSerialNumber, 8 ); - printProgStr(Dev_Nconf_str); - print_hex( buf.bNumConfigurations, 8 ); - num_conf = buf.bNumConfigurations; - return ( 0 ); -} - -void printhubdescr(uint8_t *descrptr, uint8_t addr) -{ - HubDescriptor *pHub = (HubDescriptor*) descrptr; - uint8_t len = *((uint8_t*)descrptr); - - printProgStr(PSTR("\r\n\r\nHub Descriptor:\r\n")); - printProgStr(PSTR("bDescLength:\t\t")); - Serial.println(pHub->bDescLength, HEX); - - printProgStr(PSTR("bDescriptorType:\t")); - Serial.println(pHub->bDescriptorType, HEX); - - printProgStr(PSTR("bNbrPorts:\t\t")); - Serial.println(pHub->bNbrPorts, HEX); - - printProgStr(PSTR("LogPwrSwitchMode:\t")); - Serial.println(pHub->LogPwrSwitchMode, BIN); - - printProgStr(PSTR("CompoundDevice:\t\t")); - Serial.println(pHub->CompoundDevice, BIN); - - printProgStr(PSTR("OverCurrentProtectMode:\t")); - Serial.println(pHub->OverCurrentProtectMode, BIN); - - printProgStr(PSTR("TTThinkTime:\t\t")); - Serial.println(pHub->TTThinkTime, BIN); - - printProgStr(PSTR("PortIndicatorsSupported:")); - Serial.println(pHub->PortIndicatorsSupported, BIN); - - printProgStr(PSTR("Reserved:\t\t")); - Serial.println(pHub->Reserved, HEX); - - printProgStr(PSTR("bPwrOn2PwrGood:\t\t")); - Serial.println(pHub->bPwrOn2PwrGood, HEX); - - printProgStr(PSTR("bHubContrCurrent:\t")); - Serial.println(pHub->bHubContrCurrent, HEX); - - for (uint8_t i = 7; i < len; i++) - print_hex(descrptr[i], 8); - - //for (uint8_t i=1; i<=pHub->bNbrPorts; i++) - // PrintHubPortStatus(&Usb, addr, i, 1); -} - -byte getconfdescr( byte addr, byte conf ) -{ - uint8_t buf[ BUFSIZE ]; - uint8_t* buf_ptr = buf; - byte rcode; - byte descr_length; - byte descr_type; - unsigned int total_length; - rcode = Usb.getConfDescr( addr, 0, 4, conf, buf ); //get total length - LOBYTE( total_length ) = buf[ 2 ]; - HIBYTE( total_length ) = buf[ 3 ]; - if ( total_length > 256 ) { //check if total length is larger than buffer - printProgStr(Conf_Trunc_str); - total_length = 256; - } - rcode = Usb.getConfDescr( addr, 0, total_length, conf, buf ); //get the whole descriptor - while ( buf_ptr < buf + total_length ) { //parsing descriptors - descr_length = *( buf_ptr ); - descr_type = *( buf_ptr + 1 ); - switch ( descr_type ) { - case ( USB_DESCRIPTOR_CONFIGURATION ): - printconfdescr( buf_ptr ); - break; - case ( USB_DESCRIPTOR_INTERFACE ): - printintfdescr( buf_ptr ); - break; - case ( USB_DESCRIPTOR_ENDPOINT ): - printepdescr( buf_ptr ); - break; - case 0x29: - printhubdescr( buf_ptr, addr ); - break; - default: - printunkdescr( buf_ptr ); - break; - }//switch( descr_type - buf_ptr = ( buf_ptr + descr_length ); //advance buffer pointer - }//while( buf_ptr <=... - return ( rcode ); -} -/* prints hex numbers with leading zeroes */ -// copyright, Peter H Anderson, Baltimore, MD, Nov, '07 -// source: http://www.phanderson.com/arduino/arduino_display.html -void print_hex(int v, int num_places) -{ - int mask = 0, n, num_nibbles, digit; - - for (n = 1; n <= num_places; n++) { - mask = (mask << 1) | 0x0001; - } - v = v & mask; // truncate v to specified number of places - - num_nibbles = num_places / 4; - if ((num_places % 4) != 0) { - ++num_nibbles; - } - do { - digit = ((v >> (num_nibbles - 1) * 4)) & 0x0f; - Serial.print(digit, HEX); - } - while (--num_nibbles); -} -/* function to print configuration descriptor */ -void printconfdescr( uint8_t* descr_ptr ) -{ - USB_CONFIGURATION_DESCRIPTOR* conf_ptr = ( USB_CONFIGURATION_DESCRIPTOR* )descr_ptr; - printProgStr(Conf_Header_str); - printProgStr(Conf_Totlen_str); - print_hex( conf_ptr->wTotalLength, 16 ); - printProgStr(Conf_Nint_str); - print_hex( conf_ptr->bNumInterfaces, 8 ); - printProgStr(Conf_Value_str); - print_hex( conf_ptr->bConfigurationValue, 8 ); - printProgStr(Conf_String_str); - print_hex( conf_ptr->iConfiguration, 8 ); - printProgStr(Conf_Attr_str); - print_hex( conf_ptr->bmAttributes, 8 ); - printProgStr(Conf_Pwr_str); - print_hex( conf_ptr->bMaxPower, 8 ); - return; -} -/* function to print interface descriptor */ -void printintfdescr( uint8_t* descr_ptr ) -{ - USB_INTERFACE_DESCRIPTOR* intf_ptr = ( USB_INTERFACE_DESCRIPTOR* )descr_ptr; - printProgStr(Int_Header_str); - printProgStr(Int_Number_str); - print_hex( intf_ptr->bInterfaceNumber, 8 ); - printProgStr(Int_Alt_str); - print_hex( intf_ptr->bAlternateSetting, 8 ); - printProgStr(Int_Endpoints_str); - print_hex( intf_ptr->bNumEndpoints, 8 ); - printProgStr(Int_Class_str); - print_hex( intf_ptr->bInterfaceClass, 8 ); - printProgStr(Int_Subclass_str); - print_hex( intf_ptr->bInterfaceSubClass, 8 ); - printProgStr(Int_Protocol_str); - print_hex( intf_ptr->bInterfaceProtocol, 8 ); - printProgStr(Int_String_str); - print_hex( intf_ptr->iInterface, 8 ); - return; -} -/* function to print endpoint descriptor */ -void printepdescr( uint8_t* descr_ptr ) -{ - USB_ENDPOINT_DESCRIPTOR* ep_ptr = ( USB_ENDPOINT_DESCRIPTOR* )descr_ptr; - printProgStr(End_Header_str); - printProgStr(End_Address_str); - print_hex( ep_ptr->bEndpointAddress, 8 ); - printProgStr(End_Attr_str); - print_hex( ep_ptr->bmAttributes, 8 ); - printProgStr(End_Pktsize_str); - print_hex( ep_ptr->wMaxPacketSize, 16 ); - printProgStr(End_Interval_str); - print_hex( ep_ptr->bInterval, 8 ); - - return; -} -/*function to print unknown descriptor */ -void printunkdescr( uint8_t* descr_ptr ) -{ - byte length = *descr_ptr; - byte i; - printProgStr(Unk_Header_str); - printProgStr(Unk_Length_str); - print_hex( *descr_ptr, 8 ); - printProgStr(Unk_Type_str); - print_hex( *(descr_ptr + 1 ), 8 ); - printProgStr(Unk_Contents_str); - descr_ptr += 2; - for ( i = 0; i < length; i++ ) { - print_hex( *descr_ptr, 8 ); - descr_ptr++; - } -} - - -/* Print a string from Program Memory directly to save RAM */ -void printProgStr(const char* str) -{ - char c; - if (!str) return; - while ((c = pgm_read_byte(str++))) - Serial.print(c); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/USB_desc/pgmstrings.h b/protocol/usb_hid/USB_Host_Shield_2.0/examples/USB_desc/pgmstrings.h deleted file mode 100644 index bdb0077e..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/USB_desc/pgmstrings.h +++ /dev/null @@ -1,52 +0,0 @@ -#if !defined(__PGMSTRINGS_H__) -#define __PGMSTRINGS_H__ - -#define LOBYTE(x) ((char*)(&(x)))[0] -#define HIBYTE(x) ((char*)(&(x)))[1] -#define BUFSIZE 256 //buffer size - - -/* Print strings in Program Memory */ -const char Gen_Error_str[] PROGMEM = "\r\nRequest error. Error code:\t"; -const char Dev_Header_str[] PROGMEM ="\r\nDevice descriptor: "; -const char Dev_Length_str[] PROGMEM ="\r\nDescriptor Length:\t"; -const char Dev_Type_str[] PROGMEM ="\r\nDescriptor type:\t"; -const char Dev_Version_str[] PROGMEM ="\r\nUSB version:\t\t"; -const char Dev_Class_str[] PROGMEM ="\r\nDevice class:\t\t"; -const char Dev_Subclass_str[] PROGMEM ="\r\nDevice Subclass:\t"; -const char Dev_Protocol_str[] PROGMEM ="\r\nDevice Protocol:\t"; -const char Dev_Pktsize_str[] PROGMEM ="\r\nMax.packet size:\t"; -const char Dev_Vendor_str[] PROGMEM ="\r\nVendor ID:\t\t"; -const char Dev_Product_str[] PROGMEM ="\r\nProduct ID:\t\t"; -const char Dev_Revision_str[] PROGMEM ="\r\nRevision ID:\t\t"; -const char Dev_Mfg_str[] PROGMEM ="\r\nMfg.string index:\t"; -const char Dev_Prod_str[] PROGMEM ="\r\nProd.string index:\t"; -const char Dev_Serial_str[] PROGMEM ="\r\nSerial number index:\t"; -const char Dev_Nconf_str[] PROGMEM ="\r\nNumber of conf.:\t"; -const char Conf_Trunc_str[] PROGMEM ="Total length truncated to 256 bytes"; -const char Conf_Header_str[] PROGMEM ="\r\nConfiguration descriptor:"; -const char Conf_Totlen_str[] PROGMEM ="\r\nTotal length:\t\t"; -const char Conf_Nint_str[] PROGMEM ="\r\nNum.intf:\t\t"; -const char Conf_Value_str[] PROGMEM ="\r\nConf.value:\t\t"; -const char Conf_String_str[] PROGMEM ="\r\nConf.string:\t\t"; -const char Conf_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; -const char Conf_Pwr_str[] PROGMEM ="\r\nMax.pwr:\t\t"; -const char Int_Header_str[] PROGMEM ="\r\n\r\nInterface descriptor:"; -const char Int_Number_str[] PROGMEM ="\r\nIntf.number:\t\t"; -const char Int_Alt_str[] PROGMEM ="\r\nAlt.:\t\t\t"; -const char Int_Endpoints_str[] PROGMEM ="\r\nEndpoints:\t\t"; -const char Int_Class_str[] PROGMEM ="\r\nIntf. Class:\t\t"; -const char Int_Subclass_str[] PROGMEM ="\r\nIntf. Subclass:\t\t"; -const char Int_Protocol_str[] PROGMEM ="\r\nIntf. Protocol:\t\t"; -const char Int_String_str[] PROGMEM ="\r\nIntf.string:\t\t"; -const char End_Header_str[] PROGMEM ="\r\n\r\nEndpoint descriptor:"; -const char End_Address_str[] PROGMEM ="\r\nEndpoint address:\t"; -const char End_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; -const char End_Pktsize_str[] PROGMEM ="\r\nMax.pkt size:\t\t"; -const char End_Interval_str[] PROGMEM ="\r\nPolling interval:\t"; -const char Unk_Header_str[] PROGMEM = "\r\nUnknown descriptor:"; -const char Unk_Length_str[] PROGMEM ="\r\nLength:\t\t"; -const char Unk_Type_str[] PROGMEM ="\r\nType:\t\t"; -const char Unk_Contents_str[] PROGMEM ="\r\nContents:\t"; - -#endif // __PGMSTRINGS_H__ \ No newline at end of file diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Xbox/XBOXOLD/XBOXOLD.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/Xbox/XBOXOLD/XBOXOLD.ino deleted file mode 100644 index 64a3ed61..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Xbox/XBOXOLD/XBOXOLD.ino +++ /dev/null @@ -1,110 +0,0 @@ -/* - Example sketch for the original Xbox library - developed by Kristian Lauszus - For more information visit my blog: http://blog.tkjelectronics.dk/ or - send me an e-mail: kristianl@tkjelectronics.com - */ - -#include -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -USBHub Hub1(&Usb); // The controller has a built in hub, so this instance is needed -XBOXOLD Xbox(&Usb); - -void setup() { - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); // halt - } - Serial.print(F("\r\nXBOX Library Started")); -} -void loop() { - Usb.Task(); - if (Xbox.XboxConnected) { - if (Xbox.getButtonPress(BLACK) || Xbox.getButtonPress(WHITE)) { - Serial.print("BLACK: "); - Serial.print(Xbox.getButtonPress(BLACK)); - Serial.print("\tWHITE: "); - Serial.println(Xbox.getButtonPress(WHITE)); - Xbox.setRumbleOn(Xbox.getButtonPress(BLACK), Xbox.getButtonPress(WHITE)); - } else - Xbox.setRumbleOn(0, 0); - - if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500 || Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500 || Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500 || Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) { - if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500) { - Serial.print(F("LeftHatX: ")); - Serial.print(Xbox.getAnalogHat(LeftHatX)); - Serial.print("\t"); - } - if (Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500) { - Serial.print(F("LeftHatY: ")); - Serial.print(Xbox.getAnalogHat(LeftHatY)); - Serial.print("\t"); - } - if (Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500) { - Serial.print(F("RightHatX: ")); - Serial.print(Xbox.getAnalogHat(RightHatX)); - Serial.print("\t"); - } - if (Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) { - Serial.print(F("RightHatY: ")); - Serial.print(Xbox.getAnalogHat(RightHatY)); - } - Serial.println(); - } - - if (Xbox.getButtonClick(UP)) - Serial.println(F("Up")); - if (Xbox.getButtonClick(DOWN)) - Serial.println(F("Down")); - if (Xbox.getButtonClick(LEFT)) - Serial.println(F("Left")); - if (Xbox.getButtonClick(RIGHT)) - Serial.println(F("Right")); - - if (Xbox.getButtonClick(START)) - Serial.println(F("Start")); - if (Xbox.getButtonClick(BACK)) - Serial.println(F("Back")); - if (Xbox.getButtonClick(L3)) - Serial.println(F("L3")); - if (Xbox.getButtonClick(R3)) - Serial.println(F("R3")); - - if (Xbox.getButtonPress(A)) { - Serial.print(F("A: ")); - Serial.println(Xbox.getButtonPress(A)); - } - if (Xbox.getButtonPress(B)) { - Serial.print(F("B: ")); - Serial.println(Xbox.getButtonPress(B)); - } - if (Xbox.getButtonPress(X)) { - Serial.print(F("X: ")); - Serial.println(Xbox.getButtonPress(X)); - } - if (Xbox.getButtonPress(Y)) { - Serial.print(F("Y: ")); - Serial.println(Xbox.getButtonPress(Y)); - } - if (Xbox.getButtonPress(L1)) { - Serial.print(F("L1: ")); - Serial.println(Xbox.getButtonPress(L1)); - } - if (Xbox.getButtonPress(R1)) { - Serial.print(F("R1: ")); - Serial.println(Xbox.getButtonPress(R1)); - } - } - delay(1); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Xbox/XBOXONE/XBOXONE.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/Xbox/XBOXONE/XBOXONE.ino deleted file mode 100644 index 9526f53d..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Xbox/XBOXONE/XBOXONE.ino +++ /dev/null @@ -1,106 +0,0 @@ -/* - Example sketch for the Xbox ONE USB library - by guruthree, based on work by - Kristian Lauszus. - */ - -#include -// Satisfy IDE, which only needs to see the include statment in the ino. -#ifdef dobogusinclude -#include -#endif - -USB Usb; -XBOXONE Xbox(&Usb); - -void setup() { - Serial.begin(115200); - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); //halt - } - Serial.print(F("\r\nXBOX USB Library Started")); -} -void loop() { - Usb.Task(); - if (Xbox.XboxOneConnected) { - if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500 || Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500 || Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500 || Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) { - if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500) { - Serial.print(F("LeftHatX: ")); - Serial.print(Xbox.getAnalogHat(LeftHatX)); - Serial.print("\t"); - } - if (Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500) { - Serial.print(F("LeftHatY: ")); - Serial.print(Xbox.getAnalogHat(LeftHatY)); - Serial.print("\t"); - } - if (Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500) { - Serial.print(F("RightHatX: ")); - Serial.print(Xbox.getAnalogHat(RightHatX)); - Serial.print("\t"); - } - if (Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) { - Serial.print(F("RightHatY: ")); - Serial.print(Xbox.getAnalogHat(RightHatY)); - } - Serial.println(); - } - - if (Xbox.getButtonPress(L2) > 0 || Xbox.getButtonPress(R2) > 0) { - if (Xbox.getButtonPress(L2) > 0) { - Serial.print(F("L2: ")); - Serial.print(Xbox.getButtonPress(L2)); - Serial.print("\t"); - } - if (Xbox.getButtonPress(R2) > 0) { - Serial.print(F("R2: ")); - Serial.print(Xbox.getButtonPress(R2)); - Serial.print("\t"); - } - Serial.println(); - } - - if (Xbox.getButtonClick(UP)) - Serial.println(F("Up")); - if (Xbox.getButtonClick(DOWN)) - Serial.println(F("Down")); - if (Xbox.getButtonClick(LEFT)) - Serial.println(F("Left")); - if (Xbox.getButtonClick(RIGHT)) - Serial.println(F("Right")); - - if (Xbox.getButtonClick(START)) - Serial.println(F("Start")); - if (Xbox.getButtonClick(BACK)) - Serial.println(F("Back")); - if (Xbox.getButtonClick(XBOX)) - Serial.println(F("Xbox")); - if (Xbox.getButtonClick(SYNC)) - Serial.println(F("Sync")); - - if (Xbox.getButtonClick(L1)) - Serial.println(F("L1")); - if (Xbox.getButtonClick(R1)) - Serial.println(F("R1")); - if (Xbox.getButtonClick(L2)) - Serial.println(F("L2")); - if (Xbox.getButtonClick(R2)) - Serial.println(F("R2")); - if (Xbox.getButtonClick(L3)) - Serial.println(F("L3")); - if (Xbox.getButtonClick(R3)) - Serial.println(F("R3")); - - - if (Xbox.getButtonClick(A)) - Serial.println(F("A")); - if (Xbox.getButtonClick(B)) - Serial.println(F("B")); - if (Xbox.getButtonClick(X)) - Serial.println(F("X")); - if (Xbox.getButtonClick(Y)) - Serial.println(F("Y")); - } - delay(1); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Xbox/XBOXRECV/XBOXRECV.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/Xbox/XBOXRECV/XBOXRECV.ino deleted file mode 100644 index 491b287e..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Xbox/XBOXRECV/XBOXRECV.ino +++ /dev/null @@ -1,122 +0,0 @@ -/* - Example sketch for the Xbox Wireless Reciver library - developed by Kristian Lauszus - It supports up to four controllers wirelessly - For more information see the blog post: http://blog.tkjelectronics.dk/2012/12/xbox-360-receiver-added-to-the-usb-host-library/ or - send me an e-mail: kristianl@tkjelectronics.com - */ - -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -XBOXRECV Xbox(&Usb); - -void setup() { - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); //halt - } - Serial.print(F("\r\nXbox Wireless Receiver Library Started")); -} -void loop() { - Usb.Task(); - if (Xbox.XboxReceiverConnected) { - for (uint8_t i = 0; i < 4; i++) { - if (Xbox.Xbox360Connected[i]) { - if (Xbox.getButtonPress(L2, i) || Xbox.getButtonPress(R2, i)) { - Serial.print("L2: "); - Serial.print(Xbox.getButtonPress(L2, i)); - Serial.print("\tR2: "); - Serial.println(Xbox.getButtonPress(R2, i)); - Xbox.setRumbleOn(Xbox.getButtonPress(L2, i), Xbox.getButtonPress(R2, i), i); - } - - if (Xbox.getAnalogHat(LeftHatX, i) > 7500 || Xbox.getAnalogHat(LeftHatX, i) < -7500 || Xbox.getAnalogHat(LeftHatY, i) > 7500 || Xbox.getAnalogHat(LeftHatY, i) < -7500 || Xbox.getAnalogHat(RightHatX, i) > 7500 || Xbox.getAnalogHat(RightHatX, i) < -7500 || Xbox.getAnalogHat(RightHatY, i) > 7500 || Xbox.getAnalogHat(RightHatY, i) < -7500) { - if (Xbox.getAnalogHat(LeftHatX, i) > 7500 || Xbox.getAnalogHat(LeftHatX, i) < -7500) { - Serial.print(F("LeftHatX: ")); - Serial.print(Xbox.getAnalogHat(LeftHatX, i)); - Serial.print("\t"); - } - if (Xbox.getAnalogHat(LeftHatY, i) > 7500 || Xbox.getAnalogHat(LeftHatY, i) < -7500) { - Serial.print(F("LeftHatY: ")); - Serial.print(Xbox.getAnalogHat(LeftHatY, i)); - Serial.print("\t"); - } - if (Xbox.getAnalogHat(RightHatX, i) > 7500 || Xbox.getAnalogHat(RightHatX, i) < -7500) { - Serial.print(F("RightHatX: ")); - Serial.print(Xbox.getAnalogHat(RightHatX, i)); - Serial.print("\t"); - } - if (Xbox.getAnalogHat(RightHatY, i) > 7500 || Xbox.getAnalogHat(RightHatY, i) < -7500) { - Serial.print(F("RightHatY: ")); - Serial.print(Xbox.getAnalogHat(RightHatY, i)); - } - Serial.println(); - } - - if (Xbox.getButtonClick(UP, i)) { - Xbox.setLedOn(LED1, i); - Serial.println(F("Up")); - } - if (Xbox.getButtonClick(DOWN, i)) { - Xbox.setLedOn(LED4, i); - Serial.println(F("Down")); - } - if (Xbox.getButtonClick(LEFT, i)) { - Xbox.setLedOn(LED3, i); - Serial.println(F("Left")); - } - if (Xbox.getButtonClick(RIGHT, i)) { - Xbox.setLedOn(LED2, i); - Serial.println(F("Right")); - } - - if (Xbox.getButtonClick(START, i)) { - Xbox.setLedMode(ALTERNATING, i); - Serial.println(F("Start")); - } - if (Xbox.getButtonClick(BACK, i)) { - Xbox.setLedBlink(ALL, i); - Serial.println(F("Back")); - } - if (Xbox.getButtonClick(L3, i)) - Serial.println(F("L3")); - if (Xbox.getButtonClick(R3, i)) - Serial.println(F("R3")); - - if (Xbox.getButtonClick(L1, i)) - Serial.println(F("L1")); - if (Xbox.getButtonClick(R1, i)) - Serial.println(F("R1")); - if (Xbox.getButtonClick(XBOX, i)) { - Xbox.setLedMode(ROTATING, i); - Serial.print(F("Xbox (Battery: ")); - Serial.print(Xbox.getBatteryLevel(i)); // The battery level in the range 0-3 - Serial.println(F(")")); - } - if (Xbox.getButtonClick(SYNC, i)) { - Serial.println(F("Sync")); - Xbox.disconnect(i); - } - - if (Xbox.getButtonClick(A, i)) - Serial.println(F("A")); - if (Xbox.getButtonClick(B, i)) - Serial.println(F("B")); - if (Xbox.getButtonClick(X, i)) - Serial.println(F("X")); - if (Xbox.getButtonClick(Y, i)) - Serial.println(F("Y")); - } - } - } -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Xbox/XBOXUSB/XBOXUSB.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/Xbox/XBOXUSB/XBOXUSB.ino deleted file mode 100644 index 8a5691c6..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/Xbox/XBOXUSB/XBOXUSB.ino +++ /dev/null @@ -1,113 +0,0 @@ -/* - Example sketch for the Xbox 360 USB library - developed by Kristian Lauszus - For more information visit my blog: http://blog.tkjelectronics.dk/ or - send me an e-mail: kristianl@tkjelectronics.com - */ - -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -XBOXUSB Xbox(&Usb); - -void setup() { - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print(F("\r\nOSC did not start")); - while (1); //halt - } - Serial.print(F("\r\nXBOX USB Library Started")); -} -void loop() { - Usb.Task(); - if (Xbox.Xbox360Connected) { - if (Xbox.getButtonPress(L2) || Xbox.getButtonPress(R2)) { - Serial.print("L2: "); - Serial.print(Xbox.getButtonPress(L2)); - Serial.print("\tR2: "); - Serial.println(Xbox.getButtonPress(R2)); - Xbox.setRumbleOn(Xbox.getButtonPress(L2), Xbox.getButtonPress(R2)); - } else - Xbox.setRumbleOn(0, 0); - - if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500 || Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500 || Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500 || Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) { - if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500) { - Serial.print(F("LeftHatX: ")); - Serial.print(Xbox.getAnalogHat(LeftHatX)); - Serial.print("\t"); - } - if (Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500) { - Serial.print(F("LeftHatY: ")); - Serial.print(Xbox.getAnalogHat(LeftHatY)); - Serial.print("\t"); - } - if (Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500) { - Serial.print(F("RightHatX: ")); - Serial.print(Xbox.getAnalogHat(RightHatX)); - Serial.print("\t"); - } - if (Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) { - Serial.print(F("RightHatY: ")); - Serial.print(Xbox.getAnalogHat(RightHatY)); - } - Serial.println(); - } - - if (Xbox.getButtonClick(UP)) { - Xbox.setLedOn(LED1); - Serial.println(F("Up")); - } - if (Xbox.getButtonClick(DOWN)) { - Xbox.setLedOn(LED4); - Serial.println(F("Down")); - } - if (Xbox.getButtonClick(LEFT)) { - Xbox.setLedOn(LED3); - Serial.println(F("Left")); - } - if (Xbox.getButtonClick(RIGHT)) { - Xbox.setLedOn(LED2); - Serial.println(F("Right")); - } - - if (Xbox.getButtonClick(START)) { - Xbox.setLedMode(ALTERNATING); - Serial.println(F("Start")); - } - if (Xbox.getButtonClick(BACK)) { - Xbox.setLedBlink(ALL); - Serial.println(F("Back")); - } - if (Xbox.getButtonClick(L3)) - Serial.println(F("L3")); - if (Xbox.getButtonClick(R3)) - Serial.println(F("R3")); - - if (Xbox.getButtonClick(L1)) - Serial.println(F("L1")); - if (Xbox.getButtonClick(R1)) - Serial.println(F("R1")); - if (Xbox.getButtonClick(XBOX)) { - Xbox.setLedMode(ROTATING); - Serial.println(F("Xbox")); - } - - if (Xbox.getButtonClick(A)) - Serial.println(F("A")); - if (Xbox.getButtonClick(B)) - Serial.println(F("B")); - if (Xbox.getButtonClick(X)) - Serial.println(F("X")); - if (Xbox.getButtonClick(Y)) - Serial.println(F("Y")); - } - delay(1); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/acm/acm_terminal/acm_terminal.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/acm/acm_terminal/acm_terminal.ino deleted file mode 100644 index f509cda8..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/acm/acm_terminal/acm_terminal.ino +++ /dev/null @@ -1,100 +0,0 @@ -#include -#include - -#include "pgmstrings.h" - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -class ACMAsyncOper : public CDCAsyncOper -{ -public: - uint8_t OnInit(ACM *pacm); -}; - -uint8_t ACMAsyncOper::OnInit(ACM *pacm) -{ - uint8_t rcode; - // Set DTR = 1 RTS=1 - rcode = pacm->SetControlLineState(3); - - if (rcode) - { - ErrorMessage(PSTR("SetControlLineState"), rcode); - return rcode; - } - - LINE_CODING lc; - lc.dwDTERate = 115200; - lc.bCharFormat = 0; - lc.bParityType = 0; - lc.bDataBits = 8; - - rcode = pacm->SetLineCoding(&lc); - - if (rcode) - ErrorMessage(PSTR("SetLineCoding"), rcode); - - return rcode; -} - -USB Usb; -//USBHub Hub(&Usb); -ACMAsyncOper AsyncOper; -ACM Acm(&Usb, &AsyncOper); - -void setup() -{ - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSCOKIRQ failed to assert"); - - delay( 200 ); -} - -void loop() -{ - Usb.Task(); - - if( Acm.isReady()) { - uint8_t rcode; - - /* reading the keyboard */ - if(Serial.available()) { - uint8_t data= Serial.read(); - /* sending to the phone */ - rcode = Acm.SndData(1, &data); - if (rcode) - ErrorMessage(PSTR("SndData"), rcode); - }//if(Serial.available()... - - delay(50); - - /* reading the phone */ - /* buffer size must be greater or equal to max.packet size */ - /* it it set to 64 (largest possible max.packet size) here, can be tuned down - for particular endpoint */ - uint8_t buf[64]; - uint16_t rcvd = 64; - rcode = Acm.RcvData(&rcvd, buf); - if (rcode && rcode != hrNAK) - ErrorMessage(PSTR("Ret"), rcode); - - if( rcvd ) { //more than zero bytes received - for(uint16_t i=0; i < rcvd; i++ ) { - Serial.print((char)buf[i]); //printing on the screen - } - } - delay(10); - }//if( Usb.getUsbTaskState() == USB_STATE_RUNNING.. -} - - diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/acm/acm_terminal/pgmstrings.h b/protocol/usb_hid/USB_Host_Shield_2.0/examples/acm/acm_terminal/pgmstrings.h deleted file mode 100644 index bdb0077e..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/acm/acm_terminal/pgmstrings.h +++ /dev/null @@ -1,52 +0,0 @@ -#if !defined(__PGMSTRINGS_H__) -#define __PGMSTRINGS_H__ - -#define LOBYTE(x) ((char*)(&(x)))[0] -#define HIBYTE(x) ((char*)(&(x)))[1] -#define BUFSIZE 256 //buffer size - - -/* Print strings in Program Memory */ -const char Gen_Error_str[] PROGMEM = "\r\nRequest error. Error code:\t"; -const char Dev_Header_str[] PROGMEM ="\r\nDevice descriptor: "; -const char Dev_Length_str[] PROGMEM ="\r\nDescriptor Length:\t"; -const char Dev_Type_str[] PROGMEM ="\r\nDescriptor type:\t"; -const char Dev_Version_str[] PROGMEM ="\r\nUSB version:\t\t"; -const char Dev_Class_str[] PROGMEM ="\r\nDevice class:\t\t"; -const char Dev_Subclass_str[] PROGMEM ="\r\nDevice Subclass:\t"; -const char Dev_Protocol_str[] PROGMEM ="\r\nDevice Protocol:\t"; -const char Dev_Pktsize_str[] PROGMEM ="\r\nMax.packet size:\t"; -const char Dev_Vendor_str[] PROGMEM ="\r\nVendor ID:\t\t"; -const char Dev_Product_str[] PROGMEM ="\r\nProduct ID:\t\t"; -const char Dev_Revision_str[] PROGMEM ="\r\nRevision ID:\t\t"; -const char Dev_Mfg_str[] PROGMEM ="\r\nMfg.string index:\t"; -const char Dev_Prod_str[] PROGMEM ="\r\nProd.string index:\t"; -const char Dev_Serial_str[] PROGMEM ="\r\nSerial number index:\t"; -const char Dev_Nconf_str[] PROGMEM ="\r\nNumber of conf.:\t"; -const char Conf_Trunc_str[] PROGMEM ="Total length truncated to 256 bytes"; -const char Conf_Header_str[] PROGMEM ="\r\nConfiguration descriptor:"; -const char Conf_Totlen_str[] PROGMEM ="\r\nTotal length:\t\t"; -const char Conf_Nint_str[] PROGMEM ="\r\nNum.intf:\t\t"; -const char Conf_Value_str[] PROGMEM ="\r\nConf.value:\t\t"; -const char Conf_String_str[] PROGMEM ="\r\nConf.string:\t\t"; -const char Conf_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; -const char Conf_Pwr_str[] PROGMEM ="\r\nMax.pwr:\t\t"; -const char Int_Header_str[] PROGMEM ="\r\n\r\nInterface descriptor:"; -const char Int_Number_str[] PROGMEM ="\r\nIntf.number:\t\t"; -const char Int_Alt_str[] PROGMEM ="\r\nAlt.:\t\t\t"; -const char Int_Endpoints_str[] PROGMEM ="\r\nEndpoints:\t\t"; -const char Int_Class_str[] PROGMEM ="\r\nIntf. Class:\t\t"; -const char Int_Subclass_str[] PROGMEM ="\r\nIntf. Subclass:\t\t"; -const char Int_Protocol_str[] PROGMEM ="\r\nIntf. Protocol:\t\t"; -const char Int_String_str[] PROGMEM ="\r\nIntf.string:\t\t"; -const char End_Header_str[] PROGMEM ="\r\n\r\nEndpoint descriptor:"; -const char End_Address_str[] PROGMEM ="\r\nEndpoint address:\t"; -const char End_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; -const char End_Pktsize_str[] PROGMEM ="\r\nMax.pkt size:\t\t"; -const char End_Interval_str[] PROGMEM ="\r\nPolling interval:\t"; -const char Unk_Header_str[] PROGMEM = "\r\nUnknown descriptor:"; -const char Unk_Length_str[] PROGMEM ="\r\nLength:\t\t"; -const char Unk_Type_str[] PROGMEM ="\r\nType:\t\t"; -const char Unk_Contents_str[] PROGMEM ="\r\nContents:\t"; - -#endif // __PGMSTRINGS_H__ \ No newline at end of file diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/ArduinoBlinkLED/ArduinoBlinkLED.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/ArduinoBlinkLED/ArduinoBlinkLED.ino deleted file mode 100644 index d59b9bb3..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/ArduinoBlinkLED/ArduinoBlinkLED.ino +++ /dev/null @@ -1,89 +0,0 @@ -// The source for the Android application can be found at the following link: https://github.com/Lauszus/ArduinoBlinkLED -// The code for the Android application is heavily based on this guide: http://allaboutee.com/2011/12/31/arduino-adk-board-blink-an-led-with-your-phone-code-and-explanation/ by Miguel -#include - -// -// CAUTION! WARNING! ATTENTION! VORSICHT! ADVARSEL! ¡CUIDADO! ВНИМАНИЕ! -// -// Pin 13 is occupied by the SCK pin on various Arduino boards, -// including Uno, Duemilanove, etc., so use a different pin for those boards. -// -// CAUTION! WARNING! ATTENTION! VORSICHT! ADVARSEL! ¡CUIDADO! ВНИМАНИЕ! -// -#if defined(LED_BUILTIN) -#define LED LED_BUILTIN // Use built in LED -#else -#define LED 9 // Set to something here that makes sense for your board. -#endif - - -// Satisfy IDE, which only needs to see the include statment in the ino. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -ADK adk(&Usb, "TKJElectronics", // Manufacturer Name - "ArduinoBlinkLED", // Model Name - "Example sketch for the USB Host Shield", // Description (user-visible string) - "1.0", // Version - "http://www.tkjelectronics.dk/uploads/ArduinoBlinkLED.apk", // URL (web page to visit if no installed apps support the accessory) - "123456789"); // Serial Number (optional) - -uint32_t timer; -bool connected; - -void setup() { - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - if (Usb.Init() == -1) { - Serial.print("\r\nOSCOKIRQ failed to assert"); - while (1); // halt - } - pinMode(LED, OUTPUT); - Serial.print("\r\nArduino Blink LED Started"); -} - -void loop() { - Usb.Task(); - - if (adk.isReady()) { - if (!connected) { - connected = true; - Serial.print(F("\r\nConnected to accessory")); - } - - uint8_t msg[1]; - uint16_t len = sizeof(msg); - uint8_t rcode = adk.RcvData(&len, msg); - if (rcode && rcode != hrNAK) { - Serial.print(F("\r\nData rcv: ")); - Serial.print(rcode, HEX); - } else if (len > 0) { - Serial.print(F("\r\nData Packet: ")); - Serial.print(msg[0]); - digitalWrite(LED, msg[0] ? HIGH : LOW); - } - - if (millis() - timer >= 1000) { // Send data every 1s - timer = millis(); - rcode = adk.SndData(sizeof(timer), (uint8_t*)&timer); - if (rcode && rcode != hrNAK) { - Serial.print(F("\r\nData send: ")); - Serial.print(rcode, HEX); - } else if (rcode != hrNAK) { - Serial.print(F("\r\nTimer: ")); - Serial.print(timer); - } - } - } else { - if (connected) { - connected = false; - Serial.print(F("\r\nDisconnected from accessory")); - digitalWrite(LED, LOW); - } - } -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/adk_barcode/adk_barcode.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/adk_barcode/adk_barcode.ino deleted file mode 100644 index a308ff0f..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/adk_barcode/adk_barcode.ino +++ /dev/null @@ -1,91 +0,0 @@ -/**/ -/* A sketch demonstrating data exchange between two USB devices - a HID barcode scanner and ADK-compatible Android phone */ -/**/ -#include -#include -#include - -// Satisfy IDE, which only needs to see the include statment in the ino. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -USBHub Hub1(&Usb); -USBHub Hub2(&Usb); -HIDBoot Keyboard(&Usb); - -ADK adk(&Usb,"Circuits@Home, ltd.", - "USB Host Shield", - "Arduino Terminal for Android", - "1.0", - "http://www.circuitsathome.com", - "0000000000000001"); - - -class KbdRptParser : public KeyboardReportParser -{ - -protected: - void OnKeyDown (uint8_t mod, uint8_t key); - void OnKeyPressed(uint8_t key); -}; - -void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key) -{ - uint8_t c = OemToAscii(mod, key); - - if (c) - OnKeyPressed(c); -} - -/* what to do when symbol arrives */ -void KbdRptParser::OnKeyPressed(uint8_t key) -{ -const char* new_line = "\n"; -uint8_t rcode; -uint8_t keylcl; - - if( adk.isReady() == false ) { - return; - } - - keylcl = key; - - if( keylcl == 0x13 ) { - rcode = adk.SndData( strlen( new_line ), (uint8_t *)new_line ); - } - else { - rcode = adk.SndData( 1, &keylcl ); - } - - Serial.print((char) keylcl ); - Serial.print(" : "); - Serial.println( keylcl, HEX ); -}; - -KbdRptParser Prs; - -void setup() -{ - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("\r\nADK demo start"); - - if (Usb.Init() == -1) { - Serial.println("OSCOKIRQ failed to assert"); - while(1); //halt - }//if (Usb.Init() == -1... - - Keyboard.SetReportParser(0, (HIDReportParser*)&Prs); - - delay( 200 ); -} - -void loop() -{ - Usb.Task(); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/demokit_20/demokit_20.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/demokit_20/demokit_20.ino deleted file mode 100644 index f65adf57..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/demokit_20/demokit_20.ino +++ /dev/null @@ -1,103 +0,0 @@ -#include -#include - -// Satisfy IDE, which only needs to see the include statment in the ino. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -USBHub hub0(&Usb); -USBHub hub1(&Usb); -ADK adk(&Usb,"Google, Inc.", - "DemoKit", - "DemoKit Arduino Board", - "1.0", - "http://www.android.com", - "0000000012345678"); -uint8_t b, b1; - - -#define LED1_RED 3 -#define BUTTON1 2 - -void init_buttons() -{ - pinMode(BUTTON1, INPUT); - - // enable the internal pullups - digitalWrite(BUTTON1, HIGH); -} - -void init_leds() -{ - digitalWrite(LED1_RED, 0); - - pinMode(LED1_RED, OUTPUT); -} - -void setup() -{ - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("\r\nADK demo start"); - - if (Usb.Init() == -1) { - Serial.println("OSCOKIRQ failed to assert"); - while(1); //halt - }//if (Usb.Init() == -1... - - - init_leds(); - init_buttons(); - b1 = digitalRead(BUTTON1); -} - -void loop() -{ - uint8_t rcode; - uint8_t msg[3] = { 0x00 }; - Usb.Task(); - - if( adk.isReady() == false ) { - analogWrite(LED1_RED, 255); - return; - } - uint16_t len = sizeof(msg); - - rcode = adk.RcvData(&len, msg); - if( rcode ) { - USBTRACE2("Data rcv. :", rcode ); - } - if(len > 0) { - USBTRACE("\r\nData Packet."); - // assumes only one command per packet - if (msg[0] == 0x2) { - switch( msg[1] ) { - case 0: - analogWrite(LED1_RED, 255 - msg[2]); - break; - }//switch( msg[1]... - }//if (msg[0] == 0x2... - }//if( len > 0... - - msg[0] = 0x1; - - b = digitalRead(BUTTON1); - if (b != b1) { - USBTRACE("\r\nButton state changed"); - msg[1] = 0; - msg[2] = b ? 0 : 1; - rcode = adk.SndData( 3, msg ); - if( rcode ) { - USBTRACE2("Button send: ", rcode ); - } - b1 = b; - }//if (b != b1... - - - delay( 10 ); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/term_test/term_test.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/term_test/term_test.ino deleted file mode 100644 index db681c3b..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/term_test/term_test.ino +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include - -// Satisfy IDE, which only needs to see the include statment in the ino. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -//USBHub Hub(&Usb); - -ADK adk(&Usb,"Circuits@Home, ltd.", - "USB Host Shield", - "Arduino Terminal for Android", - "1.0", - "http://www.circuitsathome.com", - "0000000000000001"); - -void setup() -{ - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("\r\nADK demo start"); - - if (Usb.Init() == -1) { - Serial.println("OSCOKIRQ failed to assert"); - while(1); //halt - }//if (Usb.Init() == -1... -} - -void loop() -{ - uint8_t rcode; - uint8_t msg[64] = { 0x00 }; - const char* recv = "Received: "; - - Usb.Task(); - - if( adk.isReady() == false ) { - return; - } - uint16_t len = 64; - - rcode = adk.RcvData(&len, msg); - if( rcode & ( rcode != hrNAK )) { - USBTRACE2("Data rcv. :", rcode ); - } - if(len > 0) { - USBTRACE("\r\nData Packet."); - - for( uint8_t i = 0; i < len; i++ ) { - Serial.print((char)msg[i]); - } - /* sending back what was received */ - rcode = adk.SndData( strlen( recv ), (uint8_t *)recv ); - rcode = adk.SndData( strlen(( char * )msg ), msg ); - - }//if( len > 0 )... - - delay( 1000 ); -} - diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/term_time/term_time.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/term_time/term_time.ino deleted file mode 100644 index a3f1dbc8..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/adk/term_time/term_time.ino +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include - -// Satisfy IDE, which only needs to see the include statment in the ino. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; - -ADK adk(&Usb,"Circuits@Home, ltd.", - "USB Host Shield", - "Arduino Terminal for Android", - "1.0", - "http://www.circuitsathome.com", - "0000000000000001"); - -void setup() -{ - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("\r\nADK demo start"); - - if (Usb.Init() == -1) { - Serial.println("OSCOKIRQ failed to assert"); - while(1); //halt - }//if (Usb.Init() == -1... -} - -void loop() -{ - uint8_t buf[ 12 ] = { 0 }; //buffer to convert unsigned long to ASCII - const char* sec_ela = " seconds elapsed\r"; - uint8_t rcode; - - Usb.Task(); - if( adk.isReady() == false ) { - return; - } - - ultoa( millis()/1000, (char *)buf, 10 ); - - rcode = adk.SndData( strlen((char *)buf), buf ); - rcode = adk.SndData( strlen( sec_ela), (uint8_t *)sec_ela ); - - delay( 1000 ); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/board_qc/board_qc.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/board_qc/board_qc.ino deleted file mode 100644 index 573c3ce0..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/board_qc/board_qc.ino +++ /dev/null @@ -1,259 +0,0 @@ -/* USB Host Shield 2.0 board quality control routine */ -/* To see the output set your terminal speed to 115200 */ -/* for GPIO test to pass you need to connect GPIN0 to GPOUT7, GPIN1 to GPOUT6, etc. */ -/* otherwise press any key after getting GPIO error to complete the test */ -/**/ -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include <../../../../hardware/pic32/libraries/SPI/SPI.h> // Hack to use the SPI library -#include // Hack to use the SPI library -#endif - -/* variables */ -uint8_t rcode; -uint8_t usbstate; -uint8_t laststate; -//uint8_t buf[sizeof(USB_DEVICE_DESCRIPTOR)]; -USB_DEVICE_DESCRIPTOR buf; - -/* objects */ -USB Usb; -//USBHub hub(&Usb); - -void setup() { - laststate = 0; - Serial.begin(115200); -#if !defined(__MIPSEL__) - while(!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - E_Notify(PSTR("\r\nCircuits At Home 2011"), 0x80); - E_Notify(PSTR("\r\nUSB Host Shield Quality Control Routine"), 0x80); - /* SPI quick test - check revision register */ - E_Notify(PSTR("\r\nReading REVISION register... Die revision "), 0x80); - Usb.Init(); // Initializes SPI, we don't care about the return value here - { - uint8_t tmpbyte = Usb.regRd(rREVISION); - switch(tmpbyte) { - case( 0x01): //rev.01 - E_Notify(PSTR("01"), 0x80); - break; - case( 0x12): //rev.02 - E_Notify(PSTR("02"), 0x80); - break; - case( 0x13): //rev.03 - E_Notify(PSTR("03"), 0x80); - break; - default: - E_Notify(PSTR("invalid. Value returned: "), 0x80); - print_hex(tmpbyte, 8); - halt55(); - break; - }//switch( tmpbyte... - }//check revision register - /* SPI long test */ - { - E_Notify(PSTR("\r\nSPI long test. Transfers 1MB of data. Each dot is 64K"), 0x80); - uint8_t sample_wr = 0; - uint8_t sample_rd = 0; - uint8_t gpinpol_copy = Usb.regRd(rGPINPOL); - for(uint8_t i = 0; i < 16; i++) { - for(uint16_t j = 0; j < 65535; j++) { - Usb.regWr(rGPINPOL, sample_wr); - sample_rd = Usb.regRd(rGPINPOL); - if(sample_rd != sample_wr) { - E_Notify(PSTR("\r\nTest failed. "), 0x80); - E_Notify(PSTR("Value written: "), 0x80); - print_hex(sample_wr, 8); - E_Notify(PSTR(" read: "), 0x80); - print_hex(sample_rd, 8); - halt55(); - }//if( sample_rd != sample_wr.. - sample_wr++; - }//for( uint16_t j... - E_Notify(PSTR("."), 0x80); - }//for( uint8_t i... - Usb.regWr(rGPINPOL, gpinpol_copy); - E_Notify(PSTR(" SPI long test passed"), 0x80); - }//SPI long test - /* GPIO test */ - /* in order to simplify board layout, GPIN pins on text fixture are connected to GPOUT */ - /* in reverse order, i.e, GPIN0 is connected to GPOUT7, GPIN1 to GPOUT6, etc. */ - { - uint8_t tmpbyte; - E_Notify(PSTR("\r\nGPIO test. Connect GPIN0 to GPOUT7, GPIN1 to GPOUT6, and so on"), 0x80); - for(uint8_t sample_gpio = 0; sample_gpio < 255; sample_gpio++) { - Usb.gpioWr(sample_gpio); - tmpbyte = Usb.gpioRd(); - /* bit reversing code copied vetbatim from http://graphics.stanford.edu/~seander/bithacks.html#BitReverseObvious */ - tmpbyte = ((tmpbyte * 0x0802LU & 0x22110LU) | (tmpbyte * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16; - if(sample_gpio != tmpbyte) { - E_Notify(PSTR("\r\nTest failed. Value written: "), 0x80); - print_hex(sample_gpio, 8); - E_Notify(PSTR(" Value read: "), 0x80); - print_hex(tmpbyte, 8); - E_Notify(PSTR(" "), 0x80); - press_any_key(); - break; - }//if( sample_gpio != tmpbyte... - }//for( uint8_t sample_gpio... - E_Notify(PSTR("\r\nGPIO test passed."), 0x80); - }//GPIO test - /* PLL test. Stops/starts MAX3421E oscillator several times */ - { - E_Notify(PSTR("\r\nPLL test. 100 chip resets will be performed"), 0x80); - /* check current state of the oscillator */ - if(!(Usb.regRd(rUSBIRQ) & bmOSCOKIRQ)) { //wrong state - should be on - E_Notify(PSTR("\r\nCurrent oscillator state unexpected."), 0x80); - press_any_key(); - } - /* Restart oscillator */ - E_Notify(PSTR("\r\nResetting oscillator\r\n"), 0x80); - for(uint16_t i = 0; i < 100; i++) { - E_Notify(PSTR("\rReset number "), 0x80); - Serial.print(i, DEC); - Usb.regWr(rUSBCTL, bmCHIPRES); //reset - if(Usb.regRd(rUSBIRQ) & bmOSCOKIRQ) { //wrong state - should be off - E_Notify(PSTR("\r\nCurrent oscillator state unexpected."), 0x80); - halt55(); - } - Usb.regWr(rUSBCTL, 0x00); //release from reset - uint16_t j = 0; - for(j = 1; j < 65535; j++) { //tracking off to on time - if(Usb.regRd(rUSBIRQ) & bmOSCOKIRQ) { - E_Notify(PSTR(" Time to stabilize - "), 0x80); - Serial.print(j, DEC); - E_Notify(PSTR(" cycles\r\n"), 0x80); - break; - } - }//for( uint16_t j = 0; j < 65535; j++ - if(j == 0) { - E_Notify(PSTR("PLL failed to stabilize"), 0x80); - press_any_key(); - } - }//for( uint8_t i = 0; i < 255; i++ - - }//PLL test - /* initializing USB stack */ - if(Usb.Init() == -1) { - E_Notify(PSTR("\r\nOSCOKIRQ failed to assert"), 0x80); - halt55(); - } - E_Notify(PSTR("\r\nChecking USB device communication.\r\n"), 0x80); -} - -void loop() { - delay(200); - Usb.Task(); - usbstate = Usb.getUsbTaskState(); - if(usbstate != laststate) { - laststate = usbstate; - /**/ - switch(usbstate) { - case( USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE): - E_Notify(PSTR("\r\nWaiting for device..."), 0x80); - break; - case( USB_ATTACHED_SUBSTATE_RESET_DEVICE): - E_Notify(PSTR("\r\nDevice connected. Resetting..."), 0x80); - break; - case( USB_ATTACHED_SUBSTATE_WAIT_SOF): - E_Notify(PSTR("\r\nReset complete. Waiting for the first SOF..."), 0x80); - break; - case( USB_ATTACHED_SUBSTATE_GET_DEVICE_DESCRIPTOR_SIZE): - E_Notify(PSTR("\r\nSOF generation started. Enumerating device..."), 0x80); - break; - case( USB_STATE_ADDRESSING): - E_Notify(PSTR("\r\nSetting device address..."), 0x80); - break; - case( USB_STATE_RUNNING): - E_Notify(PSTR("\r\nGetting device descriptor"), 0x80); - rcode = Usb.getDevDescr(1, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*) & buf); - - if(rcode) { - E_Notify(PSTR("\r\nError reading device descriptor. Error code "), 0x80); - print_hex(rcode, 8); - } else { - /**/ - E_Notify(PSTR("\r\nDescriptor Length:\t"), 0x80); - print_hex(buf.bLength, 8); - E_Notify(PSTR("\r\nDescriptor type:\t"), 0x80); - print_hex(buf.bDescriptorType, 8); - E_Notify(PSTR("\r\nUSB version:\t\t"), 0x80); - print_hex(buf.bcdUSB, 16); - E_Notify(PSTR("\r\nDevice class:\t\t"), 0x80); - print_hex(buf.bDeviceClass, 8); - E_Notify(PSTR("\r\nDevice Subclass:\t"), 0x80); - print_hex(buf.bDeviceSubClass, 8); - E_Notify(PSTR("\r\nDevice Protocol:\t"), 0x80); - print_hex(buf.bDeviceProtocol, 8); - E_Notify(PSTR("\r\nMax.packet size:\t"), 0x80); - print_hex(buf.bMaxPacketSize0, 8); - E_Notify(PSTR("\r\nVendor ID:\t\t"), 0x80); - print_hex(buf.idVendor, 16); - E_Notify(PSTR("\r\nProduct ID:\t\t"), 0x80); - print_hex(buf.idProduct, 16); - E_Notify(PSTR("\r\nRevision ID:\t\t"), 0x80); - print_hex(buf.bcdDevice, 16); - E_Notify(PSTR("\r\nMfg.string index:\t"), 0x80); - print_hex(buf.iManufacturer, 8); - E_Notify(PSTR("\r\nProd.string index:\t"), 0x80); - print_hex(buf.iProduct, 8); - E_Notify(PSTR("\r\nSerial number index:\t"), 0x80); - print_hex(buf.iSerialNumber, 8); - E_Notify(PSTR("\r\nNumber of conf.:\t"), 0x80); - print_hex(buf.bNumConfigurations, 8); - /**/ - E_Notify(PSTR("\r\n\nAll tests passed. Press RESET to restart test"), 0x80); - while(1); - } - break; - case( USB_STATE_ERROR): - E_Notify(PSTR("\r\nUSB state machine reached error state"), 0x80); - break; - - default: - break; - }//switch( usbstate... - } -}//loop()... - -/* constantly transmits 0x55 via SPI to aid probing */ -void halt55() { - - E_Notify(PSTR("\r\nUnrecoverable error - test halted!!"), 0x80); - E_Notify(PSTR("\r\n0x55 pattern is transmitted via SPI"), 0x80); - E_Notify(PSTR("\r\nPress RESET to restart test"), 0x80); - - while(1) { - Usb.regWr(0x55, 0x55); - } -} - -/* prints hex numbers with leading zeroes */ -void print_hex(int v, int num_places) { - int mask = 0, n, num_nibbles, digit; - - for(n = 1; n <= num_places; n++) { - mask = (mask << 1) | 0x0001; - } - v = v & mask; // truncate v to specified number of places - - num_nibbles = num_places / 4; - if((num_places % 4) != 0) { - ++num_nibbles; - } - do { - digit = ((v >> (num_nibbles - 1) * 4)) & 0x0f; - Serial.print(digit, HEX); - } while(--num_nibbles); -} - -/* prints "Press any key" and returns when key is pressed */ -void press_any_key() { - E_Notify(PSTR("\r\nPress any key to continue..."), 0x80); - while(Serial.available() <= 0); //wait for input - Serial.read(); //empty input buffer - return; -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/cdc_XR21B1411/XR_terminal/XR_terminal.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/cdc_XR21B1411/XR_terminal/XR_terminal.ino deleted file mode 100644 index 0173a08b..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/cdc_XR21B1411/XR_terminal/XR_terminal.ino +++ /dev/null @@ -1,83 +0,0 @@ -#include - -// Satisfy IDE, which only needs to see the include statment in the ino. -#ifdef dobogusinclude -#include -#include -#endif - -class ACMAsyncOper : public CDCAsyncOper -{ -public: - uint8_t OnInit(ACM *pacm); -}; - -uint8_t ACMAsyncOper::OnInit(ACM *pacm) -{ - uint8_t rcode; - // Set DTR = 1 RTS=1 - rcode = pacm->SetControlLineState(3); - - if (rcode) - { - ErrorMessage(PSTR("SetControlLineState"), rcode); - return rcode; - } - - LINE_CODING lc; - lc.dwDTERate = 115200; - lc.bCharFormat = 0; - lc.bParityType = 0; - lc.bDataBits = 8; - - rcode = pacm->SetLineCoding(&lc); - - if (rcode) - ErrorMessage(PSTR("SetLineCoding"), rcode); - - return rcode; -} - -USB Usb; -ACMAsyncOper AsyncOper; -XR21B1411 Acm(&Usb, &AsyncOper); - -void setup() { - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("\r\n\r\nStart"); - - if (Usb.Init() == -1) Serial.println("OSCOKIRQ failed to assert"); -} - -void loop() { - Usb.Task(); - if( Acm.isReady()) { - uint8_t rcode; - uint8_t buf[1]; - uint16_t rcvd = 1; - - /* read keyboard */ - if(Serial.available()) { - uint8_t data = Serial.read(); - /* send */ - rcode = Acm.SndData(1, &data); - if (rcode) - ErrorMessage(PSTR("SndData"), rcode); - } - - /* read XR serial */ - rcode = Acm.RcvData(&rcvd, buf); - if (rcode && rcode != hrNAK) - ErrorMessage(PSTR("Ret"), rcode); - - if( rcvd ) { //more than zero bytes received - for(uint16_t i=0; i < rcvd; i++ ) { - Serial.print((char)buf[i]); - } - } - } -} - diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/ftdi/USBFTDILoopback/USBFTDILoopback.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/ftdi/USBFTDILoopback/USBFTDILoopback.ino deleted file mode 100644 index 5be7adc2..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/ftdi/USBFTDILoopback/USBFTDILoopback.ino +++ /dev/null @@ -1,98 +0,0 @@ -#include -#include - -#include "pgmstrings.h" - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -class FTDIAsync : public FTDIAsyncOper -{ -public: - uint8_t OnInit(FTDI *pftdi); -}; - -uint8_t FTDIAsync::OnInit(FTDI *pftdi) -{ - uint8_t rcode = 0; - - rcode = pftdi->SetBaudRate(115200); - - if (rcode) - { - ErrorMessage(PSTR("SetBaudRate"), rcode); - return rcode; - } - rcode = pftdi->SetFlowControl(FTDI_SIO_DISABLE_FLOW_CTRL); - - if (rcode) - ErrorMessage(PSTR("SetFlowControl"), rcode); - - return rcode; -} - -USB Usb; -//USBHub Hub(&Usb); -FTDIAsync FtdiAsync; -FTDI Ftdi(&Usb, &FtdiAsync); - -uint32_t next_time; - -void setup() -{ - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSC did not start."); - - delay( 200 ); - - next_time = millis() + 5000; -} - -void loop() -{ - Usb.Task(); - - if( Usb.getUsbTaskState() == USB_STATE_RUNNING ) - { - uint8_t rcode; - char strbuf[] = "DEADBEEF"; - //char strbuf[] = "The quick brown fox jumps over the lazy dog"; - //char strbuf[] = "This string contains 61 character to demonstrate FTDI buffers"; //add one symbol to it to see some garbage - Serial.print("."); - - rcode = Ftdi.SndData(strlen(strbuf), (uint8_t*)strbuf); - - if (rcode) - ErrorMessage(PSTR("SndData"), rcode); - - delay(50); - - uint8_t buf[64]; - - for (uint8_t i=0; i<64; i++) - buf[i] = 0; - - uint16_t rcvd = 64; - rcode = Ftdi.RcvData(&rcvd, buf); - - if (rcode && rcode != hrNAK) - ErrorMessage(PSTR("Ret"), rcode); - - // The device reserves the first two bytes of data - // to contain the current values of the modem and line status registers. - if (rcvd > 2) - Serial.print((char*)(buf+2)); - - delay(10); - } -} - diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/ftdi/USBFTDILoopback/pgmstrings.h b/protocol/usb_hid/USB_Host_Shield_2.0/examples/ftdi/USBFTDILoopback/pgmstrings.h deleted file mode 100644 index bdb0077e..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/ftdi/USBFTDILoopback/pgmstrings.h +++ /dev/null @@ -1,52 +0,0 @@ -#if !defined(__PGMSTRINGS_H__) -#define __PGMSTRINGS_H__ - -#define LOBYTE(x) ((char*)(&(x)))[0] -#define HIBYTE(x) ((char*)(&(x)))[1] -#define BUFSIZE 256 //buffer size - - -/* Print strings in Program Memory */ -const char Gen_Error_str[] PROGMEM = "\r\nRequest error. Error code:\t"; -const char Dev_Header_str[] PROGMEM ="\r\nDevice descriptor: "; -const char Dev_Length_str[] PROGMEM ="\r\nDescriptor Length:\t"; -const char Dev_Type_str[] PROGMEM ="\r\nDescriptor type:\t"; -const char Dev_Version_str[] PROGMEM ="\r\nUSB version:\t\t"; -const char Dev_Class_str[] PROGMEM ="\r\nDevice class:\t\t"; -const char Dev_Subclass_str[] PROGMEM ="\r\nDevice Subclass:\t"; -const char Dev_Protocol_str[] PROGMEM ="\r\nDevice Protocol:\t"; -const char Dev_Pktsize_str[] PROGMEM ="\r\nMax.packet size:\t"; -const char Dev_Vendor_str[] PROGMEM ="\r\nVendor ID:\t\t"; -const char Dev_Product_str[] PROGMEM ="\r\nProduct ID:\t\t"; -const char Dev_Revision_str[] PROGMEM ="\r\nRevision ID:\t\t"; -const char Dev_Mfg_str[] PROGMEM ="\r\nMfg.string index:\t"; -const char Dev_Prod_str[] PROGMEM ="\r\nProd.string index:\t"; -const char Dev_Serial_str[] PROGMEM ="\r\nSerial number index:\t"; -const char Dev_Nconf_str[] PROGMEM ="\r\nNumber of conf.:\t"; -const char Conf_Trunc_str[] PROGMEM ="Total length truncated to 256 bytes"; -const char Conf_Header_str[] PROGMEM ="\r\nConfiguration descriptor:"; -const char Conf_Totlen_str[] PROGMEM ="\r\nTotal length:\t\t"; -const char Conf_Nint_str[] PROGMEM ="\r\nNum.intf:\t\t"; -const char Conf_Value_str[] PROGMEM ="\r\nConf.value:\t\t"; -const char Conf_String_str[] PROGMEM ="\r\nConf.string:\t\t"; -const char Conf_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; -const char Conf_Pwr_str[] PROGMEM ="\r\nMax.pwr:\t\t"; -const char Int_Header_str[] PROGMEM ="\r\n\r\nInterface descriptor:"; -const char Int_Number_str[] PROGMEM ="\r\nIntf.number:\t\t"; -const char Int_Alt_str[] PROGMEM ="\r\nAlt.:\t\t\t"; -const char Int_Endpoints_str[] PROGMEM ="\r\nEndpoints:\t\t"; -const char Int_Class_str[] PROGMEM ="\r\nIntf. Class:\t\t"; -const char Int_Subclass_str[] PROGMEM ="\r\nIntf. Subclass:\t\t"; -const char Int_Protocol_str[] PROGMEM ="\r\nIntf. Protocol:\t\t"; -const char Int_String_str[] PROGMEM ="\r\nIntf.string:\t\t"; -const char End_Header_str[] PROGMEM ="\r\n\r\nEndpoint descriptor:"; -const char End_Address_str[] PROGMEM ="\r\nEndpoint address:\t"; -const char End_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; -const char End_Pktsize_str[] PROGMEM ="\r\nMax.pkt size:\t\t"; -const char End_Interval_str[] PROGMEM ="\r\nPolling interval:\t"; -const char Unk_Header_str[] PROGMEM = "\r\nUnknown descriptor:"; -const char Unk_Length_str[] PROGMEM ="\r\nLength:\t\t"; -const char Unk_Type_str[] PROGMEM ="\r\nType:\t\t"; -const char Unk_Contents_str[] PROGMEM ="\r\nContents:\t"; - -#endif // __PGMSTRINGS_H__ \ No newline at end of file diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/hub_demo/hub_demo.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/hub_demo/hub_demo.ino deleted file mode 100644 index d8b2d4bb..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/hub_demo/hub_demo.ino +++ /dev/null @@ -1,345 +0,0 @@ -#include -#include "pgmstrings.h" - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -USBHub Hub1(&Usb); -USBHub Hub2(&Usb); -USBHub Hub3(&Usb); -USBHub Hub4(&Usb); - -uint32_t next_time; - -void PrintAllAddresses(UsbDevice *pdev) -{ - UsbDeviceAddress adr; - adr.devAddress = pdev->address.devAddress; - Serial.print("\r\nAddr:"); - Serial.print(adr.devAddress, HEX); - Serial.print("("); - Serial.print(adr.bmHub, HEX); - Serial.print("."); - Serial.print(adr.bmParent, HEX); - Serial.print("."); - Serial.print(adr.bmAddress, HEX); - Serial.println(")"); -} - -void PrintAddress(uint8_t addr) -{ - UsbDeviceAddress adr; - adr.devAddress = addr; - Serial.print("\r\nADDR:\t"); - Serial.println(adr.devAddress, HEX); - Serial.print("DEV:\t"); - Serial.println(adr.bmAddress, HEX); - Serial.print("PRNT:\t"); - Serial.println(adr.bmParent, HEX); - Serial.print("HUB:\t"); - Serial.println(adr.bmHub, HEX); -} - -void setup() -{ - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSC did not start."); - - delay( 200 ); - - next_time = millis() + 10000; -} - -byte getdevdescr( byte addr, byte &num_conf ); - -void PrintDescriptors(uint8_t addr) -{ - uint8_t rcode = 0; - byte num_conf = 0; - - rcode = getdevdescr( (byte)addr, num_conf ); - if ( rcode ) - { - printProgStr(Gen_Error_str); - print_hex( rcode, 8 ); - } - Serial.print("\r\n"); - - for (int i = 0; i < num_conf; i++) - { - rcode = getconfdescr( addr, i ); // get configuration descriptor - if ( rcode ) - { - printProgStr(Gen_Error_str); - print_hex(rcode, 8); - } - Serial.println("\r\n"); - } -} - -void PrintAllDescriptors(UsbDevice *pdev) -{ - Serial.println("\r\n"); - print_hex(pdev->address.devAddress, 8); - Serial.println("\r\n--"); - PrintDescriptors( pdev->address.devAddress ); -} - -void loop() -{ - Usb.Task(); - - if ( Usb.getUsbTaskState() == USB_STATE_RUNNING ) - { - if ((millis() - next_time) >= 0L) - { - Usb.ForEachUsbDevice(&PrintAllDescriptors); - Usb.ForEachUsbDevice(&PrintAllAddresses); - - while ( 1 ); //stop - } - } -} - -byte getdevdescr( byte addr, byte &num_conf ) -{ - USB_DEVICE_DESCRIPTOR buf; - byte rcode; - rcode = Usb.getDevDescr( addr, 0, 0x12, ( uint8_t *)&buf ); - if ( rcode ) { - return ( rcode ); - } - printProgStr(Dev_Header_str); - printProgStr(Dev_Length_str); - print_hex( buf.bLength, 8 ); - printProgStr(Dev_Type_str); - print_hex( buf.bDescriptorType, 8 ); - printProgStr(Dev_Version_str); - print_hex( buf.bcdUSB, 16 ); - printProgStr(Dev_Class_str); - print_hex( buf.bDeviceClass, 8 ); - printProgStr(Dev_Subclass_str); - print_hex( buf.bDeviceSubClass, 8 ); - printProgStr(Dev_Protocol_str); - print_hex( buf.bDeviceProtocol, 8 ); - printProgStr(Dev_Pktsize_str); - print_hex( buf.bMaxPacketSize0, 8 ); - printProgStr(Dev_Vendor_str); - print_hex( buf.idVendor, 16 ); - printProgStr(Dev_Product_str); - print_hex( buf.idProduct, 16 ); - printProgStr(Dev_Revision_str); - print_hex( buf.bcdDevice, 16 ); - printProgStr(Dev_Mfg_str); - print_hex( buf.iManufacturer, 8 ); - printProgStr(Dev_Prod_str); - print_hex( buf.iProduct, 8 ); - printProgStr(Dev_Serial_str); - print_hex( buf.iSerialNumber, 8 ); - printProgStr(Dev_Nconf_str); - print_hex( buf.bNumConfigurations, 8 ); - num_conf = buf.bNumConfigurations; - return ( 0 ); -} - -void printhubdescr(uint8_t *descrptr, uint8_t addr) -{ - HubDescriptor *pHub = (HubDescriptor*) descrptr; - uint8_t len = *((uint8_t*)descrptr); - - printProgStr(PSTR("\r\n\r\nHub Descriptor:\r\n")); - printProgStr(PSTR("bDescLength:\t\t")); - Serial.println(pHub->bDescLength, HEX); - - printProgStr(PSTR("bDescriptorType:\t")); - Serial.println(pHub->bDescriptorType, HEX); - - printProgStr(PSTR("bNbrPorts:\t\t")); - Serial.println(pHub->bNbrPorts, HEX); - - printProgStr(PSTR("LogPwrSwitchMode:\t")); - Serial.println(pHub->LogPwrSwitchMode, BIN); - - printProgStr(PSTR("CompoundDevice:\t\t")); - Serial.println(pHub->CompoundDevice, BIN); - - printProgStr(PSTR("OverCurrentProtectMode:\t")); - Serial.println(pHub->OverCurrentProtectMode, BIN); - - printProgStr(PSTR("TTThinkTime:\t\t")); - Serial.println(pHub->TTThinkTime, BIN); - - printProgStr(PSTR("PortIndicatorsSupported:")); - Serial.println(pHub->PortIndicatorsSupported, BIN); - - printProgStr(PSTR("Reserved:\t\t")); - Serial.println(pHub->Reserved, HEX); - - printProgStr(PSTR("bPwrOn2PwrGood:\t\t")); - Serial.println(pHub->bPwrOn2PwrGood, HEX); - - printProgStr(PSTR("bHubContrCurrent:\t")); - Serial.println(pHub->bHubContrCurrent, HEX); - - for (uint8_t i = 7; i < len; i++) - print_hex(descrptr[i], 8); - - //for (uint8_t i=1; i<=pHub->bNbrPorts; i++) - // PrintHubPortStatus(&Usb, addr, i, 1); -} - -byte getconfdescr( byte addr, byte conf ) -{ - uint8_t buf[ BUFSIZE ]; - uint8_t* buf_ptr = buf; - byte rcode; - byte descr_length; - byte descr_type; - unsigned int total_length; - rcode = Usb.getConfDescr( addr, 0, 4, conf, buf ); //get total length - LOBYTE( total_length ) = buf[ 2 ]; - HIBYTE( total_length ) = buf[ 3 ]; - if ( total_length > 256 ) { //check if total length is larger than buffer - printProgStr(Conf_Trunc_str); - total_length = 256; - } - rcode = Usb.getConfDescr( addr, 0, total_length, conf, buf ); //get the whole descriptor - while ( buf_ptr < buf + total_length ) { //parsing descriptors - descr_length = *( buf_ptr ); - descr_type = *( buf_ptr + 1 ); - switch ( descr_type ) { - case ( USB_DESCRIPTOR_CONFIGURATION ): - printconfdescr( buf_ptr ); - break; - case ( USB_DESCRIPTOR_INTERFACE ): - printintfdescr( buf_ptr ); - break; - case ( USB_DESCRIPTOR_ENDPOINT ): - printepdescr( buf_ptr ); - break; - case 0x29: - printhubdescr( buf_ptr, addr ); - break; - default: - printunkdescr( buf_ptr ); - break; - }//switch( descr_type - buf_ptr = ( buf_ptr + descr_length ); //advance buffer pointer - }//while( buf_ptr <=... - return ( rcode ); -} -/* prints hex numbers with leading zeroes */ -// copyright, Peter H Anderson, Baltimore, MD, Nov, '07 -// source: http://www.phanderson.com/arduino/arduino_display.html -void print_hex(int v, int num_places) -{ - int mask = 0, n, num_nibbles, digit; - - for (n = 1; n <= num_places; n++) { - mask = (mask << 1) | 0x0001; - } - v = v & mask; // truncate v to specified number of places - - num_nibbles = num_places / 4; - if ((num_places % 4) != 0) { - ++num_nibbles; - } - do { - digit = ((v >> (num_nibbles - 1) * 4)) & 0x0f; - Serial.print(digit, HEX); - } - while (--num_nibbles); -} -/* function to print configuration descriptor */ -void printconfdescr( uint8_t* descr_ptr ) -{ - USB_CONFIGURATION_DESCRIPTOR* conf_ptr = ( USB_CONFIGURATION_DESCRIPTOR* )descr_ptr; - printProgStr(Conf_Header_str); - printProgStr(Conf_Totlen_str); - print_hex( conf_ptr->wTotalLength, 16 ); - printProgStr(Conf_Nint_str); - print_hex( conf_ptr->bNumInterfaces, 8 ); - printProgStr(Conf_Value_str); - print_hex( conf_ptr->bConfigurationValue, 8 ); - printProgStr(Conf_String_str); - print_hex( conf_ptr->iConfiguration, 8 ); - printProgStr(Conf_Attr_str); - print_hex( conf_ptr->bmAttributes, 8 ); - printProgStr(Conf_Pwr_str); - print_hex( conf_ptr->bMaxPower, 8 ); - return; -} -/* function to print interface descriptor */ -void printintfdescr( uint8_t* descr_ptr ) -{ - USB_INTERFACE_DESCRIPTOR* intf_ptr = ( USB_INTERFACE_DESCRIPTOR* )descr_ptr; - printProgStr(Int_Header_str); - printProgStr(Int_Number_str); - print_hex( intf_ptr->bInterfaceNumber, 8 ); - printProgStr(Int_Alt_str); - print_hex( intf_ptr->bAlternateSetting, 8 ); - printProgStr(Int_Endpoints_str); - print_hex( intf_ptr->bNumEndpoints, 8 ); - printProgStr(Int_Class_str); - print_hex( intf_ptr->bInterfaceClass, 8 ); - printProgStr(Int_Subclass_str); - print_hex( intf_ptr->bInterfaceSubClass, 8 ); - printProgStr(Int_Protocol_str); - print_hex( intf_ptr->bInterfaceProtocol, 8 ); - printProgStr(Int_String_str); - print_hex( intf_ptr->iInterface, 8 ); - return; -} -/* function to print endpoint descriptor */ -void printepdescr( uint8_t* descr_ptr ) -{ - USB_ENDPOINT_DESCRIPTOR* ep_ptr = ( USB_ENDPOINT_DESCRIPTOR* )descr_ptr; - printProgStr(End_Header_str); - printProgStr(End_Address_str); - print_hex( ep_ptr->bEndpointAddress, 8 ); - printProgStr(End_Attr_str); - print_hex( ep_ptr->bmAttributes, 8 ); - printProgStr(End_Pktsize_str); - print_hex( ep_ptr->wMaxPacketSize, 16 ); - printProgStr(End_Interval_str); - print_hex( ep_ptr->bInterval, 8 ); - - return; -} -/*function to print unknown descriptor */ -void printunkdescr( uint8_t* descr_ptr ) -{ - byte length = *descr_ptr; - byte i; - printProgStr(Unk_Header_str); - printProgStr(Unk_Length_str); - print_hex( *descr_ptr, 8 ); - printProgStr(Unk_Type_str); - print_hex( *(descr_ptr + 1 ), 8 ); - printProgStr(Unk_Contents_str); - descr_ptr += 2; - for ( i = 0; i < length; i++ ) { - print_hex( *descr_ptr, 8 ); - descr_ptr++; - } -} - - -/* Print a string from Program Memory directly to save RAM */ -void printProgStr(const char* str) -{ - char c; - if (!str) return; - while ((c = pgm_read_byte(str++))) - Serial.print(c); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/hub_demo/pgmstrings.h b/protocol/usb_hid/USB_Host_Shield_2.0/examples/hub_demo/pgmstrings.h deleted file mode 100644 index bdb0077e..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/hub_demo/pgmstrings.h +++ /dev/null @@ -1,52 +0,0 @@ -#if !defined(__PGMSTRINGS_H__) -#define __PGMSTRINGS_H__ - -#define LOBYTE(x) ((char*)(&(x)))[0] -#define HIBYTE(x) ((char*)(&(x)))[1] -#define BUFSIZE 256 //buffer size - - -/* Print strings in Program Memory */ -const char Gen_Error_str[] PROGMEM = "\r\nRequest error. Error code:\t"; -const char Dev_Header_str[] PROGMEM ="\r\nDevice descriptor: "; -const char Dev_Length_str[] PROGMEM ="\r\nDescriptor Length:\t"; -const char Dev_Type_str[] PROGMEM ="\r\nDescriptor type:\t"; -const char Dev_Version_str[] PROGMEM ="\r\nUSB version:\t\t"; -const char Dev_Class_str[] PROGMEM ="\r\nDevice class:\t\t"; -const char Dev_Subclass_str[] PROGMEM ="\r\nDevice Subclass:\t"; -const char Dev_Protocol_str[] PROGMEM ="\r\nDevice Protocol:\t"; -const char Dev_Pktsize_str[] PROGMEM ="\r\nMax.packet size:\t"; -const char Dev_Vendor_str[] PROGMEM ="\r\nVendor ID:\t\t"; -const char Dev_Product_str[] PROGMEM ="\r\nProduct ID:\t\t"; -const char Dev_Revision_str[] PROGMEM ="\r\nRevision ID:\t\t"; -const char Dev_Mfg_str[] PROGMEM ="\r\nMfg.string index:\t"; -const char Dev_Prod_str[] PROGMEM ="\r\nProd.string index:\t"; -const char Dev_Serial_str[] PROGMEM ="\r\nSerial number index:\t"; -const char Dev_Nconf_str[] PROGMEM ="\r\nNumber of conf.:\t"; -const char Conf_Trunc_str[] PROGMEM ="Total length truncated to 256 bytes"; -const char Conf_Header_str[] PROGMEM ="\r\nConfiguration descriptor:"; -const char Conf_Totlen_str[] PROGMEM ="\r\nTotal length:\t\t"; -const char Conf_Nint_str[] PROGMEM ="\r\nNum.intf:\t\t"; -const char Conf_Value_str[] PROGMEM ="\r\nConf.value:\t\t"; -const char Conf_String_str[] PROGMEM ="\r\nConf.string:\t\t"; -const char Conf_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; -const char Conf_Pwr_str[] PROGMEM ="\r\nMax.pwr:\t\t"; -const char Int_Header_str[] PROGMEM ="\r\n\r\nInterface descriptor:"; -const char Int_Number_str[] PROGMEM ="\r\nIntf.number:\t\t"; -const char Int_Alt_str[] PROGMEM ="\r\nAlt.:\t\t\t"; -const char Int_Endpoints_str[] PROGMEM ="\r\nEndpoints:\t\t"; -const char Int_Class_str[] PROGMEM ="\r\nIntf. Class:\t\t"; -const char Int_Subclass_str[] PROGMEM ="\r\nIntf. Subclass:\t\t"; -const char Int_Protocol_str[] PROGMEM ="\r\nIntf. Protocol:\t\t"; -const char Int_String_str[] PROGMEM ="\r\nIntf.string:\t\t"; -const char End_Header_str[] PROGMEM ="\r\n\r\nEndpoint descriptor:"; -const char End_Address_str[] PROGMEM ="\r\nEndpoint address:\t"; -const char End_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; -const char End_Pktsize_str[] PROGMEM ="\r\nMax.pkt size:\t\t"; -const char End_Interval_str[] PROGMEM ="\r\nPolling interval:\t"; -const char Unk_Header_str[] PROGMEM = "\r\nUnknown descriptor:"; -const char Unk_Length_str[] PROGMEM ="\r\nLength:\t\t"; -const char Unk_Type_str[] PROGMEM ="\r\nType:\t\t"; -const char Unk_Contents_str[] PROGMEM ="\r\nContents:\t"; - -#endif // __PGMSTRINGS_H__ \ No newline at end of file diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/max_LCD/max_LCD.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/max_LCD/max_LCD.ino deleted file mode 100644 index 6603ab90..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/max_LCD/max_LCD.ino +++ /dev/null @@ -1,29 +0,0 @@ -// Just a copy of the HelloWorld example bundled with the LiquidCrystal library in the Arduino IDE - -// HD44780 compatible LCD display via MAX3421E GPOUT support header -// pinout: D[4-7] -> GPOUT[4-7], RS-> GPOUT[2], E ->GPOUT[3] - -#include - -// Satisfy IDE, which only needs to see the include statment in the ino. -#ifdef dobogusinclude -#include -#include -#endif - -USB Usb; -Max_LCD lcd(&Usb); - -void setup() { - // Set up the LCD's number of columns and rows: - lcd.begin(16, 2); - // Print a message to the LCD. - lcd.print("Hello, World!"); -} - -void loop() { - // Set the cursor to column 0, line 1 (note: line 1 is the second row, since counting begins with 0): - lcd.setCursor(0, 1); - // Print the number of seconds since reset: - lcd.print(millis() / 1000); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/pl2303/pl2303_gprs_terminal/pl2303_gprs_terminal.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/pl2303/pl2303_gprs_terminal/pl2303_gprs_terminal.ino deleted file mode 100644 index 7c4c9f6c..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/pl2303/pl2303_gprs_terminal/pl2303_gprs_terminal.ino +++ /dev/null @@ -1,101 +0,0 @@ -/* Arduino terminal for PL2303 USB to serial converter and DealeXtreme GPRS modem. */ -/* USB support */ -#include -/* CDC support */ -#include -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -class PLAsyncOper : public CDCAsyncOper -{ -public: - uint8_t OnInit(ACM *pacm); -}; - -uint8_t PLAsyncOper::OnInit(ACM *pacm) -{ - uint8_t rcode; - - // Set DTR = 1 - rcode = pacm->SetControlLineState(1); - - if (rcode) - { - ErrorMessage(PSTR("SetControlLineState"), rcode); - return rcode; - } - - LINE_CODING lc; - //lc.dwDTERate = 9600; - lc.dwDTERate = 115200; - lc.bCharFormat = 0; - lc.bParityType = 0; - lc.bDataBits = 8; - - rcode = pacm->SetLineCoding(&lc); - - if (rcode) - ErrorMessage(PSTR("SetLineCoding"), rcode); - - return rcode; -} -USB Usb; -//USBHub Hub(&Usb); -PLAsyncOper AsyncOper; -PL2303 Pl(&Usb, &AsyncOper); - -void setup() -{ - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSCOKIRQ failed to assert"); - - delay( 200 ); -} - -void loop() -{ - Usb.Task(); - - if( Usb.getUsbTaskState() == USB_STATE_RUNNING ) - { - uint8_t rcode; - - /* reading the keyboard */ - if(Serial.available()) { - uint8_t data= Serial.read(); - - /* sending to the phone */ - rcode = Pl.SndData(1, &data); - if (rcode) - ErrorMessage(PSTR("SndData"), rcode); - }//if(Serial.available()... - - /* reading the converter */ - /* buffer size must be greater or equal to max.packet size */ - /* it it set to 64 (largest possible max.packet size) here, can be tuned down - for particular endpoint */ - uint8_t buf[64]; - uint16_t rcvd = 64; - rcode = Pl.RcvData(&rcvd, buf); - if (rcode && rcode != hrNAK) - ErrorMessage(PSTR("Ret"), rcode); - - if( rcvd ) { //more than zero bytes received - for(uint16_t i=0; i < rcvd; i++ ) { - Serial.print((char)buf[i]); //printing on the screen - } - }//if( rcvd ... - }//if( Usb.getUsbTaskState() == USB_STATE_RUNNING.. -} - diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/pl2303/pl2303_gps/pl2303_gps.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/pl2303/pl2303_gps/pl2303_gps.ino deleted file mode 100644 index e8c8a022..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/pl2303/pl2303_gps/pl2303_gps.ino +++ /dev/null @@ -1,88 +0,0 @@ -/* USB Host to PL2303-based USB GPS unit interface */ -/* Navibee GM720 receiver - Sirf Star III */ -/* USB support */ -#include -/* CDC support */ -#include -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -class PLAsyncOper : public CDCAsyncOper { -public: - uint8_t OnInit(ACM *pacm); -}; - -uint8_t PLAsyncOper::OnInit(ACM *pacm) { - uint8_t rcode; - - // Set DTR = 1 - rcode = pacm->SetControlLineState(1); - - if(rcode) { - ErrorMessage(PSTR("SetControlLineState"), rcode); - return rcode; - } - - LINE_CODING lc; - lc.dwDTERate = 4800; //default serial speed of GPS unit - lc.bCharFormat = 0; - lc.bParityType = 0; - lc.bDataBits = 8; - - rcode = pacm->SetLineCoding(&lc); - - if(rcode) - ErrorMessage(PSTR("SetLineCoding"), rcode); - - return rcode; -} - -USB Usb; -USBHub Hub(&Usb); -PLAsyncOper AsyncOper; -PL2303 Pl(&Usb, &AsyncOper); -uint32_t read_delay; -#define READ_DELAY 100 - -void setup() { - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if(Usb.Init() == -1) - Serial.println("OSCOKIRQ failed to assert"); - - delay(200); -} - -void loop() { - uint8_t rcode; - uint8_t buf[64]; //serial buffer equals Max.packet size of bulk-IN endpoint - uint16_t rcvd = 64; - - Usb.Task(); - - if(Pl.isReady()) { - /* reading the GPS */ - if((long)(millis() - read_delay) >= 0L) { - read_delay += READ_DELAY; - rcode = Pl.RcvData(&rcvd, buf); - if(rcode && rcode != hrNAK) - ErrorMessage(PSTR("Ret"), rcode); - if(rcvd) { //more than zero bytes received - for(uint16_t i = 0; i < rcvd; i++) { - Serial.print((char)buf[i]); //printing on the screen - }//for( uint16_t i=0; i < rcvd; i++... - }//if( rcvd - }//if( read_delay > millis()... - }//if( Usb.getUsbTaskState() == USB_STATE_RUNNING.. -} - - diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/pl2303/pl2303_tinygps/pl2303_tinygps.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/pl2303/pl2303_tinygps/pl2303_tinygps.ino deleted file mode 100644 index d527eabe..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/pl2303/pl2303_tinygps/pl2303_tinygps.ino +++ /dev/null @@ -1,217 +0,0 @@ -/* USB Host to PL2303-based USB GPS unit interface */ -/* Navibee GM720 receiver - Sirf Star III */ -/* Mikal Hart's TinyGPS library */ -/* test_with_gps_device library example modified for PL2302 access */ - -/* USB support */ -#include - -/* CDC support */ -#include -#include - -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -/* This sample code demonstrates the normal use of a TinyGPS object. - Modified to be used with USB Host Shield Library r2.0 - and USB Host Shield 2.0 -*/ - -class PLAsyncOper : public CDCAsyncOper -{ -public: - uint8_t OnInit(ACM *pacm); -}; - -uint8_t PLAsyncOper::OnInit(ACM *pacm) -{ - uint8_t rcode; - - // Set DTR = 1 - rcode = pacm->SetControlLineState(1); - - if (rcode) { - ErrorMessage(PSTR("SetControlLineState"), rcode); - return rcode; - } - - LINE_CODING lc; - lc.dwDTERate = 4800; //default serial speed of GPS unit - lc.bCharFormat = 0; - lc.bParityType = 0; - lc.bDataBits = 8; - - rcode = pacm->SetLineCoding(&lc); - - if (rcode) { - ErrorMessage(PSTR("SetLineCoding"), rcode); - } - - return rcode; -} - -USB Usb; -//USBHub Hub(&Usb); -PLAsyncOper AsyncOper; -PL2303 Pl(&Usb, &AsyncOper); -TinyGPS gps; - -void gpsdump(TinyGPS &gps); -bool feedgps(); -void printFloat(double f, int digits = 2); - -void setup() -{ - - Serial.begin(115200); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - - Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version()); - Serial.println("by Mikal Hart"); - Serial.println(); - Serial.print("Sizeof(gpsobject) = "); Serial.println(sizeof(TinyGPS)); - Serial.println(); - /* USB Initialization */ - if (Usb.Init() == -1) { - Serial.println("OSCOKIRQ failed to assert"); - } - - delay( 200 ); -} - -void loop() -{ - Usb.Task(); - - if( Pl.isReady()) { - - bool newdata = false; - unsigned long start = millis(); - - // Every 5 seconds we print an update - while (millis() - start < 5000) { - if( feedgps()) { - newdata = true; - } - }//while (millis()... - - if (newdata) { - Serial.println("Acquired Data"); - Serial.println("-------------"); - gpsdump(gps); - Serial.println("-------------"); - Serial.println(); - }//if( newdata... - }//if( Usb.getUsbTaskState() == USB_STATE_RUNNING... -} - -void printFloat(double number, int digits) -{ - // Handle negative numbers - if (number < 0.0) - { - Serial.print('-'); - number = -number; - } - - // Round correctly so that print(1.999, 2) prints as "2.00" - double rounding = 0.5; - for (uint8_t i=0; i 0) - Serial.print("."); - - // Extract digits from the remainder one at a time - while (digits-- > 0) - { - remainder *= 10.0; - int toPrint = int(remainder); - Serial.print(toPrint); - remainder -= toPrint; - } -} - -void gpsdump(TinyGPS &gps) -{ - long lat, lon; - float flat, flon; - unsigned long age, date, time, chars; - int year; - byte month, day, hour, minute, second, hundredths; - unsigned short sentences, failed; - - gps.get_position(&lat, &lon, &age); - Serial.print("Lat/Long(10^-5 deg): "); Serial.print(lat); Serial.print(", "); Serial.print(lon); - Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms."); - - feedgps(); // If we don't feed the gps during this long routine, we may drop characters and get checksum errors - - gps.f_get_position(&flat, &flon, &age); - Serial.print("Lat/Long(float): "); printFloat(flat, 5); Serial.print(", "); printFloat(flon, 5); - Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms."); - - feedgps(); - - gps.get_datetime(&date, &time, &age); - Serial.print("Date(ddmmyy): "); Serial.print(date); Serial.print(" Time(hhmmsscc): "); Serial.print(time); - Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms."); - - feedgps(); - - gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age); - Serial.print("Date: "); Serial.print(static_cast(month)); Serial.print("/"); Serial.print(static_cast(day)); Serial.print("/"); Serial.print(year); - Serial.print(" Time: "); Serial.print(static_cast(hour)); Serial.print(":"); Serial.print(static_cast(minute)); Serial.print(":"); Serial.print(static_cast(second)); Serial.print("."); Serial.print(static_cast(hundredths)); - Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms."); - - feedgps(); - - Serial.print("Alt(cm): "); Serial.print(gps.altitude()); Serial.print(" Course(10^-2 deg): "); Serial.print(gps.course()); Serial.print(" Speed(10^-2 knots): "); Serial.println(gps.speed()); - Serial.print("Alt(float): "); printFloat(gps.f_altitude()); Serial.print(" Course(float): "); printFloat(gps.f_course()); Serial.println(); - Serial.print("Speed(knots): "); printFloat(gps.f_speed_knots()); Serial.print(" (mph): "); printFloat(gps.f_speed_mph()); - Serial.print(" (mps): "); printFloat(gps.f_speed_mps()); Serial.print(" (kmph): "); printFloat(gps.f_speed_kmph()); Serial.println(); - - feedgps(); - - gps.stats(&chars, &sentences, &failed); - Serial.print("Stats: characters: "); Serial.print(chars); Serial.print(" sentences: "); Serial.print(sentences); Serial.print(" failed checksum: "); Serial.println(failed); -} - -bool feedgps() -{ - uint8_t rcode; - uint8_t buf[64]; //serial buffer equals Max.packet size of bulk-IN endpoint - uint16_t rcvd = 64; - { - /* reading the GPS */ - rcode = Pl.RcvData(&rcvd, buf); - if (rcode && rcode != hrNAK) - ErrorMessage(PSTR("Ret"), rcode); - rcode = false; - if( rcvd ) { //more than zero bytes received - for( uint16_t i=0; i < rcvd; i++ ) { - if( gps.encode((char)buf[i])) { //feed a character to gps object - rcode = true; - }//if( gps.encode(buf[i]... - }//for( uint16_t i=0; i < rcvd; i++... - }//if( rcvd... - } - return( rcode ); -} - diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/pl2303/pl2303_xbee_terminal/pl2303_xbee_terminal.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/pl2303/pl2303_xbee_terminal/pl2303_xbee_terminal.ino deleted file mode 100644 index 67b7dab6..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/pl2303/pl2303_xbee_terminal/pl2303_xbee_terminal.ino +++ /dev/null @@ -1,117 +0,0 @@ -/* Arduino terminal for PL2303 USB to serial converter and XBee radio. */ -/* Inserts linefeed after carriage return in data sent to and received from Xbee */ -/* USB support */ -#include -/* CDC support */ -#include -#include - -// Satisfy the IDE, which needs to see the include statment in the ino too. -#ifdef dobogusinclude -#include -#include -#endif - -class PLAsyncOper : public CDCAsyncOper -{ -public: - uint8_t OnInit(ACM *pacm); -}; - -uint8_t PLAsyncOper::OnInit(ACM *pacm) -{ - uint8_t rcode; - - // Set DTR = 1 - rcode = pacm->SetControlLineState(1); - - if (rcode) - { - ErrorMessage(PSTR("SetControlLineState"), rcode); - return rcode; - } - - LINE_CODING lc; - lc.dwDTERate = 115200; - lc.bCharFormat = 0; - lc.bParityType = 0; - lc.bDataBits = 8; - - rcode = pacm->SetLineCoding(&lc); - - if (rcode) - ErrorMessage(PSTR("SetLineCoding"), rcode); - - return rcode; -} -USB Usb; -//USBHub Hub(&Usb); -PLAsyncOper AsyncOper; -PL2303 Pl(&Usb, &AsyncOper); - -void setup() -{ - Serial.begin( 115200 ); -#if !defined(__MIPSEL__) - while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection -#endif - Serial.println("Start"); - - if (Usb.Init() == -1) - Serial.println("OSCOKIRQ failed to assert"); - - delay( 200 ); -} - -void loop() -{ - Usb.Task(); - - if( Usb.getUsbTaskState() == USB_STATE_RUNNING ) - { - uint8_t rcode; - - /* reading the keyboard */ - if(Serial.available()) { - uint8_t data= Serial.read(); - - if ( data == '\r' ) { - Serial.print("\r\n"); //insert linefeed - } - else { - Serial.print( data ); //echo back to the screen - } - - /* sending to the phone */ - rcode = Pl.SndData(1, &data); - if (rcode) - ErrorMessage(PSTR("SndData"), rcode); - }//if(Serial.available()... - - delay(50); - - /* reading the converter */ - /* buffer size must be greater or equal to max.packet size */ - /* it it set to 64 (largest possible max.packet size) here, can be tuned down - for particular endpoint */ - uint8_t buf[64]; - uint16_t rcvd = 64; - rcode = Pl.RcvData(&rcvd, buf); - if (rcode && rcode != hrNAK) - ErrorMessage(PSTR("Ret"), rcode); - - if( rcvd ) { //more than zero bytes received - for(uint16_t i=0; i < rcvd; i++ ) { - if( buf[i] =='\r' ) { - Serial.print("\r\n"); //insert linefeed - } - else { - Serial.print((char)buf[i]); //printing on the screen - } - } - } - delay(10); - }//if( Usb.getUsbTaskState() == USB_STATE_RUNNING.. -} - - diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/testusbhostFAT/Makefile b/protocol/usb_hid/USB_Host_Shield_2.0/examples/testusbhostFAT/Makefile deleted file mode 100644 index 8a12ddc0..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/testusbhostFAT/Makefile +++ /dev/null @@ -1,64 +0,0 @@ -# -# These are set for a mega 1280 + quadram plus my serial patch. -# If you lack quadram, or want to disable LFN, just change _FS_TINY=1 _USE_LFN=0 -# -# If your board is a mega 2560 comment out the following two lines -BOARD = mega - -BOARD_SUB = mega.menu.cpu.atmega1280 -PROGRAMMER = arduino - -# ...and then uncomment out the following two lines -#BOARD_SUB = mega.menu.cpu.atmega2560 -#PROGRAMMER = wiring - -#BOARD = teensypp2 -#BOARD = teensy3 -#BOARD = teensy31 - -# set your Arduino tty port here -PORT = /dev/ttyUSB0 - -EXTRA_FLAGS = -D _USE_LFN=3 - -# change to 0 if you have quadram to take advantage of caching FAT -EXTRA_FLAGS += -D _FS_TINY=1 - - -EXTRA_FLAGS += -D _MAX_SS=512 - - -# Don't worry if you don't have external RAM, xmem2 detects this situation. -# You *WILL* be wanting to get some kind of external ram on your mega in order to -# do anything that is intense. -EXTRA_FLAGS += -D EXT_RAM_STACK=1 -EXTRA_FLAGS += -D EXT_RAM_HEAP=1 - - -# These are no longer needed for the demo to work. -# In the event you need more ram, uncomment these 3 lines. -#EXTRA_FLAGS += -D DISABLE_SERIAL1 -#EXTRA_FLAGS += -D DISABLE_SERIAL2 -#EXTRA_FLAGS += -D DISABLE_SERIAL3 - -# -# Advanced debug on Serial3 -# - -# uncomment the next two to enable debug on Serial3 -EXTRA_FLAGS += -D USB_HOST_SERIAL=Serial3 -#EXTRA_FLAGS += -D DEBUG_USB_HOST - -# The following are the libraries used. -LIB_DIRS += ../../ -LIB_DIRS += ../testusbhostFAT/xmem2 -LIB_DIRS += ../testusbhostFAT/generic_storage -LIB_DIRS += ../testusbhostFAT/RTClib -LIB_DIRS += $(ARD_HOME)/libraries/Wire -LIB_DIRS += $(ARD_HOME)/libraries/Wire/utility -LIB_DIRS += $(ARD_HOME)/hardware/arduino/$(BUILD_ARCH)/libraries/Wire -LIB_DIRS += $(ARD_HOME)/hardware/arduino/$(BUILD_ARCH)/libraries/Wire/utility -LIB_DIRS += $(ARD_HOME)/hardware/arduino/$(BUILD_ARCH)/libraries/SPI - -# And finally, the part that brings everything together for you. -include Arduino_Makefile_master/_Makefile.master diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/testusbhostFAT/README.md b/protocol/usb_hid/USB_Host_Shield_2.0/examples/testusbhostFAT/README.md deleted file mode 100644 index d8b4296b..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/testusbhostFAT/README.md +++ /dev/null @@ -1,29 +0,0 @@ -This small sketch tests the USB host shield mass storage library. - -__Note:__ This will not run a Arduino Uno due to the limited ram available in the ATmega328p. - -The Arduino Mega (ATmega1280) and the Arduino Mega 2560 (ATmega2560) are confirmed to work with this test code. - -To compile this example you will need the following libraries as well: - -* [xmem2](https://github.com/xxxajk/xmem2) -* [generic_storage FATfs](https://github.com/xxxajk/generic_storage) -* [RTClib](https://github.com/xxxajk/RTClib) - -The following shield is recommended for larger projects: . - -You may use the bundled [Makefile](Makefile) to compile the code instead of the Arduino IDE if you have problems or want a smaller binary. The master makefile is bundled as a submodule, but can also be downloaded manually at the following link: . - -To download the USB Host library and all the needed libraries for this test. - -Run the following command in a terminal application: - -``` -git clone --recursive https://github.com/felis/USB_Host_Shield_2.0 -``` - -If you want to update all the submodules run: - -``` -git submodule foreach --recursive git pull origin master -``` diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/examples/testusbhostFAT/testusbhostFAT.ino b/protocol/usb_hid/USB_Host_Shield_2.0/examples/testusbhostFAT/testusbhostFAT.ino deleted file mode 100644 index e8b9cd35..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/examples/testusbhostFAT/testusbhostFAT.ino +++ /dev/null @@ -1,736 +0,0 @@ -/* - * Mega + USB storage + optional DS1307 + optional expansion RAM + funky status LED, - * Includes interactive debug level setting, and supports hot-plug. - * - * IMPORTANT! PLEASE USE Arduino 1.0.5 or better! - * Older versions HAVE MAJOR BUGS AND WILL NOT WORK AT ALL! - * Use of gcc-avr and lib-c that is newer than the Arduino version is even better. - * If you experience random crashes, use make. - * The options that the IDE use can generate bad code and cause the AVR to crash. - * - * This sketch requires the following libraries: - * https://github.com/felis/USB_Host_Shield_2.0 Install as 'USB_Host_Shield_2_0' - * https://github.com/xxxajk/xmem2 Install as 'xmem', provides memory services. - * https://github.com/xxxajk/generic_storage provides access to FAT file system. - * https://github.com/xxxajk/RTClib provides access to DS1307, or fake clock. - * - * Optional, to use the Makefile (Recommended! See above!): - * https://github.com/xxxajk/Arduino_Makefile_master - * - */ - -///////////////////////////////////////////////////////////// -// Please Note: // -// This section is for info with the Arduino IDE ONLY. // -// Unfortunately due to short sightedness of the Arduino // -// code team, that you must set the following in the // -// respective libraries. // -// Changing them here will have _NO_ effect! // -///////////////////////////////////////////////////////////// - -// Uncomment to enable debugging -//#define DEBUG_USB_HOST -// This is where stderr/USB debugging goes to -//#define USB_HOST_SERIAL Serial3 - -// If you have external memory, setting this to 0 enables FAT table caches. -// The 0 setting is recommended only if you have external memory. -//#define _FS_TINY 1 - -//#define _USE_LFN 3 -//#define _MAX_SS 512 - - -///////////////////////////////////////////////////////////// -// End of Arduino IDE specific information // -///////////////////////////////////////////////////////////// - -// You can set this to 0 if you are not using a USB hub. -// It will save a little bit of flash and RAM. -// Set to 1 if you want to use a hub. -#define WANT_HUB_TEST 1 - -// this is for XMEM2 -#define EXT_RAM_STACK 1 -#define EXT_RAM_HEAP 1 -#define LOAD_XMEM - -#if defined(CORE_TEENSY) && !defined(_AVR_) -#include -#include -#endif - -#if defined(__AVR__) -#include -#include -#elif defined(ARDUINO_ARCH_SAM) -#include -#endif - -#if WANT_HUB_TEST -#include -#endif -#include -#define LOAD_RTCLIB -#include -#include -#include -#include -#include -#include -#include -#if defined(__AVR__) -static FILE tty_stdio; -static FILE tty_stderr; -volatile uint32_t LEDnext_time; // fade timeout -volatile uint32_t HEAPnext_time; // when to print out next heap report -volatile int brightness = 0; // how bright the LED is -volatile int fadeAmount = 80; // how many points to fade the LED by -#endif - -USB Usb; - -volatile uint8_t current_state = 1; -volatile uint8_t last_state = 0; -volatile bool fatready = false; -volatile bool partsready = false; -volatile bool notified = false; -volatile bool runtest = false; -volatile bool usbon = false; -volatile uint32_t usbon_time; -volatile bool change = false; -volatile bool reportlvl = false; -int cpart = 0; -PCPartition *PT; - -#if WANT_HUB_TEST -#define MAX_HUBS 1 -USBHub *Hubs[MAX_HUBS]; -#endif - -static PFAT *Fats[_VOLUMES]; -static part_t parts[_VOLUMES]; -static storage_t sto[_VOLUMES]; - -/*make sure this is a power of two. */ -#define mbxs 128 -static uint8_t My_Buff_x[mbxs]; /* File read buffer */ - -#if defined(__AVR__) - -#define prescale1 ((1 << WGM12) | (1 << CS10)) -#define prescale8 ((1 << WGM12) | (1 << CS11)) -#define prescale64 ((1 << WGM12) | (1 << CS10) | (1 << CS11)) -#define prescale256 ((1 << WGM12) | (1 << CS12)) -#define prescale1024 ((1 << WGM12) | (1 << CS12) | (1 << CS10)) - -extern "C" { - extern unsigned int freeHeap(); -} -static int tty_stderr_putc(char c, FILE *t) { - USB_HOST_SERIAL.write(c); - return 0; -} - -static int __attribute__((unused)) tty_stderr_flush(FILE *t) { - USB_HOST_SERIAL.flush(); - return 0; -} - -static int tty_std_putc(char c, FILE *t) { - Serial.write(c); - return 0; -} - -static int tty_std_getc(FILE *t) { - while(!Serial.available()); - return Serial.read(); -} - -static int __attribute__((unused)) tty_std_flush(FILE *t) { - Serial.flush(); - return 0; -} - -#else -// Supposedly the DUE has stdio already pointing to serial... -#if !defined(ARDUINO_ARCH_SAM) -// But newlib needs this... -extern "C" { - int _write(int fd, const char *ptr, int len) { - int j; - for(j = 0; j < len; j++) { - if(fd == 1) - Serial.write(*ptr++); - else if(fd == 2) - USB_HOST_SERIAL.write(*ptr++); - } - return len; - } - - int _read(int fd, char *ptr, int len) { - if(len > 0 && fd == 0) { - while(!Serial.available()); - *ptr = Serial.read(); - return 1; - } - return 0; - } - -#include - - int _fstat(int fd, struct stat *st) { - memset(st, 0, sizeof (*st)); - st->st_mode = S_IFCHR; - st->st_blksize = 1024; - return 0; - } - - int _isatty(int fd) { - return (fd < 3) ? 1 : 0; - } -} -#endif // !defined(ARDUINO_ARCH_SAM) -#endif - -void setup() { - bool serr = false; - for(int i = 0; i < _VOLUMES; i++) { - Fats[i] = NULL; - sto[i].private_data = new pvt_t; - ((pvt_t *)sto[i].private_data)->B = 255; // impossible - } - // Set this to higher values to enable more debug information - // minimum 0x00, maximum 0xff - UsbDEBUGlvl = 0x81; - -#if !defined(CORE_TEENSY) && defined(__AVR__) - // make LED pin as an output: - pinMode(LED_BUILTIN, OUTPUT); - pinMode(2, OUTPUT); - // Ensure TX is off - _SFR_BYTE(UCSR0B) &= ~_BV(TXEN0); - // Initialize 'debug' serial port - USB_HOST_SERIAL.begin(115200); - // Do not start primary Serial port if already started. - if(bit_is_clear(UCSR0B, TXEN0)) { - Serial.begin(115200); - serr = true; - } - - - // Blink LED - delay(500); - analogWrite(LED_BUILTIN, 255); - delay(500); - analogWrite(LED_BUILTIN, 0); - delay(500); -#else - while(!Serial); - Serial.begin(115200); // On the Teensy 3.x we get a delay at least! -#endif -#if defined(__AVR__) - // Set up stdio/stderr - tty_stdio.put = tty_std_putc; - tty_stdio.get = tty_std_getc; - tty_stdio.flags = _FDEV_SETUP_RW; - tty_stdio.udata = 0; - - tty_stderr.put = tty_stderr_putc; - tty_stderr.get = NULL; - tty_stderr.flags = _FDEV_SETUP_WRITE; - tty_stderr.udata = 0; - - stdout = &tty_stdio; - stdin = &tty_stdio; - stderr = &tty_stderr; -#endif - printf_P(PSTR("\r\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nStart\r\n")); - printf_P(PSTR("Current UsbDEBUGlvl %02x\r\n"), UsbDEBUGlvl); - printf_P(PSTR("'+' and '-' increase/decrease by 0x01\r\n")); - printf_P(PSTR("'.' and ',' increase/decrease by 0x10\r\n")); - printf_P(PSTR("'t' will run a 10MB write/read test and print out the time it took.\r\n")); - printf_P(PSTR("'e' will toggle vbus off for a few moments.\r\n\r\n")); - printf_P(PSTR("Long filename support: " -#if _USE_LFN - "Enabled" -#else - "Disabled" -#endif - "\r\n")); - if(serr) { - fprintf_P(stderr, PSTR("\r\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nStart\r\n")); - fprintf_P(stderr, PSTR("Current UsbDEBUGlvl %02x\r\n"), UsbDEBUGlvl); - fprintf_P(stderr, PSTR("Long filename support: " -#if _USE_LFN - "Enabled" -#else - "Disabled" -#endif - "\r\n")); - } - -#if !defined(CORE_TEENSY) && defined(__AVR__) - analogWrite(LED_BUILTIN, 255); - delay(500); - analogWrite(LED_BUILTIN, 0); - delay(500); - analogWrite(LED_BUILTIN, 255); - delay(500); - analogWrite(LED_BUILTIN, 0); - delay(500); - analogWrite(LED_BUILTIN, 255); - delay(500); - analogWrite(LED_BUILTIN, 0); - delay(500); - - LEDnext_time = millis() + 1; -#if EXT_RAM - printf_P(PSTR("Total EXT RAM banks %i\r\n"), xmem::getTotalBanks()); -#endif - printf_P(PSTR("Available heap: %u Bytes\r\n"), freeHeap()); - printf_P(PSTR("SP %x\r\n"), (uint8_t *)(SP)); -#endif - - // Even though I'm not going to actually be deleting, - // I want to be able to have slightly more control. - // Besides, it is easier to initialize stuff... -#if WANT_HUB_TEST - for(int i = 0; i < MAX_HUBS; i++) { - Hubs[i] = new USBHub(&Usb); -#if defined(__AVR__) - printf_P(PSTR("Available heap: %u Bytes\r\n"), freeHeap()); -#endif - } -#endif - // Initialize generic storage. This must be done before USB starts. - Init_Generic_Storage(); - - while(Usb.Init(1000) == -1) { - printf_P(PSTR("No USB HOST Shield?\r\n")); - Notify(PSTR("OSC did not start."), 0x40); - } - -#if !defined(CORE_TEENSY) && defined(__AVR__) - cli(); - TCCR3A = 0; - TCCR3B = 0; - // (0.01/(1/((16 *(10^6)) / 8))) - 1 = 19999 - OCR3A = 19999; - TCCR3B |= prescale8; - TIMSK3 |= (1 << OCIE1A); - sei(); - - HEAPnext_time = millis() + 10000; -#endif -#if defined(__AVR__) - HEAPnext_time = millis() + 10000; -#endif -} - -void serialEvent() { - // Adjust UsbDEBUGlvl level on-the-fly. - // + to increase, - to decrease, * to display current level. - // . to increase by 16, , to decrease by 16 - // e to flick VBUS - // * to report debug level - if(Serial.available()) { - int inByte = Serial.read(); - switch(inByte) { - case '+': - if(UsbDEBUGlvl < 0xff) UsbDEBUGlvl++; - reportlvl = true; - break; - case '-': - if(UsbDEBUGlvl > 0x00) UsbDEBUGlvl--; - reportlvl = true; - break; - case '.': - if(UsbDEBUGlvl < 0xf0) UsbDEBUGlvl += 16; - reportlvl = true; - break; - case ',': - if(UsbDEBUGlvl > 0x0f) UsbDEBUGlvl -= 16; - reportlvl = true; - break; - case '*': - reportlvl = true; - break; - case 't': - runtest = true; - break; - case 'e': - change = true; - usbon = false; - break; - } - } -} - -#if !defined(CORE_TEENSY) && defined(__AVR__) -// ALL teensy versions LACK PWM ON LED - -ISR(TIMER3_COMPA_vect) { - if((long)(millis() - LEDnext_time) >= 0L) { - LEDnext_time = millis() + 30; - - // set the brightness of LED - analogWrite(LED_BUILTIN, brightness); - - // change the brightness for next time through the loop: - brightness = brightness + fadeAmount; - - // reverse the direction of the fading at the ends of the fade: - if(brightness <= 0) { - brightness = 0; - fadeAmount = -fadeAmount; - } - if(brightness >= 255) { - brightness = 255; - fadeAmount = -fadeAmount; - } - } -} -#endif - -bool isfat(uint8_t t) { - return (t == 0x01 || t == 0x04 || t == 0x06 || t == 0x0b || t == 0x0c || t == 0x0e || t == 0x1); -} - -void die(FRESULT rc) { - printf_P(PSTR("Failed with rc=%u.\r\n"), rc); - //for (;;); -} - -void loop() { - FIL My_File_Object_x; /* File object */ - -#if defined(__AVR__) - // Print a heap status report about every 10 seconds. - if((long)(millis() - HEAPnext_time) >= 0L) { - if(UsbDEBUGlvl > 0x50) { - printf_P(PSTR("Available heap: %u Bytes\r\n"), freeHeap()); - } - HEAPnext_time = millis() + 10000; - } - TCCR3B = 0; -#endif -#if defined(CORE_TEENSY) - // Teensy suffers here, oh well... - serialEvent(); -#endif - // Horrid! This sort of thing really belongs in an ISR, not here! - // We also will be needing to test each hub port, we don't do this yet! - if(!change && !usbon && (long)(millis() - usbon_time) >= 0L) { - change = true; - usbon = true; - } - - if(change) { - change = false; - if(usbon) { - Usb.vbusPower(vbus_on); - printf_P(PSTR("VBUS on\r\n")); - } else { - Usb.vbusPower(vbus_off); - usbon_time = millis() + 2000; - } - } - Usb.Task(); - current_state = Usb.getUsbTaskState(); - if(current_state != last_state) { - if(UsbDEBUGlvl > 0x50) - printf_P(PSTR("USB state = %x\r\n"), current_state); -#if !defined(CORE_TEENSY) && defined(__AVR__) - if(current_state == USB_STATE_RUNNING) { - fadeAmount = 30; - } -#endif - if(current_state == USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE) { -#if !defined(CORE_TEENSY) && defined(__AVR__) - fadeAmount = 80; -#endif - partsready = false; - for(int i = 0; i < cpart; i++) { - if(Fats[i] != NULL) - delete Fats[i]; - Fats[i] = NULL; - } - fatready = false; - notified = false; - cpart = 0; - } - last_state = current_state; - } - - // only do any of this if usb is on - if(usbon) { - if(partsready && !fatready) { - if(cpart > 0) fatready = true; - } - // This is horrible, and needs to be moved elsewhere! - for(int B = 0; B < MAX_USB_MS_DRIVERS; B++) { - if((!partsready) && (UHS_USB_BulkOnly[B]->GetAddress())) { - - // Build a list. - int ML = UHS_USB_BulkOnly[B]->GetbMaxLUN(); - //printf("MAXLUN = %i\r\n", ML); - ML++; - for(int i = 0; i < ML; i++) { - if(UHS_USB_BulkOnly[B]->LUNIsGood(i)) { - partsready = true; - ((pvt_t *)(sto[i].private_data))->lun = i; - ((pvt_t *)(sto[i].private_data))->B = B; - sto[i].Reads = *UHS_USB_BulkOnly_Read; - sto[i].Writes = *UHS_USB_BulkOnly_Write; - sto[i].Status = *UHS_USB_BulkOnly_Status; - sto[i].Initialize = *UHS_USB_BulkOnly_Initialize; - sto[i].Commit = *UHS_USB_BulkOnly_Commit; - sto[i].TotalSectors = UHS_USB_BulkOnly[B]->GetCapacity(i); - sto[i].SectorSize = UHS_USB_BulkOnly[B]->GetSectorSize(i); - printf_P(PSTR("LUN:\t\t%u\r\n"), i); - printf_P(PSTR("Total Sectors:\t%08lx\t%lu\r\n"), sto[i].TotalSectors, sto[i].TotalSectors); - printf_P(PSTR("Sector Size:\t%04x\t\t%u\r\n"), sto[i].SectorSize, sto[i].SectorSize); - // get the partition data... - PT = new PCPartition; - - if(!PT->Init(&sto[i])) { - part_t *apart; - for(int j = 0; j < 4; j++) { - apart = PT->GetPart(j); - if(apart != NULL && apart->type != 0x00) { - memcpy(&(parts[cpart]), apart, sizeof (part_t)); - printf_P(PSTR("Partition %u type %#02x\r\n"), j, parts[cpart].type); - // for now - if(isfat(parts[cpart].type)) { - Fats[cpart] = new PFAT(&sto[i], cpart, parts[cpart].firstSector); - //int r = Fats[cpart]->Good(); - if(Fats[cpart]->MountStatus()) { - delete Fats[cpart]; - Fats[cpart] = NULL; - } else cpart++; - } - } - } - } else { - // try superblock - Fats[cpart] = new PFAT(&sto[i], cpart, 0); - //int r = Fats[cpart]->Good(); - if(Fats[cpart]->MountStatus()) { - //printf_P(PSTR("Superblock error %x\r\n"), r); - delete Fats[cpart]; - Fats[cpart] = NULL; - } else cpart++; - - } - delete PT; - } else { - sto[i].Writes = NULL; - sto[i].Reads = NULL; - sto[i].Initialize = NULL; - sto[i].TotalSectors = 0UL; - sto[i].SectorSize = 0; - } - } - - } - } - - if(fatready) { - if(Fats[0] != NULL) { - struct Pvt * p; - p = ((struct Pvt *)(Fats[0]->storage->private_data)); - if(!UHS_USB_BulkOnly[p->B]->LUNIsGood(p->lun)) { - // media change -#if !defined(CORE_TEENSY) && defined(__AVR__) - fadeAmount = 80; -#endif - partsready = false; - for(int i = 0; i < cpart; i++) { - if(Fats[i] != NULL) - delete Fats[i]; - Fats[cpart] = NULL; - } - fatready = false; - notified = false; - cpart = 0; - } - - } - } - if(fatready) { - FRESULT rc; /* Result code */ - UINT bw, br, i; - if(!notified) { -#if !defined(CORE_TEENSY) && defined(__AVR__) - fadeAmount = 5; -#endif - notified = true; - FATFS *fs = NULL; - for(int zz = 0; zz < _VOLUMES; zz++) { - if(Fats[zz]->volmap == 0) fs = Fats[zz]->ffs; - } - printf_P(PSTR("\r\nOpen an existing file (message.txt).\r\n")); - rc = f_open(&My_File_Object_x, "0:/MESSAGE.TXT", FA_READ); - if(rc) printf_P(PSTR("Error %i, message.txt not found.\r\n"), rc); - else { - printf_P(PSTR("\r\nType the file content.\r\n")); - for(;;) { - rc = f_read(&My_File_Object_x, My_Buff_x, mbxs, &br); /* Read a chunk of file */ - if(rc || !br) break; /* Error or end of file */ - for(i = 0; i < br; i++) { - /* Type the data */ - if(My_Buff_x[i] == '\n') - Serial.write('\r'); - if(My_Buff_x[i] != '\r') - Serial.write(My_Buff_x[i]); - Serial.flush(); - } - } - if(rc) { - f_close(&My_File_Object_x); - goto out; - } - - printf_P(PSTR("\r\nClose the file.\r\n")); - rc = f_close(&My_File_Object_x); - if(rc) goto out; - } - printf_P(PSTR("\r\nCreate a new file (hello.txt).\r\n")); - rc = f_open(&My_File_Object_x, "0:/Hello.TxT", FA_WRITE | FA_CREATE_ALWAYS); - if(rc) { - die(rc); - goto outdir; - } - printf_P(PSTR("\r\nWrite a text data. (Hello world!)\r\n")); - rc = f_write(&My_File_Object_x, "Hello world!\r\n", 14, &bw); - if(rc) { - goto out; - } - printf_P(PSTR("%u bytes written.\r\n"), bw); - - printf_P(PSTR("\r\nClose the file.\r\n")); - rc = f_close(&My_File_Object_x); - if(rc) { - die(rc); - goto out; - } -outdir:{ -#if _USE_LFN - char lfn[_MAX_LFN + 1]; - FILINFO My_File_Info_Object_x; /* File information object */ - My_File_Info_Object_x.lfname = lfn; -#endif - DIR My_Dir_Object_x; /* Directory object */ - printf_P(PSTR("\r\nOpen root directory.\r\n")); - rc = f_opendir(&My_Dir_Object_x, "0:/"); - if(rc) { - die(rc); - goto out; - } - - printf_P(PSTR("\r\nDirectory listing...\r\n")); -#if defined(__AVR__) - printf_P(PSTR("Available heap: %u Bytes\r\n"), freeHeap()); -#endif - for(;;) { -#if _USE_LFN - My_File_Info_Object_x.lfsize = _MAX_LFN; -#endif - - rc = f_readdir(&My_Dir_Object_x, &My_File_Info_Object_x); /* Read a directory item */ - if(rc || !My_File_Info_Object_x.fname[0]) break; /* Error or end of dir */ - - if(My_File_Info_Object_x.fattrib & AM_DIR) { - Serial.write('d'); - } else { - Serial.write('-'); - } - Serial.write('r'); - - if(My_File_Info_Object_x.fattrib & AM_RDO) { - Serial.write('-'); - } else { - Serial.write('w'); - } - if(My_File_Info_Object_x.fattrib & AM_HID) { - Serial.write('h'); - } else { - Serial.write('-'); - } - - if(My_File_Info_Object_x.fattrib & AM_SYS) { - Serial.write('s'); - } else { - Serial.write('-'); - } - - if(My_File_Info_Object_x.fattrib & AM_ARC) { - Serial.write('a'); - } else { - Serial.write('-'); - } - -#if _USE_LFN - if(*My_File_Info_Object_x.lfname) - printf_P(PSTR(" %8lu %s (%s)\r\n"), My_File_Info_Object_x.fsize, My_File_Info_Object_x.fname, My_File_Info_Object_x.lfname); - else -#endif - printf_P(PSTR(" %8lu %s\r\n"), My_File_Info_Object_x.fsize, &(My_File_Info_Object_x.fname[0])); - } - } -out: - if(rc) die(rc); - - DISK_IOCTL(fs->drv, CTRL_COMMIT, 0); - printf_P(PSTR("\r\nTest completed.\r\n")); - - } - - if(runtest) { - ULONG ii, wt, rt, start, end; - FATFS *fs = NULL; - for(int zz = 0; zz < _VOLUMES; zz++) { - if(Fats[zz]->volmap == 0) fs = Fats[zz]->ffs; - } - runtest = false; - f_unlink("0:/10MB.bin"); - printf_P(PSTR("\r\nCreate a new 10MB test file (10MB.bin).\r\n")); - rc = f_open(&My_File_Object_x, "0:/10MB.bin", FA_WRITE | FA_CREATE_ALWAYS); - if(rc) goto failed; - for(bw = 0; bw < mbxs; bw++) My_Buff_x[bw] = bw & 0xff; - fflush(stdout); - start = millis(); - while(start == millis()); - for(ii = 10485760LU / mbxs; ii > 0LU; ii--) { - rc = f_write(&My_File_Object_x, My_Buff_x, mbxs, &bw); - if(rc || !bw) goto failed; - } - rc = f_close(&My_File_Object_x); - if(rc) goto failed; - end = millis(); - wt = (end - start) - 1; - printf_P(PSTR("Time to write 10485760 bytes: %lu ms (%lu sec) \r\n"), wt, (500 + wt) / 1000UL); - rc = f_open(&My_File_Object_x, "0:/10MB.bin", FA_READ); - fflush(stdout); - start = millis(); - while(start == millis()); - if(rc) goto failed; - for(;;) { - rc = f_read(&My_File_Object_x, My_Buff_x, mbxs, &bw); /* Read a chunk of file */ - if(rc || !bw) break; /* Error or end of file */ - } - end = millis(); - if(rc) goto failed; - rc = f_close(&My_File_Object_x); - if(rc) goto failed; - rt = (end - start) - 1; - printf_P(PSTR("Time to read 10485760 bytes: %lu ms (%lu sec)\r\nDelete test file\r\n"), rt, (500 + rt) / 1000UL); -failed: - if(rc) die(rc); - DISK_IOCTL(fs->drv, CTRL_COMMIT, 0); - printf_P(PSTR("10MB timing test finished.\r\n")); - } - } - } -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/gpl2.txt b/protocol/usb_hid/USB_Host_Shield_2.0/gpl2.txt deleted file mode 100644 index 5b6e7c66..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/gpl2.txt +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/hexdump.h b/protocol/usb_hid/USB_Host_Shield_2.0/hexdump.h deleted file mode 100644 index ffa7248b..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/hexdump.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(_usb_h_) || defined(__HEXDUMP_H__) -#error "Never include hexdump.h directly; include Usb.h instead" -#else -#define __HEXDUMP_H__ - -extern int UsbDEBUGlvl; - -template -class HexDumper : public BASE_CLASS { - uint8_t byteCount; - OFFSET_TYPE byteTotal; - -public: - - HexDumper() : byteCount(0), byteTotal(0) { - }; - - void Initialize() { - byteCount = 0; - byteTotal = 0; - }; - - void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset); -}; - -template -void HexDumper::Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) { - if(UsbDEBUGlvl >= 0x80) { // Fully bypass this block of code if we do not debug. - for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) { - if(!byteCount) { - PrintHex (byteTotal, 0x80); - E_Notify(PSTR(": "), 0x80); - } - PrintHex (pbuf[j], 0x80); - E_Notify(PSTR(" "), 0x80); - - if(byteCount == 15) { - E_Notify(PSTR("\r\n"), 0x80); - byteCount = 0xFF; - } - } - } -} - -#endif // __HEXDUMP_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/hid.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/hid.cpp deleted file mode 100644 index e4c7721a..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/hid.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#include "hid.h" - -//get HID report descriptor - -/* WRONG! Endpoint is _ALWAYS_ ZERO for HID! We want the _INTERFACE_ value here! -uint8_t HID::GetReportDescr(uint8_t ep, USBReadParser *parser) { - const uint8_t constBufLen = 64; - uint8_t buf[constBufLen]; - - uint8_t rcode = pUsb->ctrlReq(bAddress, ep, bmREQ_HID_REPORT, USB_REQUEST_GET_DESCRIPTOR, 0x00, - HID_DESCRIPTOR_REPORT, 0x0000, 128, constBufLen, buf, (USBReadParser*)parser); - - //return ((rcode != hrSTALL) ? rcode : 0); - return rcode; -} - */ -uint8_t HID::GetReportDescr(uint16_t wIndex, USBReadParser *parser) { - const uint8_t constBufLen = 64; - uint8_t buf[constBufLen]; - - uint8_t rcode = pUsb->ctrlReq(bAddress, 0x00, bmREQ_HID_REPORT, USB_REQUEST_GET_DESCRIPTOR, 0x00, - HID_DESCRIPTOR_REPORT, wIndex, 128, constBufLen, buf, (USBReadParser*)parser); - - //return ((rcode != hrSTALL) ? rcode : 0); - return rcode; -} - -//uint8_t HID::getHidDescr( uint8_t ep, uint16_t nbytes, uint8_t* dataptr ) -//{ -// return( pUsb->ctrlReq( bAddress, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, HID_DESCRIPTOR_HID, 0x0000, nbytes, dataptr )); -//} - -uint8_t HID::SetReport(uint8_t ep, uint8_t iface, uint8_t report_type, uint8_t report_id, uint16_t nbytes, uint8_t* dataptr) { - return ( pUsb->ctrlReq(bAddress, ep, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, report_id, report_type, iface, nbytes, nbytes, dataptr, NULL)); -} - -uint8_t HID::GetReport(uint8_t ep, uint8_t iface, uint8_t report_type, uint8_t report_id, uint16_t nbytes, uint8_t* dataptr) { - return ( pUsb->ctrlReq(bAddress, ep, bmREQ_HID_IN, HID_REQUEST_GET_REPORT, report_id, report_type, iface, nbytes, nbytes, dataptr, NULL)); -} - -uint8_t HID::GetIdle(uint8_t iface, uint8_t reportID, uint8_t* dataptr) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HID_IN, HID_REQUEST_GET_IDLE, reportID, 0, iface, 0x0001, 0x0001, dataptr, NULL)); -} - -uint8_t HID::SetIdle(uint8_t iface, uint8_t reportID, uint8_t duration) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HID_OUT, HID_REQUEST_SET_IDLE, reportID, duration, iface, 0x0000, 0x0000, NULL, NULL)); -} - -uint8_t HID::SetProtocol(uint8_t iface, uint8_t protocol) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HID_OUT, HID_REQUEST_SET_PROTOCOL, protocol, 0x00, iface, 0x0000, 0x0000, NULL, NULL)); -} - -uint8_t HID::GetProtocol(uint8_t iface, uint8_t* dataptr) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HID_IN, HID_REQUEST_GET_PROTOCOL, 0x00, 0x00, iface, 0x0001, 0x0001, dataptr, NULL)); -} - -void HID::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) { - Notify(PSTR("Endpoint descriptor:"), 0x80); - Notify(PSTR("\r\nLength:\t\t"), 0x80); - D_PrintHex (ep_ptr->bLength, 0x80); - Notify(PSTR("\r\nType:\t\t"), 0x80); - D_PrintHex (ep_ptr->bDescriptorType, 0x80); - Notify(PSTR("\r\nAddress:\t"), 0x80); - D_PrintHex (ep_ptr->bEndpointAddress, 0x80); - Notify(PSTR("\r\nAttributes:\t"), 0x80); - D_PrintHex (ep_ptr->bmAttributes, 0x80); - Notify(PSTR("\r\nMaxPktSize:\t"), 0x80); - D_PrintHex (ep_ptr->wMaxPacketSize, 0x80); - Notify(PSTR("\r\nPoll Intrv:\t"), 0x80); - D_PrintHex (ep_ptr->bInterval, 0x80); -} - -void HID::PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc) { - Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80); - Notify(PSTR("bDescLength:\t\t"), 0x80); - D_PrintHex (pDesc->bLength, 0x80); - - Notify(PSTR("\r\nbDescriptorType:\t"), 0x80); - D_PrintHex (pDesc->bDescriptorType, 0x80); - - Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80); - D_PrintHex (pDesc->bcdHID, 0x80); - - Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80); - D_PrintHex (pDesc->bCountryCode, 0x80); - - Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80); - D_PrintHex (pDesc->bNumDescriptors, 0x80); - - Notify(PSTR("\r\nbDescrType:\t\t"), 0x80); - D_PrintHex (pDesc->bDescrType, 0x80); - - Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80); - D_PrintHex (pDesc->wDescriptorLength, 0x80); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/hid.h b/protocol/usb_hid/USB_Host_Shield_2.0/hid.h deleted file mode 100644 index 72942ebc..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/hid.h +++ /dev/null @@ -1,188 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(__HID_H__) -#define __HID_H__ - -#include "Usb.h" -#include "hidusagestr.h" - -#define MAX_REPORT_PARSERS 2 -#define HID_MAX_HID_CLASS_DESCRIPTORS 5 - -#define DATA_SIZE_MASK 0x03 -#define TYPE_MASK 0x0C -#define TAG_MASK 0xF0 - -#define DATA_SIZE_0 0x00 -#define DATA_SIZE_1 0x01 -#define DATA_SIZE_2 0x02 -#define DATA_SIZE_4 0x03 - -#define TYPE_MAIN 0x00 -#define TYPE_GLOBAL 0x04 -#define TYPE_LOCAL 0x08 - -#define TAG_MAIN_INPUT 0x80 -#define TAG_MAIN_OUTPUT 0x90 -#define TAG_MAIN_COLLECTION 0xA0 -#define TAG_MAIN_FEATURE 0xB0 -#define TAG_MAIN_ENDCOLLECTION 0xC0 - -#define TAG_GLOBAL_USAGEPAGE 0x00 -#define TAG_GLOBAL_LOGICALMIN 0x10 -#define TAG_GLOBAL_LOGICALMAX 0x20 -#define TAG_GLOBAL_PHYSMIN 0x30 -#define TAG_GLOBAL_PHYSMAX 0x40 -#define TAG_GLOBAL_UNITEXP 0x50 -#define TAG_GLOBAL_UNIT 0x60 -#define TAG_GLOBAL_REPORTSIZE 0x70 -#define TAG_GLOBAL_REPORTID 0x80 -#define TAG_GLOBAL_REPORTCOUNT 0x90 -#define TAG_GLOBAL_PUSH 0xA0 -#define TAG_GLOBAL_POP 0xB0 - -#define TAG_LOCAL_USAGE 0x00 -#define TAG_LOCAL_USAGEMIN 0x10 -#define TAG_LOCAL_USAGEMAX 0x20 - -/* HID requests */ -#define bmREQ_HID_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE -#define bmREQ_HID_IN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE -#define bmREQ_HID_REPORT USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_INTERFACE - -/* HID constants. Not part of chapter 9 */ -/* Class-Specific Requests */ -#define HID_REQUEST_GET_REPORT 0x01 -#define HID_REQUEST_GET_IDLE 0x02 -#define HID_REQUEST_GET_PROTOCOL 0x03 -#define HID_REQUEST_SET_REPORT 0x09 -#define HID_REQUEST_SET_IDLE 0x0A -#define HID_REQUEST_SET_PROTOCOL 0x0B - -/* Class Descriptor Types */ -#define HID_DESCRIPTOR_HID 0x21 -#define HID_DESCRIPTOR_REPORT 0x22 -#define HID_DESRIPTOR_PHY 0x23 - -/* Protocol Selection */ -#define HID_BOOT_PROTOCOL 0x00 -#define HID_RPT_PROTOCOL 0x01 - -/* HID Interface Class Code */ -#define HID_INTF 0x03 - -/* HID Interface Class SubClass Codes */ -#define HID_BOOT_INTF_SUBCLASS 0x01 - -/* HID Interface Class Protocol Codes */ -#define HID_PROTOCOL_NONE 0x00 -#define HID_PROTOCOL_KEYBOARD 0x01 -#define HID_PROTOCOL_MOUSE 0x02 - -#define HID_ITEM_TYPE_MAIN 0 -#define HID_ITEM_TYPE_GLOBAL 1 -#define HID_ITEM_TYPE_LOCAL 2 -#define HID_ITEM_TYPE_RESERVED 3 - -#define HID_LONG_ITEM_PREFIX 0xfe // Long item prefix value - -#define bmHID_MAIN_ITEM_TAG 0xfc // Main item tag mask - -#define bmHID_MAIN_ITEM_INPUT 0x80 // Main item Input tag value -#define bmHID_MAIN_ITEM_OUTPUT 0x90 // Main item Output tag value -#define bmHID_MAIN_ITEM_FEATURE 0xb0 // Main item Feature tag value -#define bmHID_MAIN_ITEM_COLLECTION 0xa0 // Main item Collection tag value -#define bmHID_MAIN_ITEM_END_COLLECTION 0xce // Main item End Collection tag value - -#define HID_MAIN_ITEM_COLLECTION_PHYSICAL 0 -#define HID_MAIN_ITEM_COLLECTION_APPLICATION 1 -#define HID_MAIN_ITEM_COLLECTION_LOGICAL 2 -#define HID_MAIN_ITEM_COLLECTION_REPORT 3 -#define HID_MAIN_ITEM_COLLECTION_NAMED_ARRAY 4 -#define HID_MAIN_ITEM_COLLECTION_USAGE_SWITCH 5 -#define HID_MAIN_ITEM_COLLECTION_USAGE_MODIFIER 6 - -struct HidItemPrefix { - uint8_t bSize : 2; - uint8_t bType : 2; - uint8_t bTag : 4; -}; - -struct MainItemIOFeature { - uint8_t bmIsConstantOrData : 1; - uint8_t bmIsArrayOrVariable : 1; - uint8_t bmIsRelativeOrAbsolute : 1; - uint8_t bmIsWrapOrNoWrap : 1; - uint8_t bmIsNonLonearOrLinear : 1; - uint8_t bmIsNoPreferedOrPrefered : 1; - uint8_t bmIsNullOrNoNull : 1; - uint8_t bmIsVolatileOrNonVolatile : 1; -}; - -class HID; - -class HIDReportParser { -public: - virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) = 0; -}; - -class HID : public USBDeviceConfig, public UsbConfigXtracter { -protected: - USB *pUsb; // USB class instance pointer - uint8_t bAddress; // address - -protected: - static const uint8_t epInterruptInIndex = 1; // InterruptIN endpoint index - static const uint8_t epInterruptOutIndex = 2; // InterruptOUT endpoint index - - static const uint8_t maxHidInterfaces = 3; - static const uint8_t maxEpPerInterface = 2; - static const uint8_t totalEndpoints = (maxHidInterfaces * maxEpPerInterface + 1); - - void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); - void PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc); - - virtual HIDReportParser* GetReportParser(uint8_t id) { - return NULL; - }; - -public: - - HID(USB *pusb) : pUsb(pusb) { - }; - - const USB* GetUsb() { - return pUsb; - }; - - virtual bool SetReportParser(uint8_t id, HIDReportParser *prs) { - return false; - }; - - uint8_t SetProtocol(uint8_t iface, uint8_t protocol); - uint8_t GetProtocol(uint8_t iface, uint8_t* dataptr); - uint8_t GetIdle(uint8_t iface, uint8_t reportID, uint8_t* dataptr); - uint8_t SetIdle(uint8_t iface, uint8_t reportID, uint8_t duration); - - uint8_t GetReportDescr(uint16_t wIndex, USBReadParser *parser = NULL); - - uint8_t GetHidDescr(uint8_t ep, uint16_t nbytes, uint8_t* dataptr); - uint8_t GetReport(uint8_t ep, uint8_t iface, uint8_t report_type, uint8_t report_id, uint16_t nbytes, uint8_t* dataptr); - uint8_t SetReport(uint8_t ep, uint8_t iface, uint8_t report_type, uint8_t report_id, uint16_t nbytes, uint8_t* dataptr); -}; - -#endif // __HID_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/hidboot.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/hidboot.cpp deleted file mode 100644 index 280b2f97..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/hidboot.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#include "hidboot.h" - -void MouseReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) { - MOUSEINFO *pmi = (MOUSEINFO*)buf; - // Future: - // bool event; - -#if 0 - if (prevState.mouseInfo.bmLeftButton == 0 && pmi->bmLeftButton == 1) - OnLeftButtonDown(pmi); - - if (prevState.mouseInfo.bmLeftButton == 1 && pmi->bmLeftButton == 0) - OnLeftButtonUp(pmi); - - if (prevState.mouseInfo.bmRightButton == 0 && pmi->bmRightButton == 1) - OnRightButtonDown(pmi); - - if (prevState.mouseInfo.bmRightButton == 1 && pmi->bmRightButton == 0) - OnRightButtonUp(pmi); - - if (prevState.mouseInfo.bmMiddleButton == 0 && pmi->bmMiddleButton == 1) - OnMiddleButtonDown(pmi); - - if (prevState.mouseInfo.bmMiddleButton == 1 && pmi->bmMiddleButton == 0) - OnMiddleButtonUp(pmi); - - if (prevState.mouseInfo.dX != pmi->dX || prevState.mouseInfo.dY != pmi->dY) - OnMouseMove(pmi); - - if (len > sizeof (MOUSEINFO)) - for (uint8_t i = 0; ibmLeftButton ) { - if(pmi->bmLeftButton) { - OnLeftButtonDown(pmi); - } else { - OnLeftButtonUp(pmi); - } - // Future: - // event = true; - } - - if(prevState.mouseInfo.bmRightButton != pmi->bmRightButton) { - if(pmi->bmRightButton) { - OnRightButtonDown(pmi); - } else { - OnRightButtonUp(pmi); - } - // Future: - // event = true; - } - - if(prevState.mouseInfo.bmMiddleButton != pmi->bmMiddleButton) { - if(pmi->bmMiddleButton) { - OnMiddleButtonDown(pmi); - } else { - OnMiddleButtonUp(pmi); - } - // Future: - // event = true; - } - - // - // Scroll wheel(s), are not part of the spec, but we could support it. - // Logitech wireless keyboard and mouse combo reports scroll wheel in byte 4 - // We wouldn't even need to save this information. - //if(len > 3) { - //} - // - - // Mice only report motion when they actually move! - // Why not just pass the x/y values to simplify things?? - if(pmi->dX || pmi->dY) { - OnMouseMove(pmi); - // Future: - // event = true; - } - - // - // Future: - // Provide a callback that operates on the gathered events from above. - // - // if(event) OnMouse(); - // - - // Only the first byte matters (buttons). We do NOT need to save position info. - prevState.bInfo[0] = buf[0]; -#endif - -}; - -void KeyboardReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) { - // On error - return - if (buf[2] == 1) - return; - - //KBDINFO *pki = (KBDINFO*)buf; - - // provide event for changed control key state - if (prevState.bInfo[0x00] != buf[0x00]) { - OnControlKeysChanged(prevState.bInfo[0x00], buf[0x00]); - } - - for (uint8_t i = 2; i < 8; i++) { - bool down = false; - bool up = false; - - for (uint8_t j = 2; j < 8; j++) { - if (buf[i] == prevState.bInfo[j] && buf[i] != 1) - down = true; - if (buf[j] == prevState.bInfo[i] && prevState.bInfo[i] != 1) - up = true; - } - if (!down) { - HandleLockingKeys(hid, buf[i]); - OnKeyDown(*buf, buf[i]); - } - if (!up) - OnKeyUp(prevState.bInfo[0], prevState.bInfo[i]); - } - for (uint8_t i = 0; i < 8; i++) - prevState.bInfo[i] = buf[i]; -}; - -const uint8_t KeyboardReportParser::numKeys[10] PROGMEM = {'!', '@', '#', '$', '%', '^', '&', '*', '(', ')'}; -const uint8_t KeyboardReportParser::symKeysUp[12] PROGMEM = {'_', '+', '{', '}', '|', '~', ':', '"', '~', '<', '>', '?'}; -const uint8_t KeyboardReportParser::symKeysLo[12] PROGMEM = {'-', '=', '[', ']', '\\', ' ', ';', '\'', '`', ',', '.', '/'}; -const uint8_t KeyboardReportParser::padKeys[5] PROGMEM = {'/', '*', '-', '+', 0x13}; - -uint8_t KeyboardReportParser::OemToAscii(uint8_t mod, uint8_t key) { - uint8_t shift = (mod & 0x22); - - // [a-z] - if (VALUE_WITHIN(key, 0x04, 0x1d)) { - // Upper case letters - if ((kbdLockingKeys.kbdLeds.bmCapsLock == 0 && shift) || - (kbdLockingKeys.kbdLeds.bmCapsLock == 1 && shift == 0)) - return (key - 4 + 'A'); - - // Lower case letters - else - return (key - 4 + 'a'); - }// Numbers - else if (VALUE_WITHIN(key, 0x1e, 0x27)) { - if (shift) - return ((uint8_t)pgm_read_byte(&getNumKeys()[key - 0x1e])); - else - return ((key == UHS_HID_BOOT_KEY_ZERO) ? '0' : key - 0x1e + '1'); - }// Keypad Numbers - else if(VALUE_WITHIN(key, 0x59, 0x61)) { - if(kbdLockingKeys.kbdLeds.bmNumLock == 1) - return (key - 0x59 + '1'); - } else if(VALUE_WITHIN(key, 0x2d, 0x38)) - return ((shift) ? (uint8_t)pgm_read_byte(&getSymKeysUp()[key - 0x2d]) : (uint8_t)pgm_read_byte(&getSymKeysLo()[key - 0x2d])); - else if(VALUE_WITHIN(key, 0x54, 0x58)) - return (uint8_t)pgm_read_byte(&getPadKeys()[key - 0x54]); - else { - switch(key) { - case UHS_HID_BOOT_KEY_SPACE: return (0x20); - case UHS_HID_BOOT_KEY_ENTER: return (0x13); - case UHS_HID_BOOT_KEY_ZERO2: return ((kbdLockingKeys.kbdLeds.bmNumLock == 1) ? '0': 0); - case UHS_HID_BOOT_KEY_PERIOD: return ((kbdLockingKeys.kbdLeds.bmNumLock == 1) ? '.': 0); - } - } - return ( 0); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/hidboot.h b/protocol/usb_hid/USB_Host_Shield_2.0/hidboot.h deleted file mode 100644 index fb63ec5e..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/hidboot.h +++ /dev/null @@ -1,618 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(__HIDBOOT_H__) -#define __HIDBOOT_H__ - -#include "hid.h" - -#define UHS_HID_BOOT_KEY_ZERO 0x27 -#define UHS_HID_BOOT_KEY_ENTER 0x28 -#define UHS_HID_BOOT_KEY_SPACE 0x2c -#define UHS_HID_BOOT_KEY_CAPS_LOCK 0x39 -#define UHS_HID_BOOT_KEY_SCROLL_LOCK 0x47 -#define UHS_HID_BOOT_KEY_NUM_LOCK 0x53 -#define UHS_HID_BOOT_KEY_ZERO2 0x62 -#define UHS_HID_BOOT_KEY_PERIOD 0x63 - -// Don't worry, GCC will optimize the result to a final value. -#define bitsEndpoints(p) ((((p) & HID_PROTOCOL_KEYBOARD)? 2 : 0) | (((p) & HID_PROTOCOL_MOUSE)? 1 : 0)) -#define totalEndpoints(p) ((bitsEndpoints(p) == 3) ? 3 : 2) -#define epMUL(p) ((((p) & HID_PROTOCOL_KEYBOARD)? 1 : 0) + (((p) & HID_PROTOCOL_MOUSE)? 1 : 0)) - -// Already defined in hid.h -// #define HID_MAX_HID_CLASS_DESCRIPTORS 5 - -struct MOUSEINFO { - - struct { - uint8_t bmLeftButton : 1; - uint8_t bmRightButton : 1; - uint8_t bmMiddleButton : 1; - uint8_t bmDummy : 5; - }; - int8_t dX; - int8_t dY; -}; - -class MouseReportParser : public HIDReportParser { - - union { - MOUSEINFO mouseInfo; - uint8_t bInfo[sizeof (MOUSEINFO)]; - } prevState; - -public: - void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); - -protected: - - virtual void OnMouseMove(MOUSEINFO *mi) { - }; - - virtual void OnLeftButtonUp(MOUSEINFO *mi) { - }; - - virtual void OnLeftButtonDown(MOUSEINFO *mi) { - }; - - virtual void OnRightButtonUp(MOUSEINFO *mi) { - }; - - virtual void OnRightButtonDown(MOUSEINFO *mi) { - }; - - virtual void OnMiddleButtonUp(MOUSEINFO *mi) { - }; - - virtual void OnMiddleButtonDown(MOUSEINFO *mi) { - }; -}; - -struct MODIFIERKEYS { - uint8_t bmLeftCtrl : 1; - uint8_t bmLeftShift : 1; - uint8_t bmLeftAlt : 1; - uint8_t bmLeftGUI : 1; - uint8_t bmRightCtrl : 1; - uint8_t bmRightShift : 1; - uint8_t bmRightAlt : 1; - uint8_t bmRightGUI : 1; -}; - -struct KBDINFO { - - struct { - uint8_t bmLeftCtrl : 1; - uint8_t bmLeftShift : 1; - uint8_t bmLeftAlt : 1; - uint8_t bmLeftGUI : 1; - uint8_t bmRightCtrl : 1; - uint8_t bmRightShift : 1; - uint8_t bmRightAlt : 1; - uint8_t bmRightGUI : 1; - }; - uint8_t bReserved; - uint8_t Keys[6]; -}; - -struct KBDLEDS { - uint8_t bmNumLock : 1; - uint8_t bmCapsLock : 1; - uint8_t bmScrollLock : 1; - uint8_t bmCompose : 1; - uint8_t bmKana : 1; - uint8_t bmReserved : 3; -}; - -class KeyboardReportParser : public HIDReportParser { - static const uint8_t numKeys[10]; - static const uint8_t symKeysUp[12]; - static const uint8_t symKeysLo[12]; - static const uint8_t padKeys[5]; - -protected: - - union { - KBDINFO kbdInfo; - uint8_t bInfo[sizeof (KBDINFO)]; - } prevState; - - union { - KBDLEDS kbdLeds; - uint8_t bLeds; - } kbdLockingKeys; - - uint8_t OemToAscii(uint8_t mod, uint8_t key); - -public: - - KeyboardReportParser() { - kbdLockingKeys.bLeds = 0; - }; - - void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); - -protected: - - virtual uint8_t HandleLockingKeys(HID* hid, uint8_t key) { - uint8_t old_keys = kbdLockingKeys.bLeds; - - switch(key) { - case UHS_HID_BOOT_KEY_NUM_LOCK: - kbdLockingKeys.kbdLeds.bmNumLock = ~kbdLockingKeys.kbdLeds.bmNumLock; - break; - case UHS_HID_BOOT_KEY_CAPS_LOCK: - kbdLockingKeys.kbdLeds.bmCapsLock = ~kbdLockingKeys.kbdLeds.bmCapsLock; - break; - case UHS_HID_BOOT_KEY_SCROLL_LOCK: - kbdLockingKeys.kbdLeds.bmScrollLock = ~kbdLockingKeys.kbdLeds.bmScrollLock; - break; - } - - if(old_keys != kbdLockingKeys.bLeds && hid) - return (hid->SetReport(0, 0/*hid->GetIface()*/, 2, 0, 1, &kbdLockingKeys.bLeds)); - - return 0; - }; - - virtual void OnControlKeysChanged(uint8_t before, uint8_t after) { - }; - - virtual void OnKeyDown(uint8_t mod, uint8_t key) { - }; - - virtual void OnKeyUp(uint8_t mod, uint8_t key) { - }; - - virtual const uint8_t *getNumKeys() { - return numKeys; - }; - - virtual const uint8_t *getSymKeysUp() { - return symKeysUp; - }; - - virtual const uint8_t *getSymKeysLo() { - return symKeysLo; - }; - - virtual const uint8_t *getPadKeys() { - return padKeys; - }; -}; - -template -class HIDBoot : public HID //public USBDeviceConfig, public UsbConfigXtracter -{ - EpInfo epInfo[totalEndpoints(BOOT_PROTOCOL)]; - HIDReportParser *pRptParser[epMUL(BOOT_PROTOCOL)]; - - uint8_t bConfNum; // configuration number - uint8_t bIfaceNum; // Interface Number - uint8_t bNumIface; // number of interfaces in the configuration - uint8_t bNumEP; // total number of EP in the configuration - uint32_t qNextPollTime; // next poll time - bool bPollEnable; // poll enable flag - uint8_t bInterval; // largest interval - - void Initialize(); - - virtual HIDReportParser* GetReportParser(uint8_t id) { - return pRptParser[id]; - }; - -public: - HIDBoot(USB *p); - - virtual bool SetReportParser(uint8_t id, HIDReportParser *prs) { - pRptParser[id] = prs; - return true; - }; - - // USBDeviceConfig implementation - uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - uint8_t Release(); - uint8_t Poll(); - - virtual uint8_t GetAddress() { - return bAddress; - }; - - virtual bool isReady() { - return bPollEnable; - }; - - // UsbConfigXtracter implementation - // Method should be defined here if virtual. - virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); - - virtual bool DEVCLASSOK(uint8_t klass) { - return (klass == USB_CLASS_HID); - } - - virtual bool DEVSUBCLASSOK(uint8_t subklass) { - return (subklass == BOOT_PROTOCOL); - } -}; - -template -HIDBoot::HIDBoot(USB *p) : -HID(p), -qNextPollTime(0), -bPollEnable(false) { - Initialize(); - - for(int i = 0; i < epMUL(BOOT_PROTOCOL); i++) { - pRptParser[i] = NULL; - } - if(pUsb) - pUsb->RegisterDeviceClass(this); -} - -template -void HIDBoot::Initialize() { - for(int i = 0; i < totalEndpoints(BOOT_PROTOCOL); i++) { - epInfo[i].epAddr = 0; - epInfo[i].maxPktSize = (i) ? 0 : 8; - epInfo[i].epAttribs = 0; - epInfo[i].bmNakPower = (i) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER; - } - bNumEP = 1; - bNumIface = 0; - bConfNum = 0; -} - -template -uint8_t HIDBoot::Init(uint8_t parent, uint8_t port, bool lowspeed) { - const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR); - - uint8_t buf[constBufSize]; - uint8_t rcode; - UsbDevice *p = NULL; - EpInfo *oldep_ptr = NULL; - uint8_t len = 0; - //uint16_t cd_len = 0; - - uint8_t num_of_conf; // number of configurations - //uint8_t num_of_intf; // number of interfaces - - AddressPool &addrPool = pUsb->GetAddressPool(); - - USBTRACE("BM Init\r\n"); - //USBTRACE2("totalEndpoints:", (uint8_t) (totalEndpoints(BOOT_PROTOCOL))); - //USBTRACE2("epMUL:", epMUL(BOOT_PROTOCOL)); - - if(bAddress) - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - - bInterval = 0; - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - if(!p->epinfo) { - USBTRACE("epinfo\r\n"); - return USB_ERROR_EPINFO_IS_NULL; - } - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - - p->lowspeed = lowspeed; - - // Get device descriptor - rcode = pUsb->getDevDescr(0, 0, 8, (uint8_t*)buf); - - if(!rcode) - len = (buf[0] > constBufSize) ? constBufSize : buf[0]; - - if(rcode) { - // Restore p->epinfo - p->epinfo = oldep_ptr; - - goto FailGetDevDescr; - } - - // Restore p->epinfo - p->epinfo = oldep_ptr; - - // Allocate new address according to device class - bAddress = addrPool.AllocAddress(parent, false, port); - - if(!bAddress) - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - - // Extract Max Packet Size from the device descriptor - epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0; - - // Assign new address to the device - rcode = pUsb->setAddr(0, 0, bAddress); - - if(rcode) { - p->lowspeed = false; - addrPool.FreeAddress(bAddress); - bAddress = 0; - USBTRACE2("setAddr:", rcode); - return rcode; - } - //delay(2); //per USB 2.0 sect.9.2.6.3 - - USBTRACE2("Addr:", bAddress); - - p->lowspeed = false; - - p = addrPool.GetUsbDevicePtr(bAddress); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - p->lowspeed = lowspeed; - - if(len) - rcode = pUsb->getDevDescr(bAddress, 0, len, (uint8_t*)buf); - - if(rcode) - goto FailGetDevDescr; - - num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations; - - USBTRACE2("NC:", num_of_conf); - - // GCC will optimize unused stuff away. - if((BOOT_PROTOCOL & (HID_PROTOCOL_KEYBOARD | HID_PROTOCOL_MOUSE)) == (HID_PROTOCOL_KEYBOARD | HID_PROTOCOL_MOUSE)) { - USBTRACE("HID_PROTOCOL_KEYBOARD AND MOUSE\r\n"); - ConfigDescParser< - USB_CLASS_HID, - HID_BOOT_INTF_SUBCLASS, - HID_PROTOCOL_KEYBOARD | HID_PROTOCOL_MOUSE, - CP_MASK_COMPARE_ALL > confDescrParser(this); - confDescrParser.SetOR(); // Use the OR variant. - for(uint8_t i = 0; i < num_of_conf; i++) { - pUsb->getConfDescr(bAddress, 0, i, &confDescrParser); - if(bNumEP == (uint8_t)(totalEndpoints(BOOT_PROTOCOL))) - break; - } - } else { - // GCC will optimize unused stuff away. - if(BOOT_PROTOCOL & HID_PROTOCOL_KEYBOARD) { - USBTRACE("HID_PROTOCOL_KEYBOARD\r\n"); - for(uint8_t i = 0; i < num_of_conf; i++) { - ConfigDescParser< - USB_CLASS_HID, - HID_BOOT_INTF_SUBCLASS, - HID_PROTOCOL_KEYBOARD, - CP_MASK_COMPARE_ALL> confDescrParserA(this); - - pUsb->getConfDescr(bAddress, 0, i, &confDescrParserA); - if(bNumEP == (uint8_t)(totalEndpoints(BOOT_PROTOCOL))) - break; - } - } - - // GCC will optimize unused stuff away. - if(BOOT_PROTOCOL & HID_PROTOCOL_MOUSE) { - USBTRACE("HID_PROTOCOL_MOUSE\r\n"); - for(uint8_t i = 0; i < num_of_conf; i++) { - ConfigDescParser< - USB_CLASS_HID, - HID_BOOT_INTF_SUBCLASS, - HID_PROTOCOL_MOUSE, - CP_MASK_COMPARE_ALL> confDescrParserB(this); - - pUsb->getConfDescr(bAddress, 0, i, &confDescrParserB); - if(bNumEP == ((uint8_t)(totalEndpoints(BOOT_PROTOCOL)))) - break; - - } - } - } - USBTRACE2("bNumEP:", bNumEP); - - if(bNumEP != (uint8_t)(totalEndpoints(BOOT_PROTOCOL))) { - rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - goto Fail; - } - - // Assign epInfo to epinfo pointer - rcode = pUsb->setEpInfoEntry(bAddress, bNumEP, epInfo); - //USBTRACE2("setEpInfoEntry returned ", rcode); - USBTRACE2("Cnf:", bConfNum); - - delay(1000); - - // Set Configuration Value - rcode = pUsb->setConf(bAddress, 0, bConfNum); - - if(rcode) - goto FailSetConfDescr; - - delay(1000); - - USBTRACE2("bIfaceNum:", bIfaceNum); - USBTRACE2("bNumIface:", bNumIface); - - // Yes, mouse wants SetProtocol and SetIdle too! - for(uint8_t i = 0; i < epMUL(BOOT_PROTOCOL); i++) { - USBTRACE2("\r\nInterface:", i); - rcode = SetProtocol(i, HID_BOOT_PROTOCOL); - if(rcode) goto FailSetProtocol; - USBTRACE2("PROTOCOL SET HID_BOOT rcode:", rcode); - rcode = SetIdle(i, 0, 0); - USBTRACE2("SET_IDLE rcode:", rcode); - // if(rcode) goto FailSetIdle; This can fail. - // Get the RPIPE and just throw it away. - SinkParser sink; - rcode = GetReportDescr(i, &sink); - USBTRACE2("RPIPE rcode:", rcode); - } - - // Get RPIPE and throw it away. - - if(BOOT_PROTOCOL & HID_PROTOCOL_KEYBOARD) { - // Wake keyboard interface by twinkling up to 5 LEDs that are in the spec. - // kana, compose, scroll, caps, num - rcode = 0x20; // Reuse rcode. - while(rcode) { - rcode >>= 1; - // Ignore any error returned, we don't care if LED is not supported - SetReport(0, 0, 2, 0, 1, &rcode); // Eventually becomes zero (All off) - delay(25); - } - } - USBTRACE("BM configured\r\n"); - - bPollEnable = true; - return 0; - -FailGetDevDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetDevDescr(); - goto Fail; -#endif - - //FailSetDevTblEntry: - //#ifdef DEBUG_USB_HOST - // NotifyFailSetDevTblEntry(); - // goto Fail; - //#endif - - //FailGetConfDescr: - //#ifdef DEBUG_USB_HOST - // NotifyFailGetConfDescr(); - // goto Fail; - //#endif - -FailSetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailSetConfDescr(); - goto Fail; -#endif - -FailSetProtocol: -#ifdef DEBUG_USB_HOST - USBTRACE("SetProto:"); - goto Fail; -#endif - - //FailSetIdle: - //#ifdef DEBUG_USB_HOST - // USBTRACE("SetIdle:"); - //#endif - -Fail: -#ifdef DEBUG_USB_HOST - NotifyFail(rcode); -#endif - Release(); - - return rcode; -} - -template -void HIDBoot::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) { - - // If the first configuration satisfies, the others are not considered. - //if(bNumEP > 1 && conf != bConfNum) - if(bNumEP == totalEndpoints(BOOT_PROTOCOL)) - return; - - bConfNum = conf; - bIfaceNum = iface; - - if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) { - if(pep->bInterval > bInterval) bInterval = pep->bInterval; - - // Fill in the endpoint info structure - epInfo[bNumEP].epAddr = (pep->bEndpointAddress & 0x0F); - epInfo[bNumEP].maxPktSize = (uint8_t)pep->wMaxPacketSize; - epInfo[bNumEP].epAttribs = 0; - epInfo[bNumEP].bmNakPower = USB_NAK_NOWAIT; - bNumEP++; - - } -} - -template -uint8_t HIDBoot::Release() { - pUsb->GetAddressPool().FreeAddress(bAddress); - - bConfNum = 0; - bIfaceNum = 0; - bNumEP = 1; - bAddress = 0; - qNextPollTime = 0; - bPollEnable = false; - - return 0; -} - -template -uint8_t HIDBoot::Poll() { - uint8_t rcode = 0; - - if(bPollEnable && ((long)(millis() - qNextPollTime) >= 0L)) { - - // To-do: optimize manually, using the for loop only if needed. - for(int i = 0; i < epMUL(BOOT_PROTOCOL); i++) { - const uint16_t const_buff_len = 16; - uint8_t buf[const_buff_len]; - - USBTRACE3("(hidboot.h) i=", i, 0x81); - USBTRACE3("(hidboot.h) epInfo[epInterruptInIndex + i].epAddr=", epInfo[epInterruptInIndex + i].epAddr, 0x81); - USBTRACE3("(hidboot.h) epInfo[epInterruptInIndex + i].maxPktSize=", epInfo[epInterruptInIndex + i].maxPktSize, 0x81); - uint16_t read = (uint16_t)epInfo[epInterruptInIndex + i].maxPktSize; - - rcode = pUsb->inTransfer(bAddress, epInfo[epInterruptInIndex + i].epAddr, &read, buf); - // SOME buggy dongles report extra keys (like sleep) using a 2 byte packet on the wrong endpoint. - // Since keyboard and mice must report at least 3 bytes, we ignore the extra data. - if(!rcode && read > 2) { - if(pRptParser[i]) - pRptParser[i]->Parse((HID*)this, 0, (uint8_t)read, buf); -#ifdef DEBUG_USB_HOST - // We really don't care about errors and anomalies unless we are debugging. - } else { - if(rcode != hrNAK) { - USBTRACE3("(hidboot.h) Poll:", rcode, 0x81); - } - if(!rcode && read) { - USBTRACE3("(hidboot.h) Strange read count: ", read, 0x80); - USBTRACE3("(hidboot.h) Interface:", i, 0x80); - } - } - - if(!rcode && read && (UsbDEBUGlvl > 0x7f)) { - for(uint8_t i = 0; i < read; i++) { - PrintHex (buf[i], 0x80); - USBTRACE1(" ", 0x80); - } - if(read) - USBTRACE1("\r\n", 0x80); -#endif - } - - } - qNextPollTime = millis() + bInterval; - } - return rcode; -} - -#endif // __HIDBOOTMOUSE_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/hidescriptorparser.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/hidescriptorparser.cpp deleted file mode 100644 index e4491b4e..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/hidescriptorparser.cpp +++ /dev/null @@ -1,1588 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#include "hidescriptorparser.h" - -const char * const ReportDescParserBase::usagePageTitles0[] PROGMEM = { - pstrUsagePageGenericDesktopControls, - pstrUsagePageSimulationControls, - pstrUsagePageVRControls, - pstrUsagePageSportControls, - pstrUsagePageGameControls, - pstrUsagePageGenericDeviceControls, - pstrUsagePageKeyboardKeypad, - pstrUsagePageLEDs, - pstrUsagePageButton, - pstrUsagePageOrdinal, - pstrUsagePageTelephone, - pstrUsagePageConsumer, - pstrUsagePageDigitizer, - pstrUsagePagePID, - pstrUsagePageUnicode -}; - -const char * const ReportDescParserBase::usagePageTitles1[] PROGMEM = { - pstrUsagePageBarCodeScanner, - pstrUsagePageScale, - pstrUsagePageMSRDevices, - pstrUsagePagePointOfSale, - pstrUsagePageCameraControl, - pstrUsagePageArcade -}; -const char * const ReportDescParserBase::genDesktopTitles0[] PROGMEM = { - pstrUsagePointer, - pstrUsageMouse, - pstrUsageJoystick, - pstrUsageGamePad, - pstrUsageKeyboard, - pstrUsageKeypad, - pstrUsageMultiAxisController, - pstrUsageTabletPCSystemControls - -}; -const char * const ReportDescParserBase::genDesktopTitles1[] PROGMEM = { - pstrUsageX, - pstrUsageY, - pstrUsageZ, - pstrUsageRx, - pstrUsageRy, - pstrUsageRz, - pstrUsageSlider, - pstrUsageDial, - pstrUsageWheel, - pstrUsageHatSwitch, - pstrUsageCountedBuffer, - pstrUsageByteCount, - pstrUsageMotionWakeup, - pstrUsageStart, - pstrUsageSelect, - pstrUsagePageReserved, - pstrUsageVx, - pstrUsageVy, - pstrUsageVz, - pstrUsageVbrx, - pstrUsageVbry, - pstrUsageVbrz, - pstrUsageVno, - pstrUsageFeatureNotification, - pstrUsageResolutionMultiplier -}; -const char * const ReportDescParserBase::genDesktopTitles2[] PROGMEM = { - pstrUsageSystemControl, - pstrUsageSystemPowerDown, - pstrUsageSystemSleep, - pstrUsageSystemWakeup, - pstrUsageSystemContextMenu, - pstrUsageSystemMainMenu, - pstrUsageSystemAppMenu, - pstrUsageSystemMenuHelp, - pstrUsageSystemMenuExit, - pstrUsageSystemMenuSelect, - pstrUsageSystemMenuRight, - pstrUsageSystemMenuLeft, - pstrUsageSystemMenuUp, - pstrUsageSystemMenuDown, - pstrUsageSystemColdRestart, - pstrUsageSystemWarmRestart, - pstrUsageDPadUp, - pstrUsageDPadDown, - pstrUsageDPadRight, - pstrUsageDPadLeft -}; -const char * const ReportDescParserBase::genDesktopTitles3[] PROGMEM = { - pstrUsageSystemDock, - pstrUsageSystemUndock, - pstrUsageSystemSetup, - pstrUsageSystemBreak, - pstrUsageSystemDebuggerBreak, - pstrUsageApplicationBreak, - pstrUsageApplicationDebuggerBreak, - pstrUsageSystemSpeakerMute, - pstrUsageSystemHibernate -}; -const char * const ReportDescParserBase::genDesktopTitles4[] PROGMEM = { - pstrUsageSystemDisplayInvert, - pstrUsageSystemDisplayInternal, - pstrUsageSystemDisplayExternal, - pstrUsageSystemDisplayBoth, - pstrUsageSystemDisplayDual, - pstrUsageSystemDisplayToggleIntExt, - pstrUsageSystemDisplaySwapPriSec, - pstrUsageSystemDisplayLCDAutoscale -}; -const char * const ReportDescParserBase::simuTitles0[] PROGMEM = { - pstrUsageFlightSimulationDevice, - pstrUsageAutomobileSimulationDevice, - pstrUsageTankSimulationDevice, - pstrUsageSpaceshipSimulationDevice, - pstrUsageSubmarineSimulationDevice, - pstrUsageSailingSimulationDevice, - pstrUsageMotocicleSimulationDevice, - pstrUsageSportsSimulationDevice, - pstrUsageAirplaneSimulationDevice, - pstrUsageHelicopterSimulationDevice, - pstrUsageMagicCarpetSimulationDevice, - pstrUsageBicycleSimulationDevice -}; -const char * const ReportDescParserBase::simuTitles1[] PROGMEM = { - pstrUsageFlightControlStick, - pstrUsageFlightStick, - pstrUsageCyclicControl, - pstrUsageCyclicTrim, - pstrUsageFlightYoke, - pstrUsageTrackControl -}; -const char * const ReportDescParserBase::simuTitles2[] PROGMEM = { - pstrUsageAileron, - pstrUsageAileronTrim, - pstrUsageAntiTorqueControl, - pstrUsageAutopilotEnable, - pstrUsageChaffRelease, - pstrUsageCollectiveControl, - pstrUsageDiveBrake, - pstrUsageElectronicCountermeasures, - pstrUsageElevator, - pstrUsageElevatorTrim, - pstrUsageRudder, - pstrUsageThrottle, - pstrUsageFlightCommunications, - pstrUsageFlareRelease, - pstrUsageLandingGear, - pstrUsageToeBrake, - pstrUsageTrigger, - pstrUsageWeaponsArm, - pstrUsageWeaponsSelect, - pstrUsageWingFlaps, - pstrUsageAccelerator, - pstrUsageBrake, - pstrUsageClutch, - pstrUsageShifter, - pstrUsageSteering, - pstrUsageTurretDirection, - pstrUsageBarrelElevation, - pstrUsageDivePlane, - pstrUsageBallast, - pstrUsageBicycleCrank, - pstrUsageHandleBars, - pstrUsageFrontBrake, - pstrUsageRearBrake -}; -const char * const ReportDescParserBase::vrTitles0[] PROGMEM = { - pstrUsageBelt, - pstrUsageBodySuit, - pstrUsageFlexor, - pstrUsageGlove, - pstrUsageHeadTracker, - pstrUsageHeadMountedDisplay, - pstrUsageHandTracker, - pstrUsageOculometer, - pstrUsageVest, - pstrUsageAnimatronicDevice -}; -const char * const ReportDescParserBase::vrTitles1[] PROGMEM = { - pstrUsageStereoEnable, - pstrUsageDisplayEnable -}; -const char * const ReportDescParserBase::sportsCtrlTitles0[] PROGMEM = { - pstrUsageBaseballBat, - pstrUsageGolfClub, - pstrUsageRowingMachine, - pstrUsageTreadmill -}; -const char * const ReportDescParserBase::sportsCtrlTitles1[] PROGMEM = { - pstrUsageOar, - pstrUsageSlope, - pstrUsageRate, - pstrUsageStickSpeed, - pstrUsageStickFaceAngle, - pstrUsageStickHeelToe, - pstrUsageStickFollowThough, - pstrUsageStickTempo, - pstrUsageStickType, - pstrUsageStickHeight -}; -const char * const ReportDescParserBase::sportsCtrlTitles2[] PROGMEM = { - pstrUsagePutter, - pstrUsage1Iron, - pstrUsage2Iron, - pstrUsage3Iron, - pstrUsage4Iron, - pstrUsage5Iron, - pstrUsage6Iron, - pstrUsage7Iron, - pstrUsage8Iron, - pstrUsage9Iron, - pstrUsage10Iron, - pstrUsage11Iron, - pstrUsageSandWedge, - pstrUsageLoftWedge, - pstrUsagePowerWedge, - pstrUsage1Wood, - pstrUsage3Wood, - pstrUsage5Wood, - pstrUsage7Wood, - pstrUsage9Wood -}; -const char * const ReportDescParserBase::gameTitles0[] PROGMEM = { - pstrUsage3DGameController, - pstrUsagePinballDevice, - pstrUsageGunDevice -}; -const char * const ReportDescParserBase::gameTitles1[] PROGMEM = { - pstrUsagePointOfView, - pstrUsageTurnRightLeft, - pstrUsagePitchForwardBackward, - pstrUsageRollRightLeft, - pstrUsageMoveRightLeft, - pstrUsageMoveForwardBackward, - pstrUsageMoveUpDown, - pstrUsageLeanRightLeft, - pstrUsageLeanForwardBackward, - pstrUsageHeightOfPOV, - pstrUsageFlipper, - pstrUsageSecondaryFlipper, - pstrUsageBump, - pstrUsageNewGame, - pstrUsageShootBall, - pstrUsagePlayer, - pstrUsageGunBolt, - pstrUsageGunClip, - pstrUsageGunSelector, - pstrUsageGunSingleShot, - pstrUsageGunBurst, - pstrUsageGunAutomatic, - pstrUsageGunSafety, - pstrUsageGamepadFireJump, - pstrUsageGamepadTrigger -}; -const char * const ReportDescParserBase::genDevCtrlTitles[] PROGMEM = { - pstrUsageBatteryStrength, - pstrUsageWirelessChannel, - pstrUsageWirelessID, - pstrUsageDiscoverWirelessControl, - pstrUsageSecurityCodeCharEntered, - pstrUsageSecurityCodeCharErased, - pstrUsageSecurityCodeCleared -}; -const char * const ReportDescParserBase::ledTitles[] PROGMEM = { - pstrUsageNumLock, - pstrUsageCapsLock, - pstrUsageScrollLock, - pstrUsageCompose, - pstrUsageKana, - pstrUsagePower, - pstrUsageShift, - pstrUsageDoNotDisturb, - pstrUsageMute, - pstrUsageToneEnable, - pstrUsageHighCutFilter, - pstrUsageLowCutFilter, - pstrUsageEqualizerEnable, - pstrUsageSoundFieldOn, - pstrUsageSurroundOn, - pstrUsageRepeat, - pstrUsageStereo, - pstrUsageSamplingRateDetect, - pstrUsageSpinning, - pstrUsageCAV, - pstrUsageCLV, - pstrUsageRecordingFormatDetect, - pstrUsageOffHook, - pstrUsageRing, - pstrUsageMessageWaiting, - pstrUsageDataMode, - pstrUsageBatteryOperation, - pstrUsageBatteryOK, - pstrUsageBatteryLow, - pstrUsageSpeaker, - pstrUsageHeadSet, - pstrUsageHold, - pstrUsageMicrophone, - pstrUsageCoverage, - pstrUsageNightMode, - pstrUsageSendCalls, - pstrUsageCallPickup, - pstrUsageConference, - pstrUsageStandBy, - pstrUsageCameraOn, - pstrUsageCameraOff, - pstrUsageOnLine, - pstrUsageOffLine, - pstrUsageBusy, - pstrUsageReady, - pstrUsagePaperOut, - pstrUsagePaperJam, - pstrUsageRemote, - pstrUsageForward, - pstrUsageReverse, - pstrUsageStop, - pstrUsageRewind, - pstrUsageFastForward, - pstrUsagePlay, - pstrUsagePause, - pstrUsageRecord, - pstrUsageError, - pstrUsageSelectedIndicator, - pstrUsageInUseIndicator, - pstrUsageMultiModeIndicator, - pstrUsageIndicatorOn, - pstrUsageIndicatorFlash, - pstrUsageIndicatorSlowBlink, - pstrUsageIndicatorFastBlink, - pstrUsageIndicatorOff, - pstrUsageFlashOnTime, - pstrUsageSlowBlinkOnTime, - pstrUsageSlowBlinkOffTime, - pstrUsageFastBlinkOnTime, - pstrUsageFastBlinkOffTime, - pstrUsageIndicatorColor, - pstrUsageIndicatorRed, - pstrUsageIndicatorGreen, - pstrUsageIndicatorAmber, - pstrUsageGenericIndicator, - pstrUsageSystemSuspend, - pstrUsageExternalPowerConnected -}; -const char * const ReportDescParserBase::telTitles0 [] PROGMEM = { - pstrUsagePhone, - pstrUsageAnsweringMachine, - pstrUsageMessageControls, - pstrUsageHandset, - pstrUsageHeadset, - pstrUsageTelephonyKeyPad, - pstrUsageProgrammableButton -}; -const char * const ReportDescParserBase::telTitles1 [] PROGMEM = { - pstrUsageHookSwitch, - pstrUsageFlash, - pstrUsageFeature, - pstrUsageHold, - pstrUsageRedial, - pstrUsageTransfer, - pstrUsageDrop, - pstrUsagePark, - pstrUsageForwardCalls, - pstrUsageAlternateFunction, - pstrUsageLine, - pstrUsageSpeakerPhone, - pstrUsageConference, - pstrUsageRingEnable, - pstrUsageRingSelect, - pstrUsagePhoneMute, - pstrUsageCallerID, - pstrUsageSend -}; -const char * const ReportDescParserBase::telTitles2 [] PROGMEM = { - pstrUsageSpeedDial, - pstrUsageStoreNumber, - pstrUsageRecallNumber, - pstrUsagePhoneDirectory -}; -const char * const ReportDescParserBase::telTitles3 [] PROGMEM = { - pstrUsageVoiceMail, - pstrUsageScreenCalls, - pstrUsageDoNotDisturb, - pstrUsageMessage, - pstrUsageAnswerOnOff -}; -const char * const ReportDescParserBase::telTitles4 [] PROGMEM = { - pstrUsageInsideDialTone, - pstrUsageOutsideDialTone, - pstrUsageInsideRingTone, - pstrUsageOutsideRingTone, - pstrUsagePriorityRingTone, - pstrUsageInsideRingback, - pstrUsagePriorityRingback, - pstrUsageLineBusyTone, - pstrUsageReorderTone, - pstrUsageCallWaitingTone, - pstrUsageConfirmationTone1, - pstrUsageConfirmationTone2, - pstrUsageTonesOff, - pstrUsageOutsideRingback, - pstrUsageRinger -}; -const char * const ReportDescParserBase::telTitles5 [] PROGMEM = { - pstrUsagePhoneKey0, - pstrUsagePhoneKey1, - pstrUsagePhoneKey2, - pstrUsagePhoneKey3, - pstrUsagePhoneKey4, - pstrUsagePhoneKey5, - pstrUsagePhoneKey6, - pstrUsagePhoneKey7, - pstrUsagePhoneKey8, - pstrUsagePhoneKey9, - pstrUsagePhoneKeyStar, - pstrUsagePhoneKeyPound, - pstrUsagePhoneKeyA, - pstrUsagePhoneKeyB, - pstrUsagePhoneKeyC, - pstrUsagePhoneKeyD -}; -const char * const ReportDescParserBase::consTitles0[] PROGMEM = { - pstrUsageConsumerControl, - pstrUsageNumericKeyPad, - pstrUsageProgrammableButton, - pstrUsageMicrophone, - pstrUsageHeadphone, - pstrUsageGraphicEqualizer -}; -const char * const ReportDescParserBase::consTitles1[] PROGMEM = { - pstrUsagePlus10, - pstrUsagePlus100, - pstrUsageAMPM -}; -const char * const ReportDescParserBase::consTitles2[] PROGMEM = { - pstrUsagePower, - pstrUsageReset, - pstrUsageSleep, - pstrUsageSleepAfter, - pstrUsageSleepMode, - pstrUsageIllumination, - pstrUsageFunctionButtons - -}; -const char * const ReportDescParserBase::consTitles3[] PROGMEM = { - pstrUsageMenu, - pstrUsageMenuPick, - pstrUsageMenuUp, - pstrUsageMenuDown, - pstrUsageMenuLeft, - pstrUsageMenuRight, - pstrUsageMenuEscape, - pstrUsageMenuValueIncrease, - pstrUsageMenuValueDecrease -}; -const char * const ReportDescParserBase::consTitles4[] PROGMEM = { - pstrUsageDataOnScreen, - pstrUsageClosedCaption, - pstrUsageClosedCaptionSelect, - pstrUsageVCRTV, - pstrUsageBroadcastMode, - pstrUsageSnapshot, - pstrUsageStill -}; -const char * const ReportDescParserBase::consTitles5[] PROGMEM = { - pstrUsageSelection, - pstrUsageAssignSelection, - pstrUsageModeStep, - pstrUsageRecallLast, - pstrUsageEnterChannel, - pstrUsageOrderMovie, - pstrUsageChannel, - pstrUsageMediaSelection, - pstrUsageMediaSelectComputer, - pstrUsageMediaSelectTV, - pstrUsageMediaSelectWWW, - pstrUsageMediaSelectDVD, - pstrUsageMediaSelectTelephone, - pstrUsageMediaSelectProgramGuide, - pstrUsageMediaSelectVideoPhone, - pstrUsageMediaSelectGames, - pstrUsageMediaSelectMessages, - pstrUsageMediaSelectCD, - pstrUsageMediaSelectVCR, - pstrUsageMediaSelectTuner, - pstrUsageQuit, - pstrUsageHelp, - pstrUsageMediaSelectTape, - pstrUsageMediaSelectCable, - pstrUsageMediaSelectSatellite, - pstrUsageMediaSelectSecurity, - pstrUsageMediaSelectHome, - pstrUsageMediaSelectCall, - pstrUsageChannelIncrement, - pstrUsageChannelDecrement, - pstrUsageMediaSelectSAP, - pstrUsagePageReserved, - pstrUsageVCRPlus, - pstrUsageOnce, - pstrUsageDaily, - pstrUsageWeekly, - pstrUsageMonthly -}; -const char * const ReportDescParserBase::consTitles6[] PROGMEM = { - pstrUsagePlay, - pstrUsagePause, - pstrUsageRecord, - pstrUsageFastForward, - pstrUsageRewind, - pstrUsageScanNextTrack, - pstrUsageScanPreviousTrack, - pstrUsageStop, - pstrUsageEject, - pstrUsageRandomPlay, - pstrUsageSelectDisk, - pstrUsageEnterDisk, - pstrUsageRepeat, - pstrUsageTracking, - pstrUsageTrackNormal, - pstrUsageSlowTracking, - pstrUsageFrameForward, - pstrUsageFrameBackwards, - pstrUsageMark, - pstrUsageClearMark, - pstrUsageRepeatFromMark, - pstrUsageReturnToMark, - pstrUsageSearchMarkForward, - pstrUsageSearchMarkBackwards, - pstrUsageCounterReset, - pstrUsageShowCounter, - pstrUsageTrackingIncrement, - pstrUsageTrackingDecrement, - pstrUsageStopEject, - pstrUsagePlayPause, - pstrUsagePlaySkip -}; -const char * const ReportDescParserBase::consTitles7[] PROGMEM = { - pstrUsageVolume, - pstrUsageBalance, - pstrUsageMute, - pstrUsageBass, - pstrUsageTreble, - pstrUsageBassBoost, - pstrUsageSurroundMode, - pstrUsageLoudness, - pstrUsageMPX, - pstrUsageVolumeIncrement, - pstrUsageVolumeDecrement -}; -const char * const ReportDescParserBase::consTitles8[] PROGMEM = { - pstrUsageSpeedSelect, - pstrUsagePlaybackSpeed, - pstrUsageStandardPlay, - pstrUsageLongPlay, - pstrUsageExtendedPlay, - pstrUsageSlow -}; -const char * const ReportDescParserBase::consTitles9[] PROGMEM = { - pstrUsageFanEnable, - pstrUsageFanSpeed, - pstrUsageLightEnable, - pstrUsageLightIlluminationLevel, - pstrUsageClimateControlEnable, - pstrUsageRoomTemperature, - pstrUsageSecurityEnable, - pstrUsageFireAlarm, - pstrUsagePoliceAlarm, - pstrUsageProximity, - pstrUsageMotion, - pstrUsageDuresAlarm, - pstrUsageHoldupAlarm, - pstrUsageMedicalAlarm -}; -const char * const ReportDescParserBase::consTitlesA[] PROGMEM = { - pstrUsageBalanceRight, - pstrUsageBalanceLeft, - pstrUsageBassIncrement, - pstrUsageBassDecrement, - pstrUsageTrebleIncrement, - pstrUsageTrebleDecrement -}; -const char * const ReportDescParserBase::consTitlesB[] PROGMEM = { - pstrUsageSpeakerSystem, - pstrUsageChannelLeft, - pstrUsageChannelRight, - pstrUsageChannelCenter, - pstrUsageChannelFront, - pstrUsageChannelCenterFront, - pstrUsageChannelSide, - pstrUsageChannelSurround, - pstrUsageChannelLowFreqEnhancement, - pstrUsageChannelTop, - pstrUsageChannelUnknown -}; -const char * const ReportDescParserBase::consTitlesC[] PROGMEM = { - pstrUsageSubChannel, - pstrUsageSubChannelIncrement, - pstrUsageSubChannelDecrement, - pstrUsageAlternateAudioIncrement, - pstrUsageAlternateAudioDecrement -}; -const char * const ReportDescParserBase::consTitlesD[] PROGMEM = { - pstrUsageApplicationLaunchButtons, - pstrUsageALLaunchButtonConfigTool, - pstrUsageALProgrammableButton, - pstrUsageALConsumerControlConfig, - pstrUsageALWordProcessor, - pstrUsageALTextEditor, - pstrUsageALSpreadsheet, - pstrUsageALGraphicsEditor, - pstrUsageALPresentationApp, - pstrUsageALDatabaseApp, - pstrUsageALEmailReader, - pstrUsageALNewsreader, - pstrUsageALVoicemail, - pstrUsageALContactsAddressBook, - pstrUsageALCalendarSchedule, - pstrUsageALTaskProjectManager, - pstrUsageALLogJournalTimecard, - pstrUsageALCheckbookFinance, - pstrUsageALCalculator, - pstrUsageALAVCapturePlayback, - pstrUsageALLocalMachineBrowser, - pstrUsageALLANWANBrow, - pstrUsageALInternetBrowser, - pstrUsageALRemoteNetISPConnect, - pstrUsageALNetworkConference, - pstrUsageALNetworkChat, - pstrUsageALTelephonyDialer, - pstrUsageALLogon, - pstrUsageALLogoff, - pstrUsageALLogonLogoff, - pstrUsageALTermLockScrSav, - pstrUsageALControlPannel, - pstrUsageALCommandLineProcessorRun, - pstrUsageALProcessTaskManager, - pstrUsageALSelectTaskApplication, - pstrUsageALNextTaskApplication, - pstrUsageALPreviousTaskApplication, - pstrUsageALPreemptiveHaltTaskApp, - pstrUsageALIntegratedHelpCenter, - pstrUsageALDocuments, - pstrUsageALThesaurus, - pstrUsageALDictionary, - pstrUsageALDesktop, - pstrUsageALSpellCheck, - pstrUsageALGrammarCheck, - pstrUsageALWirelessStatus, - pstrUsageALKeyboardLayout, - pstrUsageALVirusProtection, - pstrUsageALEncryption, - pstrUsageALScreenSaver, - pstrUsageALAlarms, - pstrUsageALClock, - pstrUsageALFileBrowser, - pstrUsageALPowerStatus, - pstrUsageALImageBrowser, - pstrUsageALAudioBrowser, - pstrUsageALMovieBrowser, - pstrUsageALDigitalRightsManager, - pstrUsageALDigitalWallet, - pstrUsagePageReserved, - pstrUsageALInstantMessaging, - pstrUsageALOEMFeaturesBrowser, - pstrUsageALOEMHelp, - pstrUsageALOnlineCommunity, - pstrUsageALEntertainmentContentBrow, - pstrUsageALOnlineShoppingBrowser, - pstrUsageALSmartCardInfoHelp, - pstrUsageALMarketMonitorFinBrowser, - pstrUsageALCustomCorpNewsBrowser, - pstrUsageALOnlineActivityBrowser, - pstrUsageALResearchSearchBrowser, - pstrUsageALAudioPlayer -}; -const char * const ReportDescParserBase::consTitlesE[] PROGMEM = { - pstrUsageGenericGUIAppControls, - pstrUsageACNew, - pstrUsageACOpen, - pstrUsageACClose, - pstrUsageACExit, - pstrUsageACMaximize, - pstrUsageACMinimize, - pstrUsageACSave, - pstrUsageACPrint, - pstrUsageACProperties, - pstrUsageACUndo, - pstrUsageACCopy, - pstrUsageACCut, - pstrUsageACPaste, - pstrUsageACSelectAll, - pstrUsageACFind, - pstrUsageACFindAndReplace, - pstrUsageACSearch, - pstrUsageACGoto, - pstrUsageACHome, - pstrUsageACBack, - pstrUsageACForward, - pstrUsageACStop, - pstrUsageACRefresh, - pstrUsageACPreviousLink, - pstrUsageACNextLink, - pstrUsageACBookmarks, - pstrUsageACHistory, - pstrUsageACSubscriptions, - pstrUsageACZoomIn, - pstrUsageACZoomOut, - pstrUsageACZoom, - pstrUsageACFullScreenView, - pstrUsageACNormalView, - pstrUsageACViewToggle, - pstrUsageACScrollUp, - pstrUsageACScrollDown, - pstrUsageACScroll, - pstrUsageACPanLeft, - pstrUsageACPanRight, - pstrUsageACPan, - pstrUsageACNewWindow, - pstrUsageACTileHoriz, - pstrUsageACTileVert, - pstrUsageACFormat, - pstrUsageACEdit, - pstrUsageACBold, - pstrUsageACItalics, - pstrUsageACUnderline, - pstrUsageACStrikethrough, - pstrUsageACSubscript, - pstrUsageACSuperscript, - pstrUsageACAllCaps, - pstrUsageACRotate, - pstrUsageACResize, - pstrUsageACFlipHorizontal, - pstrUsageACFlipVertical, - pstrUsageACMirrorHorizontal, - pstrUsageACMirrorVertical, - pstrUsageACFontSelect, - pstrUsageACFontColor, - pstrUsageACFontSize, - pstrUsageACJustifyLeft, - pstrUsageACJustifyCenterH, - pstrUsageACJustifyRight, - pstrUsageACJustifyBlockH, - pstrUsageACJustifyTop, - pstrUsageACJustifyCenterV, - pstrUsageACJustifyBottom, - pstrUsageACJustifyBlockV, - pstrUsageACIndentDecrease, - pstrUsageACIndentIncrease, - pstrUsageACNumberedList, - pstrUsageACRestartNumbering, - pstrUsageACBulletedList, - pstrUsageACPromote, - pstrUsageACDemote, - pstrUsageACYes, - pstrUsageACNo, - pstrUsageACCancel, - pstrUsageACCatalog, - pstrUsageACBuyChkout, - pstrUsageACAddToCart, - pstrUsageACExpand, - pstrUsageACExpandAll, - pstrUsageACCollapse, - pstrUsageACCollapseAll, - pstrUsageACPrintPreview, - pstrUsageACPasteSpecial, - pstrUsageACInsertMode, - pstrUsageACDelete, - pstrUsageACLock, - pstrUsageACUnlock, - pstrUsageACProtect, - pstrUsageACUnprotect, - pstrUsageACAttachComment, - pstrUsageACDeleteComment, - pstrUsageACViewComment, - pstrUsageACSelectWord, - pstrUsageACSelectSentence, - pstrUsageACSelectParagraph, - pstrUsageACSelectColumn, - pstrUsageACSelectRow, - pstrUsageACSelectTable, - pstrUsageACSelectObject, - pstrUsageACRedoRepeat, - pstrUsageACSort, - pstrUsageACSortAscending, - pstrUsageACSortDescending, - pstrUsageACFilter, - pstrUsageACSetClock, - pstrUsageACViewClock, - pstrUsageACSelectTimeZone, - pstrUsageACEditTimeZone, - pstrUsageACSetAlarm, - pstrUsageACClearAlarm, - pstrUsageACSnoozeAlarm, - pstrUsageACResetAlarm, - pstrUsageACSyncronize, - pstrUsageACSendReceive, - pstrUsageACSendTo, - pstrUsageACReply, - pstrUsageACReplyAll, - pstrUsageACForwardMessage, - pstrUsageACSend, - pstrUsageACAttachFile, - pstrUsageACUpload, - pstrUsageACDownload, - pstrUsageACSetBorders, - pstrUsageACInsertRow, - pstrUsageACInsertColumn, - pstrUsageACInsertFile, - pstrUsageACInsertPicture, - pstrUsageACInsertObject, - pstrUsageACInsertSymbol, - pstrUsageACSaveAndClose, - pstrUsageACRename, - pstrUsageACMerge, - pstrUsageACSplit, - pstrUsageACDistributeHorizontaly, - pstrUsageACDistributeVerticaly -}; -const char * const ReportDescParserBase::digitTitles0[] PROGMEM = { - pstrUsageDigitizer, - pstrUsagePen, - pstrUsageLightPen, - pstrUsageTouchScreen, - pstrUsageTouchPad, - pstrUsageWhiteBoard, - pstrUsageCoordinateMeasuringMachine, - pstrUsage3DDigitizer, - pstrUsageStereoPlotter, - pstrUsageArticulatedArm, - pstrUsageArmature, - pstrUsageMultiplePointDigitizer, - pstrUsageFreeSpaceWand -}; -const char * const ReportDescParserBase::digitTitles1[] PROGMEM = { - pstrUsageStylus, - pstrUsagePuck, - pstrUsageFinger - -}; -const char * const ReportDescParserBase::digitTitles2[] PROGMEM = { - pstrUsageTipPressure, - pstrUsageBarrelPressure, - pstrUsageInRange, - pstrUsageTouch, - pstrUsageUntouch, - pstrUsageTap, - pstrUsageQuality, - pstrUsageDataValid, - pstrUsageTransducerIndex, - pstrUsageTabletFunctionKeys, - pstrUsageProgramChangeKeys, - pstrUsageBatteryStrength, - pstrUsageInvert, - pstrUsageXTilt, - pstrUsageYTilt, - pstrUsageAzimuth, - pstrUsageAltitude, - pstrUsageTwist, - pstrUsageTipSwitch, - pstrUsageSecondaryTipSwitch, - pstrUsageBarrelSwitch, - pstrUsageEraser, - pstrUsageTabletPick -}; -const char * const ReportDescParserBase::aplphanumTitles0[] PROGMEM = { - pstrUsageAlphanumericDisplay, - pstrUsageBitmappedDisplay -}; -const char * const ReportDescParserBase::aplphanumTitles1[] PROGMEM = { - pstrUsageDisplayAttributesReport, - pstrUsageASCIICharacterSet, - pstrUsageDataReadBack, - pstrUsageFontReadBack, - pstrUsageDisplayControlReport, - pstrUsageClearDisplay, - pstrUsageDisplayEnable, - pstrUsageScreenSaverDelay, - pstrUsageScreenSaverEnable, - pstrUsageVerticalScroll, - pstrUsageHorizontalScroll, - pstrUsageCharacterReport, - pstrUsageDisplayData, - pstrUsageDisplayStatus, - pstrUsageStatusNotReady, - pstrUsageStatusReady, - pstrUsageErrorNotALoadableCharacter, - pstrUsageErrorFotDataCanNotBeRead, - pstrUsageCursorPositionReport, - pstrUsageRow, - pstrUsageColumn, - pstrUsageRows, - pstrUsageColumns, - pstrUsageCursorPixelPosition, - pstrUsageCursorMode, - pstrUsageCursorEnable, - pstrUsageCursorBlink, - pstrUsageFontReport, - pstrUsageFontData, - pstrUsageCharacterWidth, - pstrUsageCharacterHeight, - pstrUsageCharacterSpacingHorizontal, - pstrUsageCharacterSpacingVertical, - pstrUsageUnicodeCharset, - pstrUsageFont7Segment, - pstrUsage7SegmentDirectMap, - pstrUsageFont14Segment, - pstrUsage14SegmentDirectMap, - pstrUsageDisplayBrightness, - pstrUsageDisplayContrast, - pstrUsageCharacterAttribute, - pstrUsageAttributeReadback, - pstrUsageAttributeData, - pstrUsageCharAttributeEnhance, - pstrUsageCharAttributeUnderline, - pstrUsageCharAttributeBlink -}; -const char * const ReportDescParserBase::aplphanumTitles2[] PROGMEM = { - pstrUsageBitmapSizeX, - pstrUsageBitmapSizeY, - pstrUsagePageReserved, - pstrUsageBitDepthFormat, - pstrUsageDisplayOrientation, - pstrUsagePaletteReport, - pstrUsagePaletteDataSize, - pstrUsagePaletteDataOffset, - pstrUsagePaletteData, - pstrUsageBlitReport, - pstrUsageBlitRectangleX1, - pstrUsageBlitRectangleY1, - pstrUsageBlitRectangleX2, - pstrUsageBlitRectangleY2, - pstrUsageBlitData, - pstrUsageSoftButton, - pstrUsageSoftButtonID, - pstrUsageSoftButtonSide, - pstrUsageSoftButtonOffset1, - pstrUsageSoftButtonOffset2, - pstrUsageSoftButtonReport -}; -const char * const ReportDescParserBase::medInstrTitles0[] PROGMEM = { - pstrUsageVCRAcquisition, - pstrUsageFreezeThaw, - pstrUsageClipStore, - pstrUsageUpdate, - pstrUsageNext, - pstrUsageSave, - pstrUsagePrint, - pstrUsageMicrophoneEnable -}; -const char * const ReportDescParserBase::medInstrTitles1[] PROGMEM = { - pstrUsageCine, - pstrUsageTransmitPower, - pstrUsageVolume, - pstrUsageFocus, - pstrUsageDepth -}; -const char * const ReportDescParserBase::medInstrTitles2[] PROGMEM = { - pstrUsageSoftStepPrimary, - pstrUsageSoftStepSecondary -}; -const char * const ReportDescParserBase::medInstrTitles3[] PROGMEM = { - pstrUsageZoomSelect, - pstrUsageZoomAdjust, - pstrUsageSpectralDopplerModeSelect, - pstrUsageSpectralDopplerModeAdjust, - pstrUsageColorDopplerModeSelect, - pstrUsageColorDopplerModeAdjust, - pstrUsageMotionModeSelect, - pstrUsageMotionModeAdjust, - pstrUsage2DModeSelect, - pstrUsage2DModeAdjust -}; -const char * const ReportDescParserBase::medInstrTitles4[] PROGMEM = { - pstrUsageSoftControlSelect, - pstrUsageSoftControlAdjust -}; - -void ReportDescParserBase::Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset) { - uint16_t cntdn = (uint16_t)len; - uint8_t *p = (uint8_t*)pbuf; - - - totalSize = 0; - - while(cntdn) { - //USB_HOST_SERIAL.println(""); - //PrintHex(offset + len - cntdn); - //USB_HOST_SERIAL.print(":"); - - ParseItem(&p, &cntdn); - - //if (ParseItem(&p, &cntdn)) - // return; - } - //USBTRACE2("Total:", totalSize); -} - -void ReportDescParserBase::PrintValue(uint8_t *p, uint8_t len) { - E_Notify(PSTR("("), 0x80); - for(; len; p++, len--) - PrintHex (*p, 0x80); - E_Notify(PSTR(")"), 0x80); -} - -void ReportDescParserBase::PrintByteValue(uint8_t data) { - E_Notify(PSTR("("), 0x80); - PrintHex (data, 0x80); - E_Notify(PSTR(")"), 0x80); -} - -void ReportDescParserBase::PrintItemTitle(uint8_t prefix) { - switch(prefix & (TYPE_MASK | TAG_MASK)) { - case (TYPE_GLOBAL | TAG_GLOBAL_PUSH): - E_Notify(PSTR("\r\nPush"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_POP): - E_Notify(PSTR("\r\nPop"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_USAGEPAGE): - E_Notify(PSTR("\r\nUsage Page"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_LOGICALMIN): - E_Notify(PSTR("\r\nLogical Min"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_LOGICALMAX): - E_Notify(PSTR("\r\nLogical Max"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_PHYSMIN): - E_Notify(PSTR("\r\nPhysical Min"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_PHYSMAX): - E_Notify(PSTR("\r\nPhysical Max"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_UNITEXP): - E_Notify(PSTR("\r\nUnit Exp"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_UNIT): - E_Notify(PSTR("\r\nUnit"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_REPORTSIZE): - E_Notify(PSTR("\r\nReport Size"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_REPORTCOUNT): - E_Notify(PSTR("\r\nReport Count"), 0x80); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_REPORTID): - E_Notify(PSTR("\r\nReport Id"), 0x80); - break; - case (TYPE_LOCAL | TAG_LOCAL_USAGE): - E_Notify(PSTR("\r\nUsage"), 0x80); - break; - case (TYPE_LOCAL | TAG_LOCAL_USAGEMIN): - E_Notify(PSTR("\r\nUsage Min"), 0x80); - break; - case (TYPE_LOCAL | TAG_LOCAL_USAGEMAX): - E_Notify(PSTR("\r\nUsage Max"), 0x80); - break; - case (TYPE_MAIN | TAG_MAIN_COLLECTION): - E_Notify(PSTR("\r\nCollection"), 0x80); - break; - case (TYPE_MAIN | TAG_MAIN_ENDCOLLECTION): - E_Notify(PSTR("\r\nEnd Collection"), 0x80); - break; - case (TYPE_MAIN | TAG_MAIN_INPUT): - E_Notify(PSTR("\r\nInput"), 0x80); - break; - case (TYPE_MAIN | TAG_MAIN_OUTPUT): - E_Notify(PSTR("\r\nOutput"), 0x80); - break; - case (TYPE_MAIN | TAG_MAIN_FEATURE): - E_Notify(PSTR("\r\nFeature"), 0x80); - break; - } // switch (**pp & (TYPE_MASK | TAG_MASK)) -} - -uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint16_t *pcntdn) { - //uint8_t ret = enErrorSuccess; - //reinterpret_cast<>(varBuffer); - switch(itemParseState) { - case 0: - if(**pp == HID_LONG_ITEM_PREFIX) - USBTRACE("\r\nLONG\r\n"); - else { - uint8_t size = ((**pp) & DATA_SIZE_MASK); - - itemPrefix = (**pp); - itemSize = 1 + ((size == DATA_SIZE_4) ? 4 : size); - - PrintItemTitle(itemPrefix); - } - (*pp)++; - (*pcntdn)--; - itemSize--; - itemParseState = 1; - - if(!itemSize) - break; - - if(!pcntdn) - return enErrorIncomplete; - case 1: - //USBTRACE2("\r\niSz:",itemSize); - - theBuffer.valueSize = itemSize; - valParser.Initialize(&theBuffer); - itemParseState = 2; - case 2: - if(!valParser.Parse(pp, pcntdn)) - return enErrorIncomplete; - itemParseState = 3; - case 3: - { - uint8_t data = *((uint8_t*)varBuffer); - - switch(itemPrefix & (TYPE_MASK | TAG_MASK)) { - case (TYPE_LOCAL | TAG_LOCAL_USAGE): - if(pfUsage) { - if(theBuffer.valueSize > 1) { - uint16_t* ui16 = reinterpret_cast(varBuffer); - pfUsage(*ui16); - } else - pfUsage(data); - } - break; - case (TYPE_GLOBAL | TAG_GLOBAL_REPORTSIZE): - rptSize = data; - PrintByteValue(data); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_REPORTCOUNT): - rptCount = data; - PrintByteValue(data); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_LOGICALMIN): - case (TYPE_GLOBAL | TAG_GLOBAL_LOGICALMAX): - case (TYPE_GLOBAL | TAG_GLOBAL_PHYSMIN): - case (TYPE_GLOBAL | TAG_GLOBAL_PHYSMAX): - case (TYPE_GLOBAL | TAG_GLOBAL_REPORTID): - case (TYPE_LOCAL | TAG_LOCAL_USAGEMIN): - case (TYPE_LOCAL | TAG_LOCAL_USAGEMAX): - case (TYPE_GLOBAL | TAG_GLOBAL_UNITEXP): - case (TYPE_GLOBAL | TAG_GLOBAL_UNIT): - PrintValue(varBuffer, theBuffer.valueSize); - break; - case (TYPE_GLOBAL | TAG_GLOBAL_PUSH): - case (TYPE_GLOBAL | TAG_GLOBAL_POP): - break; - case (TYPE_GLOBAL | TAG_GLOBAL_USAGEPAGE): - SetUsagePage(data); - PrintUsagePage(data); - PrintByteValue(data); - break; - case (TYPE_MAIN | TAG_MAIN_COLLECTION): - case (TYPE_MAIN | TAG_MAIN_ENDCOLLECTION): - switch(data) { - case 0x00: - E_Notify(PSTR(" Physical"), 0x80); - break; - case 0x01: - E_Notify(PSTR(" Application"), 0x80); - break; - case 0x02: - E_Notify(PSTR(" Logical"), 0x80); - break; - case 0x03: - E_Notify(PSTR(" Report"), 0x80); - break; - case 0x04: - E_Notify(PSTR(" Named Array"), 0x80); - break; - case 0x05: - E_Notify(PSTR(" Usage Switch"), 0x80); - break; - case 0x06: - E_Notify(PSTR(" Usage Modifier"), 0x80); - break; - default: - E_Notify(PSTR(" Vendor Defined("), 0x80); - PrintHex (data, 0x80); - E_Notify(PSTR(")"), 0x80); - } - break; - case (TYPE_MAIN | TAG_MAIN_INPUT): - case (TYPE_MAIN | TAG_MAIN_OUTPUT): - case (TYPE_MAIN | TAG_MAIN_FEATURE): - totalSize += (uint16_t)rptSize * (uint16_t)rptCount; - rptSize = 0; - rptCount = 0; - E_Notify(PSTR("("), 0x80); - PrintBin (data, 0x80); - E_Notify(PSTR(")"), 0x80); - break; - } // switch (**pp & (TYPE_MASK | TAG_MASK)) - } - } // switch (itemParseState) - itemParseState = 0; - return enErrorSuccess; -} - -ReportDescParserBase::UsagePageFunc ReportDescParserBase::usagePageFunctions[] /*PROGMEM*/ = { - &ReportDescParserBase::PrintGenericDesktopPageUsage, - &ReportDescParserBase::PrintSimulationControlsPageUsage, - &ReportDescParserBase::PrintVRControlsPageUsage, - &ReportDescParserBase::PrintSportsControlsPageUsage, - &ReportDescParserBase::PrintGameControlsPageUsage, - &ReportDescParserBase::PrintGenericDeviceControlsPageUsage, - NULL, // Keyboard/Keypad - &ReportDescParserBase::PrintLEDPageUsage, - &ReportDescParserBase::PrintButtonPageUsage, - &ReportDescParserBase::PrintOrdinalPageUsage, - &ReportDescParserBase::PrintTelephonyPageUsage, - &ReportDescParserBase::PrintConsumerPageUsage, - &ReportDescParserBase::PrintDigitizerPageUsage, - NULL, // Reserved - NULL, // PID - NULL // Unicode -}; - -void ReportDescParserBase::SetUsagePage(uint16_t page) { - pfUsage = NULL; - - if(VALUE_BETWEEN(page, 0x00, 0x11)) { - pfUsage = (usagePageFunctions[page - 1]); - - } else { - switch(page) { - case 0x14: - pfUsage = &ReportDescParserBase::PrintAlphanumDisplayPageUsage; - break; - case 0x40: - pfUsage = &ReportDescParserBase::PrintMedicalInstrumentPageUsage; - break; - } - } -} - -void ReportDescParserBase::PrintUsagePage(uint16_t page) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(page, 0x00, 0x11, w, E_Notify, usagePageTitles0, 0x80) - else output_if_between(page, 0x8b, 0x92, w, E_Notify, usagePageTitles1, 0x80) - else if(VALUE_BETWEEN(page, 0x7f, 0x84)) - E_Notify(pstrUsagePageMonitor, 0x80); - else if(VALUE_BETWEEN(page, 0x83, 0x8c)) - E_Notify(pstrUsagePagePower, 0x80); - else if(page > 0xfeff /* && page <= 0xffff */) - E_Notify(pstrUsagePageVendorDefined, 0x80); - else - switch(page) { - case 0x14: - E_Notify(pstrUsagePageAlphaNumericDisplay, 0x80); - break; - case 0x40: - E_Notify(pstrUsagePageMedicalInstruments, 0x80); - break; - default: - E_Notify(pstrUsagePageUndefined, 0x80); - } -} - -void ReportDescParserBase::PrintButtonPageUsage(uint16_t usage) { - E_Notify(pstrSpace, 0x80); - E_Notify(PSTR("Btn"), 0x80); - PrintHex (usage, 0x80); - E_Notify(PSTR("\r\n"), 0x80); - //USB_HOST_SERIAL.print(usage, HEX); -} - -void ReportDescParserBase::PrintOrdinalPageUsage(uint16_t usage) { - E_Notify(pstrSpace, 0x80); - E_Notify(PSTR("Inst"), 0x80); - // Sorry, HEX for now... - PrintHex (usage, 0x80); - E_Notify(PSTR("\r\n"), 0x80); - //USB_HOST_SERIAL.print(usage, DEC); -} - -void ReportDescParserBase::PrintGenericDesktopPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x0a, w, E_Notify, genDesktopTitles0, 0x80) - else output_if_between(usage, 0x2f, 0x49, w, E_Notify, genDesktopTitles1, 0x80) - else output_if_between(usage, 0x7f, 0x94, w, E_Notify, genDesktopTitles2, 0x80) - else output_if_between(usage, 0x9f, 0xa9, w, E_Notify, genDesktopTitles3, 0x80) - else output_if_between(usage, 0xaf, 0xb8, w, E_Notify, genDesktopTitles4, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintSimulationControlsPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x0d, w, E_Notify, simuTitles0, 0x80) - else output_if_between(usage, 0x1f, 0x26, w, E_Notify, simuTitles1, 0x80) - else output_if_between(usage, 0xaf, 0xd1, w, E_Notify, simuTitles2, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintVRControlsPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x0b, w, E_Notify, vrTitles0, 0x80) - else output_if_between(usage, 0x1f, 0x22, w, E_Notify, vrTitles1, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintSportsControlsPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x05, w, E_Notify, sportsCtrlTitles0, 0x80) - else output_if_between(usage, 0x2f, 0x3a, w, E_Notify, sportsCtrlTitles1, 0x80) - else output_if_between(usage, 0x4f, 0x64, w, E_Notify, sportsCtrlTitles2, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintGameControlsPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x04, w, E_Notify, gameTitles0, 0x80) - else output_if_between(usage, 0x1f, 0x3a, w, E_Notify, gameTitles1, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintGenericDeviceControlsPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x1f, 0x27, w, E_Notify, genDevCtrlTitles, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintLEDPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x4e, w, E_Notify, ledTitles, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintTelephonyPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x08, w, E_Notify, telTitles0, 0x80) - else output_if_between(usage, 0x1f, 0x32, w, E_Notify, telTitles1, 0x80) - else output_if_between(usage, 0x4f, 0x54, w, E_Notify, telTitles2, 0x80) - else output_if_between(usage, 0x6f, 0x75, w, E_Notify, telTitles3, 0x80) - else output_if_between(usage, 0x8f, 0x9f, w, E_Notify, telTitles4, 0x80) - else output_if_between(usage, 0xaf, 0xc0, w, E_Notify, telTitles5, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintConsumerPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x07, w, E_Notify, consTitles0, 0x80) - else output_if_between(usage, 0x1f, 0x23, w, E_Notify, consTitles1, 0x80) - else output_if_between(usage, 0x2f, 0x37, w, E_Notify, consTitles2, 0x80) - else output_if_between(usage, 0x3f, 0x49, w, E_Notify, consTitles3, 0x80) - else output_if_between(usage, 0x5f, 0x67, w, E_Notify, consTitles4, 0x80) - else output_if_between(usage, 0x7f, 0xa5, w, E_Notify, consTitles5, 0x80) - else output_if_between(usage, 0xaf, 0xcf, w, E_Notify, consTitles6, 0x80) - else output_if_between(usage, 0xdf, 0xeb, w, E_Notify, consTitles7, 0x80) - else output_if_between(usage, 0xef, 0xf6, w, E_Notify, consTitles8, 0x80) - else output_if_between(usage, 0xff, 0x10e, w, E_Notify, consTitles9, 0x80) - else output_if_between(usage, 0x14f, 0x156, w, E_Notify, consTitlesA, 0x80) - else output_if_between(usage, 0x15f, 0x16b, w, E_Notify, consTitlesB, 0x80) - else output_if_between(usage, 0x16f, 0x175, w, E_Notify, consTitlesC, 0x80) - else output_if_between(usage, 0x17f, 0x1c8, w, E_Notify, consTitlesD, 0x80) - else output_if_between(usage, 0x1ff, 0x29d, w, E_Notify, consTitlesE, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintDigitizerPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x0e, w, E_Notify, digitTitles0, 0x80) - else output_if_between(usage, 0x1f, 0x23, w, E_Notify, digitTitles1, 0x80) - else output_if_between(usage, 0x2f, 0x47, w, E_Notify, digitTitles2, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintAlphanumDisplayPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - output_if_between(usage, 0x00, 0x03, w, E_Notify, aplphanumTitles0, 0x80) - else output_if_between(usage, 0x1f, 0x4e, w, E_Notify, aplphanumTitles1, 0x80) - else output_if_between(usage, 0x7f, 0x96, w, E_Notify, digitTitles2, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -void ReportDescParserBase::PrintMedicalInstrumentPageUsage(uint16_t usage) { - const char * const * w; - E_Notify(pstrSpace, 0x80); - - if(usage == 1) E_Notify(pstrUsageMedicalUltrasound, 0x80); - else if(usage == 0x70) - E_Notify(pstrUsageDepthGainCompensation, 0x80); - else output_if_between(usage, 0x1f, 0x28, w, E_Notify, medInstrTitles0, 0x80) - else output_if_between(usage, 0x3f, 0x45, w, E_Notify, medInstrTitles1, 0x80) - else output_if_between(usage, 0x5f, 0x62, w, E_Notify, medInstrTitles2, 0x80) - else output_if_between(usage, 0x7f, 0x8a, w, E_Notify, medInstrTitles3, 0x80) - else output_if_between(usage, 0x9f, 0xa2, w, E_Notify, medInstrTitles4, 0x80) - else E_Notify(pstrUsagePageUndefined, 0x80); -} - -uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint16_t *pcntdn) { - //uint8_t ret = enErrorSuccess; - - switch(itemParseState) { - case 0: - if(**pp == HID_LONG_ITEM_PREFIX) - USBTRACE("\r\nLONG\r\n"); - else { - uint8_t size = ((**pp) & DATA_SIZE_MASK); - itemPrefix = (**pp); - itemSize = 1 + ((size == DATA_SIZE_4) ? 4 : size); - } - (*pp)++; - (*pcntdn)--; - itemSize--; - itemParseState = 1; - - if(!itemSize) - break; - - if(!pcntdn) - return enErrorIncomplete; - case 1: - theBuffer.valueSize = itemSize; - valParser.Initialize(&theBuffer); - itemParseState = 2; - case 2: - if(!valParser.Parse(pp, pcntdn)) - return enErrorIncomplete; - itemParseState = 3; - case 3: - { - uint8_t data = *((uint8_t*)varBuffer); - - switch(itemPrefix & (TYPE_MASK | TAG_MASK)) { - case (TYPE_LOCAL | TAG_LOCAL_USAGE): - if(pfUsage) { - if(theBuffer.valueSize > 1) { - uint16_t* ui16 = reinterpret_cast(varBuffer); - pfUsage(*ui16); - } else - pfUsage(data); - } - break; - case (TYPE_GLOBAL | TAG_GLOBAL_REPORTSIZE): - rptSize = data; - break; - case (TYPE_GLOBAL | TAG_GLOBAL_REPORTCOUNT): - rptCount = data; - break; - case (TYPE_GLOBAL | TAG_GLOBAL_REPORTID): - rptId = data; - break; - case (TYPE_LOCAL | TAG_LOCAL_USAGEMIN): - useMin = data; - break; - case (TYPE_LOCAL | TAG_LOCAL_USAGEMAX): - useMax = data; - break; - case (TYPE_GLOBAL | TAG_GLOBAL_USAGEPAGE): - SetUsagePage(data); - break; - case (TYPE_MAIN | TAG_MAIN_OUTPUT): - case (TYPE_MAIN | TAG_MAIN_FEATURE): - rptSize = 0; - rptCount = 0; - useMin = 0; - useMax = 0; - break; - case (TYPE_MAIN | TAG_MAIN_INPUT): - OnInputItem(data); - - totalSize += (uint16_t)rptSize * (uint16_t)rptCount; - - rptSize = 0; - rptCount = 0; - useMin = 0; - useMax = 0; - break; - } // switch (**pp & (TYPE_MASK | TAG_MASK)) - } - } // switch (itemParseState) - itemParseState = 0; - return enErrorSuccess; -} - -void ReportDescParser2::OnInputItem(uint8_t itm) { - uint8_t byte_offset = (totalSize >> 3); // calculate offset to the next unhandled byte i = (int)(totalCount / 8); - uint32_t tmp = (byte_offset << 3); - uint8_t bit_offset = totalSize - tmp; // number of bits in the current byte already handled - uint8_t *p = pBuf + byte_offset; // current byte pointer - - if(bit_offset) - *p >>= bit_offset; - - uint8_t usage = useMin; - - bool print_usemin_usemax = ((useMin < useMax) && ((itm & 3) == 2) && pfUsage) ? true : false; - - uint8_t bits_of_byte = 8; - - // for each field in field array defined by rptCount - for(uint8_t field = 0; field < rptCount; field++, usage++) { - - union { - uint8_t bResult[4]; - uint16_t wResult[2]; - uint32_t dwResult; - } result; - - result.dwResult = 0; - uint8_t mask = 0; - - if(print_usemin_usemax) - pfUsage(usage); - - // bits_left - number of bits in the field(array of fields, depending on Report Count) left to process - // bits_of_byte - number of bits in current byte left to process - // bits_to_copy - number of bits to copy to result buffer - - // for each bit in a field - for(uint8_t bits_left = rptSize, bits_to_copy = 0; bits_left; - bits_left -= bits_to_copy) { - bits_to_copy = (bits_left > bits_of_byte) ? bits_of_byte : bits_left; - - result.dwResult <<= bits_to_copy; // Result buffer is shifted by the number of bits to be copied into it - - uint8_t val = *p; - - val >>= (8 - bits_of_byte); // Shift by the number of bits already processed - - mask = 0; - - for(uint8_t j = bits_to_copy; j; j--) { - mask <<= 1; - mask |= 1; - } - - result.bResult[0] = (result.bResult[0] | (val & mask)); - - bits_of_byte -= bits_to_copy; - - if(bits_of_byte < 1) { - bits_of_byte = 8; - p++; - } - } - PrintByteValue(result.dwResult); - } - E_Notify(PSTR("\r\n"), 0x80); -} - -void UniversalReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) { - ReportDescParser2 prs(len, buf); - - uint8_t ret = hid->GetReportDescr(0, &prs); - - if(ret) - ErrorMessage (PSTR("GetReportDescr-2"), ret); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/hidescriptorparser.h b/protocol/usb_hid/USB_Host_Shield_2.0/hidescriptorparser.h deleted file mode 100644 index f3b496ff..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/hidescriptorparser.h +++ /dev/null @@ -1,176 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(__HIDDESCRIPTORPARSER_H__) -#define __HIDDESCRIPTORPARSER_H__ - -#include "hid.h" - -class ReportDescParserBase : public USBReadParser { -public: - typedef void (*UsagePageFunc)(uint16_t usage); - - static void PrintGenericDesktopPageUsage(uint16_t usage); - static void PrintSimulationControlsPageUsage(uint16_t usage); - static void PrintVRControlsPageUsage(uint16_t usage); - static void PrintSportsControlsPageUsage(uint16_t usage); - static void PrintGameControlsPageUsage(uint16_t usage); - static void PrintGenericDeviceControlsPageUsage(uint16_t usage); - static void PrintLEDPageUsage(uint16_t usage); - static void PrintButtonPageUsage(uint16_t usage); - static void PrintOrdinalPageUsage(uint16_t usage); - static void PrintTelephonyPageUsage(uint16_t usage); - static void PrintConsumerPageUsage(uint16_t usage); - static void PrintDigitizerPageUsage(uint16_t usage); - static void PrintAlphanumDisplayPageUsage(uint16_t usage); - static void PrintMedicalInstrumentPageUsage(uint16_t usage); - - static void PrintValue(uint8_t *p, uint8_t len); - static void PrintByteValue(uint8_t data); - - static void PrintItemTitle(uint8_t prefix); - - static const char * const usagePageTitles0[]; - static const char * const usagePageTitles1[]; - static const char * const genDesktopTitles0[]; - static const char * const genDesktopTitles1[]; - static const char * const genDesktopTitles2[]; - static const char * const genDesktopTitles3[]; - static const char * const genDesktopTitles4[]; - static const char * const simuTitles0[]; - static const char * const simuTitles1[]; - static const char * const simuTitles2[]; - static const char * const vrTitles0[]; - static const char * const vrTitles1[]; - static const char * const sportsCtrlTitles0[]; - static const char * const sportsCtrlTitles1[]; - static const char * const sportsCtrlTitles2[]; - static const char * const gameTitles0[]; - static const char * const gameTitles1[]; - static const char * const genDevCtrlTitles[]; - static const char * const ledTitles[]; - static const char * const telTitles0[]; - static const char * const telTitles1[]; - static const char * const telTitles2[]; - static const char * const telTitles3[]; - static const char * const telTitles4[]; - static const char * const telTitles5[]; - static const char * const consTitles0[]; - static const char * const consTitles1[]; - static const char * const consTitles2[]; - static const char * const consTitles3[]; - static const char * const consTitles4[]; - static const char * const consTitles5[]; - static const char * const consTitles6[]; - static const char * const consTitles7[]; - static const char * const consTitles8[]; - static const char * const consTitles9[]; - static const char * const consTitlesA[]; - static const char * const consTitlesB[]; - static const char * const consTitlesC[]; - static const char * const consTitlesD[]; - static const char * const consTitlesE[]; - static const char * const digitTitles0[]; - static const char * const digitTitles1[]; - static const char * const digitTitles2[]; - static const char * const aplphanumTitles0[]; - static const char * const aplphanumTitles1[]; - static const char * const aplphanumTitles2[]; - static const char * const medInstrTitles0[]; - static const char * const medInstrTitles1[]; - static const char * const medInstrTitles2[]; - static const char * const medInstrTitles3[]; - static const char * const medInstrTitles4[]; - -protected: - static UsagePageFunc usagePageFunctions[]; - - MultiValueBuffer theBuffer; - MultiByteValueParser valParser; - ByteSkipper theSkipper; - uint8_t varBuffer[sizeof (USB_CONFIGURATION_DESCRIPTOR)]; - - uint8_t itemParseState; // Item parser state variable - uint8_t itemSize; // Item size - uint8_t itemPrefix; // Item prefix (first byte) - uint8_t rptSize; // Report Size - uint8_t rptCount; // Report Count - - uint16_t totalSize; // Report size in bits - - // Method should be defined here if virtual. - virtual uint8_t ParseItem(uint8_t **pp, uint16_t *pcntdn); - - UsagePageFunc pfUsage; - - static void PrintUsagePage(uint16_t page); - void SetUsagePage(uint16_t page); - -public: - - ReportDescParserBase() : - itemParseState(0), - itemSize(0), - itemPrefix(0), - rptSize(0), - rptCount(0), - pfUsage(NULL) { - theBuffer.pValue = varBuffer; - valParser.Initialize(&theBuffer); - theSkipper.Initialize(&theBuffer); - }; - - void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset); - - enum { - enErrorSuccess = 0 - , enErrorIncomplete // value or record is partialy read in buffer - , enErrorBufferTooSmall - }; -}; - -class ReportDescParser : public ReportDescParserBase { -}; - -class ReportDescParser2 : public ReportDescParserBase { - uint8_t rptId; // Report ID - uint8_t useMin; // Usage Minimum - uint8_t useMax; // Usage Maximum - uint8_t fieldCount; // Number of field being currently processed - - void OnInputItem(uint8_t itm); // Method which is called every time Input item is found - - uint8_t *pBuf; // Report buffer pointer - uint8_t bLen; // Report length - -protected: - // Method should be defined here if virtual. - virtual uint8_t ParseItem(uint8_t **pp, uint16_t *pcntdn); - -public: - - ReportDescParser2(uint16_t len, uint8_t *pbuf) : - ReportDescParserBase(), rptId(0), useMin(0), useMax(0), fieldCount(0), pBuf(pbuf), bLen(len) { - }; -}; - -class UniversalReportParser : public HIDReportParser { -public: - // Method should be defined here if virtual. - virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); -}; - -#endif // __HIDDESCRIPTORPARSER_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/hiduniversal.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/hiduniversal.cpp deleted file mode 100644 index 395aa69e..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/hiduniversal.cpp +++ /dev/null @@ -1,425 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#include "hiduniversal.h" - -HIDUniversal::HIDUniversal(USB *p) : -HID(p), -qNextPollTime(0), -pollInterval(0), -bPollEnable(false), -bHasReportId(false) { - Initialize(); - - if(pUsb) - pUsb->RegisterDeviceClass(this); -} - -uint16_t HIDUniversal::GetHidClassDescrLen(uint8_t type, uint8_t num) { - for(uint8_t i = 0, n = 0; i < HID_MAX_HID_CLASS_DESCRIPTORS; i++) { - if(descrInfo[i].bDescrType == type) { - if(n == num) - return descrInfo[i].wDescriptorLength; - n++; - } - } - return 0; -} - -void HIDUniversal::Initialize() { - for(uint8_t i = 0; i < MAX_REPORT_PARSERS; i++) { - rptParsers[i].rptId = 0; - rptParsers[i].rptParser = NULL; - } - for(uint8_t i = 0; i < HID_MAX_HID_CLASS_DESCRIPTORS; i++) { - descrInfo[i].bDescrType = 0; - descrInfo[i].wDescriptorLength = 0; - } - for(uint8_t i = 0; i < maxHidInterfaces; i++) { - hidInterfaces[i].bmInterface = 0; - hidInterfaces[i].bmProtocol = 0; - - for(uint8_t j = 0; j < maxEpPerInterface; j++) - hidInterfaces[i].epIndex[j] = 0; - } - for(uint8_t i = 0; i < totalEndpoints; i++) { - epInfo[i].epAddr = 0; - epInfo[i].maxPktSize = (i) ? 0 : 8; - epInfo[i].epAttribs = 0; - epInfo[i].bmNakPower = (i) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER; - } - bNumEP = 1; - bNumIface = 0; - bConfNum = 0; - pollInterval = 0; - - ZeroMemory(constBuffLen, prevBuf); -} - -bool HIDUniversal::SetReportParser(uint8_t id, HIDReportParser *prs) { - for(uint8_t i = 0; i < MAX_REPORT_PARSERS; i++) { - if(rptParsers[i].rptId == 0 && rptParsers[i].rptParser == NULL) { - rptParsers[i].rptId = id; - rptParsers[i].rptParser = prs; - return true; - } - } - return false; -} - -HIDReportParser* HIDUniversal::GetReportParser(uint8_t id) { - if(!bHasReportId) - return ((rptParsers[0].rptParser) ? rptParsers[0].rptParser : NULL); - - for(uint8_t i = 0; i < MAX_REPORT_PARSERS; i++) { - if(rptParsers[i].rptId == id) - return rptParsers[i].rptParser; - } - return NULL; -} - -uint8_t HIDUniversal::Init(uint8_t parent, uint8_t port, bool lowspeed) { - const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR); - - uint8_t buf[constBufSize]; - USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); - uint8_t rcode; - UsbDevice *p = NULL; - EpInfo *oldep_ptr = NULL; - uint8_t len = 0; - - uint8_t num_of_conf; // number of configurations - //uint8_t num_of_intf; // number of interfaces - - AddressPool &addrPool = pUsb->GetAddressPool(); - - USBTRACE("HU Init\r\n"); - - if(bAddress) - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - if(!p->epinfo) { - USBTRACE("epinfo\r\n"); - return USB_ERROR_EPINFO_IS_NULL; - } - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - - p->lowspeed = lowspeed; - - // Get device descriptor - rcode = pUsb->getDevDescr(0, 0, 8, (uint8_t*)buf); - - if(!rcode) - len = (buf[0] > constBufSize) ? constBufSize : buf[0]; - - if(rcode) { - // Restore p->epinfo - p->epinfo = oldep_ptr; - - goto FailGetDevDescr; - } - - // Restore p->epinfo - p->epinfo = oldep_ptr; - - // Allocate new address according to device class - bAddress = addrPool.AllocAddress(parent, false, port); - - if(!bAddress) - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - - // Extract Max Packet Size from the device descriptor - epInfo[0].maxPktSize = udd->bMaxPacketSize0; - - // Assign new address to the device - rcode = pUsb->setAddr(0, 0, bAddress); - - if(rcode) { - p->lowspeed = false; - addrPool.FreeAddress(bAddress); - bAddress = 0; - USBTRACE2("setAddr:", rcode); - return rcode; - } - - //delay(2); //per USB 2.0 sect.9.2.6.3 - - USBTRACE2("Addr:", bAddress); - - p->lowspeed = false; - - p = addrPool.GetUsbDevicePtr(bAddress); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - p->lowspeed = lowspeed; - - if(len) - rcode = pUsb->getDevDescr(bAddress, 0, len, (uint8_t*)buf); - - if(rcode) - goto FailGetDevDescr; - - VID = udd->idVendor; // Can be used by classes that inherits this class to check the VID and PID of the connected device - PID = udd->idProduct; - - num_of_conf = udd->bNumConfigurations; - - // Assign epInfo to epinfo pointer - rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo); - - if(rcode) - goto FailSetDevTblEntry; - - USBTRACE2("NC:", num_of_conf); - - for(uint8_t i = 0; i < num_of_conf; i++) { - //HexDumper HexDump; - ConfigDescParser confDescrParser(this); - - //rcode = pUsb->getConfDescr(bAddress, 0, i, &HexDump); - rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser); - - if(rcode) - goto FailGetConfDescr; - - if(bNumEP > 1) - break; - } // for - - if(bNumEP < 2) - return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - - // Assign epInfo to epinfo pointer - rcode = pUsb->setEpInfoEntry(bAddress, bNumEP, epInfo); - - USBTRACE2("Cnf:", bConfNum); - - // Set Configuration Value - rcode = pUsb->setConf(bAddress, 0, bConfNum); - - if(rcode) - goto FailSetConfDescr; - - for(uint8_t i = 0; i < bNumIface; i++) { - if(hidInterfaces[i].epIndex[epInterruptInIndex] == 0) - continue; - - rcode = SetIdle(hidInterfaces[i].bmInterface, 0, 0); - - if(rcode && rcode != hrSTALL) - goto FailSetIdle; - } - - USBTRACE("HU configured\r\n"); - - OnInitSuccessful(); - - bPollEnable = true; - return 0; - -FailGetDevDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetDevDescr(); - goto Fail; -#endif - -FailSetDevTblEntry: -#ifdef DEBUG_USB_HOST - NotifyFailSetDevTblEntry(); - goto Fail; -#endif - -FailGetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetConfDescr(); - goto Fail; -#endif - -FailSetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailSetConfDescr(); - goto Fail; -#endif - - -FailSetIdle: -#ifdef DEBUG_USB_HOST - USBTRACE("SetIdle:"); -#endif - -#ifdef DEBUG_USB_HOST -Fail: - NotifyFail(rcode); -#endif - Release(); - return rcode; -} - -HIDUniversal::HIDInterface* HIDUniversal::FindInterface(uint8_t iface, uint8_t alt, uint8_t proto) { - for(uint8_t i = 0; i < bNumIface && i < maxHidInterfaces; i++) - if(hidInterfaces[i].bmInterface == iface && hidInterfaces[i].bmAltSet == alt - && hidInterfaces[i].bmProtocol == proto) - return hidInterfaces + i; - return NULL; -} - -void HIDUniversal::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) { - // If the first configuration satisfies, the others are not concidered. - if(bNumEP > 1 && conf != bConfNum) - return; - - //ErrorMessage(PSTR("\r\nConf.Val"), conf); - //ErrorMessage(PSTR("Iface Num"), iface); - //ErrorMessage(PSTR("Alt.Set"), alt); - - bConfNum = conf; - - uint8_t index = 0; - HIDInterface *piface = FindInterface(iface, alt, proto); - - // Fill in interface structure in case of new interface - if(!piface) { - piface = hidInterfaces + bNumIface; - piface->bmInterface = iface; - piface->bmAltSet = alt; - piface->bmProtocol = proto; - bNumIface++; - } - - if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) - index = epInterruptInIndex; - else - index = epInterruptOutIndex; - - if(index) { - // Fill in the endpoint info structure - epInfo[bNumEP].epAddr = (pep->bEndpointAddress & 0x0F); - epInfo[bNumEP].maxPktSize = (uint8_t)pep->wMaxPacketSize; - epInfo[bNumEP].epAttribs = 0; - epInfo[bNumEP].bmNakPower = USB_NAK_NOWAIT; - - // Fill in the endpoint index list - piface->epIndex[index] = bNumEP; //(pep->bEndpointAddress & 0x0F); - - if(pollInterval < pep->bInterval) // Set the polling interval as the largest polling interval obtained from endpoints - pollInterval = pep->bInterval; - - bNumEP++; - } - //PrintEndpointDescriptor(pep); -} - -uint8_t HIDUniversal::Release() { - pUsb->GetAddressPool().FreeAddress(bAddress); - - bNumEP = 1; - bAddress = 0; - qNextPollTime = 0; - bPollEnable = false; - return 0; -} - -bool HIDUniversal::BuffersIdentical(uint8_t len, uint8_t *buf1, uint8_t *buf2) { - for(uint8_t i = 0; i < len; i++) - if(buf1[i] != buf2[i]) - return false; - return true; -} - -void HIDUniversal::ZeroMemory(uint8_t len, uint8_t *buf) { - for(uint8_t i = 0; i < len; i++) - buf[i] = 0; -} - -void HIDUniversal::SaveBuffer(uint8_t len, uint8_t *src, uint8_t *dest) { - for(uint8_t i = 0; i < len; i++) - dest[i] = src[i]; -} - -uint8_t HIDUniversal::Poll() { - uint8_t rcode = 0; - - if(!bPollEnable) - return 0; - - if((long)(millis() - qNextPollTime) >= 0L) { - qNextPollTime = millis() + pollInterval; - - uint8_t buf[constBuffLen]; - - for(uint8_t i = 0; i < bNumIface; i++) { - uint8_t index = hidInterfaces[i].epIndex[epInterruptInIndex]; - uint16_t read = (uint16_t)epInfo[index].maxPktSize; - - ZeroMemory(constBuffLen, buf); - - uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[index].epAddr, &read, buf); - - if(rcode) { - if(rcode != hrNAK) - USBTRACE3("(hiduniversal.h) Poll:", rcode, 0x81); - return rcode; - } - - if(read > constBuffLen) - read = constBuffLen; - - bool identical = BuffersIdentical(read, buf, prevBuf); - - SaveBuffer(read, buf, prevBuf); - - if(identical) - return 0; -#if 0 - Notify(PSTR("\r\nBuf: "), 0x80); - - for(uint8_t i = 0; i < read; i++) { - D_PrintHex (buf[i], 0x80); - Notify(PSTR(" "), 0x80); - } - - Notify(PSTR("\r\n"), 0x80); -#endif - ParseHIDData(this, bHasReportId, (uint8_t)read, buf); - - HIDReportParser *prs = GetReportParser(((bHasReportId) ? *buf : 0)); - - if(prs) - prs->Parse(this, bHasReportId, (uint8_t)read, buf); - } - } - return rcode; -} - -// Send a report to interrupt out endpoint. This is NOT SetReport() request! -uint8_t HIDUniversal::SndRpt(uint16_t nbytes, uint8_t *dataptr) { - return pUsb->outTransfer(bAddress, epInfo[epInterruptOutIndex].epAddr, nbytes, dataptr); -} \ No newline at end of file diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/hiduniversal.h b/protocol/usb_hid/USB_Host_Shield_2.0/hiduniversal.h deleted file mode 100644 index d7af3840..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/hiduniversal.h +++ /dev/null @@ -1,108 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#if !defined(__HIDUNIVERSAL_H__) -#define __HIDUNIVERSAL_H__ - -#include "hid.h" -//#include "hidescriptorparser.h" - -class HIDUniversal : public HID { - - struct ReportParser { - uint8_t rptId; - HIDReportParser *rptParser; - } rptParsers[MAX_REPORT_PARSERS]; - - // HID class specific descriptor type and length info obtained from HID descriptor - HID_CLASS_DESCRIPTOR_LEN_AND_TYPE descrInfo[HID_MAX_HID_CLASS_DESCRIPTORS]; - - // Returns HID class specific descriptor length by its type and order number - uint16_t GetHidClassDescrLen(uint8_t type, uint8_t num); - - struct HIDInterface { - struct { - uint8_t bmInterface : 3; - uint8_t bmAltSet : 3; - uint8_t bmProtocol : 2; - }; - uint8_t epIndex[maxEpPerInterface]; - }; - - uint8_t bConfNum; // configuration number - uint8_t bNumIface; // number of interfaces in the configuration - uint8_t bNumEP; // total number of EP in the configuration - uint32_t qNextPollTime; // next poll time - uint8_t pollInterval; - bool bPollEnable; // poll enable flag - - static const uint16_t constBuffLen = 64; // event buffer length - uint8_t prevBuf[constBuffLen]; // previous event buffer - - void Initialize(); - HIDInterface* FindInterface(uint8_t iface, uint8_t alt, uint8_t proto); - - void ZeroMemory(uint8_t len, uint8_t *buf); - bool BuffersIdentical(uint8_t len, uint8_t *buf1, uint8_t *buf2); - void SaveBuffer(uint8_t len, uint8_t *src, uint8_t *dest); - -protected: - EpInfo epInfo[totalEndpoints]; - HIDInterface hidInterfaces[maxHidInterfaces]; - - bool bHasReportId; - - uint16_t PID, VID; // PID and VID of connected device - - // HID implementation - HIDReportParser* GetReportParser(uint8_t id); - - virtual uint8_t OnInitSuccessful() { - return 0; - }; - - virtual void ParseHIDData(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) { - return; - }; - -public: - HIDUniversal(USB *p); - - // HID implementation - bool SetReportParser(uint8_t id, HIDReportParser *prs); - - // USBDeviceConfig implementation - uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - uint8_t Release(); - uint8_t Poll(); - - virtual uint8_t GetAddress() { - return bAddress; - }; - - virtual bool isReady() { - return bPollEnable; - }; - - // UsbConfigXtracter implementation - void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); - - // Send report - do not mix with SetReport()! - uint8_t SndRpt(uint16_t nbytes, uint8_t *dataptr); -}; - -#endif // __HIDUNIVERSAL_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/hidusagestr.h b/protocol/usb_hid/USB_Host_Shield_2.0/hidusagestr.h deleted file mode 100644 index 5ef48f92..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/hidusagestr.h +++ /dev/null @@ -1,977 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined( __HIDUSAGESTR_H__) -#define __HIDUSAGESTR_H__ - -#include "Usb.h" - -const char pstrSpace [] PROGMEM = " "; -const char pstrCRLF [] PROGMEM = "\r\n"; -const char pstrSingleTab [] PROGMEM = "\t"; -const char pstrDoubleTab [] PROGMEM = "\t\t"; -const char pstrTripleTab [] PROGMEM = "\t\t\t"; - -// Usage Page String Titles -const char pstrUsagePageUndefined [] PROGMEM = "Undef"; -const char pstrUsagePageGenericDesktopControls [] PROGMEM = "Gen Desktop Ctrls"; -const char pstrUsagePageSimulationControls [] PROGMEM = "Simu Ctrls"; -const char pstrUsagePageVRControls [] PROGMEM = "VR Ctrls"; -const char pstrUsagePageSportControls [] PROGMEM = "Sport Ctrls"; -const char pstrUsagePageGameControls [] PROGMEM = "Game Ctrls"; -const char pstrUsagePageGenericDeviceControls [] PROGMEM = "Gen Dev Ctrls"; -const char pstrUsagePageKeyboardKeypad [] PROGMEM = "Kbrd/Keypad"; -const char pstrUsagePageLEDs [] PROGMEM = "LEDs"; -const char pstrUsagePageButton [] PROGMEM = "Button"; -const char pstrUsagePageOrdinal [] PROGMEM = "Ordinal"; -const char pstrUsagePageTelephone [] PROGMEM = "Tel"; -const char pstrUsagePageConsumer [] PROGMEM = "Consumer"; -const char pstrUsagePageDigitizer [] PROGMEM = "Digitizer"; -const char pstrUsagePagePID [] PROGMEM = "PID"; -const char pstrUsagePageUnicode [] PROGMEM = "Unicode"; -const char pstrUsagePageAlphaNumericDisplay [] PROGMEM = "Alpha Num Disp"; -const char pstrUsagePageMedicalInstruments [] PROGMEM = "Medical Instr"; -const char pstrUsagePageMonitor [] PROGMEM = "Monitor"; -const char pstrUsagePagePower [] PROGMEM = "Power"; -const char pstrUsagePageBarCodeScanner [] PROGMEM = "Bar Code Scan"; -const char pstrUsagePageScale [] PROGMEM = "Scale"; -const char pstrUsagePageMSRDevices [] PROGMEM = "Magn Stripe Read Dev"; -const char pstrUsagePagePointOfSale [] PROGMEM = "POS"; -const char pstrUsagePageCameraControl [] PROGMEM = "Cam Ctrl"; -const char pstrUsagePageArcade [] PROGMEM = "Arcade"; -const char pstrUsagePageReserved [] PROGMEM = "Reserved"; -const char pstrUsagePageVendorDefined [] PROGMEM = "Vendor Def"; - -// Generic Desktop Controls Page -const char pstrUsagePointer [] PROGMEM = "Pointer"; -const char pstrUsageMouse [] PROGMEM = "Mouse"; -const char pstrUsageJoystick [] PROGMEM = "Joystick"; -const char pstrUsageGamePad [] PROGMEM = "Game Pad"; -const char pstrUsageKeyboard [] PROGMEM = "Kbrd"; -const char pstrUsageKeypad [] PROGMEM = "Keypad"; -const char pstrUsageMultiAxisController [] PROGMEM = "Multi-axis Ctrl"; -const char pstrUsageTabletPCSystemControls [] PROGMEM = "Tablet PC Sys Ctrls"; -const char pstrUsageX [] PROGMEM = "X"; -const char pstrUsageY [] PROGMEM = "Y"; -const char pstrUsageZ [] PROGMEM = "Z"; -const char pstrUsageRx [] PROGMEM = "Rx"; -const char pstrUsageRy [] PROGMEM = "Ry"; -const char pstrUsageRz [] PROGMEM = "Rz"; -const char pstrUsageSlider [] PROGMEM = "Slider"; -const char pstrUsageDial [] PROGMEM = "Dial"; -const char pstrUsageWheel [] PROGMEM = "Wheel"; -const char pstrUsageHatSwitch [] PROGMEM = "Hat Switch"; -const char pstrUsageCountedBuffer [] PROGMEM = "Counted Buf"; -const char pstrUsageByteCount [] PROGMEM = "Byte Count"; -const char pstrUsageMotionWakeup [] PROGMEM = "Motion Wakeup"; -const char pstrUsageStart [] PROGMEM = "Start"; -const char pstrUsageSelect [] PROGMEM = "Sel"; -const char pstrUsageVx [] PROGMEM = "Vx"; -const char pstrUsageVy [] PROGMEM = "Vy"; -const char pstrUsageVz [] PROGMEM = "Vz"; -const char pstrUsageVbrx [] PROGMEM = "Vbrx"; -const char pstrUsageVbry [] PROGMEM = "Vbry"; -const char pstrUsageVbrz [] PROGMEM = "Vbrz"; -const char pstrUsageVno [] PROGMEM = "Vno"; -const char pstrUsageFeatureNotification [] PROGMEM = "Feature Notif"; -const char pstrUsageResolutionMultiplier [] PROGMEM = "Res Mult"; -const char pstrUsageSystemControl [] PROGMEM = "Sys Ctrl"; -const char pstrUsageSystemPowerDown [] PROGMEM = "Sys Pwr Down"; -const char pstrUsageSystemSleep [] PROGMEM = "Sys Sleep"; -const char pstrUsageSystemWakeup [] PROGMEM = "Sys Wakeup"; -const char pstrUsageSystemContextMenu [] PROGMEM = "Sys Context Menu"; -const char pstrUsageSystemMainMenu [] PROGMEM = "Sys Main Menu"; -const char pstrUsageSystemAppMenu [] PROGMEM = "Sys App Menu"; -const char pstrUsageSystemMenuHelp [] PROGMEM = "Sys Menu Help"; -const char pstrUsageSystemMenuExit [] PROGMEM = "Sys Menu Exit"; -const char pstrUsageSystemMenuSelect [] PROGMEM = "Sys Menu Select"; -const char pstrUsageSystemMenuRight [] PROGMEM = "Sys Menu Right"; -const char pstrUsageSystemMenuLeft [] PROGMEM = "Sys Menu Left"; -const char pstrUsageSystemMenuUp [] PROGMEM = "Sys Menu Up"; -const char pstrUsageSystemMenuDown [] PROGMEM = "Sys Menu Down"; -const char pstrUsageSystemColdRestart [] PROGMEM = "Sys Cold Restart"; -const char pstrUsageSystemWarmRestart [] PROGMEM = "Sys Warm Restart"; -const char pstrUsageDPadUp [] PROGMEM = "D-pad Up"; -const char pstrUsageDPadDown [] PROGMEM = "D-pad Down"; -const char pstrUsageDPadRight [] PROGMEM = "D-pad Right"; -const char pstrUsageDPadLeft [] PROGMEM = "D-pad Left"; -const char pstrUsageSystemDock [] PROGMEM = "Sys Dock"; -const char pstrUsageSystemUndock [] PROGMEM = "Sys Undock"; -const char pstrUsageSystemSetup [] PROGMEM = "Sys Setup"; -const char pstrUsageSystemBreak [] PROGMEM = "Sys Break"; -const char pstrUsageSystemDebuggerBreak [] PROGMEM = "Sys Dbg Brk"; -const char pstrUsageApplicationBreak [] PROGMEM = "App Break"; -const char pstrUsageApplicationDebuggerBreak [] PROGMEM = "App Dbg Brk"; -const char pstrUsageSystemSpeakerMute [] PROGMEM = "Sys Spk Mute"; -const char pstrUsageSystemHibernate [] PROGMEM = "Sys Hiber"; -const char pstrUsageSystemDisplayInvert [] PROGMEM = "Sys Disp Inv"; -const char pstrUsageSystemDisplayInternal [] PROGMEM = "Sys Disp Int"; -const char pstrUsageSystemDisplayExternal [] PROGMEM = "Sys Disp Ext"; -const char pstrUsageSystemDisplayBoth [] PROGMEM = "Sys Disp Both"; -const char pstrUsageSystemDisplayDual [] PROGMEM = "Sys Disp Dual"; -const char pstrUsageSystemDisplayToggleIntExt [] PROGMEM = "Sys Disp Tgl Int/Ext"; -const char pstrUsageSystemDisplaySwapPriSec [] PROGMEM = "Sys Disp Swap Pri/Sec"; -const char pstrUsageSystemDisplayLCDAutoscale [] PROGMEM = "Sys Disp LCD Autoscale"; - -// Simulation Controls Page -const char pstrUsageFlightSimulationDevice [] PROGMEM = "Flight Simu Dev"; -const char pstrUsageAutomobileSimulationDevice [] PROGMEM = "Auto Simu Dev"; -const char pstrUsageTankSimulationDevice [] PROGMEM = "Tank Simu Dev"; -const char pstrUsageSpaceshipSimulationDevice [] PROGMEM = "Space Simu Dev"; -const char pstrUsageSubmarineSimulationDevice [] PROGMEM = "Subm Simu Dev"; -const char pstrUsageSailingSimulationDevice [] PROGMEM = "Sail Simu Dev"; -const char pstrUsageMotocicleSimulationDevice [] PROGMEM = "Moto Simu Dev"; -const char pstrUsageSportsSimulationDevice [] PROGMEM = "Sport Simu Dev"; -const char pstrUsageAirplaneSimulationDevice [] PROGMEM = "Airp Simu Dev"; -const char pstrUsageHelicopterSimulationDevice [] PROGMEM = "Heli Simu Dev"; -const char pstrUsageMagicCarpetSimulationDevice [] PROGMEM = "Magic Carpet Simu Dev"; -const char pstrUsageBicycleSimulationDevice [] PROGMEM = "Bike Simu Dev"; -const char pstrUsageFlightControlStick [] PROGMEM = "Flight Ctrl Stick"; -const char pstrUsageFlightStick [] PROGMEM = "Flight Stick"; -const char pstrUsageCyclicControl [] PROGMEM = "Cyclic Ctrl"; -const char pstrUsageCyclicTrim [] PROGMEM = "Cyclic Trim"; -const char pstrUsageFlightYoke [] PROGMEM = "Flight Yoke"; -const char pstrUsageTrackControl [] PROGMEM = "Track Ctrl"; -const char pstrUsageAileron [] PROGMEM = "Aileron"; -const char pstrUsageAileronTrim [] PROGMEM = "Aileron Trim"; -const char pstrUsageAntiTorqueControl [] PROGMEM = "Anti-Torque Ctrl"; -const char pstrUsageAutopilotEnable [] PROGMEM = "Autopilot Enable"; -const char pstrUsageChaffRelease [] PROGMEM = "Chaff Release"; -const char pstrUsageCollectiveControl [] PROGMEM = "Collective Ctrl"; -const char pstrUsageDiveBrake [] PROGMEM = "Dive Brake"; -const char pstrUsageElectronicCountermeasures [] PROGMEM = "El Countermeasures"; -const char pstrUsageElevator [] PROGMEM = "Elevator"; -const char pstrUsageElevatorTrim [] PROGMEM = "Elevator Trim"; -const char pstrUsageRudder [] PROGMEM = "Rudder"; -const char pstrUsageThrottle [] PROGMEM = "Throttle"; -const char pstrUsageFlightCommunications [] PROGMEM = "Flight Comm"; -const char pstrUsageFlareRelease [] PROGMEM = "Flare Release"; -const char pstrUsageLandingGear [] PROGMEM = "Landing Gear"; -const char pstrUsageToeBrake [] PROGMEM = "Toe Brake"; -const char pstrUsageTrigger [] PROGMEM = "Trigger"; -const char pstrUsageWeaponsArm [] PROGMEM = "Weapons Arm"; -const char pstrUsageWeaponsSelect [] PROGMEM = "Weapons Sel"; -const char pstrUsageWingFlaps [] PROGMEM = "Wing Flaps"; -const char pstrUsageAccelerator [] PROGMEM = "Accel"; -const char pstrUsageBrake [] PROGMEM = "Brake"; -const char pstrUsageClutch [] PROGMEM = "Clutch"; -const char pstrUsageShifter [] PROGMEM = "Shifter"; -const char pstrUsageSteering [] PROGMEM = "Steering"; -const char pstrUsageTurretDirection [] PROGMEM = "Turret Dir"; -const char pstrUsageBarrelElevation [] PROGMEM = "Barrel Ele"; -const char pstrUsageDivePlane [] PROGMEM = "Dive Plane"; -const char pstrUsageBallast [] PROGMEM = "Ballast"; -const char pstrUsageBicycleCrank [] PROGMEM = "Bicycle Crank"; -const char pstrUsageHandleBars [] PROGMEM = "Handle Bars"; -const char pstrUsageFrontBrake [] PROGMEM = "Front Brake"; -const char pstrUsageRearBrake [] PROGMEM = "Rear Brake"; - -// VR Controls Page -const char pstrUsageBelt [] PROGMEM = "Belt"; -const char pstrUsageBodySuit [] PROGMEM = "Body Suit"; -const char pstrUsageFlexor [] PROGMEM = "Flexor"; -const char pstrUsageGlove [] PROGMEM = "Glove"; -const char pstrUsageHeadTracker [] PROGMEM = "Head Track"; -const char pstrUsageHeadMountedDisplay [] PROGMEM = "Head Disp"; -const char pstrUsageHandTracker [] PROGMEM = "Hand Track"; -const char pstrUsageOculometer [] PROGMEM = "Oculometer"; -const char pstrUsageVest [] PROGMEM = "Vest"; -const char pstrUsageAnimatronicDevice [] PROGMEM = "Animat Dev"; -const char pstrUsageStereoEnable [] PROGMEM = "Stereo Enbl"; -const char pstrUsageDisplayEnable [] PROGMEM = "Display Enbl"; - -// Sport Controls Page -const char pstrUsageBaseballBat [] PROGMEM = "Baseball Bat"; -const char pstrUsageGolfClub [] PROGMEM = "Golf Club"; -const char pstrUsageRowingMachine [] PROGMEM = "Rowing Mach"; -const char pstrUsageTreadmill [] PROGMEM = "Treadmill"; -const char pstrUsageOar [] PROGMEM = "Oar"; -const char pstrUsageSlope [] PROGMEM = "Slope"; -const char pstrUsageRate [] PROGMEM = "Rate"; -const char pstrUsageStickSpeed [] PROGMEM = "Stick Speed"; -const char pstrUsageStickFaceAngle [] PROGMEM = "Stick Face Ang"; -const char pstrUsageStickHeelToe [] PROGMEM = "Stick Heel/Toe"; -const char pstrUsageStickFollowThough [] PROGMEM = "Stick Flw Thru"; -const char pstrUsageStickTempo [] PROGMEM = "Stick Tempo"; -const char pstrUsageStickType [] PROGMEM = "Stick Type"; -const char pstrUsageStickHeight [] PROGMEM = "Stick Hght"; -const char pstrUsagePutter [] PROGMEM = "Putter"; -const char pstrUsage1Iron [] PROGMEM = "1 Iron"; -const char pstrUsage2Iron [] PROGMEM = "2 Iron"; -const char pstrUsage3Iron [] PROGMEM = "3 Iron"; -const char pstrUsage4Iron [] PROGMEM = "4 Iron"; -const char pstrUsage5Iron [] PROGMEM = "5 Iron"; -const char pstrUsage6Iron [] PROGMEM = "6 Iron"; -const char pstrUsage7Iron [] PROGMEM = "7 Iron"; -const char pstrUsage8Iron [] PROGMEM = "8 Iron"; -const char pstrUsage9Iron [] PROGMEM = "9 Iron"; -const char pstrUsage10Iron [] PROGMEM = "10 Iron"; -const char pstrUsage11Iron [] PROGMEM = "11 Iron"; -const char pstrUsageSandWedge [] PROGMEM = "Sand Wedge"; -const char pstrUsageLoftWedge [] PROGMEM = "Loft Wedge"; -const char pstrUsagePowerWedge [] PROGMEM = "Pwr Wedge"; -const char pstrUsage1Wood [] PROGMEM = "1 Wood"; -const char pstrUsage3Wood [] PROGMEM = "3 Wood"; -const char pstrUsage5Wood [] PROGMEM = "5 Wood"; -const char pstrUsage7Wood [] PROGMEM = "7 Wood"; -const char pstrUsage9Wood [] PROGMEM = "9 Wood"; - -// Game Controls Page -const char pstrUsage3DGameController [] PROGMEM = "3D Game Ctrl"; -const char pstrUsagePinballDevice [] PROGMEM = "Pinball Dev"; -const char pstrUsageGunDevice [] PROGMEM = "Gun Dev"; -const char pstrUsagePointOfView [] PROGMEM = "POV"; -const char pstrUsageTurnRightLeft [] PROGMEM = "Turn Right Left"; -const char pstrUsagePitchForwardBackward [] PROGMEM = "Pitch Fwd/Back"; -const char pstrUsageRollRightLeft [] PROGMEM = "Roll Right/Left"; -const char pstrUsageMoveRightLeft [] PROGMEM = "Move Right/Left"; -const char pstrUsageMoveForwardBackward [] PROGMEM = "Move Fwd/Back"; -const char pstrUsageMoveUpDown [] PROGMEM = "Move Up/Down"; -const char pstrUsageLeanRightLeft [] PROGMEM = "Lean Right/Left"; -const char pstrUsageLeanForwardBackward [] PROGMEM = "Lean Fwd/Back"; -const char pstrUsageHeightOfPOV [] PROGMEM = "Height of POV"; -const char pstrUsageFlipper [] PROGMEM = "Flipper"; -const char pstrUsageSecondaryFlipper [] PROGMEM = "Second Flipper"; -const char pstrUsageBump [] PROGMEM = "Bump"; -const char pstrUsageNewGame [] PROGMEM = "New Game"; -const char pstrUsageShootBall [] PROGMEM = "Shoot Ball"; -const char pstrUsagePlayer [] PROGMEM = "Player"; -const char pstrUsageGunBolt [] PROGMEM = "Gun Bolt"; -const char pstrUsageGunClip [] PROGMEM = "Gun Clip"; -const char pstrUsageGunSelector [] PROGMEM = "Gun Sel"; -const char pstrUsageGunSingleShot [] PROGMEM = "Gun Sngl Shot"; -const char pstrUsageGunBurst [] PROGMEM = "Gun Burst"; -const char pstrUsageGunAutomatic [] PROGMEM = "Gun Auto"; -const char pstrUsageGunSafety [] PROGMEM = "Gun Safety"; -const char pstrUsageGamepadFireJump [] PROGMEM = "Gamepad Fire/Jump"; -const char pstrUsageGamepadTrigger [] PROGMEM = "Gamepad Trig"; - -// Generic Device Controls Page -const char pstrUsageBatteryStrength [] PROGMEM = "Bat Strength"; -const char pstrUsageWirelessChannel [] PROGMEM = "Wireless Ch"; -const char pstrUsageWirelessID [] PROGMEM = "Wireless ID"; -const char pstrUsageDiscoverWirelessControl [] PROGMEM = "Discover Wireless Ctrl"; -const char pstrUsageSecurityCodeCharEntered [] PROGMEM = "Sec Code Char Entrd"; -const char pstrUsageSecurityCodeCharErased [] PROGMEM = "Sec Code Char Erased"; -const char pstrUsageSecurityCodeCleared [] PROGMEM = "Sec Code Cleared"; - -// LED Page -const char pstrUsageNumLock [] PROGMEM = "Num Lock"; -const char pstrUsageCapsLock [] PROGMEM = "Caps Lock"; -const char pstrUsageScrollLock [] PROGMEM = "Scroll Lock"; -const char pstrUsageCompose [] PROGMEM = "Compose"; -const char pstrUsageKana [] PROGMEM = "Kana"; -const char pstrUsagePower [] PROGMEM = "Pwr"; -const char pstrUsageShift [] PROGMEM = "Shift"; -const char pstrUsageDoNotDisturb [] PROGMEM = "DND"; -const char pstrUsageMute [] PROGMEM = "Mute"; -const char pstrUsageToneEnable [] PROGMEM = "Tone Enbl"; -const char pstrUsageHighCutFilter [] PROGMEM = "High Cut Fltr"; -const char pstrUsageLowCutFilter [] PROGMEM = "Low Cut Fltr"; -const char pstrUsageEqualizerEnable [] PROGMEM = "Eq Enbl"; -const char pstrUsageSoundFieldOn [] PROGMEM = "Sound Field On"; -const char pstrUsageSurroundOn [] PROGMEM = "Surround On"; -const char pstrUsageRepeat [] PROGMEM = "Repeat"; -const char pstrUsageStereo [] PROGMEM = "Stereo"; -const char pstrUsageSamplingRateDetect [] PROGMEM = "Smpl Rate Detect"; -const char pstrUsageSpinning [] PROGMEM = "Spinning"; -const char pstrUsageCAV [] PROGMEM = "CAV"; -const char pstrUsageCLV [] PROGMEM = "CLV"; -const char pstrUsageRecordingFormatDetect [] PROGMEM = "Rec Format Detect"; -const char pstrUsageOffHook [] PROGMEM = "Off Hook"; -const char pstrUsageRing [] PROGMEM = "Ring"; -const char pstrUsageMessageWaiting [] PROGMEM = "Msg Wait"; -const char pstrUsageDataMode [] PROGMEM = "Data Mode"; -const char pstrUsageBatteryOperation [] PROGMEM = "Bat Op"; -const char pstrUsageBatteryOK [] PROGMEM = "Bat OK"; -const char pstrUsageBatteryLow [] PROGMEM = "Bat Low"; -const char pstrUsageSpeaker [] PROGMEM = "Speaker"; -const char pstrUsageHeadSet [] PROGMEM = "Head Set"; -const char pstrUsageHold [] PROGMEM = "Hold"; -const char pstrUsageMicrophone [] PROGMEM = "Mic"; -const char pstrUsageCoverage [] PROGMEM = "Coverage"; -const char pstrUsageNightMode [] PROGMEM = "Night Mode"; -const char pstrUsageSendCalls [] PROGMEM = "Send Calls"; -const char pstrUsageCallPickup [] PROGMEM = "Call Pickup"; -const char pstrUsageConference [] PROGMEM = "Conf"; -const char pstrUsageStandBy [] PROGMEM = "Stand-by"; -const char pstrUsageCameraOn [] PROGMEM = "Cam On"; -const char pstrUsageCameraOff [] PROGMEM = "Cam Off"; -const char pstrUsageOnLine [] PROGMEM = "On-Line"; -const char pstrUsageOffLine [] PROGMEM = "Off-Line"; -const char pstrUsageBusy [] PROGMEM = "Busy"; -const char pstrUsageReady [] PROGMEM = "Ready"; -const char pstrUsagePaperOut [] PROGMEM = "Paper Out"; -const char pstrUsagePaperJam [] PROGMEM = "Paper Jam"; -const char pstrUsageRemote [] PROGMEM = "Remote"; -const char pstrUsageForward [] PROGMEM = "Fwd"; -const char pstrUsageReverse [] PROGMEM = "Rev"; -const char pstrUsageStop [] PROGMEM = "Stop"; -const char pstrUsageRewind [] PROGMEM = "Rewind"; -const char pstrUsageFastForward [] PROGMEM = "Fast Fwd"; -const char pstrUsagePlay [] PROGMEM = "Play"; -const char pstrUsagePause [] PROGMEM = "Pause"; -const char pstrUsageRecord [] PROGMEM = "Rec"; -const char pstrUsageError [] PROGMEM = "Error"; -const char pstrUsageSelectedIndicator [] PROGMEM = "Usage Sel Ind"; -const char pstrUsageInUseIndicator [] PROGMEM = "Usage In Use Ind"; -const char pstrUsageMultiModeIndicator [] PROGMEM = "Usage Multi Mode Ind"; -const char pstrUsageIndicatorOn [] PROGMEM = "Ind On"; -const char pstrUsageIndicatorFlash [] PROGMEM = "Ind Flash"; -const char pstrUsageIndicatorSlowBlink [] PROGMEM = "Ind Slow Blk"; -const char pstrUsageIndicatorFastBlink [] PROGMEM = "Ind Fast Blk"; -const char pstrUsageIndicatorOff [] PROGMEM = "Ind Off"; -const char pstrUsageFlashOnTime [] PROGMEM = "Flash On Time"; -const char pstrUsageSlowBlinkOnTime [] PROGMEM = "Slow Blk On Time"; -const char pstrUsageSlowBlinkOffTime [] PROGMEM = "Slow Blk Off Time"; -const char pstrUsageFastBlinkOnTime [] PROGMEM = "Fast Blk On Time"; -const char pstrUsageFastBlinkOffTime [] PROGMEM = "Fast Blk Off Time"; -const char pstrUsageIndicatorColor [] PROGMEM = "Usage Ind Color"; -const char pstrUsageIndicatorRed [] PROGMEM = "Ind Red"; -const char pstrUsageIndicatorGreen [] PROGMEM = "Ind Green"; -const char pstrUsageIndicatorAmber [] PROGMEM = "Ind Amber"; -const char pstrUsageGenericIndicator [] PROGMEM = "Gen Ind"; -const char pstrUsageSystemSuspend [] PROGMEM = "Sys Suspend"; -const char pstrUsageExternalPowerConnected [] PROGMEM = "Ext Pwr Conn"; - -// Telephony Usage Page -const char pstrUsagePhone [] PROGMEM = "Phone"; -const char pstrUsageAnsweringMachine [] PROGMEM = "Answ Mach"; -const char pstrUsageMessageControls [] PROGMEM = "Msg Ctrls"; -const char pstrUsageHandset [] PROGMEM = "Handset"; -const char pstrUsageHeadset [] PROGMEM = "Headset"; -const char pstrUsageTelephonyKeyPad [] PROGMEM = "Tel Key Pad"; -const char pstrUsageProgrammableButton [] PROGMEM = "Prog Button"; -const char pstrUsageHookSwitch [] PROGMEM = "Hook Sw"; -const char pstrUsageFlash [] PROGMEM = "Flash"; -const char pstrUsageFeature [] PROGMEM = "Feature"; -//const char pstrUsageHold [] PROGMEM = "Hold"; -const char pstrUsageRedial [] PROGMEM = "Redial"; -const char pstrUsageTransfer [] PROGMEM = "Transfer"; -const char pstrUsageDrop [] PROGMEM = "Drop"; -const char pstrUsagePark [] PROGMEM = "Park"; -const char pstrUsageForwardCalls [] PROGMEM = "Fwd Calls"; -const char pstrUsageAlternateFunction [] PROGMEM = "Alt Func"; -const char pstrUsageLine [] PROGMEM = "Line"; -const char pstrUsageSpeakerPhone [] PROGMEM = "Spk Phone"; -//const char pstrUsageConference [] PROGMEM = "Conference"; -const char pstrUsageRingEnable [] PROGMEM = "Ring Enbl"; -const char pstrUsageRingSelect [] PROGMEM = "Ring Sel"; -const char pstrUsagePhoneMute [] PROGMEM = "Phone Mute"; -const char pstrUsageCallerID [] PROGMEM = "Caller ID"; -const char pstrUsageSend [] PROGMEM = "Send"; -const char pstrUsageSpeedDial [] PROGMEM = "Speed Dial"; -const char pstrUsageStoreNumber [] PROGMEM = "Store Num"; -const char pstrUsageRecallNumber [] PROGMEM = "Recall Num"; -const char pstrUsagePhoneDirectory [] PROGMEM = "Phone Dir"; -const char pstrUsageVoiceMail [] PROGMEM = "Voice Mail"; -const char pstrUsageScreenCalls [] PROGMEM = "Screen Calls"; -//const char pstrUsageDoNotDisturb [] PROGMEM = "Do Not Disturb"; -const char pstrUsageMessage [] PROGMEM = "Msg"; -const char pstrUsageAnswerOnOff [] PROGMEM = "Answer On/Off"; -const char pstrUsageInsideDialTone [] PROGMEM = "Inside Dial Tone"; -const char pstrUsageOutsideDialTone [] PROGMEM = "Outside Dial Tone"; -const char pstrUsageInsideRingTone [] PROGMEM = "Inside Ring Tone"; -const char pstrUsageOutsideRingTone [] PROGMEM = "Outside Ring Tone"; -const char pstrUsagePriorityRingTone [] PROGMEM = "Prior Ring Tone"; -const char pstrUsageInsideRingback [] PROGMEM = "Inside Ringback"; -const char pstrUsagePriorityRingback [] PROGMEM = "Priority Ringback"; -const char pstrUsageLineBusyTone [] PROGMEM = "Ln Busy Tone"; -const char pstrUsageReorderTone [] PROGMEM = "Reorder Tone"; -const char pstrUsageCallWaitingTone [] PROGMEM = "Call Wait Tone"; -const char pstrUsageConfirmationTone1 [] PROGMEM = "Cnfrm Tone1"; -const char pstrUsageConfirmationTone2 [] PROGMEM = "Cnfrm Tone2"; -const char pstrUsageTonesOff [] PROGMEM = "Tones Off"; -const char pstrUsageOutsideRingback [] PROGMEM = "Outside Ringback"; -const char pstrUsageRinger [] PROGMEM = "Ringer"; -const char pstrUsagePhoneKey0 [] PROGMEM = "0"; -const char pstrUsagePhoneKey1 [] PROGMEM = "1"; -const char pstrUsagePhoneKey2 [] PROGMEM = "2"; -const char pstrUsagePhoneKey3 [] PROGMEM = "3"; -const char pstrUsagePhoneKey4 [] PROGMEM = "4"; -const char pstrUsagePhoneKey5 [] PROGMEM = "5"; -const char pstrUsagePhoneKey6 [] PROGMEM = "6"; -const char pstrUsagePhoneKey7 [] PROGMEM = "7"; -const char pstrUsagePhoneKey8 [] PROGMEM = "8"; -const char pstrUsagePhoneKey9 [] PROGMEM = "9"; -const char pstrUsagePhoneKeyStar [] PROGMEM = "*"; -const char pstrUsagePhoneKeyPound [] PROGMEM = "#"; -const char pstrUsagePhoneKeyA [] PROGMEM = "A"; -const char pstrUsagePhoneKeyB [] PROGMEM = "B"; -const char pstrUsagePhoneKeyC [] PROGMEM = "C"; -const char pstrUsagePhoneKeyD [] PROGMEM = "D"; - -// Consumer Usage Page -const char pstrUsageConsumerControl [] PROGMEM = "Consumer Ctrl"; -const char pstrUsageNumericKeyPad [] PROGMEM = "Num Key Pad"; -//const char pstrUsageProgrammableButton [] PROGMEM = "Prog Btn"; -//const char pstrUsageMicrophone [] PROGMEM = "Mic"; -const char pstrUsageHeadphone [] PROGMEM = "Headphone"; -const char pstrUsageGraphicEqualizer [] PROGMEM = "Graph Eq"; -const char pstrUsagePlus10 [] PROGMEM = "+10"; -const char pstrUsagePlus100 [] PROGMEM = "+100"; -const char pstrUsageAMPM [] PROGMEM = "AM/PM"; -//const char pstrUsagePower [] PROGMEM = "Pwr"; -const char pstrUsageReset [] PROGMEM = "Reset"; -const char pstrUsageSleep [] PROGMEM = "Sleep"; -const char pstrUsageSleepAfter [] PROGMEM = "Sleep After"; -const char pstrUsageSleepMode [] PROGMEM = "Sleep Mode"; -const char pstrUsageIllumination [] PROGMEM = "Illumin"; -const char pstrUsageFunctionButtons [] PROGMEM = "Func Btns"; -const char pstrUsageMenu [] PROGMEM = "Menu"; -const char pstrUsageMenuPick [] PROGMEM = "Menu Pick"; -const char pstrUsageMenuUp [] PROGMEM = "Menu Up"; -const char pstrUsageMenuDown [] PROGMEM = "Menu Down"; -const char pstrUsageMenuLeft [] PROGMEM = "Menu Left"; -const char pstrUsageMenuRight [] PROGMEM = "Menu Right"; -const char pstrUsageMenuEscape [] PROGMEM = "Menu Esc"; -const char pstrUsageMenuValueIncrease [] PROGMEM = "Menu Val Inc"; -const char pstrUsageMenuValueDecrease [] PROGMEM = "Menu Val Dec"; -const char pstrUsageDataOnScreen [] PROGMEM = "Data On Scr"; -const char pstrUsageClosedCaption [] PROGMEM = "Closed Cptn"; -const char pstrUsageClosedCaptionSelect [] PROGMEM = "Closed Cptn Sel"; -const char pstrUsageVCRTV [] PROGMEM = "VCR/TV"; -const char pstrUsageBroadcastMode [] PROGMEM = "Brdcast Mode"; -const char pstrUsageSnapshot [] PROGMEM = "Snapshot"; -const char pstrUsageStill [] PROGMEM = "Still"; -const char pstrUsageSelection [] PROGMEM = "Sel"; -const char pstrUsageAssignSelection [] PROGMEM = "Assign Sel"; -const char pstrUsageModeStep [] PROGMEM = "Mode Step"; -const char pstrUsageRecallLast [] PROGMEM = "Recall Last"; -const char pstrUsageEnterChannel [] PROGMEM = "Entr Channel"; -const char pstrUsageOrderMovie [] PROGMEM = "Ord Movie"; -const char pstrUsageChannel [] PROGMEM = "Channel"; -const char pstrUsageMediaSelection [] PROGMEM = "Med Sel"; -const char pstrUsageMediaSelectComputer [] PROGMEM = "Med Sel Comp"; -const char pstrUsageMediaSelectTV [] PROGMEM = "Med Sel TV"; -const char pstrUsageMediaSelectWWW [] PROGMEM = "Med Sel WWW"; -const char pstrUsageMediaSelectDVD [] PROGMEM = "Med Sel DVD"; -const char pstrUsageMediaSelectTelephone [] PROGMEM = "Med Sel Tel"; -const char pstrUsageMediaSelectProgramGuide [] PROGMEM = "Med Sel PG"; -const char pstrUsageMediaSelectVideoPhone [] PROGMEM = "Med Sel Vid"; -const char pstrUsageMediaSelectGames [] PROGMEM = "Med Sel Games"; -const char pstrUsageMediaSelectMessages [] PROGMEM = "Med Sel Msg"; -const char pstrUsageMediaSelectCD [] PROGMEM = "Med Sel CD"; -const char pstrUsageMediaSelectVCR [] PROGMEM = "Med Sel VCR"; -const char pstrUsageMediaSelectTuner [] PROGMEM = "Med Sel Tuner"; -const char pstrUsageQuit [] PROGMEM = "Quit"; -const char pstrUsageHelp [] PROGMEM = "Help"; -const char pstrUsageMediaSelectTape [] PROGMEM = "Med Sel Tape"; -const char pstrUsageMediaSelectCable [] PROGMEM = "Med Sel Cbl"; -const char pstrUsageMediaSelectSatellite [] PROGMEM = "Med Sel Sat"; -const char pstrUsageMediaSelectSecurity [] PROGMEM = "Med Sel Secur"; -const char pstrUsageMediaSelectHome [] PROGMEM = "Med Sel Home"; -const char pstrUsageMediaSelectCall [] PROGMEM = "Med Sel Call"; -const char pstrUsageChannelIncrement [] PROGMEM = "Ch Inc"; -const char pstrUsageChannelDecrement [] PROGMEM = "Ch Dec"; -const char pstrUsageMediaSelectSAP [] PROGMEM = "Med Sel SAP"; -const char pstrUsageVCRPlus [] PROGMEM = "VCR+"; -const char pstrUsageOnce [] PROGMEM = "Once"; -const char pstrUsageDaily [] PROGMEM = "Daily"; -const char pstrUsageWeekly [] PROGMEM = "Weekly"; -const char pstrUsageMonthly [] PROGMEM = "Monthly"; -//const char pstrUsagePlay [] PROGMEM = "Play"; -//const char pstrUsagePause [] PROGMEM = "Pause"; -//const char pstrUsageRecord [] PROGMEM = "Rec"; -//const char pstrUsageFastForward [] PROGMEM = "FF"; -//const char pstrUsageRewind [] PROGMEM = "Rewind"; -const char pstrUsageScanNextTrack [] PROGMEM = "Next Track"; -const char pstrUsageScanPreviousTrack [] PROGMEM = "Prev Track"; -//const char pstrUsageStop [] PROGMEM = "Stop"; -const char pstrUsageEject [] PROGMEM = "Eject"; -const char pstrUsageRandomPlay [] PROGMEM = "Random"; -const char pstrUsageSelectDisk [] PROGMEM = "Sel Disk"; -const char pstrUsageEnterDisk [] PROGMEM = "Ent Disk"; -//const char pstrUsageRepeat [] PROGMEM = "Repeat"; -const char pstrUsageTracking [] PROGMEM = "Tracking"; -const char pstrUsageTrackNormal [] PROGMEM = "Trk Norm"; -const char pstrUsageSlowTracking [] PROGMEM = "Slow Trk"; -const char pstrUsageFrameForward [] PROGMEM = "Frm Fwd"; -const char pstrUsageFrameBackwards [] PROGMEM = "Frm Back"; -const char pstrUsageMark [] PROGMEM = "Mark"; -const char pstrUsageClearMark [] PROGMEM = "Clr Mark"; -const char pstrUsageRepeatFromMark [] PROGMEM = "Rpt Mark"; -const char pstrUsageReturnToMark [] PROGMEM = "Ret to Mark"; -const char pstrUsageSearchMarkForward [] PROGMEM = "Search Mark Fwd"; -const char pstrUsageSearchMarkBackwards [] PROGMEM = "Search Mark Back"; -const char pstrUsageCounterReset [] PROGMEM = "Counter Reset"; -const char pstrUsageShowCounter [] PROGMEM = "Show Counter"; -const char pstrUsageTrackingIncrement [] PROGMEM = "Track Inc"; -const char pstrUsageTrackingDecrement [] PROGMEM = "Track Dec"; -const char pstrUsageStopEject [] PROGMEM = "Stop/Eject"; -const char pstrUsagePlayPause [] PROGMEM = "Play/Pause"; -const char pstrUsagePlaySkip [] PROGMEM = "Play/Skip"; -const char pstrUsageVolume [] PROGMEM = "Vol"; -const char pstrUsageBalance [] PROGMEM = "Balance"; -//const char pstrUsageMute [] PROGMEM = "Mute"; -const char pstrUsageBass [] PROGMEM = "Bass"; -const char pstrUsageTreble [] PROGMEM = "Treble"; -const char pstrUsageBassBoost [] PROGMEM = "Bass Boost"; -const char pstrUsageSurroundMode [] PROGMEM = "Surround"; -const char pstrUsageLoudness [] PROGMEM = "Loud"; -const char pstrUsageMPX [] PROGMEM = "MPX"; -const char pstrUsageVolumeIncrement [] PROGMEM = "Vol Inc"; -const char pstrUsageVolumeDecrement [] PROGMEM = "Vol Dec"; -const char pstrUsageSpeedSelect [] PROGMEM = "Speed"; -const char pstrUsagePlaybackSpeed [] PROGMEM = "Play Speed"; -const char pstrUsageStandardPlay [] PROGMEM = "Std Play"; -const char pstrUsageLongPlay [] PROGMEM = "Long Play"; -const char pstrUsageExtendedPlay [] PROGMEM = "Ext Play"; -const char pstrUsageSlow [] PROGMEM = "Slow"; -const char pstrUsageFanEnable [] PROGMEM = "Fan Enbl"; -const char pstrUsageFanSpeed [] PROGMEM = "Fan Speed"; -const char pstrUsageLightEnable [] PROGMEM = "Light Enbl"; -const char pstrUsageLightIlluminationLevel [] PROGMEM = "Light Illum Lev"; -const char pstrUsageClimateControlEnable [] PROGMEM = "Climate Enbl"; -const char pstrUsageRoomTemperature [] PROGMEM = "Room Temp"; -const char pstrUsageSecurityEnable [] PROGMEM = "Secur Enbl"; -const char pstrUsageFireAlarm [] PROGMEM = "Fire Alm"; -const char pstrUsagePoliceAlarm [] PROGMEM = "Police Alm"; -const char pstrUsageProximity [] PROGMEM = "Prox"; -const char pstrUsageMotion [] PROGMEM = "Motion"; -const char pstrUsageDuresAlarm [] PROGMEM = "Dures Alm"; -const char pstrUsageHoldupAlarm [] PROGMEM = "Holdup Alm"; -const char pstrUsageMedicalAlarm [] PROGMEM = "Med Alm"; -const char pstrUsageBalanceRight [] PROGMEM = "Balance Right"; -const char pstrUsageBalanceLeft [] PROGMEM = "Balance Left"; -const char pstrUsageBassIncrement [] PROGMEM = "Bass Inc"; -const char pstrUsageBassDecrement [] PROGMEM = "Bass Dec"; -const char pstrUsageTrebleIncrement [] PROGMEM = "Treble Inc"; -const char pstrUsageTrebleDecrement [] PROGMEM = "Treble Dec"; -const char pstrUsageSpeakerSystem [] PROGMEM = "Spk Sys"; -const char pstrUsageChannelLeft [] PROGMEM = "Ch Left"; -const char pstrUsageChannelRight [] PROGMEM = "Ch Right"; -const char pstrUsageChannelCenter [] PROGMEM = "Ch Center"; -const char pstrUsageChannelFront [] PROGMEM = "Ch Front"; -const char pstrUsageChannelCenterFront [] PROGMEM = "Ch Cntr Front"; -const char pstrUsageChannelSide [] PROGMEM = "Ch Side"; -const char pstrUsageChannelSurround [] PROGMEM = "Ch Surround"; -const char pstrUsageChannelLowFreqEnhancement [] PROGMEM = "Ch Low Freq Enh"; -const char pstrUsageChannelTop [] PROGMEM = "Ch Top"; -const char pstrUsageChannelUnknown [] PROGMEM = "Ch Unk"; -const char pstrUsageSubChannel [] PROGMEM = "Sub-ch"; -const char pstrUsageSubChannelIncrement [] PROGMEM = "Sub-ch Inc"; -const char pstrUsageSubChannelDecrement [] PROGMEM = "Sub-ch Dec"; -const char pstrUsageAlternateAudioIncrement [] PROGMEM = "Alt Aud Inc"; -const char pstrUsageAlternateAudioDecrement [] PROGMEM = "Alt Aud Dec"; -const char pstrUsageApplicationLaunchButtons [] PROGMEM = "App Launch Btns"; -const char pstrUsageALLaunchButtonConfigTool [] PROGMEM = "AL Launch Conf Tl"; -const char pstrUsageALProgrammableButton [] PROGMEM = "AL Pgm Btn"; -const char pstrUsageALConsumerControlConfig [] PROGMEM = "AL Cons Ctrl Cfg"; -const char pstrUsageALWordProcessor [] PROGMEM = "AL Word Proc"; -const char pstrUsageALTextEditor [] PROGMEM = "AL Txt Edtr"; -const char pstrUsageALSpreadsheet [] PROGMEM = "AL Sprdsheet"; -const char pstrUsageALGraphicsEditor [] PROGMEM = "AL Graph Edtr"; -const char pstrUsageALPresentationApp [] PROGMEM = "AL Present App"; -const char pstrUsageALDatabaseApp [] PROGMEM = "AL DB App"; -const char pstrUsageALEmailReader [] PROGMEM = "AL E-mail Rdr"; -const char pstrUsageALNewsreader [] PROGMEM = "AL Newsrdr"; -const char pstrUsageALVoicemail [] PROGMEM = "AL Voicemail"; -const char pstrUsageALContactsAddressBook [] PROGMEM = "AL Addr Book"; -const char pstrUsageALCalendarSchedule [] PROGMEM = "AL Clndr/Schdlr"; -const char pstrUsageALTaskProjectManager [] PROGMEM = "AL Task/Prj Mgr"; -const char pstrUsageALLogJournalTimecard [] PROGMEM = "AL Log/Jrnl/Tmcrd"; -const char pstrUsageALCheckbookFinance [] PROGMEM = "AL Chckbook/Fin"; -const char pstrUsageALCalculator [] PROGMEM = "AL Calc"; -const char pstrUsageALAVCapturePlayback [] PROGMEM = "AL A/V Capt/Play"; -const char pstrUsageALLocalMachineBrowser [] PROGMEM = "AL Loc Mach Brow"; -const char pstrUsageALLANWANBrow [] PROGMEM = "AL LAN/WAN Brow"; -const char pstrUsageALInternetBrowser [] PROGMEM = "AL I-net Brow"; -const char pstrUsageALRemoteNetISPConnect [] PROGMEM = "AL Rem Net Con"; -const char pstrUsageALNetworkConference [] PROGMEM = "AL Net Conf"; -const char pstrUsageALNetworkChat [] PROGMEM = "AL Net Chat"; -const char pstrUsageALTelephonyDialer [] PROGMEM = "AL Tel/Dial"; -const char pstrUsageALLogon [] PROGMEM = "AL Logon"; -const char pstrUsageALLogoff [] PROGMEM = "AL Logoff"; -const char pstrUsageALLogonLogoff [] PROGMEM = "AL Logon/Logoff"; -const char pstrUsageALTermLockScrSav [] PROGMEM = "AL Term Lock/Scr Sav"; -const char pstrUsageALControlPannel [] PROGMEM = "AL Ctrl Pan"; -const char pstrUsageALCommandLineProcessorRun [] PROGMEM = "AL Cmd/Run"; -const char pstrUsageALProcessTaskManager [] PROGMEM = "AL Task Mgr"; -const char pstrUsageALSelectTaskApplication [] PROGMEM = "AL Sel App"; -const char pstrUsageALNextTaskApplication [] PROGMEM = "AL Next App"; -const char pstrUsageALPreviousTaskApplication [] PROGMEM = "AL Prev App"; -const char pstrUsageALPreemptiveHaltTaskApp [] PROGMEM = "AL Prmpt Halt App"; -const char pstrUsageALIntegratedHelpCenter [] PROGMEM = "AL Hlp Cntr"; -const char pstrUsageALDocuments [] PROGMEM = "AL Docs"; -const char pstrUsageALThesaurus [] PROGMEM = "AL Thsrs"; -const char pstrUsageALDictionary [] PROGMEM = "AL Dict"; -const char pstrUsageALDesktop [] PROGMEM = "AL Desktop"; -const char pstrUsageALSpellCheck [] PROGMEM = "AL Spell Chk"; -const char pstrUsageALGrammarCheck [] PROGMEM = "AL Gram Chk"; -const char pstrUsageALWirelessStatus [] PROGMEM = "AL Wireless Sts"; -const char pstrUsageALKeyboardLayout [] PROGMEM = "AL Kbd Layout"; -const char pstrUsageALVirusProtection [] PROGMEM = "AL Vir Protect"; -const char pstrUsageALEncryption [] PROGMEM = "AL Encrypt"; -const char pstrUsageALScreenSaver [] PROGMEM = "AL Scr Sav"; -const char pstrUsageALAlarms [] PROGMEM = "AL Alarms"; -const char pstrUsageALClock [] PROGMEM = "AL Clock"; -const char pstrUsageALFileBrowser [] PROGMEM = "AL File Brow"; -const char pstrUsageALPowerStatus [] PROGMEM = "AL Pwr Sts"; -const char pstrUsageALImageBrowser [] PROGMEM = "AL Img Brow"; -const char pstrUsageALAudioBrowser [] PROGMEM = "AL Aud Brow"; -const char pstrUsageALMovieBrowser [] PROGMEM = "AL Mov Brow"; -const char pstrUsageALDigitalRightsManager [] PROGMEM = "AL Dig Rights Mgr"; -const char pstrUsageALDigitalWallet [] PROGMEM = "AL Dig Wallet"; -const char pstrUsageALInstantMessaging [] PROGMEM = "AL Inst Msg"; -const char pstrUsageALOEMFeaturesBrowser [] PROGMEM = "AL OEM Tips Brow"; -const char pstrUsageALOEMHelp [] PROGMEM = "AL OEM Hlp"; -const char pstrUsageALOnlineCommunity [] PROGMEM = "AL Online Com"; -const char pstrUsageALEntertainmentContentBrow [] PROGMEM = "AL Ent Cont Brow"; -const char pstrUsageALOnlineShoppingBrowser [] PROGMEM = "AL Online Shop Brow"; -const char pstrUsageALSmartCardInfoHelp [] PROGMEM = "AL SmartCard Inf"; -const char pstrUsageALMarketMonitorFinBrowser [] PROGMEM = "AL Market Brow"; -const char pstrUsageALCustomCorpNewsBrowser [] PROGMEM = "AL Cust Corp News Brow"; -const char pstrUsageALOnlineActivityBrowser [] PROGMEM = "AL Online Act Brow"; -const char pstrUsageALResearchSearchBrowser [] PROGMEM = "AL Search Brow"; -const char pstrUsageALAudioPlayer [] PROGMEM = "AL Aud Player"; -const char pstrUsageGenericGUIAppControls [] PROGMEM = "Gen GUI App Ctrl"; -const char pstrUsageACNew [] PROGMEM = "AC New"; -const char pstrUsageACOpen [] PROGMEM = "AC Open"; -const char pstrUsageACClose [] PROGMEM = "AC Close"; -const char pstrUsageACExit [] PROGMEM = "AC Exit"; -const char pstrUsageACMaximize [] PROGMEM = "AC Max"; -const char pstrUsageACMinimize [] PROGMEM = "AC Min"; -const char pstrUsageACSave [] PROGMEM = "AC Save"; -const char pstrUsageACPrint [] PROGMEM = "AC Print"; -const char pstrUsageACProperties [] PROGMEM = "AC Prop"; -const char pstrUsageACUndo [] PROGMEM = "AC Undo"; -const char pstrUsageACCopy [] PROGMEM = "AC Copy"; -const char pstrUsageACCut [] PROGMEM = "AC Cut"; -const char pstrUsageACPaste [] PROGMEM = "AC Paste"; -const char pstrUsageACSelectAll [] PROGMEM = "AC Sel All"; -const char pstrUsageACFind [] PROGMEM = "AC Find"; -const char pstrUsageACFindAndReplace [] PROGMEM = "AC Find/Replace"; -const char pstrUsageACSearch [] PROGMEM = "AC Search"; -const char pstrUsageACGoto [] PROGMEM = "AC Goto"; -const char pstrUsageACHome [] PROGMEM = "AC Home"; -const char pstrUsageACBack [] PROGMEM = "AC Back"; -const char pstrUsageACForward [] PROGMEM = "AC Fwd"; -const char pstrUsageACStop [] PROGMEM = "AC Stop"; -const char pstrUsageACRefresh [] PROGMEM = "AC Refresh"; -const char pstrUsageACPreviousLink [] PROGMEM = "AC Prev Link"; -const char pstrUsageACNextLink [] PROGMEM = "AC Next Link"; -const char pstrUsageACBookmarks [] PROGMEM = "AC Bkmarks"; -const char pstrUsageACHistory [] PROGMEM = "AC Hist"; -const char pstrUsageACSubscriptions [] PROGMEM = "AC Subscr"; -const char pstrUsageACZoomIn [] PROGMEM = "AC Zoom In"; -const char pstrUsageACZoomOut [] PROGMEM = "AC Zoom Out"; -const char pstrUsageACZoom [] PROGMEM = "AC Zoom"; -const char pstrUsageACFullScreenView [] PROGMEM = "AC Full Scr"; -const char pstrUsageACNormalView [] PROGMEM = "AC Norm View"; -const char pstrUsageACViewToggle [] PROGMEM = "AC View Tgl"; -const char pstrUsageACScrollUp [] PROGMEM = "AC Scroll Up"; -const char pstrUsageACScrollDown [] PROGMEM = "AC Scroll Down"; -const char pstrUsageACScroll [] PROGMEM = "AC Scroll"; -const char pstrUsageACPanLeft [] PROGMEM = "AC Pan Left"; -const char pstrUsageACPanRight [] PROGMEM = "AC Pan Right"; -const char pstrUsageACPan [] PROGMEM = "AC Pan"; -const char pstrUsageACNewWindow [] PROGMEM = "AC New Wnd"; -const char pstrUsageACTileHoriz [] PROGMEM = "AC Tile Horiz"; -const char pstrUsageACTileVert [] PROGMEM = "AC Tile Vert"; -const char pstrUsageACFormat [] PROGMEM = "AC Frmt"; -const char pstrUsageACEdit [] PROGMEM = "AC Edit"; -const char pstrUsageACBold [] PROGMEM = "AC Bold"; -const char pstrUsageACItalics [] PROGMEM = "AC Ital"; -const char pstrUsageACUnderline [] PROGMEM = "AC Under"; -const char pstrUsageACStrikethrough [] PROGMEM = "AC Strike"; -const char pstrUsageACSubscript [] PROGMEM = "AC Sub"; -const char pstrUsageACSuperscript [] PROGMEM = "AC Super"; -const char pstrUsageACAllCaps [] PROGMEM = "AC All Caps"; -const char pstrUsageACRotate [] PROGMEM = "AC Rotate"; -const char pstrUsageACResize [] PROGMEM = "AC Resize"; -const char pstrUsageACFlipHorizontal [] PROGMEM = "AC Flp H"; -const char pstrUsageACFlipVertical [] PROGMEM = "AC Flp V"; -const char pstrUsageACMirrorHorizontal [] PROGMEM = "AC Mir H"; -const char pstrUsageACMirrorVertical [] PROGMEM = "AC Mir V"; -const char pstrUsageACFontSelect [] PROGMEM = "AC Fnt Sel"; -const char pstrUsageACFontColor [] PROGMEM = "AC Fnt Clr"; -const char pstrUsageACFontSize [] PROGMEM = "AC Fnt Size"; -const char pstrUsageACJustifyLeft [] PROGMEM = "AC Just Left"; -const char pstrUsageACJustifyCenterH [] PROGMEM = "AC Just Cent H"; -const char pstrUsageACJustifyRight [] PROGMEM = "AC Just Right"; -const char pstrUsageACJustifyBlockH [] PROGMEM = "AC Just Block H"; -const char pstrUsageACJustifyTop [] PROGMEM = "AC Just Top"; -const char pstrUsageACJustifyCenterV [] PROGMEM = "AC Just Cent V"; -const char pstrUsageACJustifyBottom [] PROGMEM = "AC Just Bot"; -const char pstrUsageACJustifyBlockV [] PROGMEM = "AC Just Block V"; -const char pstrUsageACIndentDecrease [] PROGMEM = "AC Indent Dec"; -const char pstrUsageACIndentIncrease [] PROGMEM = "AC Indent Inc"; -const char pstrUsageACNumberedList [] PROGMEM = "AC Num List"; -const char pstrUsageACRestartNumbering [] PROGMEM = "AC Res Num"; -const char pstrUsageACBulletedList [] PROGMEM = "AC Blt List"; -const char pstrUsageACPromote [] PROGMEM = "AC Promote"; -const char pstrUsageACDemote [] PROGMEM = "AC Demote"; -const char pstrUsageACYes [] PROGMEM = "AC Yes"; -const char pstrUsageACNo [] PROGMEM = "AC No"; -const char pstrUsageACCancel [] PROGMEM = "AC Cancel"; -const char pstrUsageACCatalog [] PROGMEM = "AC Ctlg"; -const char pstrUsageACBuyChkout [] PROGMEM = "AC Buy"; -const char pstrUsageACAddToCart [] PROGMEM = "AC Add2Cart"; -const char pstrUsageACExpand [] PROGMEM = "AC Xpnd"; -const char pstrUsageACExpandAll [] PROGMEM = "AC Xpand All"; -const char pstrUsageACCollapse [] PROGMEM = "AC Collapse"; -const char pstrUsageACCollapseAll [] PROGMEM = "AC Collapse All"; -const char pstrUsageACPrintPreview [] PROGMEM = "AC Prn Prevw"; -const char pstrUsageACPasteSpecial [] PROGMEM = "AC Paste Spec"; -const char pstrUsageACInsertMode [] PROGMEM = "AC Ins Mode"; -const char pstrUsageACDelete [] PROGMEM = "AC Del"; -const char pstrUsageACLock [] PROGMEM = "AC Lock"; -const char pstrUsageACUnlock [] PROGMEM = "AC Unlock"; -const char pstrUsageACProtect [] PROGMEM = "AC Prot"; -const char pstrUsageACUnprotect [] PROGMEM = "AC Unprot"; -const char pstrUsageACAttachComment [] PROGMEM = "AC Attach Cmnt"; -const char pstrUsageACDeleteComment [] PROGMEM = "AC Del Cmnt"; -const char pstrUsageACViewComment [] PROGMEM = "AC View Cmnt"; -const char pstrUsageACSelectWord [] PROGMEM = "AC Sel Word"; -const char pstrUsageACSelectSentence [] PROGMEM = "AC Sel Sntc"; -const char pstrUsageACSelectParagraph [] PROGMEM = "AC Sel Para"; -const char pstrUsageACSelectColumn [] PROGMEM = "AC Sel Col"; -const char pstrUsageACSelectRow [] PROGMEM = "AC Sel Row"; -const char pstrUsageACSelectTable [] PROGMEM = "AC Sel Tbl"; -const char pstrUsageACSelectObject [] PROGMEM = "AC Sel Obj"; -const char pstrUsageACRedoRepeat [] PROGMEM = "AC Redo"; -const char pstrUsageACSort [] PROGMEM = "AC Sort"; -const char pstrUsageACSortAscending [] PROGMEM = "AC Sort Asc"; -const char pstrUsageACSortDescending [] PROGMEM = "AC Sort Desc"; -const char pstrUsageACFilter [] PROGMEM = "AC Filt"; -const char pstrUsageACSetClock [] PROGMEM = "AC Set Clk"; -const char pstrUsageACViewClock [] PROGMEM = "AC View Clk"; -const char pstrUsageACSelectTimeZone [] PROGMEM = "AC Sel Time Z"; -const char pstrUsageACEditTimeZone [] PROGMEM = "AC Edt Time Z"; -const char pstrUsageACSetAlarm [] PROGMEM = "AC Set Alm"; -const char pstrUsageACClearAlarm [] PROGMEM = "AC Clr Alm"; -const char pstrUsageACSnoozeAlarm [] PROGMEM = "AC Snz Alm"; -const char pstrUsageACResetAlarm [] PROGMEM = "AC Rst Alm"; -const char pstrUsageACSyncronize [] PROGMEM = "AC Sync"; -const char pstrUsageACSendReceive [] PROGMEM = "AC Snd/Rcv"; -const char pstrUsageACSendTo [] PROGMEM = "AC Snd To"; -const char pstrUsageACReply [] PROGMEM = "AC Reply"; -const char pstrUsageACReplyAll [] PROGMEM = "AC Reply All"; -const char pstrUsageACForwardMessage [] PROGMEM = "AC Fwd Msg"; -const char pstrUsageACSend [] PROGMEM = "AC Snd"; -const char pstrUsageACAttachFile [] PROGMEM = "AC Att File"; -const char pstrUsageACUpload [] PROGMEM = "AC Upld"; -const char pstrUsageACDownload [] PROGMEM = "AC Dnld"; -const char pstrUsageACSetBorders [] PROGMEM = "AC Set Brd"; -const char pstrUsageACInsertRow [] PROGMEM = "AC Ins Row"; -const char pstrUsageACInsertColumn [] PROGMEM = "AC Ins Col"; -const char pstrUsageACInsertFile [] PROGMEM = "AC Ins File"; -const char pstrUsageACInsertPicture [] PROGMEM = "AC Ins Pic"; -const char pstrUsageACInsertObject [] PROGMEM = "AC Ins Obj"; -const char pstrUsageACInsertSymbol [] PROGMEM = "AC Ins Sym"; -const char pstrUsageACSaveAndClose [] PROGMEM = "AC Sav&Cls"; -const char pstrUsageACRename [] PROGMEM = "AC Rename"; -const char pstrUsageACMerge [] PROGMEM = "AC Merge"; -const char pstrUsageACSplit [] PROGMEM = "AC Split"; -const char pstrUsageACDistributeHorizontaly [] PROGMEM = "AC Dist Hor"; -const char pstrUsageACDistributeVerticaly [] PROGMEM = "AC Dist Ver"; - -// Digitaizers -const char pstrUsageDigitizer [] PROGMEM = "Digitizer"; -const char pstrUsagePen [] PROGMEM = "Pen"; -const char pstrUsageLightPen [] PROGMEM = "Light Pen"; -const char pstrUsageTouchScreen [] PROGMEM = "Touch Scr"; -const char pstrUsageTouchPad [] PROGMEM = "Touch Pad"; -const char pstrUsageWhiteBoard [] PROGMEM = "White Brd"; -const char pstrUsageCoordinateMeasuringMachine [] PROGMEM = "Coord Meas Mach"; -const char pstrUsage3DDigitizer [] PROGMEM = "3D Dgtz"; -const char pstrUsageStereoPlotter [] PROGMEM = "Stereo Plot"; -const char pstrUsageArticulatedArm [] PROGMEM = "Art Arm"; -const char pstrUsageArmature [] PROGMEM = "Armature"; -const char pstrUsageMultiplePointDigitizer [] PROGMEM = "Multi Point Dgtz"; -const char pstrUsageFreeSpaceWand [] PROGMEM = "Free Space Wand"; -const char pstrUsageStylus [] PROGMEM = "Stylus"; -const char pstrUsagePuck [] PROGMEM = "Puck"; -const char pstrUsageFinger [] PROGMEM = "Finger"; -const char pstrUsageTipPressure [] PROGMEM = "Tip Press"; -const char pstrUsageBarrelPressure [] PROGMEM = "Brl Press"; -const char pstrUsageInRange [] PROGMEM = "In Range"; -const char pstrUsageTouch [] PROGMEM = "Touch"; -const char pstrUsageUntouch [] PROGMEM = "Untouch"; -const char pstrUsageTap [] PROGMEM = "Tap"; -const char pstrUsageQuality [] PROGMEM = "Qlty"; -const char pstrUsageDataValid [] PROGMEM = "Data Valid"; -const char pstrUsageTransducerIndex [] PROGMEM = "Transducer Ind"; -const char pstrUsageTabletFunctionKeys [] PROGMEM = "Tabl Func Keys"; -const char pstrUsageProgramChangeKeys [] PROGMEM = "Pgm Chng Keys"; -//const char pstrUsageBatteryStrength [] PROGMEM = "Bat Strength"; -const char pstrUsageInvert [] PROGMEM = "Invert"; -const char pstrUsageXTilt [] PROGMEM = "X Tilt"; -const char pstrUsageYTilt [] PROGMEM = "Y Tilt"; -const char pstrUsageAzimuth [] PROGMEM = "Azimuth"; -const char pstrUsageAltitude [] PROGMEM = "Altitude"; -const char pstrUsageTwist [] PROGMEM = "Twist"; -const char pstrUsageTipSwitch [] PROGMEM = "Tip Sw"; -const char pstrUsageSecondaryTipSwitch [] PROGMEM = "Scnd Tip Sw"; -const char pstrUsageBarrelSwitch [] PROGMEM = "Brl Sw"; -const char pstrUsageEraser [] PROGMEM = "Eraser"; -const char pstrUsageTabletPick [] PROGMEM = "Tbl Pick"; - -// Alphanumeric Display Page -const char pstrUsageAlphanumericDisplay [] PROGMEM = "Alphanum Disp"; -const char pstrUsageBitmappedDisplay [] PROGMEM = "Bmp Disp"; -const char pstrUsageDisplayAttributesReport [] PROGMEM = "Disp Attr Rpt"; -const char pstrUsageASCIICharacterSet [] PROGMEM = "ASCII chset"; -const char pstrUsageDataReadBack [] PROGMEM = "Data Rd Back"; -const char pstrUsageFontReadBack [] PROGMEM = "Fnt Rd Back"; -const char pstrUsageDisplayControlReport [] PROGMEM = "Disp Ctrl Rpt"; -const char pstrUsageClearDisplay [] PROGMEM = "Clr Disp"; -//const char pstrUsageDisplayEnable [] PROGMEM = "Disp Enbl"; -const char pstrUsageScreenSaverDelay [] PROGMEM = "Scr Sav Delay"; -const char pstrUsageScreenSaverEnable [] PROGMEM = "Scr Sav Enbl"; -const char pstrUsageVerticalScroll [] PROGMEM = "V Scroll"; -const char pstrUsageHorizontalScroll [] PROGMEM = "H Scroll"; -const char pstrUsageCharacterReport [] PROGMEM = "Char Rpt"; -const char pstrUsageDisplayData [] PROGMEM = "Disp Data"; -const char pstrUsageDisplayStatus [] PROGMEM = "Disp Stat"; -const char pstrUsageStatusNotReady [] PROGMEM = "Stat !Ready"; -const char pstrUsageStatusReady [] PROGMEM = "Stat Ready"; -const char pstrUsageErrorNotALoadableCharacter [] PROGMEM = "Err Not Ld Char"; -const char pstrUsageErrorFotDataCanNotBeRead [] PROGMEM = "Fnt Data Rd Err"; -const char pstrUsageCursorPositionReport [] PROGMEM = "Cur Pos Rpt"; -const char pstrUsageRow [] PROGMEM = "Row"; -const char pstrUsageColumn [] PROGMEM = "Col"; -const char pstrUsageRows [] PROGMEM = "Rows"; -const char pstrUsageColumns [] PROGMEM = "Cols"; -const char pstrUsageCursorPixelPosition [] PROGMEM = "Cur Pix Pos"; -const char pstrUsageCursorMode [] PROGMEM = "Cur Mode"; -const char pstrUsageCursorEnable [] PROGMEM = "Cur Enbl"; -const char pstrUsageCursorBlink [] PROGMEM = "Cur Blnk"; -const char pstrUsageFontReport [] PROGMEM = "Fnt Rpt"; -const char pstrUsageFontData [] PROGMEM = "Fnt Data"; -const char pstrUsageCharacterWidth [] PROGMEM = "Char Wdth"; -const char pstrUsageCharacterHeight [] PROGMEM = "Char Hght"; -const char pstrUsageCharacterSpacingHorizontal [] PROGMEM = "Char Space H"; -const char pstrUsageCharacterSpacingVertical [] PROGMEM = "Char Space V"; -const char pstrUsageUnicodeCharset [] PROGMEM = "Unicode Char"; -const char pstrUsageFont7Segment [] PROGMEM = "Fnt 7-seg"; -const char pstrUsage7SegmentDirectMap [] PROGMEM = "7-seg map"; -const char pstrUsageFont14Segment [] PROGMEM = "Fnt 14-seg"; -const char pstrUsage14SegmentDirectMap [] PROGMEM = "14-seg map"; -const char pstrUsageDisplayBrightness [] PROGMEM = "Disp Bright"; -const char pstrUsageDisplayContrast [] PROGMEM = "Disp Cntrst"; -const char pstrUsageCharacterAttribute [] PROGMEM = "Char Attr"; -const char pstrUsageAttributeReadback [] PROGMEM = "Attr Readbk"; -const char pstrUsageAttributeData [] PROGMEM = "Attr Data"; -const char pstrUsageCharAttributeEnhance [] PROGMEM = "Char Attr Enh"; -const char pstrUsageCharAttributeUnderline [] PROGMEM = "Char Attr Undl"; -const char pstrUsageCharAttributeBlink [] PROGMEM = "Char Attr Blnk"; -const char pstrUsageBitmapSizeX [] PROGMEM = "Bmp Size X"; -const char pstrUsageBitmapSizeY [] PROGMEM = "Bmp Size Y"; -const char pstrUsageBitDepthFormat [] PROGMEM = "Bit Dpth Fmt"; -const char pstrUsageDisplayOrientation [] PROGMEM = "Disp Ornt"; -const char pstrUsagePaletteReport [] PROGMEM = "Pal Rpt"; -const char pstrUsagePaletteDataSize [] PROGMEM = "Pal Data Size"; -const char pstrUsagePaletteDataOffset [] PROGMEM = "Pal Data Off"; -const char pstrUsagePaletteData [] PROGMEM = "Pal Data"; -const char pstrUsageBlitReport [] PROGMEM = "Blit Rpt"; -const char pstrUsageBlitRectangleX1 [] PROGMEM = "Blit Rect X1"; -const char pstrUsageBlitRectangleY1 [] PROGMEM = "Blit Rect Y1"; -const char pstrUsageBlitRectangleX2 [] PROGMEM = "Blit Rect X2"; -const char pstrUsageBlitRectangleY2 [] PROGMEM = "Blit Rect Y2"; -const char pstrUsageBlitData [] PROGMEM = "Blit Data"; -const char pstrUsageSoftButton [] PROGMEM = "Soft Btn"; -const char pstrUsageSoftButtonID [] PROGMEM = "Soft Btn ID"; -const char pstrUsageSoftButtonSide [] PROGMEM = "Soft Btn Side"; -const char pstrUsageSoftButtonOffset1 [] PROGMEM = "Soft Btn Off1"; -const char pstrUsageSoftButtonOffset2 [] PROGMEM = "Soft Btn Off2"; -const char pstrUsageSoftButtonReport [] PROGMEM = "Soft Btn Rpt"; - -// Medical Instrument Page -const char pstrUsageMedicalUltrasound [] PROGMEM = "Med Ultrasnd"; -const char pstrUsageVCRAcquisition [] PROGMEM = "VCR/Acq"; -const char pstrUsageFreezeThaw [] PROGMEM = "Freeze"; -const char pstrUsageClipStore [] PROGMEM = "Clip Store"; -const char pstrUsageUpdate [] PROGMEM = "Update"; -const char pstrUsageNext [] PROGMEM = "Next"; -const char pstrUsageSave [] PROGMEM = "Save"; -const char pstrUsagePrint [] PROGMEM = "Print"; -const char pstrUsageMicrophoneEnable [] PROGMEM = "Mic Enbl"; -const char pstrUsageCine [] PROGMEM = "Cine"; -const char pstrUsageTransmitPower [] PROGMEM = "Trans Pwr"; -//const char pstrUsageVolume [] PROGMEM = "Vol"; -const char pstrUsageFocus [] PROGMEM = "Focus"; -const char pstrUsageDepth [] PROGMEM = "Depth"; -const char pstrUsageSoftStepPrimary [] PROGMEM = "Soft Stp-Pri"; -const char pstrUsageSoftStepSecondary [] PROGMEM = "Soft Stp-Sec"; -const char pstrUsageDepthGainCompensation [] PROGMEM = "Dpth Gain Comp"; -const char pstrUsageZoomSelect [] PROGMEM = "Zoom Sel"; -const char pstrUsageZoomAdjust [] PROGMEM = "Zoom Adj"; -const char pstrUsageSpectralDopplerModeSelect [] PROGMEM = "Spec Dop Mode Sel"; -const char pstrUsageSpectralDopplerModeAdjust [] PROGMEM = "Spec Dop Mode Adj"; -const char pstrUsageColorDopplerModeSelect [] PROGMEM = "Color Dop Mode Sel"; -const char pstrUsageColorDopplerModeAdjust [] PROGMEM = "Color Dop Mode Adj"; -const char pstrUsageMotionModeSelect [] PROGMEM = "Motion Mode Sel"; -const char pstrUsageMotionModeAdjust [] PROGMEM = "Motion Mode Adj"; -const char pstrUsage2DModeSelect [] PROGMEM = "2D Mode Sel"; -const char pstrUsage2DModeAdjust [] PROGMEM = "2D Mode Adj"; -const char pstrUsageSoftControlSelect [] PROGMEM = "Soft Ctrl Sel"; -const char pstrUsageSoftControlAdjust [] PROGMEM = "Soft Ctrl Adj"; - -//extern const char *usagePageTitles0[15]; -//const char *usagePageTitles1[]; -//const char *genDesktopTitles0[]; -//const char *genDesktopTitles1[]; -//const char *genDesktopTitles2[]; -//const char *genDesktopTitles3[]; -//const char *genDesktopTitles4[]; -//const char *simuTitles0[]; -//const char *simuTitles1[]; -//const char *simuTitles2[]; -//const char *vrTitles0[]; -//const char *vrTitles1[]; -//const char *sportsCtrlTitles0[]; -//const char *sportsCtrlTitles1[]; -//const char *sportsCtrlTitles2[]; -//const char *gameTitles0[]; -//const char *gameTitles1[]; -//const char *genDevCtrlTitles[]; -//const char *ledTitles[]; -//const char *telTitles0[]; -//const char *telTitles1[]; -//const char *telTitles2[]; -//const char *telTitles3[]; -//const char *telTitles4[]; -//const char *telTitles5[]; -//const char *consTitles0[]; -//const char *consTitles1[]; -//const char *consTitles2[]; -//const char *consTitles3[]; -//const char *consTitles4[]; -//const char *consTitles5[]; -//const char *consTitles6[]; -//const char *consTitles7[]; -//const char *consTitles8[]; -//const char *consTitles9[]; -//const char *consTitlesA[]; -//const char *consTitlesB[]; -//const char *consTitlesC[]; -//const char *consTitlesD[]; -//const char *consTitlesE[]; -//const char *digitTitles0[]; -//const char *digitTitles1[]; -//const char *digitTitles2[]; -//const char *aplphanumTitles0[]; -//const char *aplphanumTitles1[]; -//const char *aplphanumTitles2[]; -//const char *medInstrTitles0[]; -//const char *medInstrTitles1[]; -//const char *medInstrTitles2[]; -//const char *medInstrTitles3[]; -//const char *medInstrTitles4[]; - -#endif //__HIDUSAGESTR_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/hidusagetitlearrays.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/hidusagetitlearrays.cpp deleted file mode 100644 index ee233002..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/hidusagetitlearrays.cpp +++ /dev/null @@ -1,1048 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(__HIDUSAGETITLEARRAYS_H__) -#define __HIDUSAGETITLEARRAYS_H__ - -#include "hidusagestr.h" - -// This is here why? - -//const char *usagePageTitles0[] PROGMEM = -//{ -// pstrUsagePageGenericDesktopControls , -// pstrUsagePageSimulationControls , -// pstrUsagePageVRControls , -// pstrUsagePageSportControls , -// pstrUsagePageGameControls , -// pstrUsagePageGenericDeviceControls , -// pstrUsagePageKeyboardKeypad , -// pstrUsagePageLEDs , -// pstrUsagePageButton , -// pstrUsagePageOrdinal , -// pstrUsagePageTelephone , -// pstrUsagePageConsumer , -// pstrUsagePageDigitizer , -// pstrUsagePagePID , -// pstrUsagePageUnicode -//}; -// -//const char *usagePageTitles1[] PROGMEM = -//{ -// pstrUsagePageBarCodeScanner , -// pstrUsagePageScale , -// pstrUsagePageMSRDevices , -// pstrUsagePagePointOfSale , -// pstrUsagePageCameraControl , -// pstrUsagePageArcade -//}; -//const char *genDesktopTitles0[] PROGMEM = -//{ -// pstrUsagePointer , -// pstrUsageMouse , -// pstrUsageJoystick , -// pstrUsageGamePad , -// pstrUsageKeyboard , -// pstrUsageKeypad , -// pstrUsageMultiAxisController , -// pstrUsageTabletPCSystemControls -// -//}; -//const char *genDesktopTitles1[] PROGMEM = -//{ -// pstrUsageX , -// pstrUsageY , -// pstrUsageZ , -// pstrUsageRx , -// pstrUsageRy , -// pstrUsageRz , -// pstrUsageSlider , -// pstrUsageDial , -// pstrUsageWheel , -// pstrUsageHatSwitch , -// pstrUsageCountedBuffer , -// pstrUsageByteCount , -// pstrUsageMotionWakeup , -// pstrUsageStart , -// pstrUsageSelect , -// pstrUsagePageReserved , -// pstrUsageVx , -// pstrUsageVy , -// pstrUsageVz , -// pstrUsageVbrx , -// pstrUsageVbry , -// pstrUsageVbrz , -// pstrUsageVno , -// pstrUsageFeatureNotification , -// pstrUsageResolutionMultiplier -//}; -//const char *genDesktopTitles2[] PROGMEM = -//{ -// pstrUsageSystemControl , -// pstrUsageSystemPowerDown , -// pstrUsageSystemSleep , -// pstrUsageSystemWakeup , -// pstrUsageSystemContextMenu , -// pstrUsageSystemMainMenu , -// pstrUsageSystemAppMenu , -// pstrUsageSystemMenuHelp , -// pstrUsageSystemMenuExit , -// pstrUsageSystemMenuSelect , -// pstrUsageSystemMenuRight , -// pstrUsageSystemMenuLeft , -// pstrUsageSystemMenuUp , -// pstrUsageSystemMenuDown , -// pstrUsageSystemColdRestart , -// pstrUsageSystemWarmRestart , -// pstrUsageDPadUp , -// pstrUsageDPadDown , -// pstrUsageDPadRight , -// pstrUsageDPadLeft -//}; -//const char *genDesktopTitles3[] PROGMEM = -//{ -// pstrUsageSystemDock , -// pstrUsageSystemUndock , -// pstrUsageSystemSetup , -// pstrUsageSystemBreak , -// pstrUsageSystemDebuggerBreak , -// pstrUsageApplicationBreak , -// pstrUsageApplicationDebuggerBreak, -// pstrUsageSystemSpeakerMute , -// pstrUsageSystemHibernate -//}; -//const char *genDesktopTitles4[] PROGMEM = -//{ -// pstrUsageSystemDisplayInvert , -// pstrUsageSystemDisplayInternal , -// pstrUsageSystemDisplayExternal , -// pstrUsageSystemDisplayBoth , -// pstrUsageSystemDisplayDual , -// pstrUsageSystemDisplayToggleIntExt , -// pstrUsageSystemDisplaySwapPriSec , -// pstrUsageSystemDisplayLCDAutoscale -//}; -//const char *simuTitles0[] PROGMEM = -//{ -// pstrUsageFlightSimulationDevice , -// pstrUsageAutomobileSimulationDevice , -// pstrUsageTankSimulationDevice , -// pstrUsageSpaceshipSimulationDevice , -// pstrUsageSubmarineSimulationDevice , -// pstrUsageSailingSimulationDevice , -// pstrUsageMotocicleSimulationDevice , -// pstrUsageSportsSimulationDevice , -// pstrUsageAirplaneSimulationDevice , -// pstrUsageHelicopterSimulationDevice , -// pstrUsageMagicCarpetSimulationDevice, -// pstrUsageBicycleSimulationDevice -//}; -//const char *simuTitles1[] PROGMEM = -//{ -// pstrUsageFlightControlStick , -// pstrUsageFlightStick , -// pstrUsageCyclicControl , -// pstrUsageCyclicTrim , -// pstrUsageFlightYoke , -// pstrUsageTrackControl -//}; -//const char *simuTitles2[] PROGMEM = -//{ -// pstrUsageAileron , -// pstrUsageAileronTrim , -// pstrUsageAntiTorqueControl , -// pstrUsageAutopilotEnable , -// pstrUsageChaffRelease , -// pstrUsageCollectiveControl , -// pstrUsageDiveBrake , -// pstrUsageElectronicCountermeasures , -// pstrUsageElevator , -// pstrUsageElevatorTrim , -// pstrUsageRudder , -// pstrUsageThrottle , -// pstrUsageFlightCommunications , -// pstrUsageFlareRelease , -// pstrUsageLandingGear , -// pstrUsageToeBrake , -// pstrUsageTrigger , -// pstrUsageWeaponsArm , -// pstrUsageWeaponsSelect , -// pstrUsageWingFlaps , -// pstrUsageAccelerator , -// pstrUsageBrake , -// pstrUsageClutch , -// pstrUsageShifter , -// pstrUsageSteering , -// pstrUsageTurretDirection , -// pstrUsageBarrelElevation , -// pstrUsageDivePlane , -// pstrUsageBallast , -// pstrUsageBicycleCrank , -// pstrUsageHandleBars , -// pstrUsageFrontBrake , -// pstrUsageRearBrake -//}; -//const char *vrTitles0[] PROGMEM = -//{ -// pstrUsageBelt , -// pstrUsageBodySuit , -// pstrUsageFlexor , -// pstrUsageGlove , -// pstrUsageHeadTracker , -// pstrUsageHeadMountedDisplay , -// pstrUsageHandTracker , -// pstrUsageOculometer , -// pstrUsageVest , -// pstrUsageAnimatronicDevice -//}; -//const char *vrTitles1[] PROGMEM = -//{ -// pstrUsageStereoEnable , -// pstrUsageDisplayEnable -//}; -//const char *sportsCtrlTitles0[] PROGMEM = -//{ -// pstrUsageBaseballBat , -// pstrUsageGolfClub , -// pstrUsageRowingMachine , -// pstrUsageTreadmill -//}; -//const char *sportsCtrlTitles1[] PROGMEM = -//{ -// pstrUsageOar , -// pstrUsageSlope , -// pstrUsageRate , -// pstrUsageStickSpeed , -// pstrUsageStickFaceAngle , -// pstrUsageStickHeelToe , -// pstrUsageStickFollowThough , -// pstrUsageStickTempo , -// pstrUsageStickType , -// pstrUsageStickHeight -//}; -//const char *sportsCtrlTitles2[] PROGMEM = -//{ -// pstrUsagePutter , -// pstrUsage1Iron , -// pstrUsage2Iron , -// pstrUsage3Iron , -// pstrUsage4Iron , -// pstrUsage5Iron , -// pstrUsage6Iron , -// pstrUsage7Iron , -// pstrUsage8Iron , -// pstrUsage9Iron , -// pstrUsage10Iron , -// pstrUsage11Iron , -// pstrUsageSandWedge , -// pstrUsageLoftWedge , -// pstrUsagePowerWedge , -// pstrUsage1Wood , -// pstrUsage3Wood , -// pstrUsage5Wood , -// pstrUsage7Wood , -// pstrUsage9Wood -//}; -//const char *gameTitles0[] PROGMEM = -//{ -// pstrUsage3DGameController , -// pstrUsagePinballDevice , -// pstrUsageGunDevice -//}; -//const char *gameTitles1[] PROGMEM = -//{ -// pstrUsagePointOfView , -// pstrUsageTurnRightLeft , -// pstrUsagePitchForwardBackward , -// pstrUsageRollRightLeft , -// pstrUsageMoveRightLeft , -// pstrUsageMoveForwardBackward , -// pstrUsageMoveUpDown , -// pstrUsageLeanRightLeft , -// pstrUsageLeanForwardBackward , -// pstrUsageHeightOfPOV , -// pstrUsageFlipper , -// pstrUsageSecondaryFlipper , -// pstrUsageBump , -// pstrUsageNewGame , -// pstrUsageShootBall , -// pstrUsagePlayer , -// pstrUsageGunBolt , -// pstrUsageGunClip , -// pstrUsageGunSelector , -// pstrUsageGunSingleShot , -// pstrUsageGunBurst , -// pstrUsageGunAutomatic , -// pstrUsageGunSafety , -// pstrUsageGamepadFireJump , -// pstrUsageGamepadTrigger -//}; -//const char *genDevCtrlTitles[] PROGMEM = -//{ -// pstrUsageBatteryStrength, -// pstrUsageWirelessChannel, -// pstrUsageWirelessID, -// pstrUsageDiscoverWirelessControl, -// pstrUsageSecurityCodeCharEntered, -// pstrUsageSecurityCodeCharErased, -// pstrUsageSecurityCodeCleared -//}; -//const char *ledTitles[] PROGMEM = -//{ -// pstrUsageNumLock , -// pstrUsageCapsLock , -// pstrUsageScrollLock , -// pstrUsageCompose , -// pstrUsageKana , -// pstrUsagePower , -// pstrUsageShift , -// pstrUsageDoNotDisturb , -// pstrUsageMute , -// pstrUsageToneEnable , -// pstrUsageHighCutFilter , -// pstrUsageLowCutFilter , -// pstrUsageEqualizerEnable , -// pstrUsageSoundFieldOn , -// pstrUsageSurroundOn , -// pstrUsageRepeat , -// pstrUsageStereo , -// pstrUsageSamplingRateDetect , -// pstrUsageSpinning , -// pstrUsageCAV , -// pstrUsageCLV , -// pstrUsageRecordingFormatDetect , -// pstrUsageOffHook , -// pstrUsageRing , -// pstrUsageMessageWaiting , -// pstrUsageDataMode , -// pstrUsageBatteryOperation , -// pstrUsageBatteryOK , -// pstrUsageBatteryLow , -// pstrUsageSpeaker , -// pstrUsageHeadSet , -// pstrUsageHold , -// pstrUsageMicrophone , -// pstrUsageCoverage , -// pstrUsageNightMode , -// pstrUsageSendCalls , -// pstrUsageCallPickup , -// pstrUsageConference , -// pstrUsageStandBy , -// pstrUsageCameraOn , -// pstrUsageCameraOff , -// pstrUsageOnLine , -// pstrUsageOffLine , -// pstrUsageBusy , -// pstrUsageReady , -// pstrUsagePaperOut , -// pstrUsagePaperJam , -// pstrUsageRemote , -// pstrUsageForward , -// pstrUsageReverse , -// pstrUsageStop , -// pstrUsageRewind , -// pstrUsageFastForward , -// pstrUsagePlay , -// pstrUsagePause , -// pstrUsageRecord , -// pstrUsageError , -// pstrUsageSelectedIndicator , -// pstrUsageInUseIndicator , -// pstrUsageMultiModeIndicator , -// pstrUsageIndicatorOn , -// pstrUsageIndicatorFlash , -// pstrUsageIndicatorSlowBlink , -// pstrUsageIndicatorFastBlink , -// pstrUsageIndicatorOff , -// pstrUsageFlashOnTime , -// pstrUsageSlowBlinkOnTime , -// pstrUsageSlowBlinkOffTime , -// pstrUsageFastBlinkOnTime , -// pstrUsageFastBlinkOffTime , -// pstrUsageIndicatorColor , -// pstrUsageIndicatorRed , -// pstrUsageIndicatorGreen , -// pstrUsageIndicatorAmber , -// pstrUsageGenericIndicator , -// pstrUsageSystemSuspend , -// pstrUsageExternalPowerConnected -//}; -//const char *telTitles0 [] PROGMEM = -//{ -// pstrUsagePhone , -// pstrUsageAnsweringMachine , -// pstrUsageMessageControls , -// pstrUsageHandset , -// pstrUsageHeadset , -// pstrUsageTelephonyKeyPad , -// pstrUsageProgrammableButton -//}; -//const char *telTitles1 [] PROGMEM = -//{ -// pstrUsageHookSwitch , -// pstrUsageFlash , -// pstrUsageFeature , -// pstrUsageHold , -// pstrUsageRedial , -// pstrUsageTransfer , -// pstrUsageDrop , -// pstrUsagePark , -// pstrUsageForwardCalls , -// pstrUsageAlternateFunction , -// pstrUsageLine , -// pstrUsageSpeakerPhone , -// pstrUsageConference , -// pstrUsageRingEnable , -// pstrUsageRingSelect , -// pstrUsagePhoneMute , -// pstrUsageCallerID , -// pstrUsageSend -//}; -//const char *telTitles2 [] PROGMEM = -//{ -// pstrUsageSpeedDial , -// pstrUsageStoreNumber , -// pstrUsageRecallNumber , -// pstrUsagePhoneDirectory -//}; -//const char *telTitles3 [] PROGMEM = -//{ -// pstrUsageVoiceMail , -// pstrUsageScreenCalls , -// pstrUsageDoNotDisturb , -// pstrUsageMessage , -// pstrUsageAnswerOnOff -//}; -//const char *telTitles4 [] PROGMEM = -//{ -// pstrUsageInsideDialTone , -// pstrUsageOutsideDialTone , -// pstrUsageInsideRingTone , -// pstrUsageOutsideRingTone , -// pstrUsagePriorityRingTone , -// pstrUsageInsideRingback , -// pstrUsagePriorityRingback , -// pstrUsageLineBusyTone , -// pstrUsageReorderTone , -// pstrUsageCallWaitingTone , -// pstrUsageConfirmationTone1 , -// pstrUsageConfirmationTone2 , -// pstrUsageTonesOff , -// pstrUsageOutsideRingback , -// pstrUsageRinger -//}; -//const char *telTitles5 [] PROGMEM = -//{ -// pstrUsagePhoneKey0 , -// pstrUsagePhoneKey1 , -// pstrUsagePhoneKey2 , -// pstrUsagePhoneKey3 , -// pstrUsagePhoneKey4 , -// pstrUsagePhoneKey5 , -// pstrUsagePhoneKey6 , -// pstrUsagePhoneKey7 , -// pstrUsagePhoneKey8 , -// pstrUsagePhoneKey9 , -// pstrUsagePhoneKeyStar , -// pstrUsagePhoneKeyPound , -// pstrUsagePhoneKeyA , -// pstrUsagePhoneKeyB , -// pstrUsagePhoneKeyC , -// pstrUsagePhoneKeyD -//}; -//const char *consTitles0[] PROGMEM = -//{ -// pstrUsageConsumerControl, -// pstrUsageNumericKeyPad, -// pstrUsageProgrammableButton, -// pstrUsageMicrophone, -// pstrUsageHeadphone, -// pstrUsageGraphicEqualizer -//}; -//const char *consTitles1[] PROGMEM = -//{ -// pstrUsagePlus10 , -// pstrUsagePlus100, -// pstrUsageAMPM -//}; -//const char *consTitles2[] PROGMEM = -//{ -// pstrUsagePower , -// pstrUsageReset , -// pstrUsageSleep , -// pstrUsageSleepAfter , -// pstrUsageSleepMode , -// pstrUsageIllumination , -// pstrUsageFunctionButtons -// -//}; -//const char *consTitles3[] PROGMEM = -//{ -// pstrUsageMenu , -// pstrUsageMenuPick , -// pstrUsageMenuUp , -// pstrUsageMenuDown , -// pstrUsageMenuLeft , -// pstrUsageMenuRight , -// pstrUsageMenuEscape , -// pstrUsageMenuValueIncrease, -// pstrUsageMenuValueDecrease -//}; -//const char *consTitles4[] PROGMEM = -//{ -// pstrUsageDataOnScreen , -// pstrUsageClosedCaption , -// pstrUsageClosedCaptionSelect, -// pstrUsageVCRTV , -// pstrUsageBroadcastMode , -// pstrUsageSnapshot , -// pstrUsageStill -//}; -//const char *consTitles5[] PROGMEM = -//{ -// pstrUsageSelection , -// pstrUsageAssignSelection , -// pstrUsageModeStep , -// pstrUsageRecallLast , -// pstrUsageEnterChannel , -// pstrUsageOrderMovie , -// pstrUsageChannel , -// pstrUsageMediaSelection , -// pstrUsageMediaSelectComputer , -// pstrUsageMediaSelectTV , -// pstrUsageMediaSelectWWW , -// pstrUsageMediaSelectDVD , -// pstrUsageMediaSelectTelephone , -// pstrUsageMediaSelectProgramGuide , -// pstrUsageMediaSelectVideoPhone , -// pstrUsageMediaSelectGames , -// pstrUsageMediaSelectMessages , -// pstrUsageMediaSelectCD , -// pstrUsageMediaSelectVCR , -// pstrUsageMediaSelectTuner , -// pstrUsageQuit , -// pstrUsageHelp , -// pstrUsageMediaSelectTape , -// pstrUsageMediaSelectCable , -// pstrUsageMediaSelectSatellite , -// pstrUsageMediaSelectSecurity , -// pstrUsageMediaSelectHome , -// pstrUsageMediaSelectCall , -// pstrUsageChannelIncrement , -// pstrUsageChannelDecrement , -// pstrUsageMediaSelectSAP , -// pstrUsagePageReserved , -// pstrUsageVCRPlus , -// pstrUsageOnce , -// pstrUsageDaily , -// pstrUsageWeekly , -// pstrUsageMonthly -//}; -//const char *consTitles6[] PROGMEM = -//{ -// pstrUsagePlay , -// pstrUsagePause , -// pstrUsageRecord , -// pstrUsageFastForward , -// pstrUsageRewind , -// pstrUsageScanNextTrack , -// pstrUsageScanPreviousTrack , -// pstrUsageStop , -// pstrUsageEject , -// pstrUsageRandomPlay , -// pstrUsageSelectDisk , -// pstrUsageEnterDisk , -// pstrUsageRepeat , -// pstrUsageTracking , -// pstrUsageTrackNormal , -// pstrUsageSlowTracking , -// pstrUsageFrameForward , -// pstrUsageFrameBackwards , -// pstrUsageMark , -// pstrUsageClearMark , -// pstrUsageRepeatFromMark , -// pstrUsageReturnToMark , -// pstrUsageSearchMarkForward , -// pstrUsageSearchMarkBackwards , -// pstrUsageCounterReset , -// pstrUsageShowCounter , -// pstrUsageTrackingIncrement , -// pstrUsageTrackingDecrement , -// pstrUsageStopEject , -// pstrUsagePlayPause , -// pstrUsagePlaySkip -//}; -//const char *consTitles7[] PROGMEM = -//{ -// pstrUsageVolume , -// pstrUsageBalance , -// pstrUsageMute , -// pstrUsageBass , -// pstrUsageTreble , -// pstrUsageBassBoost , -// pstrUsageSurroundMode , -// pstrUsageLoudness , -// pstrUsageMPX , -// pstrUsageVolumeIncrement , -// pstrUsageVolumeDecrement -//}; -//const char *consTitles8[] PROGMEM = -//{ -// pstrUsageSpeedSelect , -// pstrUsagePlaybackSpeed , -// pstrUsageStandardPlay , -// pstrUsageLongPlay , -// pstrUsageExtendedPlay , -// pstrUsageSlow -//}; -//const char *consTitles9[] PROGMEM = -//{ -// pstrUsageFanEnable , -// pstrUsageFanSpeed , -// pstrUsageLightEnable , -// pstrUsageLightIlluminationLevel , -// pstrUsageClimateControlEnable , -// pstrUsageRoomTemperature , -// pstrUsageSecurityEnable , -// pstrUsageFireAlarm , -// pstrUsagePoliceAlarm , -// pstrUsageProximity , -// pstrUsageMotion , -// pstrUsageDuresAlarm , -// pstrUsageHoldupAlarm , -// pstrUsageMedicalAlarm -//}; -//const char *consTitlesA[] PROGMEM = -//{ -// pstrUsageBalanceRight , -// pstrUsageBalanceLeft , -// pstrUsageBassIncrement , -// pstrUsageBassDecrement , -// pstrUsageTrebleIncrement , -// pstrUsageTrebleDecrement -//}; -//const char *consTitlesB[] PROGMEM = -//{ -// pstrUsageSpeakerSystem , -// pstrUsageChannelLeft , -// pstrUsageChannelRight , -// pstrUsageChannelCenter , -// pstrUsageChannelFront , -// pstrUsageChannelCenterFront , -// pstrUsageChannelSide , -// pstrUsageChannelSurround , -// pstrUsageChannelLowFreqEnhancement , -// pstrUsageChannelTop , -// pstrUsageChannelUnknown -//}; -//const char *consTitlesC[] PROGMEM = -//{ -// pstrUsageSubChannel , -// pstrUsageSubChannelIncrement , -// pstrUsageSubChannelDecrement , -// pstrUsageAlternateAudioIncrement , -// pstrUsageAlternateAudioDecrement -//}; -//const char *consTitlesD[] PROGMEM = -//{ -// pstrUsageApplicationLaunchButtons , -// pstrUsageALLaunchButtonConfigTool , -// pstrUsageALProgrammableButton , -// pstrUsageALConsumerControlConfig , -// pstrUsageALWordProcessor , -// pstrUsageALTextEditor , -// pstrUsageALSpreadsheet , -// pstrUsageALGraphicsEditor , -// pstrUsageALPresentationApp , -// pstrUsageALDatabaseApp , -// pstrUsageALEmailReader , -// pstrUsageALNewsreader , -// pstrUsageALVoicemail , -// pstrUsageALContactsAddressBook , -// pstrUsageALCalendarSchedule , -// pstrUsageALTaskProjectManager , -// pstrUsageALLogJournalTimecard , -// pstrUsageALCheckbookFinance , -// pstrUsageALCalculator , -// pstrUsageALAVCapturePlayback , -// pstrUsageALLocalMachineBrowser , -// pstrUsageALLANWANBrow , -// pstrUsageALInternetBrowser , -// pstrUsageALRemoteNetISPConnect , -// pstrUsageALNetworkConference , -// pstrUsageALNetworkChat , -// pstrUsageALTelephonyDialer , -// pstrUsageALLogon , -// pstrUsageALLogoff , -// pstrUsageALLogonLogoff , -// pstrUsageALTermLockScrSav , -// pstrUsageALControlPannel , -// pstrUsageALCommandLineProcessorRun , -// pstrUsageALProcessTaskManager , -// pstrUsageALSelectTaskApplication , -// pstrUsageALNextTaskApplication , -// pstrUsageALPreviousTaskApplication , -// pstrUsageALPreemptiveHaltTaskApp , -// pstrUsageALIntegratedHelpCenter , -// pstrUsageALDocuments , -// pstrUsageALThesaurus , -// pstrUsageALDictionary , -// pstrUsageALDesktop , -// pstrUsageALSpellCheck , -// pstrUsageALGrammarCheck , -// pstrUsageALWirelessStatus , -// pstrUsageALKeyboardLayout , -// pstrUsageALVirusProtection , -// pstrUsageALEncryption , -// pstrUsageALScreenSaver , -// pstrUsageALAlarms , -// pstrUsageALClock , -// pstrUsageALFileBrowser , -// pstrUsageALPowerStatus , -// pstrUsageALImageBrowser , -// pstrUsageALAudioBrowser , -// pstrUsageALMovieBrowser , -// pstrUsageALDigitalRightsManager , -// pstrUsageALDigitalWallet , -// pstrUsagePageReserved , -// pstrUsageALInstantMessaging , -// pstrUsageALOEMFeaturesBrowser , -// pstrUsageALOEMHelp , -// pstrUsageALOnlineCommunity , -// pstrUsageALEntertainmentContentBrow , -// pstrUsageALOnlineShoppingBrowser , -// pstrUsageALSmartCardInfoHelp , -// pstrUsageALMarketMonitorFinBrowser , -// pstrUsageALCustomCorpNewsBrowser , -// pstrUsageALOnlineActivityBrowser , -// pstrUsageALResearchSearchBrowser , -// pstrUsageALAudioPlayer -//}; -//const char *consTitlesE[] PROGMEM = -//{ -// pstrUsageGenericGUIAppControls , -// pstrUsageACNew , -// pstrUsageACOpen , -// pstrUsageACClose , -// pstrUsageACExit , -// pstrUsageACMaximize , -// pstrUsageACMinimize , -// pstrUsageACSave , -// pstrUsageACPrint , -// pstrUsageACProperties , -// pstrUsageACUndo , -// pstrUsageACCopy , -// pstrUsageACCut , -// pstrUsageACPaste , -// pstrUsageACSelectAll , -// pstrUsageACFind , -// pstrUsageACFindAndReplace , -// pstrUsageACSearch , -// pstrUsageACGoto , -// pstrUsageACHome , -// pstrUsageACBack , -// pstrUsageACForward , -// pstrUsageACStop , -// pstrUsageACRefresh , -// pstrUsageACPreviousLink , -// pstrUsageACNextLink , -// pstrUsageACBookmarks , -// pstrUsageACHistory , -// pstrUsageACSubscriptions , -// pstrUsageACZoomIn , -// pstrUsageACZoomOut , -// pstrUsageACZoom , -// pstrUsageACFullScreenView , -// pstrUsageACNormalView , -// pstrUsageACViewToggle , -// pstrUsageACScrollUp , -// pstrUsageACScrollDown , -// pstrUsageACScroll , -// pstrUsageACPanLeft , -// pstrUsageACPanRight , -// pstrUsageACPan , -// pstrUsageACNewWindow , -// pstrUsageACTileHoriz , -// pstrUsageACTileVert , -// pstrUsageACFormat , -// pstrUsageACEdit , -// pstrUsageACBold , -// pstrUsageACItalics , -// pstrUsageACUnderline , -// pstrUsageACStrikethrough , -// pstrUsageACSubscript , -// pstrUsageACSuperscript , -// pstrUsageACAllCaps , -// pstrUsageACRotate , -// pstrUsageACResize , -// pstrUsageACFlipHorizontal , -// pstrUsageACFlipVertical , -// pstrUsageACMirrorHorizontal , -// pstrUsageACMirrorVertical , -// pstrUsageACFontSelect , -// pstrUsageACFontColor , -// pstrUsageACFontSize , -// pstrUsageACJustifyLeft , -// pstrUsageACJustifyCenterH , -// pstrUsageACJustifyRight , -// pstrUsageACJustifyBlockH , -// pstrUsageACJustifyTop , -// pstrUsageACJustifyCenterV , -// pstrUsageACJustifyBottom , -// pstrUsageACJustifyBlockV , -// pstrUsageACIndentDecrease , -// pstrUsageACIndentIncrease , -// pstrUsageACNumberedList , -// pstrUsageACRestartNumbering , -// pstrUsageACBulletedList , -// pstrUsageACPromote , -// pstrUsageACDemote , -// pstrUsageACYes , -// pstrUsageACNo , -// pstrUsageACCancel , -// pstrUsageACCatalog , -// pstrUsageACBuyChkout , -// pstrUsageACAddToCart , -// pstrUsageACExpand , -// pstrUsageACExpandAll , -// pstrUsageACCollapse , -// pstrUsageACCollapseAll , -// pstrUsageACPrintPreview , -// pstrUsageACPasteSpecial , -// pstrUsageACInsertMode , -// pstrUsageACDelete , -// pstrUsageACLock , -// pstrUsageACUnlock , -// pstrUsageACProtect , -// pstrUsageACUnprotect , -// pstrUsageACAttachComment , -// pstrUsageACDeleteComment , -// pstrUsageACViewComment , -// pstrUsageACSelectWord , -// pstrUsageACSelectSentence , -// pstrUsageACSelectParagraph , -// pstrUsageACSelectColumn , -// pstrUsageACSelectRow , -// pstrUsageACSelectTable , -// pstrUsageACSelectObject , -// pstrUsageACRedoRepeat , -// pstrUsageACSort , -// pstrUsageACSortAscending , -// pstrUsageACSortDescending , -// pstrUsageACFilter , -// pstrUsageACSetClock , -// pstrUsageACViewClock , -// pstrUsageACSelectTimeZone , -// pstrUsageACEditTimeZone , -// pstrUsageACSetAlarm , -// pstrUsageACClearAlarm , -// pstrUsageACSnoozeAlarm , -// pstrUsageACResetAlarm , -// pstrUsageACSyncronize , -// pstrUsageACSendReceive , -// pstrUsageACSendTo , -// pstrUsageACReply , -// pstrUsageACReplyAll , -// pstrUsageACForwardMessage , -// pstrUsageACSend , -// pstrUsageACAttachFile , -// pstrUsageACUpload , -// pstrUsageACDownload , -// pstrUsageACSetBorders , -// pstrUsageACInsertRow , -// pstrUsageACInsertColumn , -// pstrUsageACInsertFile , -// pstrUsageACInsertPicture , -// pstrUsageACInsertObject , -// pstrUsageACInsertSymbol , -// pstrUsageACSaveAndClose , -// pstrUsageACRename , -// pstrUsageACMerge , -// pstrUsageACSplit , -// pstrUsageACDistributeHorizontaly , -// pstrUsageACDistributeVerticaly -//}; -//const char *digitTitles0[] PROGMEM = -//{ -// pstrUsageDigitizer , -// pstrUsagePen , -// pstrUsageLightPen , -// pstrUsageTouchScreen , -// pstrUsageTouchPad , -// pstrUsageWhiteBoard , -// pstrUsageCoordinateMeasuringMachine , -// pstrUsage3DDigitizer , -// pstrUsageStereoPlotter , -// pstrUsageArticulatedArm , -// pstrUsageArmature , -// pstrUsageMultiplePointDigitizer , -// pstrUsageFreeSpaceWand -//}; -//const char *digitTitles1[] PROGMEM = -//{ -// pstrUsageStylus , -// pstrUsagePuck , -// pstrUsageFinger -// -//}; -//const char *digitTitles2[] PROGMEM = -//{ -// pstrUsageTipPressure , -// pstrUsageBarrelPressure , -// pstrUsageInRange , -// pstrUsageTouch , -// pstrUsageUntouch , -// pstrUsageTap , -// pstrUsageQuality , -// pstrUsageDataValid , -// pstrUsageTransducerIndex , -// pstrUsageTabletFunctionKeys , -// pstrUsageProgramChangeKeys , -// pstrUsageBatteryStrength , -// pstrUsageInvert , -// pstrUsageXTilt , -// pstrUsageYTilt , -// pstrUsageAzimuth , -// pstrUsageAltitude , -// pstrUsageTwist , -// pstrUsageTipSwitch , -// pstrUsageSecondaryTipSwitch , -// pstrUsageBarrelSwitch , -// pstrUsageEraser , -// pstrUsageTabletPick -//}; -//const char *aplphanumTitles0[] PROGMEM = -//{ -// pstrUsageAlphanumericDisplay, -// pstrUsageBitmappedDisplay -//}; -//const char *aplphanumTitles1[] PROGMEM = -//{ -// pstrUsageDisplayAttributesReport , -// pstrUsageASCIICharacterSet , -// pstrUsageDataReadBack , -// pstrUsageFontReadBack , -// pstrUsageDisplayControlReport , -// pstrUsageClearDisplay , -// pstrUsageDisplayEnable , -// pstrUsageScreenSaverDelay , -// pstrUsageScreenSaverEnable , -// pstrUsageVerticalScroll , -// pstrUsageHorizontalScroll , -// pstrUsageCharacterReport , -// pstrUsageDisplayData , -// pstrUsageDisplayStatus , -// pstrUsageStatusNotReady , -// pstrUsageStatusReady , -// pstrUsageErrorNotALoadableCharacter , -// pstrUsageErrorFotDataCanNotBeRead , -// pstrUsageCursorPositionReport , -// pstrUsageRow , -// pstrUsageColumn , -// pstrUsageRows , -// pstrUsageColumns , -// pstrUsageCursorPixelPosition , -// pstrUsageCursorMode , -// pstrUsageCursorEnable , -// pstrUsageCursorBlink , -// pstrUsageFontReport , -// pstrUsageFontData , -// pstrUsageCharacterWidth , -// pstrUsageCharacterHeight , -// pstrUsageCharacterSpacingHorizontal , -// pstrUsageCharacterSpacingVertical , -// pstrUsageUnicodeCharset , -// pstrUsageFont7Segment , -// pstrUsage7SegmentDirectMap , -// pstrUsageFont14Segment , -// pstrUsage14SegmentDirectMap , -// pstrUsageDisplayBrightness , -// pstrUsageDisplayContrast , -// pstrUsageCharacterAttribute , -// pstrUsageAttributeReadback , -// pstrUsageAttributeData , -// pstrUsageCharAttributeEnhance , -// pstrUsageCharAttributeUnderline , -// pstrUsageCharAttributeBlink -//}; -//const char *aplphanumTitles2[] PROGMEM = -//{ -// pstrUsageBitmapSizeX , -// pstrUsageBitmapSizeY , -// pstrUsagePageReserved , -// pstrUsageBitDepthFormat , -// pstrUsageDisplayOrientation , -// pstrUsagePaletteReport , -// pstrUsagePaletteDataSize , -// pstrUsagePaletteDataOffset , -// pstrUsagePaletteData , -// pstrUsageBlitReport , -// pstrUsageBlitRectangleX1 , -// pstrUsageBlitRectangleY1 , -// pstrUsageBlitRectangleX2 , -// pstrUsageBlitRectangleY2 , -// pstrUsageBlitData , -// pstrUsageSoftButton , -// pstrUsageSoftButtonID , -// pstrUsageSoftButtonSide , -// pstrUsageSoftButtonOffset1 , -// pstrUsageSoftButtonOffset2 , -// pstrUsageSoftButtonReport -//}; -//const char *medInstrTitles0[] PROGMEM = -//{ -// pstrUsageVCRAcquisition , -// pstrUsageFreezeThaw , -// pstrUsageClipStore , -// pstrUsageUpdate , -// pstrUsageNext , -// pstrUsageSave , -// pstrUsagePrint , -// pstrUsageMicrophoneEnable -//}; -//const char *medInstrTitles1[] PROGMEM = -//{ -// pstrUsageCine , -// pstrUsageTransmitPower , -// pstrUsageVolume , -// pstrUsageFocus , -// pstrUsageDepth -//}; -//const char *medInstrTitles2[] PROGMEM = -//{ -// pstrUsageSoftStepPrimary , -// pstrUsageSoftStepSecondary -//}; -//const char *medInstrTitles3[] PROGMEM = -//{ -// pstrUsageZoomSelect , -// pstrUsageZoomAdjust , -// pstrUsageSpectralDopplerModeSelect , -// pstrUsageSpectralDopplerModeAdjust , -// pstrUsageColorDopplerModeSelect , -// pstrUsageColorDopplerModeAdjust , -// pstrUsageMotionModeSelect , -// pstrUsageMotionModeAdjust , -// pstrUsage2DModeSelect , -// pstrUsage2DModeAdjust -//}; -//const char *medInstrTitles4[] PROGMEM = -//{ -// pstrUsageSoftControlSelect , -// pstrUsageSoftControlAdjust -//}; - -#endif // __HIDUSAGETITLEARRAYS_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/keywords.txt b/protocol/usb_hid/USB_Host_Shield_2.0/keywords.txt deleted file mode 100644 index f4e19cd1..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/keywords.txt +++ /dev/null @@ -1,371 +0,0 @@ -#################################################### -# Syntax Coloring Map For USB Library -#################################################### - -#################################################### -# Datatypes (KEYWORD1) -#################################################### - -USB KEYWORD1 -USBHub KEYWORD1 - -#################################################### -# Syntax Coloring Map For BTD (Bluetooth) Library -#################################################### - -#################################################### -# Datatypes (KEYWORD1) -#################################################### - -BTD KEYWORD1 - -#################################################### -# Methods and Functions (KEYWORD2) -#################################################### -Task KEYWORD2 - -#################################################### -# Syntax Coloring Map For PS3/PS4 Bluetooth/USB Library -#################################################### - -#################################################### -# Datatypes (KEYWORD1) -#################################################### - -PS3BT KEYWORD1 -PS3USB KEYWORD1 -PS4BT KEYWORD1 -PS4USB KEYWORD1 - -#################################################### -# Methods and Functions (KEYWORD2) -#################################################### -setBdaddr KEYWORD2 -getBdaddr KEYWORD2 -setMoveBdaddr KEYWORD2 -getMoveBdaddr KEYWORD2 -getMoveCalibration KEYWORD2 - -getButtonPress KEYWORD2 -getButtonClick KEYWORD2 -getAnalogButton KEYWORD2 -getAnalogHat KEYWORD2 -getSensor KEYWORD2 -getAngle KEYWORD2 -get9DOFValues KEYWORD2 -getStatus KEYWORD2 -printStatusString KEYWORD2 -getTemperature KEYWORD2 -disconnect KEYWORD2 - -setAllOff KEYWORD2 -setRumbleOff KEYWORD2 -setRumbleOn KEYWORD2 -setLedOff KEYWORD2 -setLedOn KEYWORD2 -setLedToggle KEYWORD2 -setLedFlash KEYWORD2 -moveSetBulb KEYWORD2 -moveSetRumble KEYWORD2 - -attachOnInit KEYWORD2 - -PS3Connected KEYWORD2 -PS3MoveConnected KEYWORD2 -PS3NavigationConnected KEYWORD2 - -isReady KEYWORD2 -watingForConnection KEYWORD2 - -isTouching KEYWORD2 -getX KEYWORD2 -getY KEYWORD2 -getTouchCounter KEYWORD2 - -getUsbStatus KEYWORD2 -getAudioStatus KEYWORD2 -getMicStatus KEYWORD2 - -#################################################### -# Constants and enums (LITERAL1) -#################################################### -OFF LITERAL1 -LED1 LITERAL1 -LED2 LITERAL1 -LED3 LITERAL1 -LED4 LITERAL1 -LED5 LITERAL1 -LED6 LITERAL1 -LED7 LITERAL1 -LED8 LITERAL1 -LED9 LITERAL1 -LED10 LITERAL1 - -Red LITERAL1 -Green LITERAL1 -Blue LITERAL1 -Yellow LITERAL1 -Lightblue LITERAL1 -Purble LITERAL1 -White LITERAL1 -Off LITERAL1 - -SELECT LITERAL1 -L3 LITERAL1 -R3 LITERAL1 -START LITERAL1 -UP LITERAL1 -RIGHT LITERAL1 -DOWN LITERAL1 -LEFT LITERAL1 -L2 LITERAL1 -R2 LITERAL1 -L1 LITERAL1 -R1 LITERAL1 -TRIANGLE LITERAL1 -CIRCLE LITERAL1 -CROSS LITERAL1 -SQUARE LITERAL1 -PS LITERAL1 -MOVE LITERAL1 -T LITERAL1 - -SHARE LITERAL1 -OPTIONS LITERAL1 -TOUCHPAD LITERAL1 - -LeftHatX LITERAL1 -LeftHatY LITERAL1 -RightHatX LITERAL1 -RightHatY LITERAL1 - -aX LITERAL1 -aY LITERAL1 -aZ LITERAL1 -gX LITERAL1 -gY LITERAL1 -gZ LITERAL1 -aXmove LITERAL1 -aYmove LITERAL1 -aZmove LITERAL1 -gXmove LITERAL1 -gYmove LITERAL1 -gZmove LITERAL1 -tempMove LITERAL1 -mXmove LITERAL1 -mZmove LITERAL1 -mYmove LITERAL1 - -Pitch LITERAL1 -Roll LITERAL1 - -Plugged LITERAL1 -Unplugged LITERAL1 -Charging LITERAL1 -NotCharging LITERAL1 -Shutdown LITERAL1 -Dying LITERAL1 -Low LITERAL1 -High LITERAL1 -Full LITERAL1 -MoveCharging LITERAL1 -MoveNotCharging LITERAL1 -MoveShutdown LITERAL1 -MoveDying LITERAL1 -MoveLow LITERAL1 -MoveHigh LITERAL1 -MoveFull LITERAL1 -CableRumble LITERAL1 -Cable LITERAL1 -BluetoothRumble LITERAL1 -Bluetooth LITERAL1 - -RumbleHigh LITERAL1 -RumbleLow LITERAL1 - -#################################################### -# Syntax Coloring Map For Xbox 360 Libraries -#################################################### - -#################################################### -# Datatypes (KEYWORD1) -#################################################### - -XBOXUSB KEYWORD1 -XBOXONE KEYWORD1 -XBOXOLD KEYWORD1 -XBOXRECV KEYWORD1 - -#################################################### -# Methods and Functions (KEYWORD2) -#################################################### - -setLedRaw KEYWORD2 -setLedBlink KEYWORD2 -setLedMode KEYWORD2 -getBatteryLevel KEYWORD2 -buttonChanged KEYWORD2 - -XboxReceiverConnected KEYWORD2 -Xbox360Connected KEYWORD2 -XboxOneConnected KEYWORD2 - -#################################################### -# Constants and enums (LITERAL1) -#################################################### - -ALL LITERAL1 - -ROTATING LITERAL1 -FASTBLINK LITERAL1 -SLOWBLINK LITERAL1 -ALTERNATING LITERAL1 - -BACK LITERAL1 - -XBOX LITERAL1 -SYNC LITERAL1 - -BLACK LITERAL1 -WHITE LITERAL1 - -A LITERAL1 -B LITERAL1 -X LITERAL1 -Y LITERAL1 - -#################################################### -# Syntax Coloring Map For RFCOMM/SPP Library -#################################################### - -#################################################### -# Datatypes (KEYWORD1) -#################################################### - -SPP KEYWORD1 - -#################################################### -# Methods and Functions (KEYWORD2) -#################################################### - -connected KEYWORD2 -discard KEYWORD2 - -#################################################### -# Syntax Coloring Map For Wiimote Library -#################################################### - -#################################################### -# Datatypes (KEYWORD1) -#################################################### - -WII KEYWORD1 - -#################################################### -# Methods and Functions (KEYWORD2) -#################################################### - -wiimoteConnected KEYWORD2 -nunchuckConnected KEYWORD2 -motionPlusConnected KEYWORD2 -wiiUProControllerConnected KEYWORD2 -wiiBalanceBoardConnected KEYWORD2 -setRumbleToggle KEYWORD2 -getPitch KEYWORD2 -getRoll KEYWORD2 -getYaw KEYWORD2 -getWiimotePitch KEYWORD2 -getWiimoteRoll KEYWORD2 -getNunchuckPitch KEYWORD2 -getNunchuckRoll KEYWORD2 -PAIR KEYWORD2 -statusRequest KEYWORD2 -getBatteryLevel KEYWORD2 -getWiiState KEYWORD2 -getWeight KEYWORD2 -getTotalWeight KEYWORD2 -getWeightRaw KEYWORD2 - -#################################################### -# Constants and enums (LITERAL1) -#################################################### - -PLUS LITERAL1 -MINUS LITERAL1 -ONE LITERAL1 -TWO LITERAL1 -HOME LITERAL1 -Z LITERAL1 -C LITERAL1 -L LITERAL1 -R LITERAL1 -ZL LITERAL1 -ZR LITERAL1 -HatX LITERAL1 -HatY LITERAL1 -TopRight LITERAL1 -BotRight LITERAL1 -TopLeft LITERAL1 -BotLeft LITERAL1 - -#################################################### -# Methods and Functions for the IR Camera -#################################################### - -IRinitialize KEYWORD2 -isIRCameraEnabled KEYWORD2 -getIRx1 KEYWORD2 -getIRy1 KEYWORD2 -getIRs1 KEYWORD2 -getIRx2 KEYWORD2 -getIRy2 KEYWORD2 -getIRs2 KEYWORD2 -getIRx3 KEYWORD2 -getIRy3 KEYWORD2 -getIRs3 KEYWORD2 -getIRx4 KEYWORD2 -getIRy4 KEYWORD2 -getIRs4 KEYWORD2 - -#################################################### -# Syntax Coloring Map For BTHID Library -#################################################### - -#################################################### -# Datatypes (KEYWORD1) -#################################################### - -BTHID KEYWORD1 - -#################################################### -# Methods and Functions (KEYWORD2) -#################################################### -SetReportParser KEYWORD2 -setProtocolMode KEYWORD2 - -#################################################### -# Syntax Coloring Map For PS Buzz Library -#################################################### - -#################################################### -# Datatypes (KEYWORD1) -#################################################### - -PSBuzz KEYWORD1 - -#################################################### -# Methods and Functions (KEYWORD2) -#################################################### - -setLedOnAll KEYWORD2 -setLedOffAll KEYWORD2 - -#################################################### -# Constants and enums (LITERAL1) -#################################################### - -RED LITERAL1 -YELLOW LITERAL1 -GREEN LITERAL1 -ORANGE LITERAL1 -BLUE LITERAL1 diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/library.json b/protocol/usb_hid/USB_Host_Shield_2.0/library.json deleted file mode 100644 index 1d649b1e..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/library.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name": "USB-Host-Shield-20", - "keywords": "usb, host, ftdi, adk, acm, pl2303, hid, bluetooth, spp, ps3, ps4, buzz, xbox, wii, mass storage", - "description": "Revision 2.0 of MAX3421E-based USB Host Shield Library", - "authors": - [ - { - "name": "Oleg Mazurov", - "email": "mazurov@circuitsathome.com", - "url": "http://www.circuitsathome.com", - "maintainer": true - }, - { - "name": "Alexei Glushchenko", - "email": "alex-gl@mail.ru" - }, - { - "name": "Kristian Lauszus", - "email": "kristianl@tkjelectronics.com", - "url": "http://tkjelectronics.com", - "maintainer": true - }, - { - "name": "Andrew Kroll", - "email": "xxxajk@gmail.com", - "maintainer": true - } - ], - "repository": - { - "type": "git", - "url": "https://github.com/felis/USB_Host_Shield_2.0.git" - }, - "examples": - [ - "examples/*/*.ino", - "examples/*/*/*.ino" - ], - "frameworks": "arduino", - "platforms": - [ - "atmelavr", - "teensy", - "atmelsam", - "nordicnrf51" - ] -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/library.properties b/protocol/usb_hid/USB_Host_Shield_2.0/library.properties deleted file mode 100644 index 7881b05e..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=USB Host Shield Library 2.0 -version=1.1.0 -author=Oleg Mazurov (Circuits@Home) , Kristian Lauszus (TKJ Electronics) , Andrew Kroll , Alexei Glushchenko (Circuits@Home) -maintainer=Oleg Mazurov (Circuits@Home) , Kristian Lauszus (TKJ Electronics) , Andrew Kroll -sentence=Revision 2.0 of MAX3421E-based USB Host Shield Library. -paragraph=Supports HID devices, FTDI, ADK, ACM, PL2303, Bluetooth HID devices, SPP communication and mass storage devices. Furthermore it supports PS3, PS4, PS Buzz, Wii and Xbox controllers. -category=Other -url=https://github.com/felis/USB_Host_Shield_2.0 -architectures=* \ No newline at end of file diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/macros.h b/protocol/usb_hid/USB_Host_Shield_2.0/macros.h deleted file mode 100644 index e14a711f..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/macros.h +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#if !defined(_usb_h_) || defined(MACROS_H) -#error "Never include macros.h directly; include Usb.h instead" -#else -#define MACROS_H - -//////////////////////////////////////////////////////////////////////////////// -// HANDY MACROS -//////////////////////////////////////////////////////////////////////////////// - -#define VALUE_BETWEEN(v,l,h) (((v)>(l)) && ((v)<(h))) -#define VALUE_WITHIN(v,l,h) (((v)>=(l)) && ((v)<=(h))) -#define output_pgm_message(wa,fp,mp,el) wa = &mp, fp((char *)pgm_read_pointer(wa), el) -#define output_if_between(v,l,h,wa,fp,mp,el) if(VALUE_BETWEEN(v,l,h)) output_pgm_message(wa,fp,mp[v-(l+1)],el); - -#define SWAP(a, b) (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b))) -#ifndef __BYTE_GRABBING_DEFINED__ -#define __BYTE_GRABBING_DEFINED__ 1 -#ifdef BROKEN_OPTIMIZER_LITTLE_ENDIAN -// Note: Use this if your compiler generates horrible assembler! -#define BGRAB0(__usi__) (((uint8_t *)&(__usi__))[0]) -#define BGRAB1(__usi__) (((uint8_t *)&(__usi__))[1]) -#define BGRAB2(__usi__) (((uint8_t *)&(__usi__))[2]) -#define BGRAB3(__usi__) (((uint8_t *)&(__usi__))[3]) -#define BGRAB4(__usi__) (((uint8_t *)&(__usi__))[4]) -#define BGRAB5(__usi__) (((uint8_t *)&(__usi__))[5]) -#define BGRAB6(__usi__) (((uint8_t *)&(__usi__))[6]) -#define BGRAB7(__usi__) (((uint8_t *)&(__usi__))[7]) -#else -// Note: The cast alone to uint8_t is actually enough. -// GCC throws out the "& 0xff", and the size is no different. -// Some compilers need it. -#define BGRAB0(__usi__) ((uint8_t)((__usi__) & 0xff )) -#define BGRAB1(__usi__) ((uint8_t)(((__usi__) >> 8) & 0xff)) -#define BGRAB2(__usi__) ((uint8_t)(((__usi__) >> 16) & 0xff)) -#define BGRAB3(__usi__) ((uint8_t)(((__usi__) >> 24) & 0xff)) -#define BGRAB4(__usi__) ((uint8_t)(((__usi__) >> 32) & 0xff)) -#define BGRAB5(__usi__) ((uint8_t)(((__usi__) >> 40) & 0xff)) -#define BGRAB6(__usi__) ((uint8_t)(((__usi__) >> 48) & 0xff)) -#define BGRAB7(__usi__) ((uint8_t)(((__usi__) >> 56) & 0xff)) -#endif -#define BOVER1(__usi__) ((uint16_t)(__usi__) << 8) -#define BOVER2(__usi__) ((uint32_t)(__usi__) << 16) -#define BOVER3(__usi__) ((uint32_t)(__usi__) << 24) -#define BOVER4(__usi__) ((uint64_t)(__usi__) << 32) -#define BOVER5(__usi__) ((uint64_t)(__usi__) << 40) -#define BOVER6(__usi__) ((uint64_t)(__usi__) << 48) -#define BOVER7(__usi__) ((uint64_t)(__usi__) << 56) - -// These are the smallest and fastest ways I have found so far in pure C/C++. -#define BMAKE16(__usc1__,__usc0__) ((uint16_t)((uint16_t)(__usc0__) | (uint16_t)BOVER1(__usc1__))) -#define BMAKE32(__usc3__,__usc2__,__usc1__,__usc0__) ((uint32_t)((uint32_t)(__usc0__) | (uint32_t)BOVER1(__usc1__) | (uint32_t)BOVER2(__usc2__) | (uint32_t)BOVER3(__usc3__))) -#define BMAKE64(__usc7__,__usc6__,__usc5__,__usc4__,__usc3__,__usc2__,__usc1__,__usc0__) ((uint64_t)((uint64_t)__usc0__ | (uint64_t)BOVER1(__usc1__) | (uint64_t)BOVER2(__usc2__) | (uint64_t)BOVER3(__usc3__) | (uint64_t)BOVER4(__usc4__) | (uint64_t)BOVER5(__usc5__) | (uint64_t)BOVER6(__usc6__) | (uint64_t)BOVER1(__usc7__))) -#endif - -/* - * Debug macros: Strings are stored in progmem (flash) instead of RAM. - */ -#define USBTRACE(s) (Notify(PSTR(s), 0x80)) -#define USBTRACE1(s,l) (Notify(PSTR(s), l)) -#define USBTRACE2(s,r) (Notify(PSTR(s), 0x80), D_PrintHex((r), 0x80), Notify(PSTR("\r\n"), 0x80)) -#define USBTRACE3(s,r,l) (Notify(PSTR(s), l), D_PrintHex((r), l), Notify(PSTR("\r\n"), l)) - - -#endif /* MACROS_H */ - diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/masstorage.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/masstorage.cpp deleted file mode 100644 index 9299f71a..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/masstorage.cpp +++ /dev/null @@ -1,1266 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#include "masstorage.h" - -const uint8_t BulkOnly::epDataInIndex = 1; -const uint8_t BulkOnly::epDataOutIndex = 2; -const uint8_t BulkOnly::epInterruptInIndex = 3; - -//////////////////////////////////////////////////////////////////////////////// - -// Interface code - -//////////////////////////////////////////////////////////////////////////////// - -/** - * Get the capacity of the media - * - * @param lun Logical Unit Number - * @return media capacity - */ -uint32_t BulkOnly::GetCapacity(uint8_t lun) { - if(LUNOk[lun]) - return CurrentCapacity[lun]; - return 0LU; -} - -/** - * Get the sector (block) size used on the media - * - * @param lun Logical Unit Number - * @return media sector size - */ -uint16_t BulkOnly::GetSectorSize(uint8_t lun) { - if(LUNOk[lun]) - return CurrentSectorSize[lun]; - return 0U; -} - -/** - * Test if LUN is ready for use - * - * @param lun Logical Unit Number - * @return true if LUN is ready for use - */ -bool BulkOnly::LUNIsGood(uint8_t lun) { - return LUNOk[lun]; -} - -/** - * Test if LUN is write protected - * - * @param lun Logical Unit Number - * @return cached status of write protect switch - */ -bool BulkOnly::WriteProtected(uint8_t lun) { - return WriteOk[lun]; -} - -/** - * Wrap and execute a SCSI CDB with length of 6 - * - * @param cdb CDB to execute - * @param buf_size Size of expected transaction - * @param buf Buffer - * @param dir MASS_CMD_DIR_IN | MASS_CMD_DIR_OUT - * @return - */ -uint8_t BulkOnly::SCSITransaction6(CDB6_t *cdb, uint16_t buf_size, void *buf, uint8_t dir) { - // promote buf_size to 32bits. - CommandBlockWrapper cbw = CommandBlockWrapper(++dCBWTag, (uint32_t)buf_size, cdb, dir); - //SetCurLUN(cdb->LUN); - return (HandleSCSIError(Transaction(&cbw, buf_size, buf))); -} - -/** - * Wrap and execute a SCSI CDB with length of 10 - * - * @param cdb CDB to execute - * @param buf_size Size of expected transaction - * @param buf Buffer - * @param dir MASS_CMD_DIR_IN | MASS_CMD_DIR_OUT - * @return - */ -uint8_t BulkOnly::SCSITransaction10(CDB10_t *cdb, uint16_t buf_size, void *buf, uint8_t dir) { - // promote buf_size to 32bits. - CommandBlockWrapper cbw = CommandBlockWrapper(++dCBWTag, (uint32_t)buf_size, cdb, dir); - //SetCurLUN(cdb->LUN); - return (HandleSCSIError(Transaction(&cbw, buf_size, buf))); -} - -/** - * Lock or Unlock the tray or door on device. - * Caution: Some devices with buggy firmware will lock up. - * - * @param lun Logical Unit Number - * @param lock 1 to lock, 0 to unlock - * @return - */ -uint8_t BulkOnly::LockMedia(uint8_t lun, uint8_t lock) { - Notify(PSTR("\r\nLockMedia\r\n"), 0x80); - Notify(PSTR("---------\r\n"), 0x80); - - CDB6_t cdb = CDB6_t(SCSI_CMD_PREVENT_REMOVAL, lun, (uint8_t)0, lock); - return SCSITransaction6(&cdb, (uint16_t)0, NULL, (uint8_t)MASS_CMD_DIR_IN); -} - -/** - * Media control, for spindle motor and media tray or door. - * This includes CDROM, TAPE and anything with a media loader. - * - * @param lun Logical Unit Number - * @param ctl 0x00 Stop Motor, 0x01 Start Motor, 0x02 Eject Media, 0x03 Load Media - * @return 0 on success - */ -uint8_t BulkOnly::MediaCTL(uint8_t lun, uint8_t ctl) { - Notify(PSTR("\r\nMediaCTL\r\n"), 0x80); - Notify(PSTR("-----------------\r\n"), 0x80); - - uint8_t rcode = MASS_ERR_UNIT_NOT_READY; - if(bAddress) { - CDB6_t cdb = CDB6_t(SCSI_CMD_START_STOP_UNIT, lun, ctl & 0x03, 0); - rcode = SCSITransaction6(&cdb, (uint16_t)0, NULL, (uint8_t)MASS_CMD_DIR_OUT); - } else { - SetCurLUN(lun); - } - return rcode; -} - -/** - * Read data from media - * - * @param lun Logical Unit Number - * @param addr LBA address on media to read - * @param bsize size of a block (we should probably use the cached size) - * @param blocks how many blocks to read - * @param buf memory that is able to hold the requested data - * @return 0 on success - */ -uint8_t BulkOnly::Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf) { - if(!LUNOk[lun]) return MASS_ERR_NO_MEDIA; - Notify(PSTR("\r\nRead LUN:\t"), 0x80); - D_PrintHex (lun, 0x90); - Notify(PSTR("\r\nLBA:\t\t"), 0x90); - D_PrintHex (addr, 0x90); - Notify(PSTR("\r\nblocks:\t\t"), 0x90); - D_PrintHex (blocks, 0x90); - Notify(PSTR("\r\nblock size:\t"), 0x90); - D_PrintHex (bsize, 0x90); - Notify(PSTR("\r\n---------\r\n"), 0x80); - CDB10_t cdb = CDB10_t(SCSI_CMD_READ_10, lun, blocks, addr); - -again: - uint8_t er = SCSITransaction10(&cdb, ((uint16_t)bsize * blocks), buf, (uint8_t)MASS_CMD_DIR_IN); - - if(er == MASS_ERR_STALL) { - MediaCTL(lun, 1); - delay(150); - if(!TestUnitReady(lun)) goto again; - } - return er; -} - -/** - * Write data to media - * - * @param lun Logical Unit Number - * @param addr LBA address on media to write - * @param bsize size of a block (we should probably use the cached size) - * @param blocks how many blocks to write - * @param buf memory that contains the data to write - * @return 0 on success - */ -uint8_t BulkOnly::Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t * buf) { - if(!LUNOk[lun]) return MASS_ERR_NO_MEDIA; - if(!WriteOk[lun]) return MASS_ERR_WRITE_PROTECTED; - Notify(PSTR("\r\nWrite LUN:\t"), 0x80); - D_PrintHex (lun, 0x90); - Notify(PSTR("\r\nLBA:\t\t"), 0x90); - D_PrintHex (addr, 0x90); - Notify(PSTR("\r\nblocks:\t\t"), 0x90); - D_PrintHex (blocks, 0x90); - Notify(PSTR("\r\nblock size:\t"), 0x90); - D_PrintHex (bsize, 0x90); - Notify(PSTR("\r\n---------\r\n"), 0x80); - CDB10_t cdb = CDB10_t(SCSI_CMD_WRITE_10, lun, blocks, addr); - -again: - uint8_t er = SCSITransaction10(&cdb, ((uint16_t)bsize * blocks), (void*)buf, (uint8_t)MASS_CMD_DIR_OUT); - - if(er == MASS_ERR_WRITE_STALL) { - MediaCTL(lun, 1); - delay(150); - if(!TestUnitReady(lun)) goto again; - } - return er; -} - -// End of user functions, the remaining code below is driver internals. -// Only developer serviceable parts below! - -//////////////////////////////////////////////////////////////////////////////// - -// Main driver code - -//////////////////////////////////////////////////////////////////////////////// - -BulkOnly::BulkOnly(USB *p) : -pUsb(p), -bAddress(0), -bIface(0), -bNumEP(1), -qNextPollTime(0), -bPollEnable(false), -//dCBWTag(0), -bLastUsbError(0) { - ClearAllEP(); - dCBWTag = 0; - if(pUsb) - pUsb->RegisterDeviceClass(this); -} - -/** - * USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET == success - * We need to standardize either the rcode, or change the API to return values - * so a signal that additional actions are required can be produced. - * Some of these codes do exist already. - * - * TECHNICAL: We could do most of this code elsewhere, with the exception of checking the class instance. - * Doing so would save some program memory when using multiple drivers. - * - * @param parent USB address of parent - * @param port address of port on parent - * @param lowspeed true if device is low speed - * @return - */ -uint8_t BulkOnly::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) { - - const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR); - - uint8_t buf[constBufSize]; - USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); - uint8_t rcode; - UsbDevice *p = NULL; - EpInfo *oldep_ptr = NULL; - USBTRACE("MS ConfigureDevice\r\n"); - ClearAllEP(); - AddressPool &addrPool = pUsb->GetAddressPool(); - - - if(bAddress) - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - - // - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - if(!p) { - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - } - - if(!p->epinfo) { - USBTRACE("epinfo\r\n"); - return USB_ERROR_EPINFO_IS_NULL; - } - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - - p->lowspeed = lowspeed; - // Get device descriptor - rcode = pUsb->getDevDescr(0, 0, constBufSize, (uint8_t*)buf); - - // Restore p->epinfo - p->epinfo = oldep_ptr; - - if(rcode) { - goto FailGetDevDescr; - } - // Allocate new address according to device class - bAddress = addrPool.AllocAddress(parent, false, port); - - if(!bAddress) - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - - // Extract Max Packet Size from the device descriptor - epInfo[0].maxPktSize = udd->bMaxPacketSize0; - // Steal and abuse from epInfo structure to save on memory. - epInfo[1].epAddr = udd->bNumConfigurations; - // - return USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET; - -FailGetDevDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetDevDescr(rcode); -#endif - rcode = USB_ERROR_FailGetDevDescr; - - Release(); - return rcode; -}; - -/** - * - * @param parent (not used) - * @param port (not used) - * @param lowspeed true if device is low speed - * @return 0 for success - */ -uint8_t BulkOnly::Init(uint8_t parent, uint8_t port, bool lowspeed) { - uint8_t rcode; - uint8_t num_of_conf = epInfo[1].epAddr; // number of configurations - epInfo[1].epAddr = 0; - USBTRACE("MS Init\r\n"); - - AddressPool &addrPool = pUsb->GetAddressPool(); - UsbDevice *p = addrPool.GetUsbDevicePtr(bAddress); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - // Assign new address to the device - delay(2000); - rcode = pUsb->setAddr(0, 0, bAddress); - - if(rcode) { - p->lowspeed = false; - addrPool.FreeAddress(bAddress); - bAddress = 0; - USBTRACE2("setAddr:", rcode); - return rcode; - } - - USBTRACE2("Addr:", bAddress); - - p->lowspeed = false; - - p = addrPool.GetUsbDevicePtr(bAddress); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - p->lowspeed = lowspeed; - - // Assign epInfo to epinfo pointer - rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo); - - if(rcode) - goto FailSetDevTblEntry; - - USBTRACE2("NC:", num_of_conf); - - for(uint8_t i = 0; i < num_of_conf; i++) { - ConfigDescParser< USB_CLASS_MASS_STORAGE, - MASS_SUBCLASS_SCSI, - MASS_PROTO_BBB, - CP_MASK_COMPARE_CLASS | - CP_MASK_COMPARE_SUBCLASS | - CP_MASK_COMPARE_PROTOCOL > BulkOnlyParser(this); - - rcode = pUsb->getConfDescr(bAddress, 0, i, &BulkOnlyParser); - - if(rcode) - goto FailGetConfDescr; - - if(bNumEP > 1) - break; - } - - if(bNumEP < 3) - return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - - // Assign epInfo to epinfo pointer - pUsb->setEpInfoEntry(bAddress, bNumEP, epInfo); - - USBTRACE2("Conf:", bConfNum); - - // Set Configuration Value - rcode = pUsb->setConf(bAddress, 0, bConfNum); - - if(rcode) - goto FailSetConfDescr; - - //Linux does a 1sec delay after this. - delay(1000); - - rcode = GetMaxLUN(&bMaxLUN); - if(rcode) - goto FailGetMaxLUN; - - if(bMaxLUN >= MASS_MAX_SUPPORTED_LUN) bMaxLUN = MASS_MAX_SUPPORTED_LUN - 1; - ErrorMessage (PSTR("MaxLUN"), bMaxLUN); - - delay(1000); // Delay a bit for slow firmware. - - for(uint8_t lun = 0; lun <= bMaxLUN; lun++) { - InquiryResponse response; - rcode = Inquiry(lun, sizeof (InquiryResponse), (uint8_t*) & response); - if(rcode) { - ErrorMessage (PSTR("Inquiry"), rcode); - } else { -#if 0 - printf("LUN %i `", lun); - uint8_t *buf = response.VendorID; - for(int i = 0; i < 28; i++) printf("%c", buf[i]); - printf("'\r\nQualifier %1.1X ", response.PeripheralQualifier); - printf("Device type %2.2X ", response.DeviceType); - printf("RMB %1.1X ", response.Removable); - printf("SSCS %1.1X ", response.SCCS); - uint8_t sv = response.Version; - printf("SCSI version %2.2X\r\nDevice conforms to ", sv); - switch(sv) { - case 0: - printf("No specific"); - break; - case 1: - printf("ANSI X3.131-1986 (ANSI 1)"); - break; - case 2: - printf("ANSI X3.131-1994 (ANSI 2)"); - break; - case 3: - printf("ANSI INCITS 301-1997 (SPC)"); - break; - case 4: - printf("ANSI INCITS 351-2001 (SPC-2)"); - break; - case 5: - printf("ANSI INCITS 408-2005 (SPC-4)"); - break; - case 6: - printf("T10/1731-D (SPC-4)"); - break; - default: - printf("unknown"); - } - printf(" standards.\r\n"); -#endif - uint8_t tries = 0xf0; - while((rcode = TestUnitReady(lun))) { - if(rcode == 0x08) break; // break on no media, this is OK to do. - // try to lock media and spin up - if(tries < 14) { - LockMedia(lun, 1); - MediaCTL(lun, 1); // I actually have a USB stick that needs this! - } else delay(2 * (tries + 1)); - tries++; - if(!tries) break; - } - if(!rcode) { - delay(1000); - LUNOk[lun] = CheckLUN(lun); - if(!LUNOk[lun]) LUNOk[lun] = CheckLUN(lun); - } - } - } - - - CheckMedia(); - - rcode = OnInit(); - - if(rcode) - goto FailOnInit; - -#ifdef DEBUG_USB_HOST - USBTRACE("MS configured\r\n\r\n"); -#endif - - bPollEnable = true; - - //USBTRACE("Poll enabled\r\n"); - return 0; - -FailSetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailSetConfDescr(); - goto Fail; -#endif - -FailOnInit: -#ifdef DEBUG_USB_HOST - USBTRACE("OnInit:"); - goto Fail; -#endif - -FailGetMaxLUN: -#ifdef DEBUG_USB_HOST - USBTRACE("GetMaxLUN:"); - goto Fail; -#endif - - //#ifdef DEBUG_USB_HOST - //FailInvalidSectorSize: - // USBTRACE("Sector Size is NOT VALID: "); - // goto Fail; - //#endif - -FailSetDevTblEntry: -#ifdef DEBUG_USB_HOST - NotifyFailSetDevTblEntry(); - goto Fail; -#endif - -FailGetConfDescr: -#ifdef DEBUG_USB_HOST - NotifyFailGetConfDescr(); -#endif - -#ifdef DEBUG_USB_HOST -Fail: - NotifyFail(rcode); -#endif - Release(); - return rcode; -} - -/** - * For driver use only. - * - * @param conf - * @param iface - * @param alt - * @param proto - * @param pep - */ -void BulkOnly::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR * pep) { - ErrorMessage (PSTR("Conf.Val"), conf); - ErrorMessage (PSTR("Iface Num"), iface); - ErrorMessage (PSTR("Alt.Set"), alt); - - bConfNum = conf; - - uint8_t index; - -#if 1 - if((pep->bmAttributes & 0x02) == 2) { - index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; - // Fill in the endpoint info structure - epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F); - epInfo[index].maxPktSize = (uint8_t)pep->wMaxPacketSize; - epInfo[index].epAttribs = 0; - - bNumEP++; - - PrintEndpointDescriptor(pep); - - } -#else - if((pep->bmAttributes & 0x03) == 3 && (pep->bEndpointAddress & 0x80) == 0x80) - index = epInterruptInIndex; - else - if((pep->bmAttributes & 0x02) == 2) - index = ((pep->bEndpointAddress & 0x80) == 0x80) ? epDataInIndex : epDataOutIndex; - else - return; - - // Fill in the endpoint info structure - epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F); - epInfo[index].maxPktSize = (uint8_t)pep->wMaxPacketSize; - epInfo[index].epAttribs = 0; - - bNumEP++; - - PrintEndpointDescriptor(pep); -#endif -} - -/** - * For driver use only. - * - * @return - */ -uint8_t BulkOnly::Release() { - ClearAllEP(); - pUsb->GetAddressPool().FreeAddress(bAddress); - return 0; -} - -/** - * For driver use only. - * - * @param lun Logical Unit Number - * @return true if LUN is ready for use. - */ -bool BulkOnly::CheckLUN(uint8_t lun) { - uint8_t rcode; - Capacity capacity; - for(uint8_t i = 0; i < 8; i++) capacity.data[i] = 0; - - rcode = ReadCapacity10(lun, (uint8_t*)capacity.data); - if(rcode) { - //printf(">>>>>>>>>>>>>>>>ReadCapacity returned %i\r\n", rcode); - return false; - } - ErrorMessage (PSTR(">>>>>>>>>>>>>>>>CAPACITY OK ON LUN"), lun); - for(uint8_t i = 0; i < 8 /*sizeof (Capacity)*/; i++) - D_PrintHex (capacity.data[i], 0x80); - Notify(PSTR("\r\n\r\n"), 0x80); - // Only 512/1024/2048/4096 are valid values! - uint32_t c = BMAKE32(capacity.data[4], capacity.data[5], capacity.data[6], capacity.data[7]); - if(c != 0x0200LU && c != 0x0400LU && c != 0x0800LU && c != 0x1000LU) { - return false; - } - // Store capacity information. - CurrentSectorSize[lun] = (uint16_t)(c); // & 0xFFFF); - - CurrentCapacity[lun] = BMAKE32(capacity.data[0], capacity.data[1], capacity.data[2], capacity.data[3]) + 1; - if(CurrentCapacity[lun] == /*0xffffffffLU */ 0x01LU || CurrentCapacity[lun] == 0x00LU) { - // Buggy firmware will report 0xffffffff or 0 for no media - if(CurrentCapacity[lun]) - ErrorMessage (PSTR(">>>>>>>>>>>>>>>>BUGGY FIRMWARE. CAPACITY FAIL ON LUN"), lun); - return false; - } - delay(20); - Page3F(lun); - if(!TestUnitReady(lun)) return true; - return false; -} - -/** - * For driver use only. - * - * Scan for media change on all LUNs - */ -void BulkOnly::CheckMedia() { - for(uint8_t lun = 0; lun <= bMaxLUN; lun++) { - if(TestUnitReady(lun)) { - LUNOk[lun] = false; - continue; - } - if(!LUNOk[lun]) - LUNOk[lun] = CheckLUN(lun); - } -#if 0 - printf("}}}}}}}}}}}}}}}}STATUS "); - for(uint8_t lun = 0; lun <= bMaxLUN; lun++) { - if(LUNOk[lun]) - printf("#"); - else printf("."); - } - printf("\r\n"); -#endif - qNextPollTime = millis() + 2000; -} - -/** - * For driver use only. - * - * @return - */ -uint8_t BulkOnly::Poll() { - //uint8_t rcode = 0; - - if(!bPollEnable) - return 0; - - if((long)(millis() - qNextPollTime) >= 0L) { - CheckMedia(); - } - //rcode = 0; - - return 0; -} - -//////////////////////////////////////////////////////////////////////////////// - - -// SCSI code - - -//////////////////////////////////////////////////////////////////////////////// - -/** - * For driver use only. - * - * @param plun - * @return - */ -uint8_t BulkOnly::GetMaxLUN(uint8_t *plun) { - uint8_t ret = pUsb->ctrlReq(bAddress, 0, bmREQ_MASSIN, MASS_REQ_GET_MAX_LUN, 0, 0, bIface, 1, 1, plun, NULL); - - if(ret == hrSTALL) - *plun = 0; - - return 0; -} - -/** - * For driver use only. Used during Driver Init - * - * @param lun Logical Unit Number - * @param bsize - * @param buf - * @return - */ -uint8_t BulkOnly::Inquiry(uint8_t lun, uint16_t bsize, uint8_t *buf) { - Notify(PSTR("\r\nInquiry\r\n"), 0x80); - Notify(PSTR("---------\r\n"), 0x80); - - CDB6_t cdb = CDB6_t(SCSI_CMD_INQUIRY, lun, 0LU, (uint8_t)bsize, 0); - uint8_t rc = SCSITransaction6(&cdb, bsize, buf, (uint8_t)MASS_CMD_DIR_IN); - - return rc; -} - -/** - * For driver use only. - * - * @param lun Logical Unit Number - * @return - */ -uint8_t BulkOnly::TestUnitReady(uint8_t lun) { - //SetCurLUN(lun); - if(!bAddress) - return MASS_ERR_UNIT_NOT_READY; - - Notify(PSTR("\r\nTestUnitReady\r\n"), 0x80); - Notify(PSTR("-----------------\r\n"), 0x80); - - CDB6_t cdb = CDB6_t(SCSI_CMD_TEST_UNIT_READY, lun, (uint8_t)0, 0); - return SCSITransaction6(&cdb, 0, NULL, (uint8_t)MASS_CMD_DIR_IN); - -} - -/** - * For driver use only. - * - * @param lun Logical Unit Number - * @param pc - * @param page - * @param subpage - * @param len - * @param pbuf - * @return - */ -uint8_t BulkOnly::ModeSense6(uint8_t lun, uint8_t pc, uint8_t page, uint8_t subpage, uint8_t len, uint8_t * pbuf) { - Notify(PSTR("\r\rModeSense\r\n"), 0x80); - Notify(PSTR("------------\r\n"), 0x80); - - CDB6_t cdb = CDB6_t(SCSI_CMD_TEST_UNIT_READY, lun, (uint32_t)((((pc << 6) | page) << 8) | subpage), len, 0); - return SCSITransaction6(&cdb, len, pbuf, (uint8_t)MASS_CMD_DIR_IN); -} - -/** - * For driver use only. - * - * @param lun Logical Unit Number - * @param bsize - * @param buf - * @return - */ -uint8_t BulkOnly::ReadCapacity10(uint8_t lun, uint8_t *buf) { - Notify(PSTR("\r\nReadCapacity\r\n"), 0x80); - Notify(PSTR("---------------\r\n"), 0x80); - - CDB10_t cdb = CDB10_t(SCSI_CMD_READ_CAPACITY_10, lun); - return SCSITransaction10(&cdb, 8, buf, (uint8_t)MASS_CMD_DIR_IN); -} - -/** - * For driver use only. - * - * Page 3F contains write protect status. - * - * @param lun Logical Unit Number to test. - * @return Write protect switch status. - */ -uint8_t BulkOnly::Page3F(uint8_t lun) { - uint8_t buf[192]; - for(int i = 0; i < 192; i++) { - buf[i] = 0x00; - } - WriteOk[lun] = true; - uint8_t rc = ModeSense6(lun, 0, 0x3f, 0, 192, buf); - if(!rc) { - WriteOk[lun] = ((buf[2] & 0x80) == 0); - Notify(PSTR("Mode Sense: "), 0x80); - for(int i = 0; i < 4; i++) { - D_PrintHex (buf[i], 0x80); - Notify(PSTR(" "), 0x80); - } - Notify(PSTR("\r\n"), 0x80); - } - return rc; -} - -/** - * For driver use only. - * - * @param lun Logical Unit Number - * @param size - * @param buf - * @return - */ -uint8_t BulkOnly::RequestSense(uint8_t lun, uint16_t size, uint8_t *buf) { - Notify(PSTR("\r\nRequestSense\r\n"), 0x80); - Notify(PSTR("----------------\r\n"), 0x80); - - CDB6_t cdb = CDB6_t(SCSI_CMD_REQUEST_SENSE, lun, 0LU, (uint8_t)size, 0); - CommandBlockWrapper cbw = CommandBlockWrapper(++dCBWTag, (uint32_t)size, &cdb, (uint8_t)MASS_CMD_DIR_IN); - //SetCurLUN(lun); - return Transaction(&cbw, size, buf); -} - - -//////////////////////////////////////////////////////////////////////////////// - - -// USB code - - -//////////////////////////////////////////////////////////////////////////////// - -/** - * For driver use only. - * - * @param index - * @return - */ -uint8_t BulkOnly::ClearEpHalt(uint8_t index) { - if(index == 0) - return 0; - - uint8_t ret = 0; - - while((ret = (pUsb->ctrlReq(bAddress, 0, USB_SETUP_HOST_TO_DEVICE | USB_SETUP_TYPE_STANDARD | USB_SETUP_RECIPIENT_ENDPOINT, USB_REQUEST_CLEAR_FEATURE, USB_FEATURE_ENDPOINT_HALT, 0, ((index == epDataInIndex) ? (0x80 | epInfo[index].epAddr) : epInfo[index].epAddr), 0, 0, NULL, NULL)) == 0x01)) - delay(6); - - if(ret) { - ErrorMessage (PSTR("ClearEpHalt"), ret); - ErrorMessage (PSTR("EP"), ((index == epDataInIndex) ? (0x80 | epInfo[index].epAddr) : epInfo[index].epAddr)); - return ret; - } - epInfo[index].bmSndToggle = 0; - epInfo[index].bmRcvToggle = 0; - // epAttribs = 0; - return 0; -} - -/** - * For driver use only. - * - */ -void BulkOnly::Reset() { - while(pUsb->ctrlReq(bAddress, 0, bmREQ_MASSOUT, MASS_REQ_BOMSR, 0, 0, bIface, 0, 0, NULL, NULL) == 0x01) delay(6); -} - -/** - * For driver use only. - * - * @return 0 if successful - */ -uint8_t BulkOnly::ResetRecovery() { - Notify(PSTR("\r\nResetRecovery\r\n"), 0x80); - Notify(PSTR("-----------------\r\n"), 0x80); - - delay(6); - Reset(); - delay(6); - ClearEpHalt(epDataInIndex); - delay(6); - bLastUsbError = ClearEpHalt(epDataOutIndex); - delay(6); - return bLastUsbError; -} - -/** - * For driver use only. - * - * Clear all EP data and clear all LUN status - */ -void BulkOnly::ClearAllEP() { - for(uint8_t i = 0; i < MASS_MAX_ENDPOINTS; i++) { - epInfo[i].epAddr = 0; - epInfo[i].maxPktSize = (i) ? 0 : 8; - epInfo[i].epAttribs = 0; - - epInfo[i].bmNakPower = USB_NAK_DEFAULT; - } - - for(uint8_t i = 0; i < MASS_MAX_SUPPORTED_LUN; i++) { - LUNOk[i] = false; - WriteOk[i] = false; - CurrentCapacity[i] = 0lu; - CurrentSectorSize[i] = 0; - } - - bIface = 0; - bNumEP = 1; - bAddress = 0; - qNextPollTime = 0; - bPollEnable = false; - bLastUsbError = 0; - bMaxLUN = 0; - bTheLUN = 0; -} - -/** - * For driver use only. - * - * @param pcsw - * @param pcbw - * @return - */ -bool BulkOnly::IsValidCSW(CommandStatusWrapper *pcsw, CommandBlockWrapperBase *pcbw) { - if(pcsw->dCSWSignature != MASS_CSW_SIGNATURE) { - Notify(PSTR("CSW:Sig error\r\n"), 0x80); - return false; - } - if(pcsw->dCSWTag != pcbw->dCBWTag) { - Notify(PSTR("CSW:Wrong tag\r\n"), 0x80); - return false; - } - return true; -} - -/** - * For driver use only. - * - * @param error - * @param index - * @return - */ -uint8_t BulkOnly::HandleUsbError(uint8_t error, uint8_t index) { - uint8_t count = 3; - - bLastUsbError = error; - //if (error) - //ClearEpHalt(index); - while(error && count) { - if(error != hrSUCCESS) { - ErrorMessage (PSTR("USB Error"), error); - ErrorMessage (PSTR("Index"), index); - } - switch(error) { - // case hrWRONGPID: - case hrSUCCESS: - return MASS_ERR_SUCCESS; - case hrBUSY: - // SIE is busy, just hang out and try again. - return MASS_ERR_UNIT_BUSY; - case hrTIMEOUT: - case hrJERR: return MASS_ERR_DEVICE_DISCONNECTED; - case hrSTALL: - if(index == 0) - return MASS_ERR_STALL; - ClearEpHalt(index); - if(index != epDataInIndex) - return MASS_ERR_WRITE_STALL; - return MASS_ERR_STALL; - - case hrNAK: - if(index == 0) - return MASS_ERR_UNIT_BUSY; - return MASS_ERR_UNIT_BUSY; - - case hrTOGERR: - // Handle a very super rare corner case, where toggles become de-synched. - // I have only ran into one device that has this firmware bug, and this is - // the only clean way to get back into sync with the buggy device firmware. - // --AJK - if(bAddress && bConfNum) { - error = pUsb->setConf(bAddress, 0, bConfNum); - - if(error) - break; - } - return MASS_ERR_SUCCESS; - default: - ErrorMessage (PSTR("\r\nUSB"), error); - return MASS_ERR_GENERAL_USB_ERROR; - } - count--; - } // while - - return ((error && !count) ? MASS_ERR_GENERAL_USB_ERROR : MASS_ERR_SUCCESS); -} - -#if MS_WANT_PARSER - -uint8_t BulkOnly::Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void *buf) { - return Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void *buf, 0); -} -#endif - -/** - * For driver use only. - * - * @param pcbw - * @param buf_size - * @param buf - * @param flags - * @return - */ -uint8_t BulkOnly::Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void *buf -#if MS_WANT_PARSER - , uint8_t flags -#endif - ) { - -#if MS_WANT_PARSER - uint16_t bytes = (pcbw->dCBWDataTransferLength > buf_size) ? buf_size : pcbw->dCBWDataTransferLength; - printf("Transfersize %i\r\n", bytes); - delay(1000); - - bool callback = (flags & MASS_TRANS_FLG_CALLBACK) == MASS_TRANS_FLG_CALLBACK; -#else - uint16_t bytes = buf_size; -#endif - bool write = (pcbw->bmCBWFlags & MASS_CMD_DIR_IN) != MASS_CMD_DIR_IN; - uint8_t ret = 0; - uint8_t usberr; - CommandStatusWrapper csw; // up here, we allocate ahead to save cpu cycles. - SetCurLUN(pcbw->bmCBWLUN); - ErrorMessage (PSTR("CBW.dCBWTag"), pcbw->dCBWTag); - - while((usberr = pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, sizeof (CommandBlockWrapper), (uint8_t*)pcbw)) == hrBUSY) delay(1); - - ret = HandleUsbError(usberr, epDataOutIndex); - //ret = HandleUsbError(pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, sizeof (CommandBlockWrapper), (uint8_t*)pcbw), epDataOutIndex); - if(ret) { - ErrorMessage (PSTR("============================ CBW"), ret); - } else { - if(bytes) { - if(!write) { -#if MS_WANT_PARSER - if(callback) { - uint8_t rbuf[bytes]; - while((usberr = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, &bytes, rbuf)) == hrBUSY) delay(1); - if(usberr == hrSUCCESS) ((USBReadParser*)buf)->Parse(bytes, rbuf, 0); - } else { -#endif - while((usberr = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, &bytes, (uint8_t*)buf)) == hrBUSY) delay(1); -#if MS_WANT_PARSER - - } -#endif - ret = HandleUsbError(usberr, epDataInIndex); - } else { - while((usberr = pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, bytes, (uint8_t*)buf)) == hrBUSY) delay(1); - ret = HandleUsbError(usberr, epDataOutIndex); - } - if(ret) { - ErrorMessage (PSTR("============================ DAT"), ret); - } - } - } - - { - bytes = sizeof (CommandStatusWrapper); - int tries = 2; - while(tries--) { - while((usberr = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, &bytes, (uint8_t*) & csw)) == hrBUSY) delay(1); - if(!usberr) break; - ClearEpHalt(epDataInIndex); - if(tries) ResetRecovery(); - } - if(!ret) { - Notify(PSTR("CBW:\t\tOK\r\n"), 0x80); - Notify(PSTR("Data Stage:\tOK\r\n"), 0x80); - } else { - // Throw away csw, IT IS NOT OF ANY USE. - ResetRecovery(); - return ret; - } - ret = HandleUsbError(usberr, epDataInIndex); - if(ret) { - ErrorMessage (PSTR("============================ CSW"), ret); - } - if(usberr == hrSUCCESS) { - if(IsValidCSW(&csw, pcbw)) { - //ErrorMessage (PSTR("CSW.dCBWTag"), csw.dCSWTag); - //ErrorMessage (PSTR("bCSWStatus"), csw.bCSWStatus); - //ErrorMessage (PSTR("dCSWDataResidue"), csw.dCSWDataResidue); - Notify(PSTR("CSW:\t\tOK\r\n\r\n"), 0x80); - return csw.bCSWStatus; - } else { - // NOTE! Sometimes this is caused by the reported residue being wrong. - // Get a different device. It isn't compliant, and should have never passed Q&A. - // I own one... 05e3:0701 Genesys Logic, Inc. USB 2.0 IDE Adapter. - // Other devices that exhibit this behavior exist in the wild too. - // Be sure to check quirks in the Linux source code before reporting a bug. --xxxajk - Notify(PSTR("Invalid CSW\r\n"), 0x80); - ResetRecovery(); - //return MASS_ERR_SUCCESS; - return MASS_ERR_INVALID_CSW; - } - } - } - return ret; -} - -/** - * For driver use only. - * - * @param lun Logical Unit Number - * @return - */ -uint8_t BulkOnly::SetCurLUN(uint8_t lun) { - if(lun > bMaxLUN) - return MASS_ERR_INVALID_LUN; - bTheLUN = lun; - return MASS_ERR_SUCCESS; -}; - -/** - * For driver use only. - * - * @param status - * @return - */ -uint8_t BulkOnly::HandleSCSIError(uint8_t status) { - uint8_t ret = 0; - - switch(status) { - case 0: return MASS_ERR_SUCCESS; - - case 2: - ErrorMessage (PSTR("Phase Error"), status); - ErrorMessage (PSTR("LUN"), bTheLUN); - ResetRecovery(); - return MASS_ERR_GENERAL_SCSI_ERROR; - - case 1: - ErrorMessage (PSTR("SCSI Error"), status); - ErrorMessage (PSTR("LUN"), bTheLUN); - RequestSenseResponce rsp; - - ret = RequestSense(bTheLUN, sizeof (RequestSenseResponce), (uint8_t*) & rsp); - - if(ret) { - return MASS_ERR_GENERAL_SCSI_ERROR; - } - ErrorMessage (PSTR("Response Code"), rsp.bResponseCode); - if(rsp.bResponseCode & 0x80) { - Notify(PSTR("Information field: "), 0x80); - for(int i = 0; i < 4; i++) { - D_PrintHex (rsp.CmdSpecificInformation[i], 0x80); - Notify(PSTR(" "), 0x80); - } - Notify(PSTR("\r\n"), 0x80); - } - ErrorMessage (PSTR("Sense Key"), rsp.bmSenseKey); - ErrorMessage (PSTR("Add Sense Code"), rsp.bAdditionalSenseCode); - ErrorMessage (PSTR("Add Sense Qual"), rsp.bAdditionalSenseQualifier); - // warning, this is not testing ASQ, only SK and ASC. - switch(rsp.bmSenseKey) { - case SCSI_S_UNIT_ATTENTION: - switch(rsp.bAdditionalSenseCode) { - case SCSI_ASC_MEDIA_CHANGED: - return MASS_ERR_MEDIA_CHANGED; - default: - return MASS_ERR_UNIT_NOT_READY; - } - case SCSI_S_NOT_READY: - switch(rsp.bAdditionalSenseCode) { - case SCSI_ASC_MEDIUM_NOT_PRESENT: - return MASS_ERR_NO_MEDIA; - default: - return MASS_ERR_UNIT_NOT_READY; - } - case SCSI_S_ILLEGAL_REQUEST: - switch(rsp.bAdditionalSenseCode) { - case SCSI_ASC_LBA_OUT_OF_RANGE: - return MASS_ERR_BAD_LBA; - default: - return MASS_ERR_CMD_NOT_SUPPORTED; - } - default: - return MASS_ERR_GENERAL_SCSI_ERROR; - } - - // case 4: return MASS_ERR_UNIT_BUSY; // Busy means retry later. - // case 0x05/0x14: we stalled out - // case 0x15/0x16: we naked out. - default: - ErrorMessage (PSTR("Gen SCSI Err"), status); - ErrorMessage (PSTR("LUN"), bTheLUN); - return status; - } // switch -} - - -//////////////////////////////////////////////////////////////////////////////// - - -// Debugging code - - -//////////////////////////////////////////////////////////////////////////////// - -/** - * - * @param ep_ptr - */ -void BulkOnly::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR * ep_ptr) { - Notify(PSTR("Endpoint descriptor:"), 0x80); - Notify(PSTR("\r\nLength:\t\t"), 0x80); - D_PrintHex (ep_ptr->bLength, 0x80); - Notify(PSTR("\r\nType:\t\t"), 0x80); - D_PrintHex (ep_ptr->bDescriptorType, 0x80); - Notify(PSTR("\r\nAddress:\t"), 0x80); - D_PrintHex (ep_ptr->bEndpointAddress, 0x80); - Notify(PSTR("\r\nAttributes:\t"), 0x80); - D_PrintHex (ep_ptr->bmAttributes, 0x80); - Notify(PSTR("\r\nMaxPktSize:\t"), 0x80); - D_PrintHex (ep_ptr->wMaxPacketSize, 0x80); - Notify(PSTR("\r\nPoll Intrv:\t"), 0x80); - D_PrintHex (ep_ptr->bInterval, 0x80); - Notify(PSTR("\r\n"), 0x80); -} - - -//////////////////////////////////////////////////////////////////////////////// - - -// misc/to kill/to-do - - -//////////////////////////////////////////////////////////////////////////////// - -/* We won't be needing this... */ -uint8_t BulkOnly::Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, USBReadParser * prs) { -#if MS_WANT_PARSER - if(!LUNOk[lun]) return MASS_ERR_NO_MEDIA; - Notify(PSTR("\r\nRead (With parser)\r\n"), 0x80); - Notify(PSTR("---------\r\n"), 0x80); - - CommandBlockWrapper cbw = CommandBlockWrapper(); - - cbw.dCBWSignature = MASS_CBW_SIGNATURE; - cbw.dCBWTag = ++dCBWTag; - cbw.dCBWDataTransferLength = ((uint32_t)bsize * blocks); - cbw.bmCBWFlags = MASS_CMD_DIR_IN, - cbw.bmCBWLUN = lun; - cbw.bmCBWCBLength = 10; - - cbw.CBWCB[0] = SCSI_CMD_READ_10; - cbw.CBWCB[8] = blocks; - cbw.CBWCB[2] = ((addr >> 24) & 0xff); - cbw.CBWCB[3] = ((addr >> 16) & 0xff); - cbw.CBWCB[4] = ((addr >> 8) & 0xff); - cbw.CBWCB[5] = (addr & 0xff); - - return HandleSCSIError(Transaction(&cbw, bsize, prs, 1)); -#else - return MASS_ERR_NOT_IMPLEMENTED; -#endif -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/masstorage.h b/protocol/usb_hid/USB_Host_Shield_2.0/masstorage.h deleted file mode 100644 index d39fd66f..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/masstorage.h +++ /dev/null @@ -1,571 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#if !defined(__MASSTORAGE_H__) -#define __MASSTORAGE_H__ - -// Cruft removal, makes driver smaller, faster. -#ifndef MS_WANT_PARSER -#define MS_WANT_PARSER 0 -#endif - -#include "Usb.h" - -#define bmREQ_MASSOUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE -#define bmREQ_MASSIN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE - -// Mass Storage Subclass Constants -#define MASS_SUBCLASS_SCSI_NOT_REPORTED 0x00 // De facto use -#define MASS_SUBCLASS_RBC 0x01 -#define MASS_SUBCLASS_ATAPI 0x02 // MMC-5 (ATAPI) -#define MASS_SUBCLASS_OBSOLETE1 0x03 // Was QIC-157 -#define MASS_SUBCLASS_UFI 0x04 // Specifies how to interface Floppy Disk Drives to USB -#define MASS_SUBCLASS_OBSOLETE2 0x05 // Was SFF-8070i -#define MASS_SUBCLASS_SCSI 0x06 // SCSI Transparent Command Set -#define MASS_SUBCLASS_LSDFS 0x07 // Specifies how host has to negotiate access before trying SCSI -#define MASS_SUBCLASS_IEEE1667 0x08 - -// Mass Storage Class Protocols -#define MASS_PROTO_CBI 0x00 // CBI (with command completion interrupt) -#define MASS_PROTO_CBI_NO_INT 0x01 // CBI (without command completion interrupt) -#define MASS_PROTO_OBSOLETE 0x02 -#define MASS_PROTO_BBB 0x50 // Bulk Only Transport -#define MASS_PROTO_UAS 0x62 - -// Request Codes -#define MASS_REQ_ADSC 0x00 -#define MASS_REQ_GET 0xFC -#define MASS_REQ_PUT 0xFD -#define MASS_REQ_GET_MAX_LUN 0xFE -#define MASS_REQ_BOMSR 0xFF // Bulk-Only Mass Storage Reset - -#define MASS_CBW_SIGNATURE 0x43425355 -#define MASS_CSW_SIGNATURE 0x53425355 - -#define MASS_CMD_DIR_OUT 0 // (0 << 7) -#define MASS_CMD_DIR_IN 0x80 //(1 << 7) - -/* - * Reference documents from T10 (http://www.t10.org) - * SCSI Primary Commands - 3 (SPC-3) - * SCSI Block Commands - 2 (SBC-2) - * Multi-Media Commands - 5 (MMC-5) - */ - -/* Group 1 commands (CDB's here are should all be 6-bytes) */ -#define SCSI_CMD_TEST_UNIT_READY 0x00 -#define SCSI_CMD_REQUEST_SENSE 0x03 -#define SCSI_CMD_FORMAT_UNIT 0x04 -#define SCSI_CMD_READ_6 0x08 -#define SCSI_CMD_WRITE_6 0x0A -#define SCSI_CMD_INQUIRY 0x12 -#define SCSI_CMD_MODE_SELECT_6 0x15 -#define SCSI_CMD_MODE_SENSE_6 0x1A -#define SCSI_CMD_START_STOP_UNIT 0x1B -#define SCSI_CMD_PREVENT_REMOVAL 0x1E -/* Group 2 Commands (CDB's here are 10-bytes) */ -#define SCSI_CMD_READ_FORMAT_CAPACITIES 0x23 -#define SCSI_CMD_READ_CAPACITY_10 0x25 -#define SCSI_CMD_READ_10 0x28 -#define SCSI_CMD_WRITE_10 0x2A -#define SCSI_CMD_SEEK_10 0x2B -#define SCSI_CMD_ERASE_10 0x2C -#define SCSI_CMD_WRITE_AND_VERIFY_10 0x2E -#define SCSI_CMD_VERIFY_10 0x2F -#define SCSI_CMD_SYNCHRONIZE_CACHE 0x35 -#define SCSI_CMD_WRITE_BUFFER 0x3B -#define SCSI_CMD_READ_BUFFER 0x3C -#define SCSI_CMD_READ_SUBCHANNEL 0x42 -#define SCSI_CMD_READ_TOC 0x43 -#define SCSI_CMD_READ_HEADER 0x44 -#define SCSI_CMD_PLAY_AUDIO_10 0x45 -#define SCSI_CMD_GET_CONFIGURATION 0x46 -#define SCSI_CMD_PLAY_AUDIO_MSF 0x47 -#define SCSI_CMD_PLAY_AUDIO_TI 0x48 -#define SCSI_CMD_PLAY_TRACK_REL_10 0x49 -#define SCSI_CMD_GET_EVENT_STATUS 0x4A -#define SCSI_CMD_PAUSE_RESUME 0x4B -#define SCSI_CMD_READ_DISC_INFORMATION 0x51 -#define SCSI_CMD_READ_TRACK_INFORMATION 0x52 -#define SCSI_CMD_RESERVE_TRACK 0x53 -#define SCSI_CMD_SEND_OPC_INFORMATION 0x54 -#define SCSI_CMD_MODE_SELECT_10 0x55 -#define SCSI_CMD_REPAIR_TRACK 0x58 -#define SCSI_CMD_MODE_SENSE_10 0x5A -#define SCSI_CMD_CLOSE_TRACK_SESSION 0x5B -#define SCSI_CMD_READ_BUFFER_CAPACITY 0x5C -#define SCSI_CMD_SEND_CUE_SHEET 0x5D -/* Group 5 Commands (CDB's here are 12-bytes) */ -#define SCSI_CMD_REPORT_LUNS 0xA0 -#define SCSI_CMD_BLANK 0xA1 -#define SCSI_CMD_SECURITY_PROTOCOL_IN 0xA2 -#define SCSI_CMD_SEND_KEY 0xA3 -#define SCSI_CMD_REPORT_KEY 0xA4 -#define SCSI_CMD_PLAY_AUDIO_12 0xA5 -#define SCSI_CMD_LOAD_UNLOAD 0xA6 -#define SCSI_CMD_SET_READ_AHEAD 0xA7 -#define SCSI_CMD_READ_12 0xA8 -#define SCSI_CMD_PLAY_TRACK_REL_12 0xA9 -#define SCSI_CMD_WRITE_12 0xAA -#define SCSI_CMD_READ_MEDIA_SERIAL_12 0xAB -#define SCSI_CMD_GET_PERFORMANCE 0xAC -#define SCSI_CMD_READ_DVD_STRUCTURE 0xAD -#define SCSI_CMD_SECURITY_PROTOCOL_OUT 0xB5 -#define SCSI_CMD_SET_STREAMING 0xB6 -#define SCSI_CMD_READ_MSF 0xB9 -#define SCSI_CMD_SET_SPEED 0xBB -#define SCSI_CMD_MECHANISM_STATUS 0xBD -#define SCSI_CMD_READ_CD 0xBE -#define SCSI_CMD_SEND_DISC_STRUCTURE 0xBF -/* Vendor-unique Commands, included for completeness */ -#define SCSI_CMD_CD_PLAYBACK_STATUS 0xC4 /* SONY unique */ -#define SCSI_CMD_PLAYBACK_CONTROL 0xC9 /* SONY unique */ -#define SCSI_CMD_READ_CDDA 0xD8 /* Vendor unique */ -#define SCSI_CMD_READ_CDXA 0xDB /* Vendor unique */ -#define SCSI_CMD_READ_ALL_SUBCODES 0xDF /* Vendor unique */ - -/* SCSI error codes */ -#define SCSI_S_NOT_READY 0x02 -#define SCSI_S_MEDIUM_ERROR 0x03 -#define SCSI_S_ILLEGAL_REQUEST 0x05 -#define SCSI_S_UNIT_ATTENTION 0x06 -#define SCSI_ASC_LBA_OUT_OF_RANGE 0x21 -#define SCSI_ASC_MEDIA_CHANGED 0x28 -#define SCSI_ASC_MEDIUM_NOT_PRESENT 0x3A - -/* USB error codes */ -#define MASS_ERR_SUCCESS 0x00 -#define MASS_ERR_PHASE_ERROR 0x02 -#define MASS_ERR_UNIT_NOT_READY 0x03 -#define MASS_ERR_UNIT_BUSY 0x04 -#define MASS_ERR_STALL 0x05 -#define MASS_ERR_CMD_NOT_SUPPORTED 0x06 -#define MASS_ERR_INVALID_CSW 0x07 -#define MASS_ERR_NO_MEDIA 0x08 -#define MASS_ERR_BAD_LBA 0x09 -#define MASS_ERR_MEDIA_CHANGED 0x0A -#define MASS_ERR_DEVICE_DISCONNECTED 0x11 -#define MASS_ERR_UNABLE_TO_RECOVER 0x12 // Reset recovery error -#define MASS_ERR_INVALID_LUN 0x13 -#define MASS_ERR_WRITE_STALL 0x14 -#define MASS_ERR_READ_NAKS 0x15 -#define MASS_ERR_WRITE_NAKS 0x16 -#define MASS_ERR_WRITE_PROTECTED 0x17 -#define MASS_ERR_NOT_IMPLEMENTED 0xFD -#define MASS_ERR_GENERAL_SCSI_ERROR 0xFE -#define MASS_ERR_GENERAL_USB_ERROR 0xFF -#define MASS_ERR_USER 0xA0 // For subclasses to define their own error codes - -#define MASS_TRANS_FLG_CALLBACK 0x01 // Callback is involved -#define MASS_TRANS_FLG_NO_STALL_CHECK 0x02 // STALL condition is not checked -#define MASS_TRANS_FLG_NO_PHASE_CHECK 0x04 // PHASE_ERROR is not checked - -#define MASS_MAX_ENDPOINTS 3 - -struct Capacity { - uint8_t data[8]; - //uint32_t dwBlockAddress; - //uint32_t dwBlockLength; -} __attribute__((packed)); - -struct BASICCDB { - uint8_t Opcode; - - unsigned unused : 5; - unsigned LUN : 3; - - uint8_t info[12]; -} __attribute__((packed)); - -typedef BASICCDB BASICCDB_t; - -struct CDB6 { - uint8_t Opcode; - - unsigned LBAMSB : 5; - unsigned LUN : 3; - - uint8_t LBAHB; - uint8_t LBALB; - uint8_t AllocationLength; - uint8_t Control; - -public: - - CDB6(uint8_t _Opcode, uint8_t _LUN, uint32_t LBA, uint8_t _AllocationLength, uint8_t _Control) : - Opcode(_Opcode), LBAMSB(BGRAB2(LBA) & 0x1f), LUN(_LUN), LBAHB(BGRAB1(LBA)), LBALB(BGRAB0(LBA)), - AllocationLength(_AllocationLength), Control(_Control) { - } - - CDB6(uint8_t _Opcode, uint8_t _LUN, uint8_t _AllocationLength, uint8_t _Control) : - Opcode(_Opcode), LBAMSB(0), LUN(_LUN), LBAHB(0), LBALB(0), - AllocationLength(_AllocationLength), Control(_Control) { - } -} __attribute__((packed)); - -typedef CDB6 CDB6_t; - -struct CDB10 { - uint8_t Opcode; - - unsigned Service_Action : 5; - unsigned LUN : 3; - - uint8_t LBA_L_M_MB; - uint8_t LBA_L_M_LB; - uint8_t LBA_L_L_MB; - uint8_t LBA_L_L_LB; - - uint8_t Misc2; - - uint8_t ALC_MB; - uint8_t ALC_LB; - - uint8_t Control; -public: - - CDB10(uint8_t _Opcode, uint8_t _LUN) : - Opcode(_Opcode), Service_Action(0), LUN(_LUN), - LBA_L_M_MB(0), LBA_L_M_LB(0), LBA_L_L_MB(0), LBA_L_L_LB(0), - Misc2(0), ALC_MB(0), ALC_LB(0), Control(0) { - } - - CDB10(uint8_t _Opcode, uint8_t _LUN, uint16_t xflen, uint32_t _LBA) : - Opcode(_Opcode), Service_Action(0), LUN(_LUN), - LBA_L_M_MB(BGRAB3(_LBA)), LBA_L_M_LB(BGRAB2(_LBA)), LBA_L_L_MB(BGRAB1(_LBA)), LBA_L_L_LB(BGRAB0(_LBA)), - Misc2(0), ALC_MB(BGRAB1(xflen)), ALC_LB(BGRAB0(xflen)), Control(0) { - } -} __attribute__((packed)); - -typedef CDB10 CDB10_t; - -struct CDB12 { - uint8_t Opcode; - - unsigned Service_Action : 5; - unsigned Misc : 3; - - uint8_t LBA_L_M_LB; - uint8_t LBA_L_L_MB; - uint8_t LBA_L_L_LB; - - uint8_t ALC_M_LB; - uint8_t ALC_L_MB; - uint8_t ALC_L_LB; - uint8_t Control; -} __attribute__((packed)); - -typedef CDB12 CDB12_t; - -struct CDB_LBA32_16 { - uint8_t Opcode; - - unsigned Service_Action : 5; - unsigned Misc : 3; - - uint8_t LBA_L_M_MB; - uint8_t LBA_L_M_LB; - uint8_t LBA_L_L_MB; - uint8_t LBA_L_L_LB; - - uint8_t A_M_M_MB; - uint8_t A_M_M_LB; - uint8_t A_M_L_MB; - uint8_t A_M_L_LB; - - uint8_t ALC_M_MB; - uint8_t ALC_M_LB; - uint8_t ALC_L_MB; - uint8_t ALC_L_LB; - - uint8_t Misc2; - uint8_t Control; -} __attribute__((packed)); - -struct CDB_LBA64_16 { - uint8_t Opcode; - uint8_t Misc; - - uint8_t LBA_M_M_MB; - uint8_t LBA_M_M_LB; - uint8_t LBA_M_L_MB; - uint8_t LBA_M_L_LB; - - uint8_t LBA_L_M_MB; - uint8_t LBA_L_M_LB; - uint8_t LBA_L_L_MB; - uint8_t LBA_L_L_LB; - - uint8_t ALC_M_MB; - uint8_t ALC_M_LB; - uint8_t ALC_L_MB; - uint8_t ALC_L_LB; - - uint8_t Misc2; - uint8_t Control; -} __attribute__((packed)); - -struct InquiryResponse { - uint8_t DeviceType : 5; - uint8_t PeripheralQualifier : 3; - - unsigned Reserved : 7; - unsigned Removable : 1; - - uint8_t Version; - - unsigned ResponseDataFormat : 4; - unsigned HISUP : 1; - unsigned NormACA : 1; - unsigned TrmTsk : 1; - unsigned AERC : 1; - - uint8_t AdditionalLength; - //uint8_t Reserved3[2]; - - unsigned PROTECT : 1; - unsigned Res : 2; - unsigned ThreePC : 1; - unsigned TPGS : 2; - unsigned ACC : 1; - unsigned SCCS : 1; - - unsigned ADDR16 : 1; - unsigned R1 : 1; - unsigned R2 : 1; - unsigned MCHNGR : 1; - unsigned MULTIP : 1; - unsigned VS : 1; - unsigned ENCSERV : 1; - unsigned BQUE : 1; - - unsigned SoftReset : 1; - unsigned CmdQue : 1; - unsigned Reserved4 : 1; - unsigned Linked : 1; - unsigned Sync : 1; - unsigned WideBus16Bit : 1; - unsigned WideBus32Bit : 1; - unsigned RelAddr : 1; - - uint8_t VendorID[8]; - uint8_t ProductID[16]; - uint8_t RevisionID[4]; -} __attribute__((packed)); - -struct CommandBlockWrapperBase { - uint32_t dCBWSignature; - uint32_t dCBWTag; - uint32_t dCBWDataTransferLength; - uint8_t bmCBWFlags; -public: - - CommandBlockWrapperBase() { - } - - CommandBlockWrapperBase(uint32_t tag, uint32_t xflen, uint8_t flgs) : - dCBWSignature(MASS_CBW_SIGNATURE), dCBWTag(tag), dCBWDataTransferLength(xflen), bmCBWFlags(flgs) { - } -} __attribute__((packed)); - -struct CommandBlockWrapper : public CommandBlockWrapperBase { - - struct { - uint8_t bmCBWLUN : 4; - uint8_t bmReserved1 : 4; - }; - - struct { - uint8_t bmCBWCBLength : 4; - uint8_t bmReserved2 : 4; - }; - - uint8_t CBWCB[16]; - -public: - // All zeroed. - - CommandBlockWrapper() : - CommandBlockWrapperBase(0, 0, 0), bmReserved1(0), bmReserved2(0) { - for(int i = 0; i < 16; i++) CBWCB[i] = 0; - } - - // Generic Wrap, CDB zeroed. - - CommandBlockWrapper(uint32_t tag, uint32_t xflen, uint8_t flgs, uint8_t lu, uint8_t cmdlen, uint8_t cmd) : - CommandBlockWrapperBase(tag, xflen, flgs), - bmCBWLUN(lu), bmReserved1(0), bmCBWCBLength(cmdlen), bmReserved2(0) { - for(int i = 0; i < 16; i++) CBWCB[i] = 0; - // Type punning can cause optimization problems and bugs. - // Using reinterpret_cast to a dreinterpretifferent object is the proper way to do this. - //(((BASICCDB_t *) CBWCB)->LUN) = cmd; - BASICCDB_t *x = reinterpret_cast(CBWCB); - x->LUN = cmd; - } - - // Wrap for CDB of 6 - - CommandBlockWrapper(uint32_t tag, uint32_t xflen, CDB6_t *cdb, uint8_t dir) : - CommandBlockWrapperBase(tag, xflen, dir), - bmCBWLUN(cdb->LUN), bmReserved1(0), bmCBWCBLength(6), bmReserved2(0) { - memcpy(&CBWCB, cdb, 6); - } - // Wrap for CDB of 10 - - CommandBlockWrapper(uint32_t tag, uint32_t xflen, CDB10_t *cdb, uint8_t dir) : - CommandBlockWrapperBase(tag, xflen, dir), - bmCBWLUN(cdb->LUN), bmReserved1(0), bmCBWCBLength(10), bmReserved2(0) { - memcpy(&CBWCB, cdb, 10); - } -} __attribute__((packed)); - -struct CommandStatusWrapper { - uint32_t dCSWSignature; - uint32_t dCSWTag; - uint32_t dCSWDataResidue; - uint8_t bCSWStatus; -} __attribute__((packed)); - -struct RequestSenseResponce { - uint8_t bResponseCode; - uint8_t bSegmentNumber; - - uint8_t bmSenseKey : 4; - uint8_t bmReserved : 1; - uint8_t bmILI : 1; - uint8_t bmEOM : 1; - uint8_t bmFileMark : 1; - - uint8_t Information[4]; - uint8_t bAdditionalLength; - uint8_t CmdSpecificInformation[4]; - uint8_t bAdditionalSenseCode; - uint8_t bAdditionalSenseQualifier; - uint8_t bFieldReplaceableUnitCode; - uint8_t SenseKeySpecific[3]; -} __attribute__((packed)); - -class BulkOnly : public USBDeviceConfig, public UsbConfigXtracter { -protected: - static const uint8_t epDataInIndex; // DataIn endpoint index - static const uint8_t epDataOutIndex; // DataOUT endpoint index - static const uint8_t epInterruptInIndex; // InterruptIN endpoint index - - USB *pUsb; - uint8_t bAddress; - uint8_t bConfNum; // configuration number - uint8_t bIface; // interface value - uint8_t bNumEP; // total number of EP in the configuration - uint32_t qNextPollTime; // next poll time - bool bPollEnable; // poll enable flag - - EpInfo epInfo[MASS_MAX_ENDPOINTS]; - - uint32_t dCBWTag; // Tag - //uint32_t dCBWDataTransferLength; // Data Transfer Length - uint8_t bLastUsbError; // Last USB error - uint8_t bMaxLUN; // Max LUN - uint8_t bTheLUN; // Active LUN - uint32_t CurrentCapacity[MASS_MAX_SUPPORTED_LUN]; // Total sectors - uint16_t CurrentSectorSize[MASS_MAX_SUPPORTED_LUN]; // Sector size, clipped to 16 bits - bool LUNOk[MASS_MAX_SUPPORTED_LUN]; // use this to check for media changes. - bool WriteOk[MASS_MAX_SUPPORTED_LUN]; - void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); - - - // Additional Initialization Method for Subclasses - - virtual uint8_t OnInit() { - return 0; - }; -public: - BulkOnly(USB *p); - - uint8_t GetLastUsbError() { - return bLastUsbError; - }; - - uint8_t GetbMaxLUN() { - return bMaxLUN; // Max LUN - } - - uint8_t GetbTheLUN() { - return bTheLUN; // Active LUN - } - - bool WriteProtected(uint8_t lun); - uint8_t MediaCTL(uint8_t lun, uint8_t ctl); - uint8_t Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf); - uint8_t Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, USBReadParser *prs); - uint8_t Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t *buf); - uint8_t LockMedia(uint8_t lun, uint8_t lock); - - bool LUNIsGood(uint8_t lun); - uint32_t GetCapacity(uint8_t lun); - uint16_t GetSectorSize(uint8_t lun); - - // USBDeviceConfig implementation - uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed); - - uint8_t Release(); - uint8_t Poll(); - - virtual uint8_t GetAddress() { - return bAddress; - }; - - // UsbConfigXtracter implementation - void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); - - virtual bool DEVCLASSOK(uint8_t klass) { - return (klass == USB_CLASS_MASS_STORAGE); - } - - uint8_t SCSITransaction6(CDB6_t *cdb, uint16_t buf_size, void *buf, uint8_t dir); - uint8_t SCSITransaction10(CDB10_t *cdb, uint16_t buf_size, void *buf, uint8_t dir); - -private: - uint8_t Inquiry(uint8_t lun, uint16_t size, uint8_t *buf); - uint8_t TestUnitReady(uint8_t lun); - uint8_t RequestSense(uint8_t lun, uint16_t size, uint8_t *buf); - uint8_t ModeSense6(uint8_t lun, uint8_t pc, uint8_t page, uint8_t subpage, uint8_t len, uint8_t *buf); - uint8_t GetMaxLUN(uint8_t *max_lun); - uint8_t SetCurLUN(uint8_t lun); - void Reset(); - uint8_t ResetRecovery(); - uint8_t ReadCapacity10(uint8_t lun, uint8_t *buf); - void ClearAllEP(); - void CheckMedia(); - bool CheckLUN(uint8_t lun); - uint8_t Page3F(uint8_t lun); - bool IsValidCBW(uint8_t size, uint8_t *pcbw); - bool IsMeaningfulCBW(uint8_t size, uint8_t *pcbw); - - bool IsValidCSW(CommandStatusWrapper *pcsw, CommandBlockWrapperBase *pcbw); - - uint8_t ClearEpHalt(uint8_t index); -#if MS_WANT_PARSER - uint8_t Transaction(CommandBlockWrapper *cbw, uint16_t bsize, void *buf, uint8_t flags); -#endif - uint8_t Transaction(CommandBlockWrapper *cbw, uint16_t bsize, void *buf); - uint8_t HandleUsbError(uint8_t error, uint8_t index); - uint8_t HandleSCSIError(uint8_t status); - -}; - -#endif // __MASSTORAGE_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/max3421e.h b/protocol/usb_hid/USB_Host_Shield_2.0/max3421e.h deleted file mode 100644 index 4e45a35e..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/max3421e.h +++ /dev/null @@ -1,228 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(_usb_h_) || defined(_max3421e_h_) -#error "Never include max3421e.h directly; include Usb.h instead" -#else - -#define _max3421e_h_ - -/* MAX3421E register/bit names and bitmasks */ - -/* Arduino pin definitions */ -/* pin numbers to port numbers */ - -#define SE0 0 -#define SE1 1 -#define FSHOST 2 -#define LSHOST 3 - -/* MAX3421E command byte format: rrrrr0wa where 'r' is register number */ -// -// MAX3421E Registers in HOST mode. -// -#define rRCVFIFO 0x08 //1<<3 -#define rSNDFIFO 0x10 //2<<3 -#define rSUDFIFO 0x20 //4<<3 -#define rRCVBC 0x30 //6<<3 -#define rSNDBC 0x38 //7<<3 - -#define rUSBIRQ 0x68 //13<<3 -/* USBIRQ Bits */ -#define bmVBUSIRQ 0x40 //b6 -#define bmNOVBUSIRQ 0x20 //b5 -#define bmOSCOKIRQ 0x01 //b0 - -#define rUSBIEN 0x70 //14<<3 -/* USBIEN Bits */ -#define bmVBUSIE 0x40 //b6 -#define bmNOVBUSIE 0x20 //b5 -#define bmOSCOKIE 0x01 //b0 - -#define rUSBCTL 0x78 //15<<3 -/* USBCTL Bits */ -#define bmCHIPRES 0x20 //b5 -#define bmPWRDOWN 0x10 //b4 - -#define rCPUCTL 0x80 //16<<3 -/* CPUCTL Bits */ -#define bmPUSLEWID1 0x80 //b7 -#define bmPULSEWID0 0x40 //b6 -#define bmIE 0x01 //b0 - -#define rPINCTL 0x88 //17<<3 -/* PINCTL Bits */ -#define bmFDUPSPI 0x10 //b4 -#define bmINTLEVEL 0x08 //b3 -#define bmPOSINT 0x04 //b2 -#define bmGPXB 0x02 //b1 -#define bmGPXA 0x01 //b0 -// GPX pin selections -#define GPX_OPERATE 0x00 -#define GPX_VBDET 0x01 -#define GPX_BUSACT 0x02 -#define GPX_SOF 0x03 - -#define rREVISION 0x90 //18<<3 - -#define rIOPINS1 0xa0 //20<<3 - -/* IOPINS1 Bits */ -#define bmGPOUT0 0x01 -#define bmGPOUT1 0x02 -#define bmGPOUT2 0x04 -#define bmGPOUT3 0x08 -#define bmGPIN0 0x10 -#define bmGPIN1 0x20 -#define bmGPIN2 0x40 -#define bmGPIN3 0x80 - -#define rIOPINS2 0xa8 //21<<3 -/* IOPINS2 Bits */ -#define bmGPOUT4 0x01 -#define bmGPOUT5 0x02 -#define bmGPOUT6 0x04 -#define bmGPOUT7 0x08 -#define bmGPIN4 0x10 -#define bmGPIN5 0x20 -#define bmGPIN6 0x40 -#define bmGPIN7 0x80 - -#define rGPINIRQ 0xb0 //22<<3 -/* GPINIRQ Bits */ -#define bmGPINIRQ0 0x01 -#define bmGPINIRQ1 0x02 -#define bmGPINIRQ2 0x04 -#define bmGPINIRQ3 0x08 -#define bmGPINIRQ4 0x10 -#define bmGPINIRQ5 0x20 -#define bmGPINIRQ6 0x40 -#define bmGPINIRQ7 0x80 - -#define rGPINIEN 0xb8 //23<<3 -/* GPINIEN Bits */ -#define bmGPINIEN0 0x01 -#define bmGPINIEN1 0x02 -#define bmGPINIEN2 0x04 -#define bmGPINIEN3 0x08 -#define bmGPINIEN4 0x10 -#define bmGPINIEN5 0x20 -#define bmGPINIEN6 0x40 -#define bmGPINIEN7 0x80 - -#define rGPINPOL 0xc0 //24<<3 -/* GPINPOL Bits */ -#define bmGPINPOL0 0x01 -#define bmGPINPOL1 0x02 -#define bmGPINPOL2 0x04 -#define bmGPINPOL3 0x08 -#define bmGPINPOL4 0x10 -#define bmGPINPOL5 0x20 -#define bmGPINPOL6 0x40 -#define bmGPINPOL7 0x80 - -#define rHIRQ 0xc8 //25<<3 -/* HIRQ Bits */ -#define bmBUSEVENTIRQ 0x01 // indicates BUS Reset Done or BUS Resume -#define bmRWUIRQ 0x02 -#define bmRCVDAVIRQ 0x04 -#define bmSNDBAVIRQ 0x08 -#define bmSUSDNIRQ 0x10 -#define bmCONDETIRQ 0x20 -#define bmFRAMEIRQ 0x40 -#define bmHXFRDNIRQ 0x80 - -#define rHIEN 0xd0 //26<<3 - -/* HIEN Bits */ -#define bmBUSEVENTIE 0x01 -#define bmRWUIE 0x02 -#define bmRCVDAVIE 0x04 -#define bmSNDBAVIE 0x08 -#define bmSUSDNIE 0x10 -#define bmCONDETIE 0x20 -#define bmFRAMEIE 0x40 -#define bmHXFRDNIE 0x80 - -#define rMODE 0xd8 //27<<3 - -/* MODE Bits */ -#define bmHOST 0x01 -#define bmLOWSPEED 0x02 -#define bmHUBPRE 0x04 -#define bmSOFKAENAB 0x08 -#define bmSEPIRQ 0x10 -#define bmDELAYISO 0x20 -#define bmDMPULLDN 0x40 -#define bmDPPULLDN 0x80 - -#define rPERADDR 0xe0 //28<<3 - -#define rHCTL 0xe8 //29<<3 -/* HCTL Bits */ -#define bmBUSRST 0x01 -#define bmFRMRST 0x02 -#define bmSAMPLEBUS 0x04 -#define bmSIGRSM 0x08 -#define bmRCVTOG0 0x10 -#define bmRCVTOG1 0x20 -#define bmSNDTOG0 0x40 -#define bmSNDTOG1 0x80 - -#define rHXFR 0xf0 //30<<3 -/* Host transfer token values for writing the HXFR register (R30) */ -/* OR this bit field with the endpoint number in bits 3:0 */ -#define tokSETUP 0x10 // HS=0, ISO=0, OUTNIN=0, SETUP=1 -#define tokIN 0x00 // HS=0, ISO=0, OUTNIN=0, SETUP=0 -#define tokOUT 0x20 // HS=0, ISO=0, OUTNIN=1, SETUP=0 -#define tokINHS 0x80 // HS=1, ISO=0, OUTNIN=0, SETUP=0 -#define tokOUTHS 0xA0 // HS=1, ISO=0, OUTNIN=1, SETUP=0 -#define tokISOIN 0x40 // HS=0, ISO=1, OUTNIN=0, SETUP=0 -#define tokISOOUT 0x60 // HS=0, ISO=1, OUTNIN=1, SETUP=0 - -#define rHRSL 0xf8 //31<<3 - -/* HRSL Bits */ -#define bmRCVTOGRD 0x10 -#define bmSNDTOGRD 0x20 -#define bmKSTATUS 0x40 -#define bmJSTATUS 0x80 -#define bmSE0 0x00 //SE0 - disconnect state -#define bmSE1 0xc0 //SE1 - illegal state - -/* Host error result codes, the 4 LSB's in the HRSL register */ -#define hrSUCCESS 0x00 -#define hrBUSY 0x01 -#define hrBADREQ 0x02 -#define hrUNDEF 0x03 -#define hrNAK 0x04 -#define hrSTALL 0x05 -#define hrTOGERR 0x06 -#define hrWRONGPID 0x07 -#define hrBADBC 0x08 -#define hrPIDERR 0x09 -#define hrPKTERR 0x0A -#define hrCRCERR 0x0B -#define hrKERR 0x0C -#define hrJERR 0x0D -#define hrTIMEOUT 0x0E -#define hrBABBLE 0x0F - -#define MODE_FS_HOST (bmDPPULLDN|bmDMPULLDN|bmHOST|bmSOFKAENAB) -#define MODE_LS_HOST (bmDPPULLDN|bmDMPULLDN|bmHOST|bmLOWSPEED|bmSOFKAENAB) - - -#endif //_max3421e_h_ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/max_LCD.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/max_LCD.cpp deleted file mode 100644 index f0c64666..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/max_LCD.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#include "max_LCD.h" -#include - -// pin definition and set/clear - -#define RS 0x04 // RS pin -#define E 0x08 // E pin - -#define SET_RS lcdPins |= RS -#define CLR_RS lcdPins &= ~RS -#define SET_E lcdPins |= E -#define CLR_E lcdPins &= ~E - -#define SENDlcdPins() pUsb->gpioWr( lcdPins ) - -#define LCD_sendcmd(a) { CLR_RS; \ - sendbyte(a); \ - } - -#define LCD_sendchar(a) { SET_RS; \ - sendbyte(a); \ - } - -static byte lcdPins; //copy of LCD pins - -Max_LCD::Max_LCD(USB *pusb) : pUsb(pusb) { - lcdPins = 0; -} - -void Max_LCD::init() { - _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; - - // MAX3421E::gpioWr(0x55); - - begin(16, 1); -} - -void Max_LCD::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { - if(lines > 1) { - _displayfunction |= LCD_2LINE; - } - _numlines = lines; - _currline = 0; - - // for some 1 line displays you can select a 10 pixel high font - if((dotsize != 0) && (lines == 1)) { - _displayfunction |= LCD_5x10DOTS; - } - - // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! - // according to datasheet, we need at least 40ms after power rises above 2.7V - // before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50 - delayMicroseconds(50000); - lcdPins = 0x30; - SET_E; - SENDlcdPins(); - CLR_E; - SENDlcdPins(); - delayMicroseconds(10000); // wait min 4.1ms - //second try - SET_E; - SENDlcdPins(); - CLR_E; - SENDlcdPins(); - delayMicroseconds(10000); // wait min 4.1ms - // third go! - SET_E; - SENDlcdPins(); - CLR_E; - SENDlcdPins(); - delayMicroseconds(10000); - // finally, set to 4-bit interface - lcdPins = 0x20; - //SET_RS; - SET_E; - SENDlcdPins(); - //CLR_RS; - CLR_E; - SENDlcdPins(); - delayMicroseconds(10000); - // finally, set # lines, font size, etc. - command(LCD_FUNCTIONSET | _displayfunction); - - // turn the display on with no cursor or blinking default - _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; - display(); - - // clear it off - clear(); - - // Initialize to default text direction (for romance languages) - _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT; - // set the entry mode - command(LCD_ENTRYMODESET | _displaymode); -} - -/********** high level commands, for the user! */ -void Max_LCD::clear() { - command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero - delayMicroseconds(2000); // this command takes a long time! -} - -void Max_LCD::home() { - command(LCD_RETURNHOME); // set cursor position to zero - delayMicroseconds(2000); // this command takes a long time! -} - -void Max_LCD::setCursor(uint8_t col, uint8_t row) { - int row_offsets[] = {0x00, 0x40, 0x14, 0x54}; - if(row > _numlines) { - row = _numlines - 1; // we count rows starting w/0 - } - - command(LCD_SETDDRAMADDR | (col + row_offsets[row])); -} - -// Turn the display on/off (quickly) - -void Max_LCD::noDisplay() { - _displaycontrol &= ~LCD_DISPLAYON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -void Max_LCD::display() { - _displaycontrol |= LCD_DISPLAYON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -// Turns the underline cursor on/off - -void Max_LCD::noCursor() { - _displaycontrol &= ~LCD_CURSORON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -void Max_LCD::cursor() { - _displaycontrol |= LCD_CURSORON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - - -// Turn on and off the blinking cursor - -void Max_LCD::noBlink() { - _displaycontrol &= ~LCD_BLINKON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -void Max_LCD::blink() { - _displaycontrol |= LCD_BLINKON; - command(LCD_DISPLAYCONTROL | _displaycontrol); -} - -// These commands scroll the display without changing the RAM - -void Max_LCD::scrollDisplayLeft(void) { - command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT); -} - -void Max_LCD::scrollDisplayRight(void) { - command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT); -} - -// This is for text that flows Left to Right - -void Max_LCD::leftToRight(void) { - _displaymode |= LCD_ENTRYLEFT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// This is for text that flows Right to Left - -void Max_LCD::rightToLeft(void) { - _displaymode &= ~LCD_ENTRYLEFT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// This will 'right justify' text from the cursor - -void Max_LCD::autoscroll(void) { - _displaymode |= LCD_ENTRYSHIFTINCREMENT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// This will 'left justify' text from the cursor - -void Max_LCD::noAutoscroll(void) { - _displaymode &= ~LCD_ENTRYSHIFTINCREMENT; - command(LCD_ENTRYMODESET | _displaymode); -} - -// Allows us to fill the first 8 CGRAM locations -// with custom characters - -void Max_LCD::createChar(uint8_t location, uint8_t charmap[]) { - location &= 0x7; // we only have 8 locations 0-7 - command(LCD_SETCGRAMADDR | (location << 3)); - for(int i = 0; i < 8; i++) { - write(charmap[i]); - } -} - -/*********** mid level commands, for sending data/cmds */ - -inline void Max_LCD::command(uint8_t value) { - LCD_sendcmd(value); - delayMicroseconds(100); -} - -#if defined(ARDUINO) && ARDUINO >=100 - -inline size_t Max_LCD::write(uint8_t value) { - LCD_sendchar(value); - return 1; // Assume success -} -#else - -inline void Max_LCD::write(uint8_t value) { - LCD_sendchar(value); -} -#endif - -void Max_LCD::sendbyte(uint8_t val) { - lcdPins &= 0x0f; //prepare place for the upper nibble - lcdPins |= (val & 0xf0); //copy upper nibble to LCD variable - SET_E; //send - SENDlcdPins(); - delayMicroseconds(2); - CLR_E; - delayMicroseconds(2); - SENDlcdPins(); - lcdPins &= 0x0f; //prepare place for the lower nibble - lcdPins |= (val << 4) & 0xf0; //copy lower nibble to LCD variable - SET_E; //send - SENDlcdPins(); - CLR_E; - SENDlcdPins(); - delayMicroseconds(100); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/max_LCD.h b/protocol/usb_hid/USB_Host_Shield_2.0/max_LCD.h deleted file mode 100644 index 950c9c5a..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/max_LCD.h +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -//HD44780 compatible LCD display via MAX3421E GPOUT support header -//pinout: D[4-7] -> GPOUT[4-7], RS-> GPOUT[2], E ->GPOUT[3] -// - -#ifndef _Max_LCD_h_ -#define _Max_LCD_h_ - -#include "Usb.h" -#include "Print.h" - -// commands -#define LCD_CLEARDISPLAY 0x01 -#define LCD_RETURNHOME 0x02 -#define LCD_ENTRYMODESET 0x04 -#define LCD_DISPLAYCONTROL 0x08 -#define LCD_CURSORSHIFT 0x10 -#define LCD_FUNCTIONSET 0x20 -#define LCD_SETCGRAMADDR 0x40 -#define LCD_SETDDRAMADDR 0x80 - -// flags for display entry mode -#define LCD_ENTRYRIGHT 0x00 -#define LCD_ENTRYLEFT 0x02 -#define LCD_ENTRYSHIFTINCREMENT 0x01 -#define LCD_ENTRYSHIFTDECREMENT 0x00 - -// flags for display on/off control -#define LCD_DISPLAYON 0x04 -#define LCD_DISPLAYOFF 0x00 -#define LCD_CURSORON 0x02 -#define LCD_CURSOROFF 0x00 -#define LCD_BLINKON 0x01 -#define LCD_BLINKOFF 0x00 - -// flags for display/cursor shift -#define LCD_DISPLAYMOVE 0x08 -#define LCD_CURSORMOVE 0x00 -#define LCD_MOVERIGHT 0x04 -#define LCD_MOVELEFT 0x00 - -// flags for function set -#define LCD_8BITMODE 0x10 -#define LCD_4BITMODE 0x00 -#define LCD_2LINE 0x08 -#define LCD_1LINE 0x00 -#define LCD_5x10DOTS 0x04 -#define LCD_5x8DOTS 0x00 - -class Max_LCD : public Print { - USB *pUsb; - -public: - Max_LCD(USB *pusb); - void init(); - void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); - void clear(); - void home(); - void noDisplay(); - void display(); - void noBlink(); - void blink(); - void noCursor(); - void cursor(); - void scrollDisplayLeft(); - void scrollDisplayRight(); - void leftToRight(); - void rightToLeft(); - void autoscroll(); - void noAutoscroll(); - void createChar(uint8_t, uint8_t[]); - void setCursor(uint8_t, uint8_t); - void command(uint8_t); - -#if defined(ARDUINO) && ARDUINO >=100 - size_t write(uint8_t); - using Print::write; -#else - void write(uint8_t); -#endif - -private: - void sendbyte(uint8_t val); - uint8_t _displayfunction; //tokill - uint8_t _displaycontrol; - uint8_t _displaymode; - uint8_t _initialized; - uint8_t _numlines, _currline; -}; - -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/message.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/message.cpp deleted file mode 100644 index bdcdd183..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/message.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#include "Usb.h" -// 0x80 is the default (i.e. trace) to turn off set this global to something lower. -// this allows for 126 other debugging levels. -// TO-DO: Allow assignment to a different serial port by software -int UsbDEBUGlvl = 0x80; - -void E_Notifyc(char c, int lvl) { - if(UsbDEBUGlvl < lvl) return; -#if defined(ARDUINO) && ARDUINO >=100 - USB_HOST_SERIAL.print(c); -#else - USB_HOST_SERIAL.print(c, BYTE); -#endif - //USB_HOST_SERIAL.flush(); -} - -void E_Notify(char const * msg, int lvl) { - if(UsbDEBUGlvl < lvl) return; - if(!msg) return; - char c; - - while((c = pgm_read_byte(msg++))) E_Notifyc(c, lvl); -} - -void E_NotifyStr(char const * msg, int lvl) { - if(UsbDEBUGlvl < lvl) return; - if(!msg) return; - char c; - - while((c = *msg++)) E_Notifyc(c, lvl); -} - -void E_Notify(uint8_t b, int lvl) { - if(UsbDEBUGlvl < lvl) return; -#if defined(ARDUINO) && ARDUINO >=100 - USB_HOST_SERIAL.print(b); -#else - USB_HOST_SERIAL.print(b, DEC); -#endif - //USB_HOST_SERIAL.flush(); -} - -void E_Notify(double d, int lvl) { - if(UsbDEBUGlvl < lvl) return; - USB_HOST_SERIAL.print(d); - //USB_HOST_SERIAL.flush(); -} - -#ifdef DEBUG_USB_HOST - -void NotifyFailGetDevDescr(void) { - Notify(PSTR("\r\ngetDevDescr "), 0x80); -} - -void NotifyFailSetDevTblEntry(void) { - Notify(PSTR("\r\nsetDevTblEn "), 0x80); -} - -void NotifyFailGetConfDescr(void) { - Notify(PSTR("\r\ngetConf "), 0x80); -} - -void NotifyFailSetConfDescr(void) { - Notify(PSTR("\r\nsetConf "), 0x80); -} - -void NotifyFailGetDevDescr(uint8_t reason) { - NotifyFailGetDevDescr(); - NotifyFail(reason); -} - -void NotifyFailSetDevTblEntry(uint8_t reason) { - NotifyFailSetDevTblEntry(); - NotifyFail(reason); - -} - -void NotifyFailGetConfDescr(uint8_t reason) { - NotifyFailGetConfDescr(); - NotifyFail(reason); -} - -void NotifyFailSetConfDescr(uint8_t reason) { - NotifyFailSetConfDescr(); - NotifyFail(reason); -} - -void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID) { - Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80); - D_PrintHex (VID, 0x80); - Notify(PSTR(" PID: "), 0x80); - D_PrintHex (PID, 0x80); -} - -void NotifyFail(uint8_t rcode) { - D_PrintHex (rcode, 0x80); - Notify(PSTR("\r\n"), 0x80); -} -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/message.h b/protocol/usb_hid/USB_Host_Shield_2.0/message.h deleted file mode 100644 index c26628e7..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/message.h +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(_usb_h_) || defined(__MESSAGE_H__) -#error "Never include message.h directly; include Usb.h instead" -#else -#define __MESSAGE_H__ - -extern int UsbDEBUGlvl; - -void E_Notify(char const * msg, int lvl); -void E_Notify(uint8_t b, int lvl); -void E_NotifyStr(char const * msg, int lvl); -void E_Notifyc(char c, int lvl); - -#ifdef DEBUG_USB_HOST -#define Notify E_Notify -#define NotifyStr E_NotifyStr -#define Notifyc E_Notifyc -void NotifyFailGetDevDescr(uint8_t reason); -void NotifyFailSetDevTblEntry(uint8_t reason); -void NotifyFailGetConfDescr(uint8_t reason); -void NotifyFailSetConfDescr(uint8_t reason); -void NotifyFailGetDevDescr(void); -void NotifyFailSetDevTblEntry(void); -void NotifyFailGetConfDescr(void); -void NotifyFailSetConfDescr(void); -void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID); -void NotifyFail(uint8_t rcode); -#else -#define Notify(...) ((void)0) -#define NotifyStr(...) ((void)0) -#define Notifyc(...) ((void)0) -#define NotifyFailGetDevDescr(...) ((void)0) -#define NotifyFailSetDevTblEntry(...) ((void)0) -#define NotifyFailGetConfDescr(...) ((void)0) -#define NotifyFailGetDevDescr(...) ((void)0) -#define NotifyFailSetDevTblEntry(...) ((void)0) -#define NotifyFailGetConfDescr(...) ((void)0) -#define NotifyFailSetConfDescr(...) ((void)0) -#define NotifyFailUnknownDevice(...) ((void)0) -#define NotifyFail(...) ((void)0) -#endif - -template -void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) { -#ifdef DEBUG_USB_HOST - Notify(msg, level); - Notify(PSTR(": "), level); - D_PrintHex (rcode, level); - Notify(PSTR("\r\n"), level); -#endif -} - -template -void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) { -#ifdef DEBUG_USB_HOST - Notify(msg, 0x80); - Notify(PSTR(": "), 0x80); - D_PrintHex (rcode, 0x80); - Notify(PSTR("\r\n"), 0x80); -#endif -} - -#endif // __MESSAGE_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/parsetools.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/parsetools.cpp deleted file mode 100644 index 74a86105..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/parsetools.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#include "Usb.h" - -bool MultiByteValueParser::Parse(uint8_t **pp, uint16_t *pcntdn) { - if(!pBuf) { - Notify(PSTR("Buffer pointer is NULL!\r\n"), 0x80); - return false; - } - for(; countDown && (*pcntdn); countDown--, (*pcntdn)--, (*pp)++) - pBuf[valueSize - countDown] = (**pp); - - if(countDown) - return false; - - countDown = valueSize; - return true; -} - -bool PTPListParser::Parse(uint8_t **pp, uint16_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me) { - switch(nStage) { - case 0: - pBuf->valueSize = lenSize; - theParser.Initialize(pBuf); - nStage = 1; - - case 1: - if(!theParser.Parse(pp, pcntdn)) - return false; - - arLen = 0; - arLen = (pBuf->valueSize >= 4) ? *((uint32_t*)pBuf->pValue) : (uint32_t)(*((uint16_t*)pBuf->pValue)); - arLenCntdn = arLen; - nStage = 2; - - case 2: - pBuf->valueSize = valSize; - theParser.Initialize(pBuf); - nStage = 3; - - case 3: - for(; arLenCntdn; arLenCntdn--) { - if(!theParser.Parse(pp, pcntdn)) - return false; - - if(pf) - pf(pBuf, (arLen - arLenCntdn), me); - } - - nStage = 0; - } - return true; -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/parsetools.h b/protocol/usb_hid/USB_Host_Shield_2.0/parsetools.h deleted file mode 100644 index 66e9531c..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/parsetools.h +++ /dev/null @@ -1,140 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#if !defined(_usb_h_) || defined(__PARSETOOLS_H__) -#error "Never include parsetools.h directly; include Usb.h instead" -#else -#define __PARSETOOLS_H__ - -struct MultiValueBuffer { - uint8_t valueSize; - void *pValue; -} __attribute__((packed)); - -class MultiByteValueParser { - uint8_t * pBuf; - uint8_t countDown; - uint8_t valueSize; - -public: - - MultiByteValueParser() : pBuf(NULL), countDown(0), valueSize(0) { - }; - - const uint8_t* GetBuffer() { - return pBuf; - }; - - void Initialize(MultiValueBuffer * const pbuf) { - pBuf = (uint8_t*)pbuf->pValue; - countDown = valueSize = pbuf->valueSize; - }; - - bool Parse(uint8_t **pp, uint16_t *pcntdn); -}; - -class ByteSkipper { - uint8_t *pBuf; - uint8_t nStage; - uint16_t countDown; - -public: - - ByteSkipper() : pBuf(NULL), nStage(0), countDown(0) { - }; - - void Initialize(MultiValueBuffer *pbuf) { - pBuf = (uint8_t*)pbuf->pValue; - countDown = 0; - }; - - bool Skip(uint8_t **pp, uint16_t *pcntdn, uint16_t bytes_to_skip) { - switch(nStage) { - case 0: - countDown = bytes_to_skip; - nStage++; - case 1: - for(; countDown && (*pcntdn); countDown--, (*pp)++, (*pcntdn)--); - - if(!countDown) - nStage = 0; - }; - return (!countDown); - }; -}; - -// Pointer to a callback function triggered for each element of PTP array when used with PTPArrayParser -typedef void (*PTP_ARRAY_EL_FUNC)(const MultiValueBuffer * const p, uint32_t count, const void *me); - -class PTPListParser { -public: - - enum ParseMode { - modeArray, modeRange/*, modeEnum*/ - }; - -private: - uint8_t nStage; - uint8_t enStage; - - uint32_t arLen; - uint32_t arLenCntdn; - - uint8_t lenSize; // size of the array length field in bytes - uint8_t valSize; // size of the array element in bytes - - MultiValueBuffer *pBuf; - - // The only parser for both size and array element parsing - MultiByteValueParser theParser; - - uint8_t /*ParseMode*/ prsMode; - -public: - - PTPListParser() : - nStage(0), - enStage(0), - arLen(0), - arLenCntdn(0), - lenSize(0), - valSize(0), - pBuf(NULL), - prsMode(modeArray) { - }; - - void Initialize(const uint8_t len_size, const uint8_t val_size, MultiValueBuffer * const p, const uint8_t mode = modeArray) { - pBuf = p; - lenSize = len_size; - valSize = val_size; - prsMode = mode; - - if(prsMode == modeRange) { - arLenCntdn = arLen = 3; - nStage = 2; - } else { - arLenCntdn = arLen = 0; - nStage = 0; - } - enStage = 0; - theParser.Initialize(p); - }; - - bool Parse(uint8_t **pp, uint16_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me = NULL); -}; - -#endif // __PARSETOOLS_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/printhex.h b/protocol/usb_hid/USB_Host_Shield_2.0/printhex.h deleted file mode 100644 index 369d7e1f..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/printhex.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#if !defined(_usb_h_) || defined(__PRINTHEX_H__) -#error "Never include printhex.h directly; include Usb.h instead" -#else -#define __PRINTHEX_H__ - -void E_Notifyc(char c, int lvl); - -template -void PrintHex(T val, int lvl) { - int num_nibbles = sizeof (T) * 2; - - do { - char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0f); - if(v > 57) v += 7; - E_Notifyc(v, lvl); - } while(--num_nibbles); -} - -template -void PrintBin(T val, int lvl) { - for(T mask = (((T)1) << ((sizeof (T) << 3) - 1)); mask; mask >>= 1) - if(val & mask) - E_Notifyc('1', lvl); - else - E_Notifyc('0', lvl); -} - -template -void SerialPrintHex(T val) { - int num_nibbles = sizeof (T) * 2; - - do { - char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0f); - if(v > 57) v += 7; - USB_HOST_SERIAL.print(v); - } while(--num_nibbles); -} - -template -void PrintHex2(Print *prn, T val) { - T mask = (((T)1) << (((sizeof (T) << 1) - 1) << 2)); - - while(mask > 1) { - if(val < mask) - prn->print("0"); - - mask >>= 4; - } - prn->print((T)val, HEX); -} - -template void D_PrintHex(T val, int lvl) { -#ifdef DEBUG_USB_HOST - PrintHex (val, lvl); -#endif -} - -template -void D_PrintBin(T val, int lvl) { -#ifdef DEBUG_USB_HOST - PrintBin (val, lvl); -#endif -} - - - -#endif // __PRINTHEX_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/settings.h b/protocol/usb_hid/USB_Host_Shield_2.0/settings.h deleted file mode 100644 index 5c060354..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/settings.h +++ /dev/null @@ -1,139 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#ifndef USB_HOST_SHIELD_SETTINGS_H -#define USB_HOST_SHIELD_SETTINGS_H -#include "macros.h" - -//////////////////////////////////////////////////////////////////////////////// -// DEBUGGING -//////////////////////////////////////////////////////////////////////////////// - -/* Set this to 1 to activate serial debugging */ -#define ENABLE_UHS_DEBUGGING 0 - -/* This can be used to select which serial port to use for debugging if - * multiple serial ports are available. - * For example Serial3. - */ -#ifndef USB_HOST_SERIAL -#define USB_HOST_SERIAL Serial -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Manual board activation -//////////////////////////////////////////////////////////////////////////////// - -/* Set this to 1 if you are using an Arduino Mega ADK board with MAX3421e built-in */ -#define USE_UHS_MEGA_ADK 0 // If you are using Arduino 1.5.5 or newer there is no need to do this manually - -/* Set this to 1 if you are using a Black Widdow */ -#define USE_UHS_BLACK_WIDDOW 0 - -/* Set this to a one to use the xmem2 lock. This is needed for multitasking and threading */ -#define USE_XMEM_SPI_LOCK 0 - -//////////////////////////////////////////////////////////////////////////////// -// Wii IR camera -//////////////////////////////////////////////////////////////////////////////// - -/* Set this to 1 to activate code for the Wii IR camera */ -#define ENABLE_WII_IR_CAMERA 0 - -//////////////////////////////////////////////////////////////////////////////// -// MASS STORAGE -//////////////////////////////////////////////////////////////////////////////// -// <<<<<<<<<<<<<<<< IMPORTANT >>>>>>>>>>>>>>> -// Set this to 1 to support single LUN devices, and save RAM. -- I.E. thumb drives. -// Each LUN needs ~13 bytes to be able to track the state of each unit. -#ifndef MASS_MAX_SUPPORTED_LUN -#define MASS_MAX_SUPPORTED_LUN 8 -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Set to 1 to use the faster spi4teensy3 driver. -//////////////////////////////////////////////////////////////////////////////// -#ifndef USE_SPI4TEENSY3 -#define USE_SPI4TEENSY3 1 -#endif - -//////////////////////////////////////////////////////////////////////////////// -// AUTOMATIC Settings -//////////////////////////////////////////////////////////////////////////////// - -// No user serviceable parts below this line. -// DO NOT change anything below here unless you are a developer! - -#include "version_helper.h" - -#if defined(__GNUC__) && defined(__AVR__) -#ifndef GCC_VERSION -#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) -#endif -#if GCC_VERSION < 40602 // Test for GCC < 4.6.2 -#ifdef PROGMEM -#undef PROGMEM -#define PROGMEM __attribute__((section(".progmem.data"))) // Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734#c4 -#ifdef PSTR -#undef PSTR -#define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0];})) // Copied from pgmspace.h in avr-libc source -#endif -#endif -#endif -#endif - -#if !defined(DEBUG_USB_HOST) && ENABLE_UHS_DEBUGGING -#define DEBUG_USB_HOST -#endif - -#if !defined(WIICAMERA) && ENABLE_WII_IR_CAMERA -#define WIICAMERA -#endif - -// To use some other locking (e.g. freertos), -// define XMEM_ACQUIRE_SPI and XMEM_RELEASE_SPI to point to your lock and unlock. -// NOTE: NO argument is passed. You have to do this within your routine for -// whatever you are using to lock and unlock. -#if !defined(XMEM_ACQUIRE_SPI) -#if USE_XMEM_SPI_LOCK || defined(USE_MULTIPLE_APP_API) -#include -#else -#define XMEM_ACQUIRE_SPI() (void(0)) -#define XMEM_RELEASE_SPI() (void(0)) -#endif -#endif - -#if !defined(EXT_RAM) && defined(EXT_RAM_STACK) || defined(EXT_RAM_HEAP) -#include -#else -#define EXT_RAM 0 -#endif - -#if defined(CORE_TEENSY) && (defined(__MK20DX128__) || defined(__MK20DX256__)) -#define USING_SPI4TEENSY3 USE_SPI4TEENSY3 -#else -#define USING_SPI4TEENSY3 0 -#endif - -#if ((defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(RBL_NRF51822) || defined(__ARDUINO_X86__) || ARDUINO >= 10600) && !USING_SPI4TEENSY3 -#include // Use the Arduino SPI library for the Arduino Due, RedBearLab nRF51822, Intel Galileo 1 & 2, Intel Edison or if the SPI library with transaction is available -#endif -#if defined(__PIC32MX__) || defined(__PIC32MZ__) -#include <../../../../hardware/pic32/libraries/SPI/SPI.h> // Hack to use the SPI library -#endif - -#endif /* SETTINGS_H */ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/sink_parser.h b/protocol/usb_hid/USB_Host_Shield_2.0/sink_parser.h deleted file mode 100644 index a23637d2..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/sink_parser.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(_usb_h_) || defined(__SINK_PARSER_H__) -#error "Never include hexdump.h directly; include Usb.h instead" -#else -#define __SINK_PARSER_H__ - -extern int UsbDEBUGlvl; - -// This parser does absolutely nothing with the data, just swallows it. - -template -class SinkParser : public BASE_CLASS { -public: - - SinkParser() { - }; - - void Initialize() { - }; - - void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) { - }; -}; - - -#endif // __HEXDUMP_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/usb_ch9.h b/protocol/usb_hid/USB_Host_Shield_2.0/usb_ch9.h deleted file mode 100644 index 18f2d3e2..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/usb_ch9.h +++ /dev/null @@ -1,166 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -#if !defined(_usb_h_) || defined(_ch9_h_) -#error "Never include usb_ch9.h directly; include Usb.h instead" -#else - -/* USB chapter 9 structures */ -#define _ch9_h_ - -/* Misc.USB constants */ -#define DEV_DESCR_LEN 18 //device descriptor length -#define CONF_DESCR_LEN 9 //configuration descriptor length -#define INTR_DESCR_LEN 9 //interface descriptor length -#define EP_DESCR_LEN 7 //endpoint descriptor length - -/* Standard Device Requests */ - -#define USB_REQUEST_GET_STATUS 0 // Standard Device Request - GET STATUS -#define USB_REQUEST_CLEAR_FEATURE 1 // Standard Device Request - CLEAR FEATURE -#define USB_REQUEST_SET_FEATURE 3 // Standard Device Request - SET FEATURE -#define USB_REQUEST_SET_ADDRESS 5 // Standard Device Request - SET ADDRESS -#define USB_REQUEST_GET_DESCRIPTOR 6 // Standard Device Request - GET DESCRIPTOR -#define USB_REQUEST_SET_DESCRIPTOR 7 // Standard Device Request - SET DESCRIPTOR -#define USB_REQUEST_GET_CONFIGURATION 8 // Standard Device Request - GET CONFIGURATION -#define USB_REQUEST_SET_CONFIGURATION 9 // Standard Device Request - SET CONFIGURATION -#define USB_REQUEST_GET_INTERFACE 10 // Standard Device Request - GET INTERFACE -#define USB_REQUEST_SET_INTERFACE 11 // Standard Device Request - SET INTERFACE -#define USB_REQUEST_SYNCH_FRAME 12 // Standard Device Request - SYNCH FRAME - -#define USB_FEATURE_ENDPOINT_HALT 0 // CLEAR/SET FEATURE - Endpoint Halt -#define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // CLEAR/SET FEATURE - Device remote wake-up -#define USB_FEATURE_TEST_MODE 2 // CLEAR/SET FEATURE - Test mode - -/* Setup Data Constants */ - -#define USB_SETUP_HOST_TO_DEVICE 0x00 // Device Request bmRequestType transfer direction - host to device transfer -#define USB_SETUP_DEVICE_TO_HOST 0x80 // Device Request bmRequestType transfer direction - device to host transfer -#define USB_SETUP_TYPE_STANDARD 0x00 // Device Request bmRequestType type - standard -#define USB_SETUP_TYPE_CLASS 0x20 // Device Request bmRequestType type - class -#define USB_SETUP_TYPE_VENDOR 0x40 // Device Request bmRequestType type - vendor -#define USB_SETUP_RECIPIENT_DEVICE 0x00 // Device Request bmRequestType recipient - device -#define USB_SETUP_RECIPIENT_INTERFACE 0x01 // Device Request bmRequestType recipient - interface -#define USB_SETUP_RECIPIENT_ENDPOINT 0x02 // Device Request bmRequestType recipient - endpoint -#define USB_SETUP_RECIPIENT_OTHER 0x03 // Device Request bmRequestType recipient - other - -/* USB descriptors */ - -#define USB_DESCRIPTOR_DEVICE 0x01 // bDescriptorType for a Device Descriptor. -#define USB_DESCRIPTOR_CONFIGURATION 0x02 // bDescriptorType for a Configuration Descriptor. -#define USB_DESCRIPTOR_STRING 0x03 // bDescriptorType for a String Descriptor. -#define USB_DESCRIPTOR_INTERFACE 0x04 // bDescriptorType for an Interface Descriptor. -#define USB_DESCRIPTOR_ENDPOINT 0x05 // bDescriptorType for an Endpoint Descriptor. -#define USB_DESCRIPTOR_DEVICE_QUALIFIER 0x06 // bDescriptorType for a Device Qualifier. -#define USB_DESCRIPTOR_OTHER_SPEED 0x07 // bDescriptorType for a Other Speed Configuration. -#define USB_DESCRIPTOR_INTERFACE_POWER 0x08 // bDescriptorType for Interface Power. -#define USB_DESCRIPTOR_OTG 0x09 // bDescriptorType for an OTG Descriptor. - -#define HID_DESCRIPTOR_HID 0x21 - - - -/* OTG SET FEATURE Constants */ -#define OTG_FEATURE_B_HNP_ENABLE 3 // SET FEATURE OTG - Enable B device to perform HNP -#define OTG_FEATURE_A_HNP_SUPPORT 4 // SET FEATURE OTG - A device supports HNP -#define OTG_FEATURE_A_ALT_HNP_SUPPORT 5 // SET FEATURE OTG - Another port on the A device supports HNP - -/* USB Endpoint Transfer Types */ -#define USB_TRANSFER_TYPE_CONTROL 0x00 // Endpoint is a control endpoint. -#define USB_TRANSFER_TYPE_ISOCHRONOUS 0x01 // Endpoint is an isochronous endpoint. -#define USB_TRANSFER_TYPE_BULK 0x02 // Endpoint is a bulk endpoint. -#define USB_TRANSFER_TYPE_INTERRUPT 0x03 // Endpoint is an interrupt endpoint. -#define bmUSB_TRANSFER_TYPE 0x03 // bit mask to separate transfer type from ISO attributes - - -/* Standard Feature Selectors for CLEAR_FEATURE Requests */ -#define USB_FEATURE_ENDPOINT_STALL 0 // Endpoint recipient -#define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // Device recipient -#define USB_FEATURE_TEST_MODE 2 // Device recipient - -/* descriptor data structures */ - -/* Device descriptor structure */ -typedef struct { - uint8_t bLength; // Length of this descriptor. - uint8_t bDescriptorType; // DEVICE descriptor type (USB_DESCRIPTOR_DEVICE). - uint16_t bcdUSB; // USB Spec Release Number (BCD). - uint8_t bDeviceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific. - uint8_t bDeviceSubClass; // Subclass code (assigned by the USB-IF). - uint8_t bDeviceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific. - uint8_t bMaxPacketSize0; // Maximum packet size for endpoint 0. - uint16_t idVendor; // Vendor ID (assigned by the USB-IF). - uint16_t idProduct; // Product ID (assigned by the manufacturer). - uint16_t bcdDevice; // Device release number (BCD). - uint8_t iManufacturer; // Index of String Descriptor describing the manufacturer. - uint8_t iProduct; // Index of String Descriptor describing the product. - uint8_t iSerialNumber; // Index of String Descriptor with the device's serial number. - uint8_t bNumConfigurations; // Number of possible configurations. -} __attribute__((packed)) USB_DEVICE_DESCRIPTOR; - -/* Configuration descriptor structure */ -typedef struct { - uint8_t bLength; // Length of this descriptor. - uint8_t bDescriptorType; // CONFIGURATION descriptor type (USB_DESCRIPTOR_CONFIGURATION). - uint16_t wTotalLength; // Total length of all descriptors for this configuration. - uint8_t bNumInterfaces; // Number of interfaces in this configuration. - uint8_t bConfigurationValue; // Value of this configuration (1 based). - uint8_t iConfiguration; // Index of String Descriptor describing the configuration. - uint8_t bmAttributes; // Configuration characteristics. - uint8_t bMaxPower; // Maximum power consumed by this configuration. -} __attribute__((packed)) USB_CONFIGURATION_DESCRIPTOR; - -/* Interface descriptor structure */ -typedef struct { - uint8_t bLength; // Length of this descriptor. - uint8_t bDescriptorType; // INTERFACE descriptor type (USB_DESCRIPTOR_INTERFACE). - uint8_t bInterfaceNumber; // Number of this interface (0 based). - uint8_t bAlternateSetting; // Value of this alternate interface setting. - uint8_t bNumEndpoints; // Number of endpoints in this interface. - uint8_t bInterfaceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific. - uint8_t bInterfaceSubClass; // Subclass code (assigned by the USB-IF). - uint8_t bInterfaceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific. - uint8_t iInterface; // Index of String Descriptor describing the interface. -} __attribute__((packed)) USB_INTERFACE_DESCRIPTOR; - -/* Endpoint descriptor structure */ -typedef struct { - uint8_t bLength; // Length of this descriptor. - uint8_t bDescriptorType; // ENDPOINT descriptor type (USB_DESCRIPTOR_ENDPOINT). - uint8_t bEndpointAddress; // Endpoint address. Bit 7 indicates direction (0=OUT, 1=IN). - uint8_t bmAttributes; // Endpoint transfer type. - uint16_t wMaxPacketSize; // Maximum packet size. - uint8_t bInterval; // Polling interval in frames. -} __attribute__((packed)) USB_ENDPOINT_DESCRIPTOR; - -/* HID descriptor */ -typedef struct { - uint8_t bLength; - uint8_t bDescriptorType; - uint16_t bcdHID; // HID class specification release - uint8_t bCountryCode; - uint8_t bNumDescriptors; // Number of additional class specific descriptors - uint8_t bDescrType; // Type of class descriptor - uint16_t wDescriptorLength; // Total size of the Report descriptor -} __attribute__((packed)) USB_HID_DESCRIPTOR; - -typedef struct { - uint8_t bDescrType; // Type of class descriptor - uint16_t wDescriptorLength; // Total size of the Report descriptor -} __attribute__((packed)) HID_CLASS_DESCRIPTOR_LEN_AND_TYPE; - -#endif // _ch9_h_ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/usbhost.h b/protocol/usb_hid/USB_Host_Shield_2.0/usbhost.h deleted file mode 100644 index eba480e6..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/usbhost.h +++ /dev/null @@ -1,529 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -/* MAX3421E-based USB Host Library header file */ - - -#if !defined(_usb_h_) || defined(_USBHOST_H_) -#error "Never include usbhost.h directly; include Usb.h instead" -#else -#define _USBHOST_H_ - -#if USING_SPI4TEENSY3 -#include -#include -#endif - -/* SPI initialization */ -template< typename SPI_CLK, typename SPI_MOSI, typename SPI_MISO, typename SPI_SS > class SPi { -public: -#if USING_SPI4TEENSY3 - static void init() { - // spi4teensy3 inits everything for us, except /SS - // CLK, MOSI and MISO are hard coded for now. - // spi4teensy3::init(0,0,0); // full speed, cpol 0, cpha 0 - spi4teensy3::init(); // full speed, cpol 0, cpha 0 - SPI_SS::SetDirWrite(); - SPI_SS::Set(); - } -#elif SPI_HAS_TRANSACTION - static void init() { - SPI.begin(); // The SPI library with transaction will take care of setting up the pins - settings is set in beginTransaction() - } -#elif !defined(SPDR) - static void init() { - SPI_SS::SetDirWrite(); - SPI_SS::Set(); - SPI.begin(); -#if defined(__MIPSEL__) - SPI.setClockDivider(1); -#elif defined(__ARDUINO_X86__) - #ifdef SPI_CLOCK_1M // Hack used to check if setClockSpeed is available - SPI.setClockSpeed(12000000); // The MAX3421E can handle up to 26MHz, but in practice this was the maximum that I could reliably use - #else - SPI.setClockDivider(SPI_CLOCK_DIV2); // This will set the SPI frequency to 8MHz - it could be higher, but it is not supported in the old API - #endif -#else - SPI.setClockDivider(4); // Set speed to 84MHz/4=21MHz - the MAX3421E can handle up to 26MHz -#endif - } -#elif defined(RBL_NRF51822) - static void init() { - SPI_SS::SetDirWrite(); - SPI_SS::Set(); - SPI.begin(); - // SPI.setFrequency(SPI_FREQUENCY_8M); - } -#else - static void init() { - //uint8_t tmp; - SPI_CLK::SetDirWrite(); - SPI_MOSI::SetDirWrite(); - SPI_MISO::SetDirRead(); - SPI_SS::SetDirWrite(); - /* mode 00 (CPOL=0, CPHA=0) master, fclk/2. Mode 11 (CPOL=11, CPHA=11) is also supported by MAX3421E */ - SPCR = 0x50; - SPSR = 0x01; // 0x01 - /**/ - //tmp = SPSR; - //tmp = SPDR; - } -#endif -}; - -/* SPI pin definitions. see avrpins.h */ -#if defined(__AVR_ATmega1280__) || (__AVR_ATmega2560__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) -typedef SPi< Pb1, Pb2, Pb3, Pb0 > spi; -#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) -typedef SPi< Pb5, Pb3, Pb4, Pb2 > spi; -#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) -typedef SPi< Pb7, Pb5, Pb6, Pb4 > spi; -#elif (defined(CORE_TEENSY) && (defined(__MK20DX128__) || defined(__MK20DX256__))) || defined(__ARDUINO_X86__) || defined(__MIPSEL__) -typedef SPi< P13, P11, P12, P10 > spi; -#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__) -typedef SPi< P76, P75, P74, P10 > spi; -#elif defined(RBL_NRF51822) -typedef SPi< P16, P18, P17, P10 > spi; -#else -#error "No SPI entry in usbhost.h" -#endif - -typedef enum { - vbus_on = 0, - vbus_off = GPX_VBDET -} VBUS_t; - -template< typename SPI_SS, typename INTR > class MAX3421e /* : public spi */ { - static uint8_t vbusState; - -public: - MAX3421e(); - void regWr(uint8_t reg, uint8_t data); - uint8_t* bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p); - void gpioWr(uint8_t data); - uint8_t regRd(uint8_t reg); - uint8_t* bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p); - uint8_t gpioRd(); - uint16_t reset(); - int8_t Init(); - int8_t Init(int mseconds); - - void vbusPower(VBUS_t state) { - regWr(rPINCTL, (bmFDUPSPI | bmINTLEVEL | state)); - } - - uint8_t getVbusState(void) { - return vbusState; - }; - void busprobe(); - uint8_t GpxHandler(); - uint8_t IntHandler(); - uint8_t Task(); -}; - -template< typename SPI_SS, typename INTR > - uint8_t MAX3421e< SPI_SS, INTR >::vbusState = 0; - -/* constructor */ -template< typename SPI_SS, typename INTR > -MAX3421e< SPI_SS, INTR >::MAX3421e() { - // Leaving ADK hardware setup in here, for now. This really belongs with the other parts. -#ifdef BOARD_MEGA_ADK - // For Mega ADK, which has a Max3421e on-board, set MAX_RESET to output mode, and then set it to HIGH - P55::SetDirWrite(); - P55::Set(); -#endif -}; - -/* write single byte into MAX3421 register */ -template< typename SPI_SS, typename INTR > -void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) { - XMEM_ACQUIRE_SPI(); -#if SPI_HAS_TRANSACTION - SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0 -#endif - SPI_SS::Clear(); - -#if USING_SPI4TEENSY3 - uint8_t c[2]; - c[0] = reg | 0x02; - c[1] = data; - spi4teensy3::send(c, 2); -#elif SPI_HAS_TRANSACTION - uint8_t c[2]; - c[0] = reg | 0x02; - c[1] = data; - SPI.transfer(c, 2); -#elif !defined(SPDR) - SPI.transfer(reg | 0x02); - SPI.transfer(data); -#else - SPDR = (reg | 0x02); - while(!(SPSR & (1 << SPIF))); - SPDR = data; - while(!(SPSR & (1 << SPIF))); -#endif - - SPI_SS::Set(); -#if SPI_HAS_TRANSACTION - SPI.endTransaction(); -#endif - XMEM_RELEASE_SPI(); - return; -}; -/* multiple-byte write */ - -/* returns a pointer to memory position after last written */ -template< typename SPI_SS, typename INTR > -uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p) { - XMEM_ACQUIRE_SPI(); -#if SPI_HAS_TRANSACTION - SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0 -#endif - SPI_SS::Clear(); - -#if USING_SPI4TEENSY3 - spi4teensy3::send(reg | 0x02); - spi4teensy3::send(data_p, nbytes); - data_p += nbytes; -#elif SPI_HAS_TRANSACTION - SPI.transfer(reg | 0x02); - SPI.transfer(data_p, nbytes); - data_p += nbytes; -#elif defined(__ARDUINO_X86__) - SPI.transfer(reg | 0x02); - SPI.transferBuffer(data_p, NULL, nbytes); - data_p += nbytes; -#elif !defined(SPDR) - SPI.transfer(reg | 0x02); - while(nbytes) { - SPI.transfer(*data_p); - nbytes--; - data_p++; // advance data pointer - } -#else - SPDR = (reg | 0x02); //set WR bit and send register number - while(nbytes) { - while(!(SPSR & (1 << SPIF))); //check if previous byte was sent - SPDR = (*data_p); // send next data byte - nbytes--; - data_p++; // advance data pointer - } - while(!(SPSR & (1 << SPIF))); -#endif - - SPI_SS::Set(); -#if SPI_HAS_TRANSACTION - SPI.endTransaction(); -#endif - XMEM_RELEASE_SPI(); - return ( data_p); -} -/* GPIO write */ -/*GPIO byte is split between 2 registers, so two writes are needed to write one byte */ - -/* GPOUT bits are in the low nibble. 0-3 in IOPINS1, 4-7 in IOPINS2 */ -template< typename SPI_SS, typename INTR > -void MAX3421e< SPI_SS, INTR >::gpioWr(uint8_t data) { - regWr(rIOPINS1, data); - data >>= 4; - regWr(rIOPINS2, data); - return; -} - -/* single host register read */ -template< typename SPI_SS, typename INTR > -uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) { - XMEM_ACQUIRE_SPI(); -#if SPI_HAS_TRANSACTION - SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0 -#endif - SPI_SS::Clear(); - -#if USING_SPI4TEENSY3 - spi4teensy3::send(reg); - uint8_t rv = spi4teensy3::receive(); - SPI_SS::Set(); -#elif !defined(SPDR) || SPI_HAS_TRANSACTION - SPI.transfer(reg); - uint8_t rv = SPI.transfer(0); // Send empty byte - SPI_SS::Set(); -#else - SPDR = reg; - while(!(SPSR & (1 << SPIF))); - SPDR = 0; // Send empty byte - while(!(SPSR & (1 << SPIF))); - SPI_SS::Set(); - uint8_t rv = SPDR; -#endif - -#if SPI_HAS_TRANSACTION - SPI.endTransaction(); -#endif - XMEM_RELEASE_SPI(); - return (rv); -} -/* multiple-byte register read */ - -/* returns a pointer to a memory position after last read */ -template< typename SPI_SS, typename INTR > -uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p) { - XMEM_ACQUIRE_SPI(); -#if SPI_HAS_TRANSACTION - SPI.beginTransaction(SPISettings(26000000, MSBFIRST, SPI_MODE0)); // The MAX3421E can handle up to 26MHz, use MSB First and SPI mode 0 -#endif - SPI_SS::Clear(); - -#if USING_SPI4TEENSY3 - spi4teensy3::send(reg); - spi4teensy3::receive(data_p, nbytes); - data_p += nbytes; -#elif SPI_HAS_TRANSACTION - SPI.transfer(reg); - memset(data_p, 0, nbytes); // Make sure we send out empty bytes - SPI.transfer(data_p, nbytes); - data_p += nbytes; -#elif defined(__ARDUINO_X86__) - SPI.transfer(reg); - SPI.transferBuffer(NULL, data_p, nbytes); - data_p += nbytes; -#elif !defined(SPDR) - SPI.transfer(reg); - while(nbytes) { - *data_p++ = SPI.transfer(0); - nbytes--; - } -#else - SPDR = reg; - while(!(SPSR & (1 << SPIF))); //wait - while(nbytes) { - SPDR = 0; // Send empty byte - nbytes--; - while(!(SPSR & (1 << SPIF))); -#if 0 - { - *data_p = SPDR; - printf("%2.2x ", *data_p); - } - data_p++; - } - printf("\r\n"); -#else - *data_p++ = SPDR; - } -#endif -#endif - - SPI_SS::Set(); -#if SPI_HAS_TRANSACTION - SPI.endTransaction(); -#endif - XMEM_RELEASE_SPI(); - return ( data_p); -} -/* GPIO read. See gpioWr for explanation */ - -/* GPIN pins are in high nibbles of IOPINS1, IOPINS2 */ -template< typename SPI_SS, typename INTR > -uint8_t MAX3421e< SPI_SS, INTR >::gpioRd() { - uint8_t gpin = 0; - gpin = regRd(rIOPINS2); //pins 4-7 - gpin &= 0xf0; //clean lower nibble - gpin |= (regRd(rIOPINS1) >> 4); //shift low bits and OR with upper from previous operation. - return ( gpin); -} - -/* reset MAX3421E. Returns number of cycles it took for PLL to stabilize after reset - or zero if PLL haven't stabilized in 65535 cycles */ -template< typename SPI_SS, typename INTR > -uint16_t MAX3421e< SPI_SS, INTR >::reset() { - uint16_t i = 0; - regWr(rUSBCTL, bmCHIPRES); - regWr(rUSBCTL, 0x00); - while(++i) { - if((regRd(rUSBIRQ) & bmOSCOKIRQ)) { - break; - } - } - return ( i); -} - -/* initialize MAX3421E. Set Host mode, pullups, and stuff. Returns 0 if success, -1 if not */ -template< typename SPI_SS, typename INTR > -int8_t MAX3421e< SPI_SS, INTR >::Init() { - XMEM_ACQUIRE_SPI(); - // Moved here. - // you really should not init hardware in the constructor when it involves locks. - // Also avoids the vbus flicker issue confusing some devices. - /* pin and peripheral setup */ - SPI_SS::SetDirWrite(); - SPI_SS::Set(); - spi::init(); - INTR::SetDirRead(); - XMEM_RELEASE_SPI(); - /* MAX3421E - full-duplex SPI, level interrupt */ - // GPX pin on. Moved here, otherwise we flicker the vbus. - regWr(rPINCTL, (bmFDUPSPI | bmINTLEVEL)); - - if(reset() == 0) { //OSCOKIRQ hasn't asserted in time - return ( -1); - } - - regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); // set pull-downs, Host - - regWr(rHIEN, bmCONDETIE | bmFRAMEIE); //connection detection - - /* check if device is connected */ - regWr(rHCTL, bmSAMPLEBUS); // sample USB bus - while(!(regRd(rHCTL) & bmSAMPLEBUS)); //wait for sample operation to finish - - busprobe(); //check if anything is connected - - regWr(rHIRQ, bmCONDETIRQ); //clear connection detect interrupt - regWr(rCPUCTL, 0x01); //enable interrupt pin - - return ( 0); -} - -/* initialize MAX3421E. Set Host mode, pullups, and stuff. Returns 0 if success, -1 if not */ -template< typename SPI_SS, typename INTR > -int8_t MAX3421e< SPI_SS, INTR >::Init(int mseconds) { - XMEM_ACQUIRE_SPI(); - // Moved here. - // you really should not init hardware in the constructor when it involves locks. - // Also avoids the vbus flicker issue confusing some devices. - /* pin and peripheral setup */ - SPI_SS::SetDirWrite(); - SPI_SS::Set(); - spi::init(); - INTR::SetDirRead(); - XMEM_RELEASE_SPI(); - /* MAX3421E - full-duplex SPI, level interrupt, vbus off */ - regWr(rPINCTL, (bmFDUPSPI | bmINTLEVEL | GPX_VBDET)); - - if(reset() == 0) { //OSCOKIRQ hasn't asserted in time - return ( -1); - } - - // Delay a minimum of 1 second to ensure any capacitors are drained. - // 1 second is required to make sure we do not smoke a Microdrive! - if(mseconds < 1000) mseconds = 1000; - delay(mseconds); - - regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); // set pull-downs, Host - - regWr(rHIEN, bmCONDETIE | bmFRAMEIE); //connection detection - - /* check if device is connected */ - regWr(rHCTL, bmSAMPLEBUS); // sample USB bus - while(!(regRd(rHCTL) & bmSAMPLEBUS)); //wait for sample operation to finish - - busprobe(); //check if anything is connected - - regWr(rHIRQ, bmCONDETIRQ); //clear connection detect interrupt - regWr(rCPUCTL, 0x01); //enable interrupt pin - - // GPX pin on. This is done here so that busprobe will fail if we have a switch connected. - regWr(rPINCTL, (bmFDUPSPI | bmINTLEVEL)); - - return ( 0); -} - -/* probe bus to determine device presence and speed and switch host to this speed */ -template< typename SPI_SS, typename INTR > -void MAX3421e< SPI_SS, INTR >::busprobe() { - uint8_t bus_sample; - bus_sample = regRd(rHRSL); //Get J,K status - bus_sample &= (bmJSTATUS | bmKSTATUS); //zero the rest of the byte - switch(bus_sample) { //start full-speed or low-speed host - case( bmJSTATUS): - if((regRd(rMODE) & bmLOWSPEED) == 0) { - regWr(rMODE, MODE_FS_HOST); //start full-speed host - vbusState = FSHOST; - } else { - regWr(rMODE, MODE_LS_HOST); //start low-speed host - vbusState = LSHOST; - } - break; - case( bmKSTATUS): - if((regRd(rMODE) & bmLOWSPEED) == 0) { - regWr(rMODE, MODE_LS_HOST); //start low-speed host - vbusState = LSHOST; - } else { - regWr(rMODE, MODE_FS_HOST); //start full-speed host - vbusState = FSHOST; - } - break; - case( bmSE1): //illegal state - vbusState = SE1; - break; - case( bmSE0): //disconnected state - regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST | bmSEPIRQ); - vbusState = SE0; - break; - }//end switch( bus_sample ) -} - -/* MAX3421 state change task and interrupt handler */ -template< typename SPI_SS, typename INTR > -uint8_t MAX3421e< SPI_SS, INTR >::Task(void) { - uint8_t rcode = 0; - uint8_t pinvalue; - //USB_HOST_SERIAL.print("Vbus state: "); - //USB_HOST_SERIAL.println( vbusState, HEX ); - pinvalue = INTR::IsSet(); //Read(); - //pinvalue = digitalRead( MAX_INT ); - if(pinvalue == 0) { - rcode = IntHandler(); - } - // pinvalue = digitalRead( MAX_GPX ); - // if( pinvalue == LOW ) { - // GpxHandler(); - // } - // usbSM(); //USB state machine - return ( rcode); -} - -template< typename SPI_SS, typename INTR > -uint8_t MAX3421e< SPI_SS, INTR >::IntHandler() { - uint8_t HIRQ; - uint8_t HIRQ_sendback = 0x00; - HIRQ = regRd(rHIRQ); //determine interrupt source - //if( HIRQ & bmFRAMEIRQ ) { //->1ms SOF interrupt handler - // HIRQ_sendback |= bmFRAMEIRQ; - //}//end FRAMEIRQ handling - if(HIRQ & bmCONDETIRQ) { - busprobe(); - HIRQ_sendback |= bmCONDETIRQ; - } - /* End HIRQ interrupts handling, clear serviced IRQs */ - regWr(rHIRQ, HIRQ_sendback); - return ( HIRQ_sendback); -} -//template< typename SPI_SS, typename INTR > -//uint8_t MAX3421e< SPI_SS, INTR >::GpxHandler() -//{ -// uint8_t GPINIRQ = regRd( rGPINIRQ ); //read GPIN IRQ register -//// if( GPINIRQ & bmGPINIRQ7 ) { //vbus overload -//// vbusPwr( OFF ); //attempt powercycle -//// delay( 1000 ); -//// vbusPwr( ON ); -//// regWr( rGPINIRQ, bmGPINIRQ7 ); -//// } -// return( GPINIRQ ); -//} - -#endif // _USBHOST_H_ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/usbhub.cpp b/protocol/usb_hid/USB_Host_Shield_2.0/usbhub.cpp deleted file mode 100644 index 7fed48e7..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/usbhub.cpp +++ /dev/null @@ -1,425 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#include "usbhub.h" - -bool USBHub::bResetInitiated = false; - -USBHub::USBHub(USB *p) : -pUsb(p), -bAddress(0), -bNbrPorts(0), -//bInitState(0), -qNextPollTime(0), -bPollEnable(false) { - epInfo[0].epAddr = 0; - epInfo[0].maxPktSize = 8; - epInfo[0].epAttribs = 0; - epInfo[0].bmNakPower = USB_NAK_MAX_POWER; - - epInfo[1].epAddr = 1; - epInfo[1].maxPktSize = 8; //kludge - epInfo[1].epAttribs = 0; - epInfo[1].bmNakPower = USB_NAK_NOWAIT; - - if(pUsb) - pUsb->RegisterDeviceClass(this); -} - -uint8_t USBHub::Init(uint8_t parent, uint8_t port, bool lowspeed) { - uint8_t buf[32]; - USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast(buf); - HubDescriptor* hd = reinterpret_cast(buf); - USB_CONFIGURATION_DESCRIPTOR * ucd = reinterpret_cast(buf); - uint8_t rcode; - UsbDevice *p = NULL; - EpInfo *oldep_ptr = NULL; - uint8_t len = 0; - uint16_t cd_len = 0; - - //USBTRACE("\r\nHub Init Start "); - //D_PrintHex (bInitState, 0x80); - - AddressPool &addrPool = pUsb->GetAddressPool(); - - //switch (bInitState) { - // case 0: - if(bAddress) - return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE; - - // Get pointer to pseudo device with address 0 assigned - p = addrPool.GetUsbDevicePtr(0); - - if(!p) - return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL; - - if(!p->epinfo) - return USB_ERROR_EPINFO_IS_NULL; - - // Save old pointer to EP_RECORD of address 0 - oldep_ptr = p->epinfo; - - // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence - p->epinfo = epInfo; - - p->lowspeed = lowspeed; - - // Get device descriptor - rcode = pUsb->getDevDescr(0, 0, 8, (uint8_t*)buf); - - p->lowspeed = false; - - if(!rcode) - len = (buf[0] > 32) ? 32 : buf[0]; - - if(rcode) { - // Restore p->epinfo - p->epinfo = oldep_ptr; - return rcode; - } - - // Extract device class from device descriptor - // If device class is not a hub return - if(udd->bDeviceClass != 0x09) - return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED; - - // Allocate new address according to device class - bAddress = addrPool.AllocAddress(parent, (udd->bDeviceClass == 0x09) ? true : false, port); - - if(!bAddress) - return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL; - - // Extract Max Packet Size from the device descriptor - epInfo[0].maxPktSize = udd->bMaxPacketSize0; - - // Assign new address to the device - rcode = pUsb->setAddr(0, 0, bAddress); - - if(rcode) { - // Restore p->epinfo - p->epinfo = oldep_ptr; - addrPool.FreeAddress(bAddress); - bAddress = 0; - return rcode; - } - - //USBTRACE2("\r\nHub address: ", bAddress ); - - // Restore p->epinfo - p->epinfo = oldep_ptr; - - if(len) - rcode = pUsb->getDevDescr(bAddress, 0, len, (uint8_t*)buf); - - if(rcode) - goto FailGetDevDescr; - - // Assign epInfo to epinfo pointer - rcode = pUsb->setEpInfoEntry(bAddress, 2, epInfo); - - if(rcode) - goto FailSetDevTblEntry; - - // bInitState = 1; - - // case 1: - // Get hub descriptor - rcode = GetHubDescriptor(0, 8, buf); - - if(rcode) - goto FailGetHubDescr; - - // Save number of ports for future use - bNbrPorts = hd->bNbrPorts; - - // bInitState = 2; - - // case 2: - // Read configuration Descriptor in Order To Obtain Proper Configuration Value - rcode = pUsb->getConfDescr(bAddress, 0, 8, 0, buf); - - if(!rcode) { - cd_len = ucd->wTotalLength; - rcode = pUsb->getConfDescr(bAddress, 0, cd_len, 0, buf); - } - if(rcode) - goto FailGetConfDescr; - - // The following code is of no practical use in real life applications. - // It only intended for the usb protocol sniffer to properly parse hub-class requests. - { - uint8_t buf2[24]; - - rcode = pUsb->getConfDescr(bAddress, 0, buf[0], 0, buf2); - - if(rcode) - goto FailGetConfDescr; - } - - // Set Configuration Value - rcode = pUsb->setConf(bAddress, 0, buf[5]); - - if(rcode) - goto FailSetConfDescr; - - // bInitState = 3; - - // case 3: - // Power on all ports - for(uint8_t j = 1; j <= bNbrPorts; j++) - SetPortFeature(HUB_FEATURE_PORT_POWER, j, 0); //HubPortPowerOn(j); - - pUsb->SetHubPreMask(); - bPollEnable = true; - // bInitState = 0; - //} - //bInitState = 0; - //USBTRACE("...OK\r\n"); - return 0; - - // Oleg, No debugging?? -- xxxajk -FailGetDevDescr: - goto Fail; - -FailSetDevTblEntry: - goto Fail; - -FailGetHubDescr: - goto Fail; - -FailGetConfDescr: - goto Fail; - -FailSetConfDescr: - goto Fail; - -Fail: - USBTRACE("...FAIL\r\n"); - return rcode; -} - -uint8_t USBHub::Release() { - pUsb->GetAddressPool().FreeAddress(bAddress); - - if(bAddress == 0x41) - pUsb->SetHubPreMask(); - - bAddress = 0; - bNbrPorts = 0; - qNextPollTime = 0; - bPollEnable = false; - return 0; -} - -uint8_t USBHub::Poll() { - uint8_t rcode = 0; - - if(!bPollEnable) - return 0; - - if(((long)(millis() - qNextPollTime) >= 0L)) { - rcode = CheckHubStatus(); - qNextPollTime = millis() + 100; - } - return rcode; -} - -uint8_t USBHub::CheckHubStatus() { - uint8_t rcode; - uint8_t buf[8]; - uint16_t read = 1; - - rcode = pUsb->inTransfer(bAddress, 1, &read, buf); - - if(rcode) - return rcode; - - //if (buf[0] & 0x01) // Hub Status Change - //{ - // pUsb->PrintHubStatus(addr); - // rcode = GetHubStatus(1, 0, 1, 4, buf); - // if (rcode) - // { - // USB_HOST_SERIAL.print("GetHubStatus Error"); - // USB_HOST_SERIAL.println(rcode, HEX); - // return rcode; - // } - //} - for(uint8_t port = 1, mask = 0x02; port < 8; mask <<= 1, port++) { - if(buf[0] & mask) { - HubEvent evt; - evt.bmEvent = 0; - - rcode = GetPortStatus(port, 4, evt.evtBuff); - - if(rcode) - continue; - - rcode = PortStatusChange(port, evt); - - if(rcode == HUB_ERROR_PORT_HAS_BEEN_RESET) - return 0; - - if(rcode) - return rcode; - } - } // for - - for(uint8_t port = 1; port <= bNbrPorts; port++) { - HubEvent evt; - evt.bmEvent = 0; - - rcode = GetPortStatus(port, 4, evt.evtBuff); - - if(rcode) - continue; - - if((evt.bmStatus & bmHUB_PORT_STATE_CHECK_DISABLED) != bmHUB_PORT_STATE_DISABLED) - continue; - - // Emulate connection event for the port - evt.bmChange |= bmHUB_PORT_STATUS_C_PORT_CONNECTION; - - rcode = PortStatusChange(port, evt); - - if(rcode == HUB_ERROR_PORT_HAS_BEEN_RESET) - return 0; - - if(rcode) - return rcode; - } // for - return 0; -} - -void USBHub::ResetHubPort(uint8_t port) { - HubEvent evt; - evt.bmEvent = 0; - uint8_t rcode; - - ClearPortFeature(HUB_FEATURE_C_PORT_ENABLE, port, 0); - ClearPortFeature(HUB_FEATURE_C_PORT_CONNECTION, port, 0); - SetPortFeature(HUB_FEATURE_PORT_RESET, port, 0); - - - for(int i = 0; i < 3; i++) { - rcode = GetPortStatus(port, 4, evt.evtBuff); - if(rcode) break; // Some kind of error, bail. - if(evt.bmEvent == bmHUB_PORT_EVENT_RESET_COMPLETE || evt.bmEvent == bmHUB_PORT_EVENT_LS_RESET_COMPLETE) { - break; - } - delay(100); // simulate polling. - } - ClearPortFeature(HUB_FEATURE_C_PORT_RESET, port, 0); - ClearPortFeature(HUB_FEATURE_C_PORT_CONNECTION, port, 0); - delay(20); -} - -uint8_t USBHub::PortStatusChange(uint8_t port, HubEvent &evt) { - switch(evt.bmEvent) { - // Device connected event - case bmHUB_PORT_EVENT_CONNECT: - case bmHUB_PORT_EVENT_LS_CONNECT: - if(bResetInitiated) - return 0; - - ClearPortFeature(HUB_FEATURE_C_PORT_ENABLE, port, 0); - ClearPortFeature(HUB_FEATURE_C_PORT_CONNECTION, port, 0); - SetPortFeature(HUB_FEATURE_PORT_RESET, port, 0); - bResetInitiated = true; - return HUB_ERROR_PORT_HAS_BEEN_RESET; - - // Device disconnected event - case bmHUB_PORT_EVENT_DISCONNECT: - ClearPortFeature(HUB_FEATURE_C_PORT_ENABLE, port, 0); - ClearPortFeature(HUB_FEATURE_C_PORT_CONNECTION, port, 0); - bResetInitiated = false; - - UsbDeviceAddress a; - a.devAddress = 0; - a.bmHub = 0; - a.bmParent = bAddress; - a.bmAddress = port; - pUsb->ReleaseDevice(a.devAddress); - return 0; - - // Reset complete event - case bmHUB_PORT_EVENT_RESET_COMPLETE: - case bmHUB_PORT_EVENT_LS_RESET_COMPLETE: - ClearPortFeature(HUB_FEATURE_C_PORT_RESET, port, 0); - ClearPortFeature(HUB_FEATURE_C_PORT_CONNECTION, port, 0); - - delay(20); - - a.devAddress = bAddress; - - pUsb->Configuring(a.bmAddress, port, (evt.bmStatus & bmHUB_PORT_STATUS_PORT_LOW_SPEED)); - bResetInitiated = false; - break; - - } // switch (evt.bmEvent) - return 0; -} - -void PrintHubPortStatus(USBHub *hubptr, uint8_t addr, uint8_t port, bool print_changes) { - uint8_t rcode = 0; - HubEvent evt; - - rcode = hubptr->GetPortStatus(port, 4, evt.evtBuff); - - if(rcode) { - USB_HOST_SERIAL.println("ERROR!"); - return; - } - USB_HOST_SERIAL.print("\r\nPort "); - USB_HOST_SERIAL.println(port, DEC); - - USB_HOST_SERIAL.println("Status"); - USB_HOST_SERIAL.print("CONNECTION:\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_CONNECTION) > 0, DEC); - USB_HOST_SERIAL.print("ENABLE:\t\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_ENABLE) > 0, DEC); - USB_HOST_SERIAL.print("SUSPEND:\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_SUSPEND) > 0, DEC); - USB_HOST_SERIAL.print("OVER_CURRENT:\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_OVER_CURRENT) > 0, DEC); - USB_HOST_SERIAL.print("RESET:\t\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_RESET) > 0, DEC); - USB_HOST_SERIAL.print("POWER:\t\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_POWER) > 0, DEC); - USB_HOST_SERIAL.print("LOW_SPEED:\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_LOW_SPEED) > 0, DEC); - USB_HOST_SERIAL.print("HIGH_SPEED:\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_HIGH_SPEED) > 0, DEC); - USB_HOST_SERIAL.print("TEST:\t\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_TEST) > 0, DEC); - USB_HOST_SERIAL.print("INDICATOR:\t"); - USB_HOST_SERIAL.println((evt.bmStatus & bmHUB_PORT_STATUS_PORT_INDICATOR) > 0, DEC); - - if(!print_changes) - return; - - USB_HOST_SERIAL.println("\r\nChange"); - USB_HOST_SERIAL.print("CONNECTION:\t"); - USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_CONNECTION) > 0, DEC); - USB_HOST_SERIAL.print("ENABLE:\t\t"); - USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_ENABLE) > 0, DEC); - USB_HOST_SERIAL.print("SUSPEND:\t"); - USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_SUSPEND) > 0, DEC); - USB_HOST_SERIAL.print("OVER_CURRENT:\t"); - USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_OVER_CURRENT) > 0, DEC); - USB_HOST_SERIAL.print("RESET:\t\t"); - USB_HOST_SERIAL.println((evt.bmChange & bmHUB_PORT_STATUS_C_PORT_RESET) > 0, DEC); -} diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/usbhub.h b/protocol/usb_hid/USB_Host_Shield_2.0/usbhub.h deleted file mode 100644 index 1ac94944..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/usbhub.h +++ /dev/null @@ -1,252 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ -#if !defined(__USBHUB_H__) -#define __USBHUB_H__ - -#include "Usb.h" - -#define USB_DESCRIPTOR_HUB 0x09 // Hub descriptor type - -// Hub Requests -#define bmREQ_CLEAR_HUB_FEATURE USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE -#define bmREQ_CLEAR_PORT_FEATURE USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_OTHER -#define bmREQ_CLEAR_TT_BUFFER USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_OTHER -#define bmREQ_GET_HUB_DESCRIPTOR USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE -#define bmREQ_GET_HUB_STATUS USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE -#define bmREQ_GET_PORT_STATUS USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_OTHER -#define bmREQ_RESET_TT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_OTHER -#define bmREQ_SET_HUB_DESCRIPTOR USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE -#define bmREQ_SET_HUB_FEATURE USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE -#define bmREQ_SET_PORT_FEATURE USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_OTHER -#define bmREQ_GET_TT_STATE USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_OTHER -#define bmREQ_STOP_TT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_OTHER - -// Hub Class Requests -#define HUB_REQUEST_CLEAR_TT_BUFFER 8 -#define HUB_REQUEST_RESET_TT 9 -#define HUB_REQUEST_GET_TT_STATE 10 -#define HUB_REQUEST_STOP_TT 11 - -// Hub Features -#define HUB_FEATURE_C_HUB_LOCAL_POWER 0 -#define HUB_FEATURE_C_HUB_OVER_CURRENT 1 -#define HUB_FEATURE_PORT_CONNECTION 0 -#define HUB_FEATURE_PORT_ENABLE 1 -#define HUB_FEATURE_PORT_SUSPEND 2 -#define HUB_FEATURE_PORT_OVER_CURRENT 3 -#define HUB_FEATURE_PORT_RESET 4 -#define HUB_FEATURE_PORT_POWER 8 -#define HUB_FEATURE_PORT_LOW_SPEED 9 -#define HUB_FEATURE_C_PORT_CONNECTION 16 -#define HUB_FEATURE_C_PORT_ENABLE 17 -#define HUB_FEATURE_C_PORT_SUSPEND 18 -#define HUB_FEATURE_C_PORT_OVER_CURRENT 19 -#define HUB_FEATURE_C_PORT_RESET 20 -#define HUB_FEATURE_PORT_TEST 21 -#define HUB_FEATURE_PORT_INDICATOR 22 - -// Hub Port Test Modes -#define HUB_PORT_TEST_MODE_J 1 -#define HUB_PORT_TEST_MODE_K 2 -#define HUB_PORT_TEST_MODE_SE0_NAK 3 -#define HUB_PORT_TEST_MODE_PACKET 4 -#define HUB_PORT_TEST_MODE_FORCE_ENABLE 5 - -// Hub Port Indicator Color -#define HUB_PORT_INDICATOR_AUTO 0 -#define HUB_PORT_INDICATOR_AMBER 1 -#define HUB_PORT_INDICATOR_GREEN 2 -#define HUB_PORT_INDICATOR_OFF 3 - -// Hub Port Status Bitmasks -#define bmHUB_PORT_STATUS_PORT_CONNECTION 0x0001 -#define bmHUB_PORT_STATUS_PORT_ENABLE 0x0002 -#define bmHUB_PORT_STATUS_PORT_SUSPEND 0x0004 -#define bmHUB_PORT_STATUS_PORT_OVER_CURRENT 0x0008 -#define bmHUB_PORT_STATUS_PORT_RESET 0x0010 -#define bmHUB_PORT_STATUS_PORT_POWER 0x0100 -#define bmHUB_PORT_STATUS_PORT_LOW_SPEED 0x0200 -#define bmHUB_PORT_STATUS_PORT_HIGH_SPEED 0x0400 -#define bmHUB_PORT_STATUS_PORT_TEST 0x0800 -#define bmHUB_PORT_STATUS_PORT_INDICATOR 0x1000 - -// Hub Port Status Change Bitmasks (used one byte instead of two) -#define bmHUB_PORT_STATUS_C_PORT_CONNECTION 0x0001 -#define bmHUB_PORT_STATUS_C_PORT_ENABLE 0x0002 -#define bmHUB_PORT_STATUS_C_PORT_SUSPEND 0x0004 -#define bmHUB_PORT_STATUS_C_PORT_OVER_CURRENT 0x0008 -#define bmHUB_PORT_STATUS_C_PORT_RESET 0x0010 - -// Hub Status Bitmasks (used one byte instead of two) -#define bmHUB_STATUS_LOCAL_POWER_SOURCE 0x01 -#define bmHUB_STATUS_OVER_CURRENT 0x12 - -// Hub Status Change Bitmasks (used one byte instead of two) -#define bmHUB_STATUS_C_LOCAL_POWER_SOURCE 0x01 -#define bmHUB_STATUS_C_OVER_CURRENT 0x12 - - -// Hub Port Configuring Substates -#define USB_STATE_HUB_PORT_CONFIGURING 0xb0 -#define USB_STATE_HUB_PORT_POWERED_OFF 0xb1 -#define USB_STATE_HUB_PORT_WAIT_FOR_POWER_GOOD 0xb2 -#define USB_STATE_HUB_PORT_DISCONNECTED 0xb3 -#define USB_STATE_HUB_PORT_DISABLED 0xb4 -#define USB_STATE_HUB_PORT_RESETTING 0xb5 -#define USB_STATE_HUB_PORT_ENABLED 0xb6 - -// Additional Error Codes -#define HUB_ERROR_PORT_HAS_BEEN_RESET 0xb1 - -// The bit mask to check for all necessary state bits -#define bmHUB_PORT_STATUS_ALL_MAIN ((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION | bmHUB_PORT_STATUS_C_PORT_ENABLE | bmHUB_PORT_STATUS_C_PORT_SUSPEND | bmHUB_PORT_STATUS_C_PORT_RESET) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_SUSPEND) - -// Bit mask to check for DISABLED state in HubEvent::bmStatus field -#define bmHUB_PORT_STATE_CHECK_DISABLED (0x0000 | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_SUSPEND) - -// Hub Port States -#define bmHUB_PORT_STATE_DISABLED (0x0000 | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_CONNECTION) - -// Hub Port Events -#define bmHUB_PORT_EVENT_CONNECT (((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_CONNECTION) -#define bmHUB_PORT_EVENT_DISCONNECT (((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION) << 16) | bmHUB_PORT_STATUS_PORT_POWER) -#define bmHUB_PORT_EVENT_RESET_COMPLETE (((0UL | bmHUB_PORT_STATUS_C_PORT_RESET) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION) - -#define bmHUB_PORT_EVENT_LS_CONNECT (((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_LOW_SPEED) -#define bmHUB_PORT_EVENT_LS_RESET_COMPLETE (((0UL | bmHUB_PORT_STATUS_C_PORT_RESET) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_LOW_SPEED) -#define bmHUB_PORT_EVENT_LS_PORT_ENABLED (((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION | bmHUB_PORT_STATUS_C_PORT_ENABLE) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_LOW_SPEED) - -struct HubDescriptor { - uint8_t bDescLength; // descriptor length - uint8_t bDescriptorType; // descriptor type - uint8_t bNbrPorts; // number of ports a hub equiped with - - struct { - uint16_t LogPwrSwitchMode : 2; - uint16_t CompoundDevice : 1; - uint16_t OverCurrentProtectMode : 2; - uint16_t TTThinkTime : 2; - uint16_t PortIndicatorsSupported : 1; - uint16_t Reserved : 8; - } __attribute__((packed)); - - uint8_t bPwrOn2PwrGood; - uint8_t bHubContrCurrent; -} __attribute__((packed)); - -struct HubEvent { - - union { - - struct { - uint16_t bmStatus; // port status bits - uint16_t bmChange; // port status change bits - } __attribute__((packed)); - uint32_t bmEvent; - uint8_t evtBuff[4]; - }; -} __attribute__((packed)); - -class USBHub : USBDeviceConfig { - static bool bResetInitiated; // True when reset is triggered - - USB *pUsb; // USB class instance pointer - - EpInfo epInfo[2]; // interrupt endpoint info structure - - uint8_t bAddress; // address - uint8_t bNbrPorts; // number of ports - // uint8_t bInitState; // initialization state variable - uint32_t qNextPollTime; // next poll time - bool bPollEnable; // poll enable flag - - uint8_t CheckHubStatus(); - uint8_t PortStatusChange(uint8_t port, HubEvent &evt); - -public: - USBHub(USB *p); - - uint8_t ClearHubFeature(uint8_t fid); - uint8_t ClearPortFeature(uint8_t fid, uint8_t port, uint8_t sel = 0); - uint8_t GetHubDescriptor(uint8_t index, uint16_t nbytes, uint8_t *dataptr); - uint8_t GetHubStatus(uint16_t nbytes, uint8_t* dataptr); - uint8_t GetPortStatus(uint8_t port, uint16_t nbytes, uint8_t* dataptr); - uint8_t SetHubDescriptor(uint8_t port, uint16_t nbytes, uint8_t* dataptr); - uint8_t SetHubFeature(uint8_t fid); - uint8_t SetPortFeature(uint8_t fid, uint8_t port, uint8_t sel = 0); - - void PrintHubStatus(); - - uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); - uint8_t Release(); - uint8_t Poll(); - void ResetHubPort(uint8_t port); - - virtual uint8_t GetAddress() { - return bAddress; - }; - - virtual bool DEVCLASSOK(uint8_t klass) { - return (klass == 0x09); - } - -}; - -// Clear Hub Feature - -inline uint8_t USBHub::ClearHubFeature(uint8_t fid) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_CLEAR_HUB_FEATURE, USB_REQUEST_CLEAR_FEATURE, fid, 0, 0, 0, 0, NULL, NULL)); -} -// Clear Port Feature - -inline uint8_t USBHub::ClearPortFeature(uint8_t fid, uint8_t port, uint8_t sel) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_CLEAR_PORT_FEATURE, USB_REQUEST_CLEAR_FEATURE, fid, 0, ((0x0000 | port) | (sel << 8)), 0, 0, NULL, NULL)); -} -// Get Hub Descriptor - -inline uint8_t USBHub::GetHubDescriptor(uint8_t index, uint16_t nbytes, uint8_t *dataptr) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_GET_HUB_DESCRIPTOR, USB_REQUEST_GET_DESCRIPTOR, index, 0x29, 0, nbytes, nbytes, dataptr, NULL)); -} -// Get Hub Status - -inline uint8_t USBHub::GetHubStatus(uint16_t nbytes, uint8_t* dataptr) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_GET_HUB_STATUS, USB_REQUEST_GET_STATUS, 0, 0, 0x0000, nbytes, nbytes, dataptr, NULL)); -} -// Get Port Status - -inline uint8_t USBHub::GetPortStatus(uint8_t port, uint16_t nbytes, uint8_t* dataptr) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_GET_PORT_STATUS, USB_REQUEST_GET_STATUS, 0, 0, port, nbytes, nbytes, dataptr, NULL)); -} -// Set Hub Descriptor - -inline uint8_t USBHub::SetHubDescriptor(uint8_t port, uint16_t nbytes, uint8_t* dataptr) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_SET_HUB_DESCRIPTOR, USB_REQUEST_SET_DESCRIPTOR, 0, 0, port, nbytes, nbytes, dataptr, NULL)); -} -// Set Hub Feature - -inline uint8_t USBHub::SetHubFeature(uint8_t fid) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_SET_HUB_FEATURE, USB_REQUEST_SET_FEATURE, fid, 0, 0, 0, 0, NULL, NULL)); -} -// Set Port Feature - -inline uint8_t USBHub::SetPortFeature(uint8_t fid, uint8_t port, uint8_t sel) { - return ( pUsb->ctrlReq(bAddress, 0, bmREQ_SET_PORT_FEATURE, USB_REQUEST_SET_FEATURE, fid, 0, (((0x0000 | sel) << 8) | port), 0, 0, NULL, NULL)); -} - -void PrintHubPortStatus(USB *usbptr, uint8_t addr, uint8_t port, bool print_changes = false); - -#endif // __USBHUB_H__ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/version_helper.h b/protocol/usb_hid/USB_Host_Shield_2.0/version_helper.h deleted file mode 100644 index 0cb3b4ad..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/version_helper.h +++ /dev/null @@ -1,194 +0,0 @@ -/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as published by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : http://www.circuitsathome.com -e-mail : support@circuitsathome.com - */ - -/* - * Universal Arduino(tm) "IDE" fixups. - * Includes fixes for versions as low as 0023, used by Digilent. - */ - -#if defined(ARDUINO) && ARDUINO >=100 -#include -#else -#include -#include -#ifdef __AVR__ -#include -#include -#else -#endif -#endif - -#ifndef __PGMSPACE_H_ -#define __PGMSPACE_H_ 1 - -#include - -#ifndef PROGMEM -#define PROGMEM -#endif -#ifndef PGM_P -#define PGM_P const char * -#endif -#ifndef PSTR -#define PSTR(str) (str) -#endif -#ifndef F -#define F(str) (str) -#endif -#ifndef _SFR_BYTE -#define _SFR_BYTE(n) (n) -#endif - -#ifndef memchr_P -#define memchr_P(str, c, len) memchr((str), (c), (len)) -#endif -#ifndef memcmp_P -#define memcmp_P(a, b, n) memcmp((a), (b), (n)) -#endif -#ifndef memcpy_P -#define memcpy_P(dest, src, num) memcpy((dest), (src), (num)) -#endif -#ifndef memmem_P -#define memmem_P(a, alen, b, blen) memmem((a), (alen), (b), (blen)) -#endif -#ifndef memrchr_P -#define memrchr_P(str, val, len) memrchr((str), (val), (len)) -#endif -#ifndef strcat_P -#define strcat_P(dest, src) strcat((dest), (src)) -#endif -#ifndef strchr_P -#define strchr_P(str, c) strchr((str), (c)) -#endif -#ifndef strchrnul_P -#define strchrnul_P(str, c) strchrnul((str), (c)) -#endif -#ifndef strcmp_P -#define strcmp_P(a, b) strcmp((a), (b)) -#endif -#ifndef strcpy_P -#define strcpy_P(dest, src) strcpy((dest), (src)) -#endif -#ifndef strcasecmp_P -#define strcasecmp_P(a, b) strcasecmp((a), (b)) -#endif -#ifndef strcasestr_P -#define strcasestr_P(a, b) strcasestr((a), (b)) -#endif -#ifndef strlcat_P -#define strlcat_P(dest, src, len) strlcat((dest), (src), (len)) -#endif -#ifndef strlcpy_P -#define strlcpy_P(dest, src, len) strlcpy((dest), (src), (len)) -#endif -#ifndef strlen_P -#define strlen_P(s) strlen((const char *)(s)) -#endif -#ifndef strnlen_P -#define strnlen_P(str, len) strnlen((str), (len)) -#endif -#ifndef strncmp_P -#define strncmp_P(a, b, n) strncmp((a), (b), (n)) -#endif -#ifndef strncasecmp_P -#define strncasecmp_P(a, b, n) strncasecmp((a), (b), (n)) -#endif -#ifndef strncat_P -#define strncat_P(a, b, n) strncat((a), (b), (n)) -#endif -#ifndef strncpy_P -#define strncpy_P(a, b, n) strncmp((a), (b), (n)) -#endif -#ifndef strpbrk_P -#define strpbrk_P(str, chrs) strpbrk((str), (chrs)) -#endif -#ifndef strrchr_P -#define strrchr_P(str, c) strrchr((str), (c)) -#endif -#ifndef strsep_P -#define strsep_P(strp, delim) strsep((strp), (delim)) -#endif -#ifndef strspn_P -#define strspn_P(str, chrs) strspn((str), (chrs)) -#endif -#ifndef strstr_P -#define strstr_P(a, b) strstr((a), (b)) -#endif -#ifndef sprintf_P -#define sprintf_P(s, ...) sprintf((s), __VA_ARGS__) -#endif -#ifndef vfprintf_P -#define vfprintf_P(s, ...) vfprintf((s), __VA_ARGS__) -#endif -#ifndef printf_P -#define printf_P(...) printf(__VA_ARGS__) -#endif -#ifndef snprintf_P -#define snprintf_P(s, n, ...) ((s), (n), __VA_ARGS__) -#endif -#ifndef vsprintf_P -#define vsprintf_P(s, ...) ((s),__VA_ARGS__) -#endif -#ifndef vsnprintf_P -#define vsnprintf_P(s, n, ...) ((s), (n),__VA_ARGS__) -#endif -#ifndef fprintf_P -#define fprintf_P(s, ...) ((s), __VA_ARGS__) -#endif - -#ifndef pgm_read_byte -#define pgm_read_byte(addr) (*(const unsigned char *)(addr)) -#endif -#ifndef pgm_read_word -#define pgm_read_word(addr) (*(const unsigned short *)(addr)) -#endif -#ifndef pgm_read_dword -#define pgm_read_dword(addr) (*(const unsigned long *)(addr)) -#endif -#ifndef pgm_read_float -#define pgm_read_float(addr) (*(const float *)(addr)) -#endif - -#ifndef pgm_read_byte_near -#define pgm_read_byte_near(addr) pgm_read_byte(addr) -#endif -#ifndef pgm_read_word_near -#define pgm_read_word_near(addr) pgm_read_word(addr) -#endif -#ifndef pgm_read_dword_near -#define pgm_read_dword_near(addr) pgm_read_dword(addr) -#endif -#ifndef pgm_read_float_near -#define pgm_read_float_near(addr) pgm_read_float(addr) -#endif -#ifndef pgm_read_byte_far -#define pgm_read_byte_far(addr) pgm_read_byte(addr) -#endif -#ifndef pgm_read_word_far -#define pgm_read_word_far(addr) pgm_read_word(addr) -#endif -#ifndef pgm_read_dword_far -#define pgm_read_dword_far(addr) pgm_read_dword(addr) -#endif -#ifndef pgm_read_float_far -#define pgm_read_float_far(addr) pgm_read_float(addr) -#endif - -#ifndef pgm_read_pointer -#define pgm_read_pointer -#endif -#endif diff --git a/protocol/usb_hid/USB_Host_Shield_2.0/xboxEnums.h b/protocol/usb_hid/USB_Host_Shield_2.0/xboxEnums.h deleted file mode 100644 index 84b137bb..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0/xboxEnums.h +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. - - This software may be distributed and modified under the terms of the GNU - General Public License version 2 (GPL2) as published by the Free Software - Foundation and appearing in the file GPL2.TXT included in the packaging of - this file. Please note that GPL2 Section 2[b] requires that all works based - on this software must also be made publicly available under the terms of - the GPL2 ("Copyleft"). - - Contact information - ------------------- - - Kristian Lauszus, TKJ Electronics - Web : http://www.tkjelectronics.com - e-mail : kristianl@tkjelectronics.com - */ - -#ifndef _xboxenums_h -#define _xboxenums_h - -#include "controllerEnums.h" - -/** Enum used to set special LED modes supported by the Xbox controller. */ -enum LEDModeEnum { - ROTATING = 0x0A, - FASTBLINK = 0x0B, - SLOWBLINK = 0x0C, - ALTERNATING = 0x0D, -}; - -/** Used to set the LEDs on the controllers */ -const uint8_t XBOX_LEDS[] PROGMEM = { - 0x00, // OFF - 0x02, // LED1 - 0x03, // LED2 - 0x04, // LED3 - 0x05, // LED4 - 0x01, // ALL - Used to blink all LEDs -}; -/** Buttons on the controllers */ -const uint16_t XBOX_BUTTONS[] PROGMEM = { - 0x0100, // UP - 0x0800, // RIGHT - 0x0200, // DOWN - 0x0400, // LEFT - - 0x2000, // BACK - 0x1000, // START - 0x4000, // L3 - 0x8000, // R3 - - 0, 0, // Skip L2 and R2 as these are analog buttons - 0x0001, // L1 - 0x0002, // R1 - - 0x0020, // B - 0x0010, // A - 0x0040, // X - 0x0080, // Y - - 0x0004, // XBOX - 0x0008, // SYNC -}; - -#endif From 84d28c6a211a737ca5d22f4563e96be54540385e Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 30 Oct 2018 17:58:09 +0900 Subject: [PATCH 124/217] usb_hid: Add USB_Host_Shield_2.0 submodule --- protocol/usb_hid/USB_Host_Shield_2.0-git | 1 + 1 file changed, 1 insertion(+) create mode 160000 protocol/usb_hid/USB_Host_Shield_2.0-git diff --git a/protocol/usb_hid/USB_Host_Shield_2.0-git b/protocol/usb_hid/USB_Host_Shield_2.0-git new file mode 160000 index 00000000..ed08df7e --- /dev/null +++ b/protocol/usb_hid/USB_Host_Shield_2.0-git @@ -0,0 +1 @@ +Subproject commit ed08df7e68af06a5612d938b1bbf55cc4458518a From beb27f921483601e46628ad512da8380647e4de8 Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 30 Oct 2018 15:50:51 +0900 Subject: [PATCH 125/217] usb_usb: usb_hid: Change for USB_Host_Shield_2.0 --- protocol/usb_hid.mk | 4 ++-- protocol/usb_hid/parser.cpp | 2 +- protocol/usb_hid/parser.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/protocol/usb_hid.mk b/protocol/usb_hid.mk index 1f79bda3..495c4bee 100644 --- a/protocol/usb_hid.mk +++ b/protocol/usb_hid.mk @@ -4,10 +4,10 @@ USB_HID_DIR = protocol/usb_hid # # USB Host Shield # -USB_HOST_SHIELD_DIR = $(USB_HID_DIR)/USB_Host_Shield_2.0 +USB_HOST_SHIELD_DIR = $(USB_HID_DIR)/USB_Host_Shield_2.0-git USB_HOST_SHIELD_SRC = \ $(USB_HOST_SHIELD_DIR)/Usb.cpp \ - $(USB_HOST_SHIELD_DIR)/hid.cpp \ + $(USB_HOST_SHIELD_DIR)/usbhid.cpp \ $(USB_HOST_SHIELD_DIR)/usbhub.cpp \ $(USB_HOST_SHIELD_DIR)/parsetools.cpp \ $(USB_HOST_SHIELD_DIR)/message.cpp diff --git a/protocol/usb_hid/parser.cpp b/protocol/usb_hid/parser.cpp index 730a20d7..81a5bfa6 100644 --- a/protocol/usb_hid/parser.cpp +++ b/protocol/usb_hid/parser.cpp @@ -4,7 +4,7 @@ #include "debug.h" -void KBDReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) +void KBDReportParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) { dprintf("input %d:", hid->GetAddress()); for (uint8_t i = 0; i < len; i++) { diff --git a/protocol/usb_hid/parser.h b/protocol/usb_hid/parser.h index 036281fa..24cad551 100644 --- a/protocol/usb_hid/parser.h +++ b/protocol/usb_hid/parser.h @@ -1,7 +1,7 @@ #ifndef PARSER_H #define PARSER_H -#include "hid.h" +#include "usbhid.h" #include "report.h" class KBDReportParser : public HIDReportParser @@ -9,7 +9,7 @@ class KBDReportParser : public HIDReportParser public: report_keyboard_t report; uint16_t time_stamp; - virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); + virtual void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); }; #endif From 98c7d39685dda0cc729032fd4e2c56d44173c3e9 Mon Sep 17 00:00:00 2001 From: rxy0424 Date: Wed, 7 Nov 2018 07:08:08 +0800 Subject: [PATCH 126/217] make some change to complie stm32_f103_onekey with new version of Chibios (#583) --- common/chibios/timer.c | 8 ++++---- protocol/chibios/usb_main.c | 14 +++++++------- tool/chibios/chibios.mk | 5 +++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/common/chibios/timer.c b/common/chibios/timer.c index 3de4cc36..0208a593 100644 --- a/common/chibios/timer.c +++ b/common/chibios/timer.c @@ -8,20 +8,20 @@ void timer_clear(void) {} uint16_t timer_read(void) { - return (uint16_t)ST2MS(chVTGetSystemTime()); + return (uint16_t)TIME_I2MS(chVTGetSystemTime()); } uint32_t timer_read32(void) { - return ST2MS(chVTGetSystemTime()); + return TIME_I2MS(chVTGetSystemTime()); } uint16_t timer_elapsed(uint16_t last) { - return (uint16_t)(ST2MS(chVTTimeElapsedSinceX(MS2ST(last)))); + return (uint16_t)(TIME_I2MS(chVTTimeElapsedSinceX(TIME_MS2I(last)))); } uint32_t timer_elapsed32(uint32_t last) { - return ST2MS(chVTTimeElapsedSinceX(MS2ST(last))); + return TIME_I2MS(chVTTimeElapsedSinceX(TIME_MS2I(last))); } diff --git a/protocol/chibios/usb_main.c b/protocol/chibios/usb_main.c index e8f103a2..60e1dd94 100644 --- a/protocol/chibios/usb_main.c +++ b/protocol/chibios/usb_main.c @@ -963,7 +963,7 @@ static bool usb_request_hook_cb(USBDriver *usbp) { #endif /* NKRO_ENABLE */ /* arm the idle timer if boot protocol & idle */ osalSysLockFromISR(); - chVTSetI(&keyboard_idle_timer, 4*MS2ST(keyboard_idle), keyboard_idle_timer_cb, (void *)usbp); + chVTSetI(&keyboard_idle_timer, 4*TIME_MS2I(keyboard_idle), keyboard_idle_timer_cb, (void *)usbp); osalSysUnlockFromISR(); } } @@ -980,7 +980,7 @@ static bool usb_request_hook_cb(USBDriver *usbp) { if(keyboard_idle) { #endif /* NKRO_ENABLE */ osalSysLockFromISR(); - chVTSetI(&keyboard_idle_timer, 4*MS2ST(keyboard_idle), keyboard_idle_timer_cb, (void *)usbp); + chVTSetI(&keyboard_idle_timer, 4*TIME_MS2I(keyboard_idle), keyboard_idle_timer_cb, (void *)usbp); osalSysUnlockFromISR(); } usbSetupTransfer(usbp, NULL, 0, NULL); @@ -1111,7 +1111,7 @@ static void keyboard_idle_timer_cb(void *arg) { usbStartTransmitI(usbp, KBD_ENDPOINT, (uint8_t *)&keyboard_report_sent, KBD_EPSIZE); } /* rearm the timer */ - chVTSetI(&keyboard_idle_timer, 4*MS2ST(keyboard_idle), keyboard_idle_timer_cb, (void *)usbp); + chVTSetI(&keyboard_idle_timer, 4*TIME_MS2I(keyboard_idle), keyboard_idle_timer_cb, (void *)usbp); } /* do not rearm the timer if the condition above fails @@ -1270,7 +1270,7 @@ void console_in_cb(USBDriver *usbp, usbep_t ep) { osalSysLockFromISR(); /* rearm the timer */ - chVTSetI(&console_flush_timer, MS2ST(CONSOLE_FLUSH_MS), console_flush_cb, (void *)usbp); + chVTSetI(&console_flush_timer, TIME_MS2I(CONSOLE_FLUSH_MS), console_flush_cb, (void *)usbp); /* Freeing the buffer just transmitted, if it was not a zero size packet.*/ if (usbp->epc[CONSOLE_ENDPOINT]->in_state->txsize > 0U) { @@ -1322,7 +1322,7 @@ static void console_flush_cb(void *arg) { /* check that the states of things are as they're supposed to */ if(usbGetDriverStateI(usbp) != USB_ACTIVE) { /* rearm the timer */ - chVTSetI(&console_flush_timer, MS2ST(CONSOLE_FLUSH_MS), console_flush_cb, (void *)usbp); + chVTSetI(&console_flush_timer, TIME_MS2I(CONSOLE_FLUSH_MS), console_flush_cb, (void *)usbp); osalSysUnlockFromISR(); return; } @@ -1331,7 +1331,7 @@ static void console_flush_cb(void *arg) { started.*/ if (usbGetTransmitStatusI(usbp, CONSOLE_ENDPOINT)) { /* rearm the timer */ - chVTSetI(&console_flush_timer, MS2ST(CONSOLE_FLUSH_MS), console_flush_cb, (void *)usbp); + chVTSetI(&console_flush_timer, TIME_MS2I(CONSOLE_FLUSH_MS), console_flush_cb, (void *)usbp); osalSysUnlockFromISR(); return; } @@ -1351,7 +1351,7 @@ static void console_flush_cb(void *arg) { } /* rearm the timer */ - chVTSetI(&console_flush_timer, MS2ST(CONSOLE_FLUSH_MS), console_flush_cb, (void *)usbp); + chVTSetI(&console_flush_timer, TIME_MS2I(CONSOLE_FLUSH_MS), console_flush_cb, (void *)usbp); osalSysUnlockFromISR(); } diff --git a/tool/chibios/chibios.mk b/tool/chibios/chibios.mk index 88ba94ae..5afcb193 100644 --- a/tool/chibios/chibios.mk +++ b/tool/chibios/chibios.mk @@ -142,6 +142,7 @@ CSRC = $(STARTUPSRC) \ $(PLATFORMSRC) \ $(BOARDSRC) \ $(STREAMSSRC) \ + $(LIBSRC) \ $(TMK_DIR)/protocol/chibios/usb_main.c \ $(TMK_DIR)/protocol/chibios/main.c \ $(SRC) @@ -177,7 +178,7 @@ ASMXSRC = $(STARTUPASM) $(PORTASM) $(OSALASM) INCDIR = $(CHIBIOS)/os/license \ $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \ $(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \ - $(STREAMSINC) $(CHIBIOS)/os/various \ + $(STREAMSINC) $(LIBINC) $(CHIBIOS)/os/various \ $(TMK_DIR) $(COMMON_DIR) $(TMK_DIR)/protocol/chibios \ $(TMK_DIR)/protocol $(TARGET_DIR) @@ -256,6 +257,6 @@ endif RULESPATH = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC ifeq ("$(wildcard $(RULESPATH)/rules.mk)","") -RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC +RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk endif include $(RULESPATH)/rules.mk From 753f7b0647592f9c3e30a1a58ed450493da8af8d Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 26 Jan 2019 08:42:20 +0900 Subject: [PATCH 127/217] core: System control key descriptor fix #435 https://github.com/qmk/qmk_firmware/pull/963 --- protocol/lufa/descriptor.c | 4 ++-- protocol/lufa/lufa.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/protocol/lufa/descriptor.c b/protocol/lufa/descriptor.c index 4fb5219d..25356343 100644 --- a/protocol/lufa/descriptor.c +++ b/protocol/lufa/descriptor.c @@ -140,8 +140,8 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM ExtrakeyReport[] = HID_RI_USAGE(8, 0x80), /* System Control */ HID_RI_COLLECTION(8, 0x01), /* Application */ HID_RI_REPORT_ID(8, REPORT_ID_SYSTEM), - HID_RI_LOGICAL_MINIMUM(16, 0x0081), - HID_RI_LOGICAL_MAXIMUM(16, 0x00B7), + HID_RI_LOGICAL_MINIMUM(16, 0x0001), + HID_RI_LOGICAL_MAXIMUM(16, 0x0037), HID_RI_USAGE_MINIMUM(16, 0x0081), /* System Power Down */ HID_RI_USAGE_MAXIMUM(16, 0x00B7), /* System Display LCD Autoscale */ HID_RI_REPORT_SIZE(8, 16), diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index 4a42f789..b5d0b50e 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -535,7 +535,7 @@ static void send_system(uint16_t data) report_extra_t r = { .report_id = REPORT_ID_SYSTEM, - .usage = data + .usage = data - SYSTEM_POWER_DOWN + 1 }; Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM); From 5f1e70370e5c2dbb563acca2ccc3f409a374239b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?You=20Xiaojie=20/=20=E5=B0=A4=E6=99=93=E6=9D=B0?= Date: Wed, 13 Mar 2019 07:37:46 +0800 Subject: [PATCH 128/217] Correct two errors of keycode.txt (#594) --- doc/keycode.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/keycode.txt b/doc/keycode.txt index 1712929c..ee4b4f6f 100644 --- a/doc/keycode.txt +++ b/doc/keycode.txt @@ -84,7 +84,7 @@ KC_PAUSE KC_PAUS 48 Keyboard Pause1 KC_INSERT KC_INS 49 Keyboard Insert1 KC_HOME 4A Keyboard Home1 KC_PGUP 4B Keyboard PageUp1 -KC_DELETE KC_DELETE 4C Keyboard Delete Forward +KC_DELETE KC_DEL 4C Keyboard Delete Forward KC_END 4D Keyboard End1 KC_PGDOWN KC_PGDN 4E Keyboard PageDown1 KC_RIGHT KC_RGHT 4F Keyboard RightArrow1 @@ -201,7 +201,7 @@ KC_MEDIA_STOP KC_MSTP Stop KC_MEDIA_FAST_FORWARD KC_MFFD Fast Forward KC_MEDIA_REWIND KC_MRWD Rewind KC_MEDIA_PLAY_PAUSE KC_MPLY Play/Pause -KC_EJCT KC_MEDIA_EJECT Stop/Eject +KC_MEDIA_EJECT KC_EJCT Stop/Eject KC_MEDIA_SELECT KC_MSEL AL Consumer Control Configuration KC_MAIL KC_MAIL AL Email Reader KC_CALCULATOR KC_CALC AL Calculator From 58d4d2aca02b81b2953751760a70b09220b8fbbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?You=20Xiaojie=20/=20=E5=B0=A4=E6=99=93=E6=9D=B0?= Date: Mon, 18 Mar 2019 06:55:40 +0800 Subject: [PATCH 129/217] Correct typo for linux "showkey" command (#603) --- doc/USB_NKRO.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/USB_NKRO.txt b/doc/USB_NKRO.txt index d9f1d122..ddf79c25 100644 --- a/doc/USB_NKRO.txt +++ b/doc/USB_NKRO.txt @@ -155,6 +155,6 @@ AquaKeyTest.exe http://geekhack.org/showthread.php?t=6643 Linux: xkeycaps xev -showkeys +showkey EOF From 6eb2ece3902bfa01d0acc1db6437939883e2217d Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 22 Mar 2019 22:15:26 +0900 Subject: [PATCH 130/217] core: Fix uart.c for ATmega32U4 --- common/{ => avr}/uart.c | 54 ++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 11 deletions(-) rename common/{ => avr}/uart.c (69%) diff --git a/common/uart.c b/common/avr/uart.c similarity index 69% rename from common/uart.c rename to common/avr/uart.c index c17649b0..d9d42390 100644 --- a/common/uart.c +++ b/common/avr/uart.c @@ -1,4 +1,3 @@ -// TODO: Teensy support(ATMega32u4/AT90USB128) // Fixed for Arduino Duemilanove ATmega168p by Jun Wako /* UART Example for Teensy USB Development Board * http://www.pjrc.com/teensy/ @@ -32,6 +31,39 @@ #include "uart.h" +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) +# define UDRn UDR0 +# define UBRRn UBRR0 +# define UCSRnA UCSR0A +# define UCSRnB UCSR0B +# define UCSRnC UCSR0C +# define U2Xn U2X0 +# define RXENn RXEN0 +# define TXENn TXEN0 +# define RXCIEn RXCIE0 +# define UCSZn1 UCSZ01 +# define UCSZn0 UCSZ00 +# define UDRIEn UDRIE0 +# define UDRE_vect USART_UDRE_vect +# define RX_vect USART_RX_vect +#elif defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U2__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) +# define UDRn UDR1 +# define UBRRn UBRR1 +# define UCSRnA UCSR1A +# define UCSRnB UCSR1B +# define UCSRnC UCSR1C +# define U2Xn U2X1 +# define RXENn RXEN1 +# define TXENn TXEN1 +# define RXCIEn RXCIE1 +# define UCSZn1 UCSZ11 +# define UCSZn0 UCSZ10 +# define UDRIEn UDRIE1 +# define UDRE_vect USART1_UDRE_vect +# define RX_vect USART1_RX_vect +#endif + + // These buffers may be any size from 2 to 256 bytes. #define RX_BUFFER_SIZE 64 #define TX_BUFFER_SIZE 40 @@ -47,10 +79,10 @@ static volatile uint8_t rx_buffer_tail; void uart_init(uint32_t baud) { cli(); - UBRR0 = (F_CPU / 4 / baud - 1) / 2; - UCSR0A = (1<= TX_BUFFER_SIZE) i = 0; - UDR0 = tx_buffer[i]; + UDRn = tx_buffer[i]; tx_buffer_tail = i; } } // Receive Interrupt -ISR(USART_RX_vect) +ISR(RX_vect) { uint8_t c, i; - c = UDR0; + c = UDRn; i = rx_buffer_head + 1; if (i >= RX_BUFFER_SIZE) i = 0; if (i != rx_buffer_tail) { From 5144edbcbe110e898bfd9af848e8ee2ba4768f6a Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 26 Mar 2019 16:09:45 +0900 Subject: [PATCH 131/217] lufa: Add debug print support with UART --- common.mk | 8 ++++++-- protocol/lufa.mk | 13 +++++++++++++ protocol/lufa/lufa.c | 29 +++++++++++++++++++---------- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/common.mk b/common.mk index 14951ec8..06507ecf 100644 --- a/common.mk +++ b/common.mk @@ -50,8 +50,12 @@ endif ifeq (yes,$(strip $(CONSOLE_ENABLE))) OPT_DEFS += -DCONSOLE_ENABLE else - OPT_DEFS += -DNO_PRINT - OPT_DEFS += -DNO_DEBUG + # Remove print functions when console is disabled and + # no other print method like UART is available + ifneq (yes, $(strip $(DEBUG_PRINT_AVAILABLE))) + OPT_DEFS += -DNO_PRINT + OPT_DEFS += -DNO_DEBUG + endif endif ifeq (yes,$(strip $(COMMAND_ENABLE))) diff --git a/protocol/lufa.mk b/protocol/lufa.mk index 1b529bde..19fc80d4 100644 --- a/protocol/lufa.mk +++ b/protocol/lufa.mk @@ -49,7 +49,20 @@ OPT_DEFS += $(LUFA_OPTS) # This indicates using LUFA stack OPT_DEFS += -DPROTOCOL_LUFA +ifeq (yes,$(strip $(LUFA_DEBUG))) + LUFA_OPTS += -DLUFA_DEBUG +endif + ifeq (yes,$(strip $(LUFA_DEBUG_SUART))) SRC += common/avr/suart.S LUFA_OPTS += -DLUFA_DEBUG_SUART + # Keep print/debug lines when disabling HID console. See common.mk. + DEBUG_PRINT_AVAILABLE = yes +endif + +ifeq (yes,$(strip $(LUFA_DEBUG_UART))) + SRC += common/avr/uart.c + LUFA_OPTS += -DLUFA_DEBUG_UART + # Keep print/debug lines when disabling HID console. See common.mk. + DEBUG_PRINT_AVAILABLE = yes endif diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index b5d0b50e..ffa5cfbd 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -56,6 +56,10 @@ #include "avr/suart.h" #endif +#ifdef LUFA_DEBUG_UART +#include "uart.h" +#endif + #include "matrix.h" #include "descriptor.h" #include "lufa.h" @@ -218,7 +222,9 @@ static void console_task(void) */ void EVENT_USB_Device_Connect(void) { +#ifdef LUFA_DEBUG print("[C]"); +#endif /* For battery powered device */ if (!USB_IsInitialized) { USB_Disable(); @@ -229,7 +235,9 @@ void EVENT_USB_Device_Connect(void) void EVENT_USB_Device_Disconnect(void) { +#ifdef LUFA_DEBUG print("[D]"); +#endif /* For battery powered device */ USB_IsInitialized = false; /* TODO: This doesn't work. After several plug in/outs can not be enumerated. @@ -575,25 +583,22 @@ static void send_consumer(uint16_t data) /******************************************************************************* * sendchar ******************************************************************************/ -#ifdef CONSOLE_ENABLE int8_t sendchar(uint8_t c) { #ifdef LUFA_DEBUG_SUART xmit(c); #endif - bool r = console_putc(c); - return (r ? 0 : -1); -} -#else -int8_t sendchar(uint8_t c) -{ - #ifdef LUFA_DEBUG_SUART - xmit(c); + #ifdef LUFA_DEBUG_UART + uart_putchar(c); + #endif + + #ifdef CONSOLE_ENABLE + console_putc(c); #endif + return 0; } -#endif /******************************************************************************* @@ -629,6 +634,10 @@ int main(void) SUART_OUT_PORT |= (1< Date: Sun, 31 Mar 2019 14:42:19 +0900 Subject: [PATCH 132/217] lufa: This prevents resume when debug --- protocol/lufa/lufa.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index ffa5cfbd..400011d1 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -669,9 +669,6 @@ int main(void) print("\nKeyboard start.\n"); while (1) { while (USB_DeviceState == DEVICE_STATE_Suspended) { -#ifdef LUFA_DEBUG - print("[s]"); -#endif hook_usb_suspend_loop(); } From 321edf9fca09125d44b7372457c40105129d4787 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 26 Apr 2019 09:17:50 +0900 Subject: [PATCH 133/217] lufa: Fix for UART debug print --- protocol/lufa/lufa.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index 400011d1..eade7d1b 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -713,7 +713,10 @@ void hook_usb_suspend_entry(void) __attribute__((weak)) void hook_usb_suspend_loop(void) { +#ifndef LUFA_DEBUG_UART + // This corrupts debug print when suspend suspend_power_down(); +#endif if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) { USB_Device_SendRemoteWakeup(); } From 617e7fe6a5b26d32a25438ab57a8347fa09313cf Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 2 May 2019 20:57:48 +0900 Subject: [PATCH 134/217] core: Avoid deadlock when uart.c is used in ISR --- common/avr/uart.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/avr/uart.c b/common/avr/uart.c index d9d42390..0fec705f 100644 --- a/common/avr/uart.c +++ b/common/avr/uart.c @@ -66,7 +66,7 @@ // These buffers may be any size from 2 to 256 bytes. #define RX_BUFFER_SIZE 64 -#define TX_BUFFER_SIZE 40 +#define TX_BUFFER_SIZE 256 static volatile uint8_t tx_buffer[TX_BUFFER_SIZE]; static volatile uint8_t tx_buffer_head; @@ -95,6 +95,8 @@ void uart_putchar(uint8_t c) i = tx_buffer_head + 1; if (i >= TX_BUFFER_SIZE) i = 0; + // return immediately to avoid deadlock when interrupt is disabled(called from ISR) + if (tx_buffer_tail == i && (SREG & (1< Date: Mon, 6 May 2019 16:27:46 +0900 Subject: [PATCH 135/217] lufa: Fix Change debug print message --- protocol/lufa/lufa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index eade7d1b..991c2719 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -642,7 +642,7 @@ int main(void) print_set_sendchar(sendchar); host_set_driver(&lufa_driver); - print("Keyboard init.\n"); + print("\n\nKeyboard init.\n"); hook_early_init(); keyboard_setup(); setup_usb(); @@ -663,6 +663,7 @@ int main(void) #endif matrix_scan(); } + print("\nUSB configured.\n"); hook_late_init(); From e646a5cf3936b8610e80f84218b9b76240ac14fe Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 29 Mar 2019 15:45:20 +0900 Subject: [PATCH 136/217] lufa: Fix for freeze at re/boot time problem Calling led_set() in ISR can cause the problem. With converter especially, led_set() can take long time and USB can be stuck in the end. USB-USB converter freezes occasionally when computer power up or reboot. https://geekhack.org/index.php?topic=69169.msg2740179#msg2740179 This is also related to suspend/wakeup issue #386. --- protocol/lufa/lufa.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index 991c2719..48034dbe 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -697,12 +697,12 @@ static uint8_t _led_stats = 0; __attribute__((weak)) void hook_usb_suspend_entry(void) { - // Turn LED off to save power - // Set 0 with putting aside status before suspend and restore - // it after wakeup, then LED is updated at keyboard_task() in main loop + // Turn off LED to save power and keep its status to resotre it later. + // LED status will be updated by keyboard_task() in main loop hopefully. _led_stats = keyboard_led_stats; keyboard_led_stats = 0; - led_set(keyboard_led_stats); + + // Calling long task here can prevent USB state transition matrix_clear(); clear_keyboard(); @@ -731,10 +731,8 @@ void hook_usb_wakeup(void) sleep_led_disable(); #endif - // Restore LED status - // BIOS/grub won't recognize/enumerate if led_set() takes long(around 40ms?) - // Converters fall into the case and miss wakeup event(timeout to reply?) in the end. - //led_set(host_keyboard_leds()); - // Instead, restore stats and update at keyboard_task() in main loop + // Restore LED status and update at keyboard_task() in main loop keyboard_led_stats = _led_stats; + + // Calling long task here can prevent USB state transition } From 2bb39cc91ff724d9c2bdf59052e42663abf8a736 Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 6 May 2019 23:01:18 +0900 Subject: [PATCH 137/217] usb_hid: Change to USB_Host_Shield_2.0 of tmk repo - Fix SOF/Keep Alive start timing - Disable bus detection during settling after attach - Remove keyboard LED blinking at configuring --- protocol/usb_hid.mk | 2 +- protocol/usb_hid/USB_Host_Shield_2.0-git | 1 - protocol/usb_hid/USB_Host_Shield_2.0-tmk | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 160000 protocol/usb_hid/USB_Host_Shield_2.0-git create mode 160000 protocol/usb_hid/USB_Host_Shield_2.0-tmk diff --git a/protocol/usb_hid.mk b/protocol/usb_hid.mk index 495c4bee..bba4292f 100644 --- a/protocol/usb_hid.mk +++ b/protocol/usb_hid.mk @@ -4,7 +4,7 @@ USB_HID_DIR = protocol/usb_hid # # USB Host Shield # -USB_HOST_SHIELD_DIR = $(USB_HID_DIR)/USB_Host_Shield_2.0-git +USB_HOST_SHIELD_DIR = $(USB_HID_DIR)/USB_Host_Shield_2.0-tmk USB_HOST_SHIELD_SRC = \ $(USB_HOST_SHIELD_DIR)/Usb.cpp \ $(USB_HOST_SHIELD_DIR)/usbhid.cpp \ diff --git a/protocol/usb_hid/USB_Host_Shield_2.0-git b/protocol/usb_hid/USB_Host_Shield_2.0-git deleted file mode 160000 index ed08df7e..00000000 --- a/protocol/usb_hid/USB_Host_Shield_2.0-git +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ed08df7e68af06a5612d938b1bbf55cc4458518a diff --git a/protocol/usb_hid/USB_Host_Shield_2.0-tmk b/protocol/usb_hid/USB_Host_Shield_2.0-tmk new file mode 160000 index 00000000..48b2a095 --- /dev/null +++ b/protocol/usb_hid/USB_Host_Shield_2.0-tmk @@ -0,0 +1 @@ +Subproject commit 48b2a0950496c7b8ba1bb6ddb937b6f00a6de781 From 6f46be08ab6cb75393b8c8fbc3e3b9a7d5cb7569 Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 6 May 2019 01:52:25 +0900 Subject: [PATCH 138/217] lufa:usb_usb: matrix_scan() is no longer needed This is due to SOF timing fix of USB_Host_Shield_2.0. The matrix_scan() was needed for usb_usb converter to recognize FC660C at startup. --- protocol/lufa/lufa.c | 1 - 1 file changed, 1 deletion(-) diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index 48034dbe..aecaa050 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -661,7 +661,6 @@ int main(void) #else USB_USBTask(); #endif - matrix_scan(); } print("\nUSB configured.\n"); From ec94691e0b0847725184f5a29c0d3cc61205c021 Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 7 May 2019 11:09:25 +0900 Subject: [PATCH 139/217] lufa: Startup and suspend loop can be disabled Startup wait loop is originally intended to start keyboard task loop and after console output endpoint becomes available. But now that console output is buffered when it is not available and you don't have to wait for it to be ready. You can disable the startup wait loop by defining NO_WAIT_FOR_USB_CONFIGURED in config.h Suspend loop is used for power saving by making tasks stop while USB bus is under suspend status. But this may cause problem on some devices like converter that must keep doing its task to retain communication with keyboard. The suspend loop can block its task for around 15-17ms. You can disable the suspend loop by defining NO_USB_SUSPEND_LOOP in config.h. --- protocol/lufa/lufa.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index aecaa050..ce15ec73 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -654,6 +654,7 @@ int main(void) keyboard_init(); +#ifndef NO_USB_STARTUP_WAIT_LOOP /* wait for USB startup */ while (USB_DeviceState != DEVICE_STATE_Configured) { #if defined(INTERRUPT_CONTROL_ENDPOINT) @@ -663,14 +664,17 @@ int main(void) #endif } print("\nUSB configured.\n"); +#endif hook_late_init(); print("\nKeyboard start.\n"); while (1) { +#ifndef NO_USB_SUSPEND_LOOP while (USB_DeviceState == DEVICE_STATE_Suspended) { hook_usb_suspend_loop(); } +#endif keyboard_task(); From 2e1c26a371993bbebfd36d9e5c0c1e923d4d9047 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 8 May 2019 11:44:56 +0900 Subject: [PATCH 140/217] core: Add hook_usb_startup_wait_loop --- common/hook.h | 11 +++++++++++ common/suspend.h | 8 ++++++++ doc/hook.txt | 2 ++ protocol/lufa/lufa.c | 4 ++++ 4 files changed, 25 insertions(+) diff --git a/common/hook.h b/common/hook.h index 56fe5677..140e2779 100644 --- a/common/hook.h +++ b/common/hook.h @@ -21,6 +21,10 @@ along with this program. If not, see . #include "keyboard.h" #include "led.h" +#ifdef __cplusplus +extern "C" { +#endif + /* ------------------------------------- * Protocol hooks * ------------------------------------- */ @@ -47,6 +51,10 @@ void hook_usb_suspend_loop(void); * the "normal" indicator LED status by default. */ void hook_usb_wakeup(void); +/* Called repeatedly until getting to CONFIGURED state */ +/* Default behaviour: do nothing. */ +void hook_usb_startup_wait_loop(void); + /* ------------------------------------- * Keyboard hooks @@ -76,5 +84,8 @@ void hook_keyboard_leds_change(uint8_t led_status); /* Default behaviour: do nothing. */ void hook_bootmagic(void); +#ifdef __cplusplus +} +#endif #endif /* _HOOKS_H_ */ diff --git a/common/suspend.h b/common/suspend.h index 80617a82..f0a668cf 100644 --- a/common/suspend.h +++ b/common/suspend.h @@ -5,9 +5,17 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + void suspend_idle(uint8_t timeout); void suspend_power_down(void); bool suspend_wakeup_condition(void); void suspend_wakeup_init(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/doc/hook.txt b/doc/hook.txt index 1689034e..acd77cce 100644 --- a/doc/hook.txt +++ b/doc/hook.txt @@ -9,6 +9,8 @@ Hook function | Timing `hook_early_init(void)` | Early in the boot process, before the matrix is initialized and before a connection is made with the host. Thus, this hook has access to very few parameters, but it is a good place to define any custom parameters needed by other early processes. `hook_late_init(void)` | Near the end of the boot process, after Boot Magic has run and LEDs have been initialized. `hook_bootmagic(void)` | During the Boot Magic window, after EEPROM and Bootloader checks are made, but before any other built-in Boot Magic checks are made. +`hook_usb_startup_wait_loop(void)` | Continuously, until the device gets ready and into USB configured state. + `hook_usb_wakeup(void)` | When the device wakes up from USB suspend state. `hook_usb_suspend_entry(void)` | When the device enters USB suspend state. `hook_usb_suspend_loop(void)` | Continuously, while the device is in USB suspend state. *Default action:* power down and periodically check the matrix, causing wakeup if needed. diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index ce15ec73..9dadd572 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -662,6 +662,7 @@ int main(void) #else USB_USBTask(); #endif + hook_usb_startup_wait_loop(); } print("\nUSB configured.\n"); #endif @@ -739,3 +740,6 @@ void hook_usb_wakeup(void) // Calling long task here can prevent USB state transition } + +__attribute__((weak)) +void hook_usb_startup_wait_loop(void) {} From 26abe5d309dc1c655f1b89c4f3b75ea13119fc10 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 10 May 2019 10:37:19 +0900 Subject: [PATCH 141/217] usb_usb: Handle Rollover error How keyobards report Rollover error: Cherry: 0101010101010101 https://geekhack.org/index.php?topic=69169.msg2638223#msg2638223 Apple: 0000010101010101 https://geekhack.org/index.php?topic=69169.msg2760969#msg2760969 --- protocol/usb_hid/parser.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/protocol/usb_hid/parser.cpp b/protocol/usb_hid/parser.cpp index 81a5bfa6..5e9a3efb 100644 --- a/protocol/usb_hid/parser.cpp +++ b/protocol/usb_hid/parser.cpp @@ -12,10 +12,13 @@ void KBDReportParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *b } dprint("\r\n"); - // ignore Cherry 0101010101010101 bug report + // Rollover error + // Cherry: 0101010101010101 // https://geekhack.org/index.php?topic=69169.msg2638223#msg2638223 - if (buf[1] == 0x01) { - dprint("Cherry bug: ignored\r\n"); + // Apple: 0000010101010101 + // https://geekhack.org/index.php?topic=69169.msg2760969#msg2760969 + if (buf[2] == 0x01) { + dprint("Rollover error: ignored\r\n"); return; } From 7fb7960b699636ee93bcd541a74fe27480238234 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 29 May 2019 23:40:35 +0900 Subject: [PATCH 142/217] lufa: Print TMK version to console --- common.mk | 4 ++-- common/command.c | 2 +- protocol/lufa/lufa.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common.mk b/common.mk index 06507ecf..a38ff081 100644 --- a/common.mk +++ b/common.mk @@ -99,8 +99,8 @@ ifeq (yes,$(strip $(KEYMAP_SECTION_ENABLE))) endif # Version string -VERSION := $(shell (git describe --always --dirty || echo 'unknown') 2> /dev/null) -OPT_DEFS += -DVERSION=$(VERSION) +TMK_VERSION := $(shell (git describe --always --dirty=+ || echo 'unknown') 2> /dev/null) +OPT_DEFS += -DTMK_VERSION=$(TMK_VERSION) # Search Path diff --git a/common/command.c b/common/command.c index e08f91e5..54050bd9 100644 --- a/common/command.c +++ b/common/command.c @@ -284,7 +284,7 @@ static bool command_common(uint8_t code) print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") " "PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") " "VER: " STR(DEVICE_VER) "\n"); - print("BUILD: " STR(VERSION) " (" __TIME__ " " __DATE__ ")\n"); + print("BUILD: " STR(TMK_VERSION) " (" __TIME__ " " __DATE__ ")\n"); /* build options */ print("OPTIONS:" #ifdef PROTOCOL_PJRC diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index 9dadd572..32bc6981 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -642,7 +642,7 @@ int main(void) print_set_sendchar(sendchar); host_set_driver(&lufa_driver); - print("\n\nKeyboard init.\n"); + print("\n\nTMK:" STR(TMK_VERSION) "/LUFA\n\n"); hook_early_init(); keyboard_setup(); setup_usb(); From 7ad851376ccfced099f94aa99b35709420e0f506 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 29 May 2019 14:08:03 +0900 Subject: [PATCH 143/217] core: Add hook_process_action() --- common/action.c | 2 ++ common/hook.c | 5 +++++ common/hook.h | 5 +++++ doc/{hook.txt => hook.md} | 26 +++++++++++++------------- 4 files changed, 25 insertions(+), 13 deletions(-) rename doc/{hook.txt => hook.md} (54%) diff --git a/common/action.c b/common/action.c index 9b139d48..c256892c 100644 --- a/common/action.c +++ b/common/action.c @@ -58,6 +58,8 @@ void action_exec(keyevent_t event) void process_action(keyrecord_t *record) { + if (hook_process_action(record)) return; + keyevent_t event = record->event; #ifndef NO_ACTION_TAPPING uint8_t tap_count = record->tap.count; diff --git a/common/hook.c b/common/hook.c index 4ed2403c..22be9a30 100644 --- a/common/hook.c +++ b/common/hook.c @@ -47,3 +47,8 @@ void hook_keyboard_leds_change(uint8_t led_status) { __attribute__((weak)) void hook_bootmagic(void) {} + +__attribute__((weak)) +bool hook_process_action(keyrecord_t *record) { + return false; +} diff --git a/common/hook.h b/common/hook.h index 140e2779..ddd05c6f 100644 --- a/common/hook.h +++ b/common/hook.h @@ -20,6 +20,7 @@ along with this program. If not, see . #include "keyboard.h" #include "led.h" +#include "action.h" #ifdef __cplusplus extern "C" { @@ -84,6 +85,10 @@ void hook_keyboard_leds_change(uint8_t led_status); /* Default behaviour: do nothing. */ void hook_bootmagic(void); +/* Called on before processing key event */ +/* returns true if the event is consumed and default action is not needed. */ +bool hook_process_action(keyrecord_t *record); + #ifdef __cplusplus } #endif diff --git a/doc/hook.txt b/doc/hook.md similarity index 54% rename from doc/hook.txt rename to doc/hook.md index acd77cce..0cebf858 100644 --- a/doc/hook.txt +++ b/doc/hook.md @@ -6,19 +6,19 @@ The following hooks are available available: Hook function | Timing --------------------------------|----------------------------------------------- -`hook_early_init(void)` | Early in the boot process, before the matrix is initialized and before a connection is made with the host. Thus, this hook has access to very few parameters, but it is a good place to define any custom parameters needed by other early processes. -`hook_late_init(void)` | Near the end of the boot process, after Boot Magic has run and LEDs have been initialized. -`hook_bootmagic(void)` | During the Boot Magic window, after EEPROM and Bootloader checks are made, but before any other built-in Boot Magic checks are made. -`hook_usb_startup_wait_loop(void)` | Continuously, until the device gets ready and into USB configured state. - -`hook_usb_wakeup(void)` | When the device wakes up from USB suspend state. -`hook_usb_suspend_entry(void)` | When the device enters USB suspend state. -`hook_usb_suspend_loop(void)` | Continuously, while the device is in USB suspend state. *Default action:* power down and periodically check the matrix, causing wakeup if needed. -`hook_keyboard_loop(void)` | Continuously, during the main loop, after the matrix is checked. -`hook_matrix_change(keyevent_t event)` | When a matrix state change is detected, before any other actions are processed. -`hook_layer_change(uint32_t layer_state)` | When any layer is changed. -`hook_default_layer_change(uint32_t default_layer_state)` | When any default layer is changed. -`hook_keyboard_leds_change(uint8_t led_status)` | Whenever a change in the LED status is performed. *Default action:* call `keyboard_set_leds(led_status)` +`void hook_early_init(void)` | Early in the boot process, before the matrix is initialized and before a connection is made with the host. Thus, this hook has access to very few parameters, but it is a good place to define any custom parameters needed by other early processes. +`void hook_late_init(void)` | Near the end of the boot process, after Boot Magic has run and LEDs have been initialized. +`void hook_bootmagic(void)` | During the Boot Magic window, after EEPROM and Bootloader checks are made, but before any other built-in Boot Magic checks are made. +`void hook_usb_startup_wait_loop(void)` | Continuously, until the device gets ready and into USB configured state. +`void hook_usb_wakeup(void)` | When the device wakes up from USB suspend state. +`void hook_usb_suspend_entry(void)` | When the device enters USB suspend state. +`void hook_usb_suspend_loop(void)` | Continuously, while the device is in USB suspend state. *Default action:* power down and periodically check the matrix, causing wakeup if needed. +`void hook_keyboard_loop(void)` | Continuously, during the main loop, after the matrix is checked. +`void hook_matrix_change(keyevent_t event)` | When a matrix state change is detected, before any other actions are processed. +`void hook_layer_change(uint32_t layer_state)` | When any layer is changed. +`void hook_default_layer_change(uint32_t default_layer_state)` | When any default layer is changed. +`void hook_keyboard_leds_change(uint8_t led_status)` | Whenever a change in the LED status is performed. *Default action:* call `keyboard_set_leds(led_status)` +`bool hook_process_action(keyrecord_t *record)` | Before key event is processed by tmk_core. Return true if the event is consumed and default action is not needed. From d55207d1e18b32d9f00bbf35c7988250adcdbded Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 21 Jun 2019 13:03:49 +0900 Subject: [PATCH 144/217] core:adb_usb: Add Extended Mouse Protocol support #274 Also add Kensington Turbo Mouse 5 specific initialization --- common/report.h | 3 ++ protocol/adb.c | 98 ++++++++++++++++++++++++++++++++----------------- protocol/adb.h | 13 +++++-- 3 files changed, 76 insertions(+), 38 deletions(-) diff --git a/common/report.h b/common/report.h index f21e84ee..2a2ff2de 100644 --- a/common/report.h +++ b/common/report.h @@ -33,6 +33,9 @@ along with this program. If not, see . #define MOUSE_BTN3 (1<<2) #define MOUSE_BTN4 (1<<3) #define MOUSE_BTN5 (1<<4) +#define MOUSE_BTN6 (1<<5) +#define MOUSE_BTN7 (1<<6) +#define MOUSE_BTN8 (1<<7) /* Consumer Page(0x0C) * following are supported by Windows: http://msdn.microsoft.com/en-us/windows/hardware/gg463372.aspx diff --git a/protocol/adb.c b/protocol/adb.c index 164255ef..7feffb30 100644 --- a/protocol/adb.c +++ b/protocol/adb.c @@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include "adb.h" +#include "print.h" // GCC doesn't inline functions normally @@ -92,22 +93,25 @@ uint16_t adb_host_kbd_recv(uint8_t addr) } #ifdef ADB_MOUSE_ENABLE +__attribute__ ((weak)) void adb_mouse_init(void) { - return; + return; } -uint16_t adb_host_mouse_recv(void) -{ - return adb_host_talk(ADB_ADDR_MOUSE, ADB_REG_0); +__attribute__ ((weak)) +void adb_mouse_task(void) { + return; } #endif -uint16_t adb_host_talk(uint8_t addr, uint8_t reg) +// This sends Talk command to read data from register and returns length of the data. +uint8_t adb_host_talk_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len) { - uint16_t data = 0; + for (int8_t i =0; i < len; i++) buf[i] = 0; + cli(); attention(); - send_byte((addr<<4) | (ADB_CMD_TALK<<2) | reg); + send_byte((addr<<4) | ADB_CMD_TALK | reg); place_bit0(); // Stopbit(0) if (!wait_data_hi(500)) { // Service Request(310us Adjustable Keyboard): just ignored sei(); @@ -118,58 +122,84 @@ uint16_t adb_host_talk(uint8_t addr, uint8_t reg) return 0; // No data to send } - uint8_t n = 17; // start bit + 16 data bits + // start bit(1) + if (!wait_data_hi(40)) return 0; + if (!wait_data_lo(100)) return 0; + + uint8_t n = 0; // bit count do { + // + // |<- bit_cell_max(130) ->| + // | |<- lo ->| + // | | |<-hi->| + // _______ + // | | | + // | 130-lo | lo-hi | + // |________| | + // uint8_t lo = (uint8_t) wait_data_hi(130); if (!lo) - goto error; + goto error; // no more bit or after stop bit uint8_t hi = (uint8_t) wait_data_lo(lo); if (!hi) - goto error; + goto error; // stop bit extedned by Srq - hi = lo - hi; - lo = 130 - lo; + if (n/8 >= len) continue; // can't store in buf - data <<= 1; - if (lo < hi) { - data |= 1; + buf[n/8] <<= 1; + if ((130 - lo) < (lo - hi)) { + buf[n/8] |= 1; } - else if (n == 17) { - sei(); - return -20; - } - } - while ( --n ); - - // Stop bit can't be checked normally since it could have service request lenghtening - // and its high state never goes low. - if (!wait_data_hi(351) || wait_data_lo(91)) { - sei(); - return -21; } - sei(); - return data; + while ( ++n ); error: sei(); - return -n; + return n/8; } -void adb_host_listen(uint8_t addr, uint8_t reg, uint8_t data_h, uint8_t data_l) +uint16_t adb_host_talk(uint8_t addr, uint8_t reg) +{ + uint8_t len; + uint8_t buf[8]; + len = adb_host_talk_buf(addr, reg, buf, 8); + if (len != 2) return 0; + return (buf[0]<<8 | buf[1]); +} + +void adb_host_listen_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len) { cli(); attention(); - send_byte((addr<<4) | (ADB_CMD_LISTEN<<2) | reg); + send_byte((addr<<4) | ADB_CMD_LISTEN | reg); place_bit0(); // Stopbit(0) _delay_us(200); // Tlt/Stop to Start place_bit1(); // Startbit(1) - send_byte(data_h); - send_byte(data_l); + for (int8_t i = 0; i < len; i++) { + send_byte(buf[i]); + //xprintf("%02X ", buf[i]); + } place_bit0(); // Stopbit(0); sei(); } +void adb_host_listen(uint8_t addr, uint8_t reg, uint8_t data_h, uint8_t data_l) +{ + uint8_t buf[2] = { data_h, data_l }; + adb_host_listen_buf(addr, reg, buf, 2); +} + +void adb_host_flush(uint8_t addr) +{ + cli(); + attention(); + send_byte((addr<<4) | ADB_CMD_FLUSH); + place_bit0(); // Stopbit(0) + _delay_us(200); // Tlt/Stop to Start + sei(); +} + // send state of LEDs void adb_host_kbd_led(uint8_t addr, uint8_t led) { diff --git a/protocol/adb.h b/protocol/adb.h index a8b97ea5..52932c94 100644 --- a/protocol/adb.h +++ b/protocol/adb.h @@ -62,8 +62,8 @@ POSSIBILITY OF SUCH DAMAGE. // Command Type #define ADB_CMD_RESET 0 #define ADB_CMD_FLUSH 1 -#define ADB_CMD_LISTEN 2 -#define ADB_CMD_TALK 3 +#define ADB_CMD_LISTEN 8 +#define ADB_CMD_TALK 12 // Register #define ADB_REG_0 0 #define ADB_REG_1 1 @@ -76,16 +76,21 @@ POSSIBILITY OF SUCH DAMAGE. #define ADB_HANDLER_M0115 0x02 #define ADB_HANDLER_M3501 0x02 #define ADB_HANDLER_M1242_ANSI 0x10 -#define ADB_HANDLER_EXTENDED_PROTOCOL 0x03 +#define ADB_HANDLER_EXTENDED_KEYBOARD 0x03 +#define ADB_HANDLER_CLASSIC1_MOUSE 0x01 +#define ADB_HANDLER_CLASSIC2_MOUSE 0x02 +#define ADB_HANDLER_EXTENDED_MOUSE 0x04 // ADB host void adb_host_init(void); bool adb_host_psw(void); uint16_t adb_host_kbd_recv(uint8_t addr); -uint16_t adb_host_mouse_recv(void); uint16_t adb_host_talk(uint8_t addr, uint8_t reg); +uint8_t adb_host_talk_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len); void adb_host_listen(uint8_t addr, uint8_t reg, uint8_t data_h, uint8_t data_l); +void adb_host_listen_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len); +void adb_host_flush(uint8_t addr); void adb_host_kbd_led(uint8_t addr, uint8_t led); void adb_mouse_task(void); void adb_mouse_init(void); From dc8c3d840a3acb06b5e64e4144289dac18ec2892 Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 23 Jun 2019 13:31:54 +0900 Subject: [PATCH 145/217] adb_usb: Fix mouse_init --- protocol/adb.c | 66 +++++++++++++++++++++++++++++++++++++++++++++----- protocol/adb.h | 15 +++++++++++- 2 files changed, 74 insertions(+), 7 deletions(-) diff --git a/protocol/adb.c b/protocol/adb.c index 7feffb30..36005951 100644 --- a/protocol/adb.c +++ b/protocol/adb.c @@ -1,5 +1,5 @@ /* -Copyright 2011 Jun WAKO +Copyright 2011-19 Jun WAKO Copyright 2013 Shay Green This software is licensed with a Modified BSD License. @@ -113,18 +113,71 @@ uint8_t adb_host_talk_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len) attention(); send_byte((addr<<4) | ADB_CMD_TALK | reg); place_bit0(); // Stopbit(0) + // TODO: Service Request(Srq): + // Device holds low part of comannd stopbit for 140-260us + // + // Command: + // ......._ ______________________ ___ ............_ ------- + // | | | | | | | + // Command | | | | | Data bytes | | + // ........|___| | 140-260 |__| |_............|___| + // |stop0 | Tlt Stop-to-Start |start1| |stop0 | + // + // Command without data: + // ......._ __________________________ + // | | + // Command | | + // ........|___| | 140-260 | + // |stop0 | Tlt Stop-to-Start | + // + // Service Request: + // ......._ ______ ___ ............_ ------- + // | 140-260 | | | | | | + // Command | Service Request | | | | Data bytes | | + // ........|___________________| |__| |_............|___| + // |stop0 | |start1| |stop0 | + // ......._ __________ + // | 140-260 | + // Command | Service Request | + // ........|___________________| + // |stop0 | + // This can be happened? + // ......._ ______________________ ___ ............_ ----- + // | | | | | | 140-260 | + // Command | | | | | Data bytes | Service Request | + // ........|___| | 140-260 |__| |_............|_________________| + // |stop0 | Tlt Stop-to-Start |start1| |stop0 | + // + // "Service requests are issued by the devices during a very specific time at the + // end of the reception of the command packet. + // If a device in need of service issues a service request, it must do so within + // the 65 µs of the Stop Bit’s low time and maintain the line low for a total of 300 µs." + // + // "A device sends a Service Request signal by holding the bus low during the low + // portion of the stop bit of any command or data transaction. The device must lengthen + // the stop by a minimum of 140 J.lS beyond its normal duration, as shown in Figure 8-15." + // http://ww1.microchip.com/downloads/en/AppNotes/00591b.pdf if (!wait_data_hi(500)) { // Service Request(310us Adjustable Keyboard): just ignored + xprintf("R"); sei(); - return -30; // something wrong + return 0; } if (!wait_data_lo(500)) { // Tlt/Stop to Start(140-260us) sei(); - return 0; // No data to send + return 0; // No data from device(not error); } // start bit(1) - if (!wait_data_hi(40)) return 0; - if (!wait_data_lo(100)) return 0; + if (!wait_data_hi(40)) { + xprintf("S"); + sei(); + return 0; + } + if (!wait_data_lo(100)) { + xprintf("s"); + sei(); + return 0; + } uint8_t n = 0; // bit count do { @@ -143,7 +196,7 @@ uint8_t adb_host_talk_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len) uint8_t hi = (uint8_t) wait_data_lo(lo); if (!hi) - goto error; // stop bit extedned by Srq + goto error; // stop bit extedned by Srq? if (n/8 >= len) continue; // can't store in buf @@ -174,6 +227,7 @@ void adb_host_listen_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len) attention(); send_byte((addr<<4) | ADB_CMD_LISTEN | reg); place_bit0(); // Stopbit(0) + // TODO: Service Request _delay_us(200); // Tlt/Stop to Start place_bit1(); // Startbit(1) for (int8_t i = 0; i < len; i++) { diff --git a/protocol/adb.h b/protocol/adb.h index 52932c94..5e155cbc 100644 --- a/protocol/adb.h +++ b/protocol/adb.h @@ -1,5 +1,5 @@ /* -Copyright 2011 Jun WAKO +Copyright 2011-19 Jun WAKO This software is licensed with a Modified BSD License. All of this is supposed to be Free Software, Open Source, DFSG-free, @@ -54,11 +54,23 @@ POSSIBILITY OF SUCH DAMAGE. /* ADB commands */ // Default Address +#define ADB_ADDR_0 0 #define ADB_ADDR_DONGLE 1 #define ADB_ADDR_KEYBOARD 2 #define ADB_ADDR_MOUSE 3 #define ADB_ADDR_TABLET 4 #define ADB_ADDR_APPLIANCE 7 +#define ADB_ADDR_8 8 +#define ADB_ADDR_9 9 +#define ADB_ADDR_10 10 +#define ADB_ADDR_11 11 +#define ADB_ADDR_12 12 +#define ADB_ADDR_13 13 +#define ADB_ADDR_14 14 +#define ADB_ADDR_15 15 +// for temporary purpose, do not use for polling +#define ADB_ADDR_TMP 15 +#define ADB_ADDR_MOUSE_POLL 10 // Command Type #define ADB_CMD_RESET 0 #define ADB_CMD_FLUSH 1 @@ -80,6 +92,7 @@ POSSIBILITY OF SUCH DAMAGE. #define ADB_HANDLER_CLASSIC1_MOUSE 0x01 #define ADB_HANDLER_CLASSIC2_MOUSE 0x02 #define ADB_HANDLER_EXTENDED_MOUSE 0x04 +#define ADB_HANDLER_TURBO_MOUSE 0x32 // ADB host From 4acc276420e2945cdae138c9c3f6e504b0caf866 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 12 Jul 2019 16:08:05 +0900 Subject: [PATCH 146/217] core: Fix ibm4704_send() wait for clock to start --- protocol/ibm4704.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/protocol/ibm4704.c b/protocol/ibm4704.c index 6a03cd44..75e7db12 100644 --- a/protocol/ibm4704.c +++ b/protocol/ibm4704.c @@ -39,7 +39,7 @@ Data ____|__/ X____X____X____X____X____X____X____X____X____X \___ | Start 0 1 2 3 4 5 6 7 P Stop Request by host -Start bit: can be long as 300-350us. +Start bit: can be long as 300-350us during start up and upto 2500us while key scanning Request: Host pulls Clock line down to request to send a command. Timing: After Request keyboard pull up Data and down Clock line to low for start bit. After request host release Clock line once Data line becomes hi. @@ -58,7 +58,7 @@ uint8_t ibm4704_send(uint8_t data) clock_lo(); /* wait for Start bit(Clock:lo/Data:hi) */ - WAIT(data_hi, 300, 0x30); + WAIT(data_hi, 5000, 0x30); /* Data bit */ for (uint8_t i = 0; i < 8; i++) { @@ -89,7 +89,7 @@ uint8_t ibm4704_send(uint8_t data) return 0; ERROR: idle(); - if (ibm4704_error > 0x30) { + if (ibm4704_error >= 0x30) { xprintf("S:%02X ", ibm4704_error); } IBM4704_INT_ON(); From 9cd7ae4a1ad9e4a7208729afb04e2e8df4b8f06e Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 16 Sep 2019 17:49:38 +0900 Subject: [PATCH 147/217] core: Add bootkey of Caterina bootloader The bootkey set in bootloader_jump() works with Pro Micro and Leonardo. This fix doesn't seem to prevent other bootloaders, however, it can be disabled by defining NO_BOOTLOADER_CATERINA_BOOTKEY. --- common/avr/bootloader.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/common/avr/bootloader.c b/common/avr/bootloader.c index 7c744e8c..8d6de1a0 100644 --- a/common/avr/bootloader.c +++ b/common/avr/bootloader.c @@ -87,6 +87,14 @@ void bootloader_jump(void) { _delay_ms(5); #endif +#ifndef NO_BOOTLOADER_CATERINA_BOOTKEY + // Set bootkey for Arduino Leonardo and Pro Micro bootloader + // Watchdog reset with bootkey causes the bootloader to enter program mode instead of starting application. + // https://github.com/arduino/ArduinoCore-avr/blob/master/bootloaders/caterina/Caterina.c#L68-L69 + // https://github.com/sparkfun/SF32u4_boards/blob/master/sparkfun/avr/bootloaders/caterina/Caterina.c#L88-L89 + *(volatile uint16_t *)0x0800 = 0x7777; +#endif + // watchdog reset reset_key = BOOTLOADER_RESET_KEY; wdt_enable(WDTO_250MS); @@ -108,6 +116,13 @@ void bootloader_jump_after_watchdog_reset(void) MCUSR &= ~(1< Date: Mon, 16 Sep 2019 18:42:50 +0900 Subject: [PATCH 148/217] core: Fix comment and remove unused code --- common/avr/bootloader.c | 115 ++++++---------------------------------- 1 file changed, 15 insertions(+), 100 deletions(-) diff --git a/common/avr/bootloader.c b/common/avr/bootloader.c index 8d6de1a0..31d9a3ba 100644 --- a/common/avr/bootloader.c +++ b/common/avr/bootloader.c @@ -16,8 +16,8 @@ * AVR Boot section size are defined by setting BOOTSZ fuse in fact. Consult with your MCU datasheet. * Note that 'Word'(2 bytes) size and address are used in datasheet while TMK uses 'Byte'. * - * * Size of Bootloaders in bytes: + * Atmel DFU loader(ATmega32U2) 4096 * Atmel DFU loader(ATmega32U4) 4096 * Atmel DFU loader(AT90USB128) 8192 * LUFA bootloader(ATmega32U4) 4096 @@ -27,33 +27,19 @@ * Teensy++ halfKay(AT90USB128) 1024 * * - * AVR Boot section is located at the end of Flash memory like the followings. - * - * - * byte Atmel/LUFA(ATMega32u4) byte Atmel(AT90SUB128) - * 0x0000 +---------------+ 0x00000 +---------------+ - * | | | | - * | | | | - * | Application | | Application | - * | | | | - * = = = = - * | | 32KB-4KB | | 128KB-8KB - * 0x6000 +---------------+ 0x1FC00 +---------------+ - * | Bootloader | 4KB | Bootloader | 8KB - * 0x7FFF +---------------+ 0x1FFFF +---------------+ - * + * AVR Boot section is located at the end of Flash memory. * - * byte Teensy(ATMega32u4) byte Teensy++(AT90SUB128) - * 0x0000 +---------------+ 0x00000 +---------------+ - * | | | | - * | | | | - * | Application | | Application | - * | | | | - * = = = = - * | | 32KB-512B | | 128KB-1KB - * 0x7E00 +---------------+ 0x1FC00 +---------------+ - * | Bootloader | 512B | Bootloader | 1KB - * 0x7FFF +---------------+ 0x1FFFF +---------------+ + * byte ATMega32u4 with 4096-byte Boot section + * 0x0000 +---------------+ + * | | + * | | + * | Application | 28KB + * | | + * = = + * | | + * 0x7000 +---------------+ <---- BOOTLOADER_START + * | Bootloader | 4KB BOOTLOADER_SIZE + * 0x7FFF +---------------+ <---- FLASHEND */ #ifndef BOOTLOADER_SIZE #warning To use bootloader_jump() you need to define BOOTLOADER_SIZE in config.h. @@ -64,8 +50,8 @@ #define BOOTLOADER_START (FLASH_SIZE - BOOTLOADER_SIZE) -/* - * Entering the Bootloader via Software +/* + * Entering the Bootloader via Software * http://www.fourwalledcubicle.com/files/LUFA/Doc/120730/html/_page__software_bootloader_start.html */ #define BOOTLOADER_RESET_KEY 0xB007B007 @@ -127,74 +113,3 @@ void bootloader_jump_after_watchdog_reset(void) ((void (*)(void))(BOOTLOADER_START/2))(); } } - - -#if 0 -/* Jumping To The Bootloader - * http://www.pjrc.com/teensy/jump_to_bootloader.html - * - * This method doen't work when using LUFA. idk why. - * - needs to initialize more regisers or interrupt setting? - */ -void bootloader_jump(void) { -#ifdef PROTOCOL_LUFA - USB_Disable(); - cli(); - _delay_ms(2000); -#endif - -#ifdef PROTOCOL_PJRC - cli(); - UDCON = 1; - USBCON = (1< Date: Tue, 17 Sep 2019 16:19:52 +0900 Subject: [PATCH 149/217] core: Read bootloader size from AVR fuse bits This makes defining BOOTLOADER_SIZE macro optional. --- common/avr/bootloader.c | 44 ++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/common/avr/bootloader.c b/common/avr/bootloader.c index 31d9a3ba..2a898f8c 100644 --- a/common/avr/bootloader.c +++ b/common/avr/bootloader.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "bootloader.h" @@ -41,13 +42,42 @@ * | Bootloader | 4KB BOOTLOADER_SIZE * 0x7FFF +---------------+ <---- FLASHEND */ -#ifndef BOOTLOADER_SIZE -#warning To use bootloader_jump() you need to define BOOTLOADER_SIZE in config.h. -#define BOOTLOADER_SIZE 4096 -#endif -#define FLASH_SIZE (FLASHEND + 1L) -#define BOOTLOADER_START (FLASH_SIZE - BOOTLOADER_SIZE) +/* bootloader start address in byte */ +#define BOOTLOADER_START (FLASHEND - bootloader_size() + 1) + +/* boot section size in byte */ +static inline uint16_t bootloader_size(void) +{ +#if defined(BOOTLOADER_SIZE) + return BOOTLOADER_SIZE; +#else + #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U2__) || \ + defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega16U2__) || \ + defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__) + uint8_t hfuse = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS); + switch ((hfuse >> 1) & 3) { + case 0: return 4096; + case 1: return 2048; + case 2: return 1024; + case 3: return 512; + } + return 4096; + #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || \ + defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) + uint8_t hfuse = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS); + switch ((hfuse >> 1) & 3) { + case 0: return 8192; + case 1: return 4096; + case 2: return 2048; + case 3: return 1024; + } + return 8192; + #else + #error Set Boot section size to BOOTLOADER_SIZE in config.h + #endif +#endif +} /* @@ -110,6 +140,6 @@ void bootloader_jump_after_watchdog_reset(void) #endif // This is compled into 'icall', address should be in word unit, not byte. - ((void (*)(void))(BOOTLOADER_START/2))(); + ((void (*)(void))(BOOTLOADER_START / 2))(); } } From 725a9fe597608348ac6430a1e23009d68a98df30 Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 17 Sep 2019 20:55:35 +0900 Subject: [PATCH 150/217] core: Add AC_BTLD to actionmap and unimap Now that it can jump to bootloader with AC_BTLD --- common/action.c | 10 ++++++++++ common/action_code.h | 20 ++++++++++++------- common/actionmap.h | 47 ++++++++------------------------------------ common/keymap.c | 4 +--- 4 files changed, 32 insertions(+), 49 deletions(-) diff --git a/common/action.c b/common/action.c index c256892c..5a6f3df3 100644 --- a/common/action.c +++ b/common/action.c @@ -28,6 +28,7 @@ along with this program. If not, see . #include "action.h" #include "hook.h" #include "wait.h" +#include "bootloader.h" #ifdef DEBUG_ACTION #include "debug.h" @@ -341,6 +342,15 @@ void process_action(keyrecord_t *record) break; #endif case ACT_COMMAND: + switch (action.command.id) { + case COMMAND_BOOTLOADER: + if (event.pressed) { + clear_keyboard(); + wait_ms(50); + bootloader_jump(); + } + break; + } break; #ifndef NO_ACTION_FUNCTION case ACT_FUNCTION: diff --git a/common/action_code.h b/common/action_code.h index 1eb69104..77c7c342 100644 --- a/common/action_code.h +++ b/common/action_code.h @@ -48,7 +48,7 @@ along with this program. If not, see . * 0100|10| usage(10) (reserved) * 0100|11| usage(10) (reserved) * - * ACT_MOUSEKEY(0110): TODO: Not needed? + * ACT_MOUSEKEY(0101): TODO: Not needed? * 0101|xxxx| keycode Mouse key * * 011x|xxxx xxxx xxxx (reseved) @@ -290,6 +290,12 @@ enum layer_pram_tap_op { /* * Extensions */ +/* Macro */ +#define ACTION_MACRO(id) ACTION(ACT_MACRO, (id)) +#define ACTION_MACRO_TAP(id) ACTION(ACT_MACRO, FUNC_TAP<<8 | (id)) +#define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id)) + +/* Backlight */ enum backlight_opt { BACKLIGHT_INCREASE = 0, BACKLIGHT_DECREASE = 1, @@ -297,18 +303,18 @@ enum backlight_opt { BACKLIGHT_STEP = 3, BACKLIGHT_LEVEL = 4, }; -/* Macro */ -#define ACTION_MACRO(id) ACTION(ACT_MACRO, (id)) -#define ACTION_MACRO_TAP(id) ACTION(ACT_MACRO, FUNC_TAP<<8 | (id)) -#define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id)) -/* Backlight */ #define ACTION_BACKLIGHT_INCREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_INCREASE << 8) #define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE << 8) #define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE << 8) #define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP << 8) #define ACTION_BACKLIGHT_LEVEL(level) ACTION(ACT_BACKLIGHT, BACKLIGHT_LEVEL << 8 | level) + /* Command */ -#define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (addr)) +enum command_ids { + COMMAND_BOOTLOADER, // jump to bootloader +}; +#define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (id)) + /* Function */ enum function_opts { FUNC_TAP = 0x8, /* indciates function is tappable */ diff --git a/common/actionmap.h b/common/actionmap.h index 2ebfb0d0..a96c84b3 100644 --- a/common/actionmap.h +++ b/common/actionmap.h @@ -283,43 +283,7 @@ along with this program. If not, see . #define AC_WWW_STOP ACTION_USAGE_CONSUMER(APPCONTROL_STOP) #define AC_WWW_REFRESH ACTION_USAGE_CONSUMER(APPCONTROL_REFRESH) #define AC_WWW_FAVORITES ACTION_USAGE_CONSUMER(APPCONTROL_BOOKMARKS) -/* Jump to bootloader */ -#define AC_BOOTLOADER ACTION_KEY(KC_BOOTLOADER) -/* Fn key */ -/* -#define AC_FN0 ACTION_KEY(KC_FN0) -#define AC_FN1 ACTION_KEY(KC_FN1) -#define AC_FN2 ACTION_KEY(KC_FN2) -#define AC_FN3 ACTION_KEY(KC_FN3) -#define AC_FN4 ACTION_KEY(KC_FN4) -#define AC_FN5 ACTION_KEY(KC_FN5) -#define AC_FN6 ACTION_KEY(KC_FN6) -#define AC_FN7 ACTION_KEY(KC_FN7) -#define AC_FN8 ACTION_KEY(KC_FN8) -#define AC_FN9 ACTION_KEY(KC_FN9) -#define AC_FN10 ACTION_KEY(KC_FN10) -#define AC_FN11 ACTION_KEY(KC_FN11) -#define AC_FN12 ACTION_KEY(KC_FN12) -#define AC_FN13 ACTION_KEY(KC_FN13) -#define AC_FN14 ACTION_KEY(KC_FN14) -#define AC_FN15 ACTION_KEY(KC_FN15) -#define AC_FN16 ACTION_KEY(KC_FN16) -#define AC_FN17 ACTION_KEY(KC_FN17) -#define AC_FN18 ACTION_KEY(KC_FN18) -#define AC_FN19 ACTION_KEY(KC_FN19) -#define AC_FN20 ACTION_KEY(KC_FN20) -#define AC_FN21 ACTION_KEY(KC_FN21) -#define AC_FN22 ACTION_KEY(KC_FN22) -#define AC_FN23 ACTION_KEY(KC_FN23) -#define AC_FN24 ACTION_KEY(KC_FN24) -#define AC_FN25 ACTION_KEY(KC_FN25) -#define AC_FN26 ACTION_KEY(KC_FN26) -#define AC_FN27 ACTION_KEY(KC_FN27) -#define AC_FN28 ACTION_KEY(KC_FN28) -#define AC_FN29 ACTION_KEY(KC_FN29) -#define AC_FN30 ACTION_KEY(KC_FN30) -#define AC_FN31 ACTION_KEY(KC_FN31) -*/ + /* Mousekey */ #define AC_MS_UP ACTION_MOUSEKEY(KC_MS_UP) #define AC_MS_DOWN ACTION_MOUSEKEY(KC_MS_DOWN) @@ -338,6 +302,10 @@ along with this program. If not, see . #define AC_MS_ACCEL1 ACTION_MOUSEKEY(KC_MS_ACCEL1) #define AC_MS_ACCEL2 ACTION_MOUSEKEY(KC_MS_ACCEL2) +/* Command */ +#define AC_BOOTLOADER ACTION_COMMAND(COMMAND_BOOTLOADER, 0) + + /* * Short names */ @@ -447,9 +415,10 @@ along with this program. If not, see . #define AC_WSTP ACTION_USAGE_CONSUMER(APPCONTROL_STOP) #define AC_WREF ACTION_USAGE_CONSUMER(APPCONTROL_REFRESH) #define AC_WFAV ACTION_USAGE_CONSUMER(APPCONTROL_BOOKMARKS) -/* Jump to bootloader */ -#define AC_BTLD ACTION_KEY(KC_BOOTLOADER) /* Transparent */ #define AC_TRNS ACTION_KEY(KC_TRANSPARENT) +/* Command */ +#define AC_BTLD AC_BOOTLOADER + #endif diff --git a/common/keymap.c b/common/keymap.c index 01c6e642..80ad388e 100644 --- a/common/keymap.c +++ b/common/keymap.c @@ -155,9 +155,7 @@ static action_t keycode_to_action(uint8_t keycode) return (action_t)ACTION_TRANSPARENT; break; case KC_BOOTLOADER: - clear_keyboard(); - wait_ms(50); - bootloader_jump(); // not return + return (action_t)ACTION_COMMAND(COMMAND_BOOTLOADER, 0); break; default: return (action_t)ACTION_NO; From 57c4260b821e37f0d9d35f12d54882240eecbcbb Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 18 Sep 2019 14:14:25 +0900 Subject: [PATCH 151/217] core: Remove unneeded code in bootloader_jump --- common/avr/bootloader.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/common/avr/bootloader.c b/common/avr/bootloader.c index 2a898f8c..8a1bec06 100644 --- a/common/avr/bootloader.c +++ b/common/avr/bootloader.c @@ -92,7 +92,6 @@ void bootloader_jump(void) { #ifdef PROTOCOL_LUFA USB_Disable(); cli(); - _delay_ms(2000); #endif #ifdef PROTOCOL_PJRC @@ -125,11 +124,10 @@ void bootloader_jump_after_watchdog_reset(void) if ((MCUSR & (1< Date: Wed, 18 Sep 2019 15:09:02 +0900 Subject: [PATCH 152/217] core: Add NO_PRINT and NO_DEBUG build option Lines below in Makefile disable print and debug functions respectively. NO_PRINT = yes NO_DEBUG = yes --- common.mk | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common.mk b/common.mk index a38ff081..090bbe6e 100644 --- a/common.mk +++ b/common.mk @@ -58,6 +58,14 @@ else endif endif +ifeq (yes,$(strip $(NO_DEBUG))) + OPT_DEFS += -DNO_DEBUG +endif + +ifeq (yes,$(strip $(NO_PRINT))) + OPT_DEFS += -DNO_PRINT +endif + ifeq (yes,$(strip $(COMMAND_ENABLE))) SRC += $(COMMON_DIR)/command.c OPT_DEFS += -DCOMMAND_ENABLE From b1eaaa3e45cd53f06d4d0dcc6493fc10ffe39bcf Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 18 Sep 2019 15:29:38 +0900 Subject: [PATCH 153/217] usb_usb: Clean print for debug --- protocol/usb_hid/parser.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/protocol/usb_hid/parser.cpp b/protocol/usb_hid/parser.cpp index 5e9a3efb..bc2744d0 100644 --- a/protocol/usb_hid/parser.cpp +++ b/protocol/usb_hid/parser.cpp @@ -1,16 +1,16 @@ #include "parser.h" #include "usb_hid.h" -#include "debug.h" +#include "print.h" void KBDReportParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) { - dprintf("input %d:", hid->GetAddress()); + xprintf("input %d:", hid->GetAddress()); for (uint8_t i = 0; i < len; i++) { - dprintf(" %02X", buf[i]); + xprintf(" %02X", buf[i]); } - dprint("\r\n"); + xprintf("\r\n"); // Rollover error // Cherry: 0101010101010101 @@ -18,7 +18,7 @@ void KBDReportParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *b // Apple: 0000010101010101 // https://geekhack.org/index.php?topic=69169.msg2760969#msg2760969 if (buf[2] == 0x01) { - dprint("Rollover error: ignored\r\n"); + xprintf("Rollover error: ignored\r\n"); return; } From 5a2ffa20a7b73334276baed6590b60ba6dc1c630 Mon Sep 17 00:00:00 2001 From: tmk Date: Tue, 12 Nov 2019 15:37:23 +0900 Subject: [PATCH 154/217] core: Add short name for keycode KP_00 and KP_000 --- common/actionmap.h | 2 ++ common/keycode.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/common/actionmap.h b/common/actionmap.h index a96c84b3..ca643e82 100644 --- a/common/actionmap.h +++ b/common/actionmap.h @@ -364,6 +364,8 @@ along with this program. If not, see . #define AC_P8 ACTION_KEY(KC_KP_8) #define AC_P9 ACTION_KEY(KC_KP_9) #define AC_P0 ACTION_KEY(KC_KP_0) +#define AC_P00 ACTION_KEY(KC_KP_00) +#define AC_P000 ACTION_KEY(KC_KP_000) #define AC_PDOT ACTION_KEY(KC_KP_DOT) #define AC_PCMM ACTION_KEY(KC_KP_COMMA) #define AC_PSLS ACTION_KEY(KC_KP_SLASH) diff --git a/common/keycode.h b/common/keycode.h index 63d52e89..acbe5c32 100644 --- a/common/keycode.h +++ b/common/keycode.h @@ -116,6 +116,8 @@ along with this program. If not, see . #define KC_P8 KC_KP_8 #define KC_P9 KC_KP_9 #define KC_P0 KC_KP_0 +#define KC_P00 KC_KP_00 +#define KC_P000 KC_KP_000 #define KC_PDOT KC_KP_DOT #define KC_PCMM KC_KP_COMMA #define KC_PSLS KC_KP_SLASH From 626fa8a898ddca577413fbe18f769519f99c94fa Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 4 Dec 2019 11:34:05 +0900 Subject: [PATCH 155/217] core: Add IBM PC Keyboard protocol support --- protocol/ibmpc.c | 264 +++++++++++++++++++++++++++++++++++++++++++++++ protocol/ibmpc.h | 199 +++++++++++++++++++++++++++++++++++ 2 files changed, 463 insertions(+) create mode 100644 protocol/ibmpc.c create mode 100644 protocol/ibmpc.h diff --git a/protocol/ibmpc.c b/protocol/ibmpc.c new file mode 100644 index 00000000..e65ac461 --- /dev/null +++ b/protocol/ibmpc.c @@ -0,0 +1,264 @@ +/* +Copyright 2010,2011,2012,2013,2019 Jun WAKO + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * IBM PC keyboard protocol + */ + +#include +#include +#include "ringbuf.h" +#include "ibmpc.h" +#include "debug.h" +#include "timer.h" +#include "wait.h" + + +#define WAIT(stat, us, err) do { \ + if (!wait_##stat(us)) { \ + ibmpc_error = err; \ + goto ERROR; \ + } \ +} while (0) + + +#define BUF_SIZE 16 +static uint8_t buf[BUF_SIZE]; +static ringbuf_t rb = { + .buffer = buf, + .head = 0, + .tail = 0, + .size_mask = BUF_SIZE - 1 +}; + +volatile uint8_t ibmpc_protocol = IBMPC_PROTOCOL_AT; +volatile uint8_t ibmpc_error = IBMPC_ERR_NONE; + +void ibmpc_host_init(void) +{ + clock_init(); + data_init(); + idle(); + IBMPC_INT_INIT(); + IBMPC_INT_ON(); + // POR(150-2000ms) plus BAT(300-500ms) may take 2.5sec([3]p.20) + //wait_ms(2500); +} + +int16_t ibmpc_host_send(uint8_t data) +{ + bool parity = true; + ibmpc_error = IBMPC_ERR_NONE; + + if (ibmpc_protocol == IBMPC_PROTOCOL_XT) return -1; + + dprintf("w%02X ", data); + + IBMPC_INT_OFF(); + + /* terminate a transmission if we have */ + inhibit(); + wait_us(100); // 100us [4]p.13, [5]p.50 + + /* 'Request to Send' and Start bit */ + data_lo(); + clock_hi(); + WAIT(clock_lo, 10000, 1); // 10ms [5]p.50 + + /* Data bit[2-9] */ + for (uint8_t i = 0; i < 8; i++) { + wait_us(15); + if (data&(1< 10) { + ibmpc_error = IBMPC_ERR_TIMEOUT | IBMPC_ERR_RECV | state; + state = START; + data = 0; + parity = 1; + } + last_time = timer_read(); + + switch (state) { + case START: + if (ibmpc_protocol == IBMPC_PROTOCOL_XT) { + // ignore start(0) bit + if (!data_in()) return; + } else { + if (data_in()) + goto ERROR; + } + case BIT0: + case BIT1: + case BIT2: + case BIT3: + case BIT4: + case BIT5: + case BIT6: + case BIT7: + data >>= 1; + if (data_in()) { + data |= 0x80; + parity++; + } + if (state == BIT7 && ibmpc_protocol == IBMPC_PROTOCOL_XT) { + if (!ringbuf_put(&rb, data)) { + ibmpc_error = IBMPC_ERR_FULL; + goto ERROR; + } + ibmpc_error = IBMPC_ERR_NONE; + goto DONE; + } + break; + case PARITY: + if (data_in()) { + if (!(parity & 0x01)) + goto ERROR; + } else { + if (parity & 0x01) + goto ERROR; + } + break; + case STOP: + if (!data_in()) + goto ERROR; + if (!ringbuf_put(&rb, data)) { + ibmpc_error = IBMPC_ERR_FULL; + goto ERROR; + } + ibmpc_error = IBMPC_ERR_NONE; + goto DONE; + break; + default: + goto ERROR; + } + goto NEXT; + +ERROR: + ibmpc_error |= state; + ibmpc_error |= IBMPC_ERR_RECV; + ringbuf_reset(&rb); +DONE: + last_time = 0; + state = START; + data = 0; + parity = 1; + return; +NEXT: + state++; + return; +} + +/* send LED state to keyboard */ +void ibmpc_host_set_led(uint8_t led) +{ + ibmpc_host_send(0xED); + ibmpc_host_send(led); +} diff --git a/protocol/ibmpc.h b/protocol/ibmpc.h new file mode 100644 index 00000000..47e71e27 --- /dev/null +++ b/protocol/ibmpc.h @@ -0,0 +1,199 @@ +/* +Copyright 2010,2011,2012,2013,2019 Jun WAKO + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef IBMPC_H +#define IBMPC_H + +#include +#include "wait.h" +#include "print.h" + +/* + * IBM PC keyboard protocol + * + * PS/2 Resources + * -------------- + * [1] The PS/2 Mouse/Keyboard Protocol + * http://www.computer-engineering.org/ps2protocol/ + * Concise and thorough primer of PS/2 protocol. + * + * [2] Keyboard and Auxiliary Device Controller + * http://www.mcamafia.de/pdf/ibm_hitrc07.pdf + * Signal Timing and Format + * + * [3] Keyboards(101- and 102-key) + * http://www.mcamafia.de/pdf/ibm_hitrc11.pdf + * Keyboard Layout, Scan Code Set, POR, and Commands. + * + * [4] PS/2 Reference Manuals + * http://www.mcamafia.de/pdf/ibm_hitrc07.pdf + * Collection of IBM Personal System/2 documents. + * + * [5] TrackPoint Engineering Specifications for version 3E + * https://web.archive.org/web/20100526161812/http://wwwcssrv.almaden.ibm.com/trackpoint/download.html + */ +#define IBMPC_ACK 0xFA +#define IBMPC_RESEND 0xFE +#define IBMPC_SET_LED 0xED + +#define IBMPC_PROTOCOL_AT 0 +#define IBMPC_PROTOCOL_XT 1 + +// TODO: error numbers +#define IBMPC_ERR_NONE 0 +#define IBMPC_ERR_RECV 0x00 +#define IBMPC_ERR_SEND 0x10 +#define IBMPC_ERR_TIMEOUT 0x20 +#define IBMPC_ERR_FULL 0x40 + +#define IBMPC_LED_SCROLL_LOCK 0 +#define IBMPC_LED_NUM_LOCK 1 +#define IBMPC_LED_CAPS_LOCK 2 + + +extern volatile uint8_t ibmpc_protocol; +extern volatile uint8_t ibmpc_error; + +void ibmpc_host_init(void); +int16_t ibmpc_host_send(uint8_t data); +int16_t ibmpc_host_recv_response(void); +int16_t ibmpc_host_recv(void); +void ibmpc_host_set_led(uint8_t usb_led); + + +/*-------------------------------------------------------------------- + * static functions + *------------------------------------------------------------------*/ +#if defined(__AVR__) +/* + * Clock + */ +static inline void clock_init(void) +{ + IBMPC_CLOCK_PORT &= ~(1< Date: Wed, 4 Dec 2019 14:29:49 +0900 Subject: [PATCH 156/217] core: Add ldscript for AT90USB to support unimap --- common.mk | 2 + ldscript_keymap_avr51.x | 263 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 265 insertions(+) create mode 100644 ldscript_keymap_avr51.x diff --git a/common.mk b/common.mk index 090bbe6e..9c3425b4 100644 --- a/common.mk +++ b/common.mk @@ -101,6 +101,8 @@ ifeq (yes,$(strip $(KEYMAP_SECTION_ENABLE))) EXTRALDFLAGS = -Wl,-L$(TMK_DIR),-Tldscript_keymap_avr35.x else ifeq ($(strip $(MCU)),atmega32u4) EXTRALDFLAGS = -Wl,-L$(TMK_DIR),-Tldscript_keymap_avr5.x + else ifeq ($(strip $(MCU)),at90usb1286) + EXTRALDFLAGS = -Wl,-L$(TMK_DIR),-Tldscript_keymap_avr51.x else EXTRALDFLAGS = $(error no ldscript for keymap section) endif diff --git a/ldscript_keymap_avr51.x b/ldscript_keymap_avr51.x new file mode 100644 index 00000000..864a4dec --- /dev/null +++ b/ldscript_keymap_avr51.x @@ -0,0 +1,263 @@ +/* Default linker script, for normal executables */ +/* Copyright (C) 2014-2015 Free Software Foundation, Inc. + Copying and distribution of this script, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. */ +OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr") +OUTPUT_ARCH(avr:51) +__TEXT_REGION_LENGTH__ = DEFINED(__TEXT_REGION_LENGTH__) ? __TEXT_REGION_LENGTH__ : 128K; +__DATA_REGION_LENGTH__ = DEFINED(__DATA_REGION_LENGTH__) ? __DATA_REGION_LENGTH__ : 0xff00; +__EEPROM_REGION_LENGTH__ = DEFINED(__EEPROM_REGION_LENGTH__) ? __EEPROM_REGION_LENGTH__ : 64K; +__FUSE_REGION_LENGTH__ = DEFINED(__FUSE_REGION_LENGTH__) ? __FUSE_REGION_LENGTH__ : 1K; +__LOCK_REGION_LENGTH__ = DEFINED(__LOCK_REGION_LENGTH__) ? __LOCK_REGION_LENGTH__ : 1K; +__SIGNATURE_REGION_LENGTH__ = DEFINED(__SIGNATURE_REGION_LENGTH__) ? __SIGNATURE_REGION_LENGTH__ : 1K; +__USER_SIGNATURE_REGION_LENGTH__ = DEFINED(__USER_SIGNATURE_REGION_LENGTH__) ? __USER_SIGNATURE_REGION_LENGTH__ : 1K; +MEMORY +{ + text (rx) : ORIGIN = 0, LENGTH = __TEXT_REGION_LENGTH__ + data (rw!x) : ORIGIN = 0x800100, LENGTH = __DATA_REGION_LENGTH__ + eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = __EEPROM_REGION_LENGTH__ + fuse (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__ + lock (rw!x) : ORIGIN = 0x830000, LENGTH = __LOCK_REGION_LENGTH__ + signature (rw!x) : ORIGIN = 0x840000, LENGTH = __SIGNATURE_REGION_LENGTH__ + user_signatures (rw!x) : ORIGIN = 0x850000, LENGTH = __USER_SIGNATURE_REGION_LENGTH__ +} +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.init : { *(.rel.init) } + .rela.init : { *(.rela.init) } + .rel.text : + { + *(.rel.text) + *(.rel.text.*) + *(.rel.gnu.linkonce.t*) + } + .rela.text : + { + *(.rela.text) + *(.rela.text.*) + *(.rela.gnu.linkonce.t*) + } + .rel.fini : { *(.rel.fini) } + .rela.fini : { *(.rela.fini) } + .rel.rodata : + { + *(.rel.rodata) + *(.rel.rodata.*) + *(.rel.gnu.linkonce.r*) + } + .rela.rodata : + { + *(.rela.rodata) + *(.rela.rodata.*) + *(.rela.gnu.linkonce.r*) + } + .rel.data : + { + *(.rel.data) + *(.rel.data.*) + *(.rel.gnu.linkonce.d*) + } + .rela.data : + { + *(.rela.data) + *(.rela.data.*) + *(.rela.gnu.linkonce.d*) + } + .rel.ctors : { *(.rel.ctors) } + .rela.ctors : { *(.rela.ctors) } + .rel.dtors : { *(.rel.dtors) } + .rela.dtors : { *(.rela.dtors) } + .rel.got : { *(.rel.got) } + .rela.got : { *(.rela.got) } + .rel.bss : { *(.rel.bss) } + .rela.bss : { *(.rela.bss) } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + /* Internal text space or external memory. */ + .text : + { + *(.vectors) + KEEP(*(.vectors)) + /* For data that needs to reside in the lower 64k of progmem. */ + *(.progmem.gcc*) + /* PR 13812: Placing the trampolines here gives a better chance + that they will be in range of the code that uses them. */ + . = ALIGN(2); + __trampolines_start = . ; + /* The jump trampolines for the 16-bit limited relocs will reside here. */ + *(.trampolines) + *(.trampolines*) + __trampolines_end = . ; + /* avr-libc expects these data to reside in lower 64K. */ + *libprintf_flt.a:*(.progmem.data) + *libc.a:*(.progmem.data) + *(.progmem*) + . = ALIGN(2); + /* For future tablejump instruction arrays for 3 byte pc devices. + We don't relax jump/call instructions within these sections. */ + *(.jumptables) + *(.jumptables*) + /* For code that needs to reside in the lower 128k progmem. */ + *(.lowtext) + *(.lowtext*) + __ctors_start = . ; + *(.ctors) + __ctors_end = . ; + __dtors_start = . ; + *(.dtors) + __dtors_end = . ; + KEEP(SORT(*)(.ctors)) + KEEP(SORT(*)(.dtors)) + /* From this point on, we don't bother about wether the insns are + below or above the 16 bits boundary. */ + *(.init0) /* Start here after reset. */ + KEEP (*(.init0)) + *(.init1) + KEEP (*(.init1)) + *(.init2) /* Clear __zero_reg__, set up stack pointer. */ + KEEP (*(.init2)) + *(.init3) + KEEP (*(.init3)) + *(.init4) /* Initialize data and BSS. */ + KEEP (*(.init4)) + *(.init5) + KEEP (*(.init5)) + *(.init6) /* C++ constructors. */ + KEEP (*(.init6)) + *(.init7) + KEEP (*(.init7)) + *(.init8) + KEEP (*(.init8)) + *(.init9) /* Call main(). */ + KEEP (*(.init9)) + *(.text) + . = ALIGN(2); + *(.text.*) + . = ALIGN(2); + *(.fini9) /* _exit() starts here. */ + KEEP (*(.fini9)) + *(.fini8) + KEEP (*(.fini8)) + *(.fini7) + KEEP (*(.fini7)) + *(.fini6) /* C++ destructors. */ + KEEP (*(.fini6)) + *(.fini5) + KEEP (*(.fini5)) + *(.fini4) + KEEP (*(.fini4)) + *(.fini3) + KEEP (*(.fini3)) + *(.fini2) + KEEP (*(.fini2)) + *(.fini1) + KEEP (*(.fini1)) + *(.fini0) /* Infinite loop after program termination. */ + KEEP (*(.fini0)) + _etext = . ; + } > text + .data : + { + PROVIDE (__data_start = .) ; + *(.data) + *(.data*) + *(.gnu.linkonce.d*) + *(.rodata) /* We need to include .rodata here if gcc is used */ + *(.rodata*) /* with -fdata-sections. */ + *(.gnu.linkonce.r*) + . = ALIGN(2); + _edata = . ; + PROVIDE (__data_end = .) ; + } > data AT> text + .bss ADDR(.data) + SIZEOF (.data) : AT (ADDR (.bss)) + { + PROVIDE (__bss_start = .) ; + *(.bss) + *(.bss*) + *(COMMON) + PROVIDE (__bss_end = .) ; + } > data + __data_load_start = LOADADDR(.data); + __data_load_end = __data_load_start + SIZEOF(.data); + /* Global data not cleared after reset. */ + .noinit ADDR(.bss) + SIZEOF (.bss) : AT (ADDR (.noinit)) + { + PROVIDE (__noinit_start = .) ; + *(.noinit*) + PROVIDE (__noinit_end = .) ; + _end = . ; + PROVIDE (__heap_start = .) ; + } > data + .eeprom : + { + /* See .data above... */ + KEEP(*(.eeprom*)) + __eeprom_end = . ; + } > eeprom + .fuse : + { + KEEP(*(.fuse)) + KEEP(*(.lfuse)) + KEEP(*(.hfuse)) + KEEP(*(.efuse)) + } > fuse + .lock : + { + KEEP(*(.lock*)) + } > lock + .signature : + { + KEEP(*(.signature*)) + } > signature + .user_signatures : + { + KEEP(*(.user_signatures*)) + } > user_signatures + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .note.gnu.build-id : { *(.note.gnu.build-id) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* DWARF 3 */ + .debug_pubtypes 0 : { *(.debug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges) } + /* DWARF Extension. */ + .debug_macro 0 : { *(.debug_macro) } +} From 5f326f048e02ec8835c2c6ac109d07a29525f97e Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 4 Dec 2019 15:05:55 +0900 Subject: [PATCH 157/217] core: Fix ldscript for AT90USB to support unimap --- ldscript_keymap_avr51.x | 59 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/ldscript_keymap_avr51.x b/ldscript_keymap_avr51.x index 864a4dec..00845bd4 100644 --- a/ldscript_keymap_avr51.x +++ b/ldscript_keymap_avr51.x @@ -14,7 +14,53 @@ __SIGNATURE_REGION_LENGTH__ = DEFINED(__SIGNATURE_REGION_LENGTH__) ? __SIGNATURE __USER_SIGNATURE_REGION_LENGTH__ = DEFINED(__USER_SIGNATURE_REGION_LENGTH__) ? __USER_SIGNATURE_REGION_LENGTH__ : 1K; MEMORY { + /* With keymap section + * + * TODO: should be as below + * Flash Map of AT90USB(128KB) + * +------------+ 0x0000 + * | .vectors | + * | .progmem | + * | .init0-9 | > text region + * | .text | + * | .fini9-0 | + * | | + * |------------| _etext + * | .data | + * | .bss | > data region + * | .noinit | + * | | + * |------------| 0x1D800 + * | .keymap | > keymap region(2KB) + * |------------| 0x1E000 + * | bootloader | 8KB + * +------------+ 0x1FFFF + * + * FIXME: Use this To fit to ATMega32U4 unimap address + * Flash Map of AT90USB(128KB) + * +------------+ 0x0000 + * | .vectors | + * | .progmem | + * | .init0-9 | > text region + * | .text | + * | .fini9-0 | + * | | + * |------------| _etext + * | .data | + * | .bss | > data region + * | .noinit | + * | | + * |------------| 0x6800 + * | .keymap | > keymap region(2KB) + * |------------| 0x7000 + * ~ ~ + * ~ ~ + * |------------| 0x1E000 + * | bootloader | 8KB + * +------------+ 0x1FFFF + */ text (rx) : ORIGIN = 0, LENGTH = __TEXT_REGION_LENGTH__ + keymap (rw!x) : ORIGIN = 0x6800, LENGTH = 2K data (rw!x) : ORIGIN = 0x800100, LENGTH = __DATA_REGION_LENGTH__ eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = __EEPROM_REGION_LENGTH__ fuse (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__ @@ -196,6 +242,19 @@ SECTIONS _end = . ; PROVIDE (__heap_start = .) ; } > data + /* keymap region is located at end of flash + * .fn_actions Fn actions definitions + * .keymaps Mapping layers + */ + .keymap : + { + PROVIDE(__keymap_start = .) ; + *(.keymap.fn_actions) /* 32*actions = 64bytes */ + . = ALIGN(0x40); + *(.keymap.keymaps) /* rest of .keymap section */ + *(.keymap*) + /* . = ALIGN(0x800); */ /* keymap section takes 2KB- */ + } > keymap = 0x00 /* zero fill */ .eeprom : { /* See .data above... */ From 29a80453e7a2f529b94d7dbf98a413993576cfc6 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 4 Dec 2019 15:02:28 +0900 Subject: [PATCH 158/217] core: Fix bootloader for 128KB flash Got warning on bootloader address calculation when MCU has 128KB flash --- common/avr/bootloader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/avr/bootloader.c b/common/avr/bootloader.c index 8a1bec06..8abce9d8 100644 --- a/common/avr/bootloader.c +++ b/common/avr/bootloader.c @@ -138,6 +138,6 @@ void bootloader_jump_after_watchdog_reset(void) #endif // This is compled into 'icall', address should be in word unit, not byte. - ((void (*)(void))(BOOTLOADER_START / 2))(); + ((void (*)(void))( (uint16_t)(BOOTLOADER_START / 2) ))(); } } From 43a86305f9e9ec562fcb9b882c380cbd3b66fc07 Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 3 Feb 2020 12:36:26 +0900 Subject: [PATCH 159/217] core: Fix unimap translation range --- common/unimap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/unimap.c b/common/unimap.c index 84109b5a..fcdc93bd 100644 --- a/common/unimap.c +++ b/common/unimap.c @@ -25,8 +25,8 @@ keypos_t unimap_translate(keypos_t key) unimap_trans[key.row][key.col]; #endif return (keypos_t) { - .row = ((unimap_pos & 0xf0) >> 4), - .col = (unimap_pos & 0x0f) + .row = ((unimap_pos >> 4 ) & 0x07), + .col = (unimap_pos & 0x0F) }; } @@ -35,13 +35,13 @@ __attribute__ ((weak)) action_t action_for_key(uint8_t layer, keypos_t key) { keypos_t uni = unimap_translate(key); - if ((uni.row << 4 | uni.col) == UNIMAP_NO) { + if ((uni.row << 4 | uni.col) > 0x7F) { return (action_t)ACTION_NO; } #if defined(__AVR__) - return (action_t)pgm_read_word(&actionmaps[(layer)][(uni.row & 0x7)][(uni.col)]); + return (action_t)pgm_read_word(&actionmaps[(layer)][(uni.row & 0x07)][(uni.col & 0x0F)]); #else - return actionmaps[(layer)][(uni.row & 0x7)][(uni.col)]; + return actionmaps[(layer)][(uni.row & 0x07)][(uni.col & 0x0F)]; #endif } From 4b96b048327efada062482b93675b3912ae04583 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 7 Feb 2020 15:25:57 +0900 Subject: [PATCH 160/217] lufa: Fix console_putc buffering before host and hid_listen become ready --- protocol/lufa/lufa.c | 55 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index 32bc6981..ac05e75b 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c @@ -120,20 +120,35 @@ static bool console_is_ready(void) static bool console_putc(uint8_t c) { - if (!console_is_ready()) - goto EXIT; - // return immediately if called while interrupt if (!(SREG & (1< Date: Sat, 8 Feb 2020 23:02:42 +0900 Subject: [PATCH 161/217] lufa: Remove old LUFA directory --- protocol/lufa/LUFA-git/.gitignore | 14 - .../LUFA-git/Bootloaders/CDC/BootloaderAPI.c | 75 - .../LUFA-git/Bootloaders/CDC/BootloaderAPI.h | 58 - .../Bootloaders/CDC/BootloaderAPITable.S | 91 - .../LUFA-git/Bootloaders/CDC/BootloaderCDC.c | 641 --- .../LUFA-git/Bootloaders/CDC/BootloaderCDC.h | 144 - .../Bootloaders/CDC/BootloaderCDC.txt | 240 - .../Bootloaders/CDC/Config/AppConfig.h | 50 - .../Bootloaders/CDC/Config/LUFAConfig.h | 93 - .../LUFA-git/Bootloaders/CDC/Descriptors.c | 244 - .../LUFA-git/Bootloaders/CDC/Descriptors.h | 158 - .../Bootloaders/CDC/LUFA CDC Bootloader.inf | 66 - .../lufa/LUFA-git/Bootloaders/CDC/asf.xml | 161 - .../lufa/LUFA-git/Bootloaders/CDC/doxyfile | 2365 ---------- .../lufa/LUFA-git/Bootloaders/CDC/makefile | 55 - .../LUFA-git/Bootloaders/DFU/BootloaderAPI.c | 76 - .../LUFA-git/Bootloaders/DFU/BootloaderAPI.h | 58 - .../Bootloaders/DFU/BootloaderAPITable.S | 91 - .../LUFA-git/Bootloaders/DFU/BootloaderDFU.c | 804 ---- .../LUFA-git/Bootloaders/DFU/BootloaderDFU.h | 216 - .../Bootloaders/DFU/BootloaderDFU.txt | 233 - .../Bootloaders/DFU/Config/AppConfig.h | 48 - .../Bootloaders/DFU/Config/LUFAConfig.h | 93 - .../LUFA-git/Bootloaders/DFU/Descriptors.c | 185 - .../LUFA-git/Bootloaders/DFU/Descriptors.h | 194 - .../lufa/LUFA-git/Bootloaders/DFU/asf.xml | 156 - .../lufa/LUFA-git/Bootloaders/DFU/doxyfile | 2365 ---------- .../lufa/LUFA-git/Bootloaders/DFU/makefile | 55 - .../LUFA-git/Bootloaders/HID/BootloaderHID.c | 190 - .../LUFA-git/Bootloaders/HID/BootloaderHID.h | 73 - .../Bootloaders/HID/BootloaderHID.txt | 105 - .../Bootloaders/HID/Config/LUFAConfig.h | 93 - .../LUFA-git/Bootloaders/HID/Descriptors.c | 187 - .../LUFA-git/Bootloaders/HID/Descriptors.h | 80 - .../Bootloaders/HID/HostLoaderApp/Makefile | 39 - .../HID/HostLoaderApp/Makefile.bsd | 21 - .../Bootloaders/HID/HostLoaderApp/gpl3.txt | 674 --- .../HID/HostLoaderApp/hid_bootloader_cli.c | 1010 ---- .../hid_bootloader_loader.py | 120 - .../lufa/LUFA-git/Bootloaders/HID/asf.xml | 123 - .../lufa/LUFA-git/Bootloaders/HID/doxyfile | 2367 ---------- .../lufa/LUFA-git/Bootloaders/HID/makefile | 48 - .../Bootloaders/MassStorage/BootloaderAPI.c | 76 - .../Bootloaders/MassStorage/BootloaderAPI.h | 63 - .../MassStorage/BootloaderAPITable.S | 102 - .../MassStorage/BootloaderMassStorage.c | 238 - .../MassStorage/BootloaderMassStorage.h | 99 - .../MassStorage/BootloaderMassStorage.txt | 225 - .../MassStorage/Config/AppConfig.h | 47 - .../MassStorage/Config/LUFAConfig.h | 93 - .../Bootloaders/MassStorage/Descriptors.c | 157 - .../Bootloaders/MassStorage/Descriptors.h | 88 - .../Bootloaders/MassStorage/Lib/SCSI.c | 294 -- .../Bootloaders/MassStorage/Lib/SCSI.h | 84 - .../Bootloaders/MassStorage/Lib/VirtualFAT.c | 482 -- .../Bootloaders/MassStorage/Lib/VirtualFAT.h | 302 -- .../LUFA-git/Bootloaders/MassStorage/asf.xml | 156 - .../LUFA-git/Bootloaders/MassStorage/doxyfile | 2365 ---------- .../LUFA-git/Bootloaders/MassStorage/makefile | 68 - .../Bootloaders/Printer/BootloaderAPI.c | 75 - .../Bootloaders/Printer/BootloaderAPI.h | 56 - .../Bootloaders/Printer/BootloaderAPITable.S | 91 - .../Bootloaders/Printer/BootloaderPrinter.c | 431 -- .../Bootloaders/Printer/BootloaderPrinter.h | 108 - .../Bootloaders/Printer/BootloaderPrinter.txt | 190 - .../Bootloaders/Printer/Config/LUFAConfig.h | 93 - .../Bootloaders/Printer/Descriptors.c | 194 - .../Bootloaders/Printer/Descriptors.h | 96 - .../lufa/LUFA-git/Bootloaders/Printer/asf.xml | 159 - .../LUFA-git/Bootloaders/Printer/doxyfile | 2365 ---------- .../LUFA-git/Bootloaders/Printer/makefile | 55 - protocol/lufa/LUFA-git/Bootloaders/makefile | 46 - .../BuildTests/BoardDriverTest/Board/Board.h | 82 - .../BoardDriverTest/Board/Buttons.h | 92 - .../BoardDriverTest/Board/Dataflash.h | 197 - .../BoardDriverTest/Board/Joystick.h | 104 - .../BuildTests/BoardDriverTest/Board/LEDs.h | 132 - .../BoardDriverTest/BoardDeviceMap.cfg | 87 - .../BuildTests/BoardDriverTest/Test.c | 115 - .../BuildTests/BoardDriverTest/makefile | 68 - .../BuildTests/BoardDriverTest/makefile.test | 27 - .../BootloaderTest/BootloaderDeviceMap.cfg | 167 - .../BuildTests/BootloaderTest/makefile | 64 - .../LUFA-git/BuildTests/ModuleTest/Dummy.S | 41 - .../LUFA-git/BuildTests/ModuleTest/Modules.h | 56 - .../LUFA-git/BuildTests/ModuleTest/Test_C.c | 31 - .../BuildTests/ModuleTest/Test_CPP.cpp | 31 - .../LUFA-git/BuildTests/ModuleTest/makefile | 66 - .../BuildTests/ModuleTest/makefile.test | 88 - .../BuildTests/SingleUSBModeTest/Dummy.S | 42 - .../BuildTests/SingleUSBModeTest/Test.c | 32 - .../BuildTests/SingleUSBModeTest/makefile | 56 - .../SingleUSBModeTest/makefile.test | 69 - .../BuildTests/StaticAnalysisTest/makefile | 47 - protocol/lufa/LUFA-git/BuildTests/makefile | 24 - .../ClassDriver/AudioInput/AudioInput.c | 274 -- .../ClassDriver/AudioInput/AudioInput.h | 94 - .../ClassDriver/AudioInput/AudioInput.txt | 92 - .../ClassDriver/AudioInput/Config/AppConfig.h | 51 - .../AudioInput/Config/LUFAConfig.h | 93 - .../ClassDriver/AudioInput/Descriptors.c | 312 -- .../ClassDriver/AudioInput/Descriptors.h | 106 - .../Device/ClassDriver/AudioInput/asf.xml | 52 - .../Device/ClassDriver/AudioInput/doxyfile | 2364 ---------- .../Device/ClassDriver/AudioInput/makefile | 38 - .../ClassDriver/AudioOutput/AudioOutput.c | 311 -- .../ClassDriver/AudioOutput/AudioOutput.h | 87 - .../ClassDriver/AudioOutput/AudioOutput.txt | 92 - .../AudioOutput/Config/AppConfig.h | 50 - .../AudioOutput/Config/LUFAConfig.h | 93 - .../ClassDriver/AudioOutput/Descriptors.c | 312 -- .../ClassDriver/AudioOutput/Descriptors.h | 106 - .../Device/ClassDriver/AudioOutput/asf.xml | 50 - .../Device/ClassDriver/AudioOutput/doxyfile | 2364 ---------- .../Device/ClassDriver/AudioOutput/makefile | 38 - .../ClassDriver/DualMIDI/Config/LUFAConfig.h | 126 - .../Device/ClassDriver/DualMIDI/Descriptors.c | 366 -- .../Device/ClassDriver/DualMIDI/Descriptors.h | 124 - .../Device/ClassDriver/DualMIDI/DualMIDI.c | 211 - .../Device/ClassDriver/DualMIDI/DualMIDI.h | 78 - .../Device/ClassDriver/DualMIDI/DualMIDI.txt | 78 - .../Demos/Device/ClassDriver/DualMIDI/asf.xml | 62 - .../Device/ClassDriver/DualMIDI/doxyfile | 2364 ---------- .../Device/ClassDriver/DualMIDI/makefile | 38 - .../DualVirtualSerial/Config/LUFAConfig.h | 126 - .../DualVirtualSerial/Descriptors.c | 360 -- .../DualVirtualSerial/Descriptors.h | 135 - .../DualVirtualSerial/DualVirtualSerial.c | 218 - .../DualVirtualSerial/DualVirtualSerial.h | 76 - .../DualVirtualSerial/DualVirtualSerial.txt | 89 - .../LUFA DualVirtualSerial.inf | 66 - .../ClassDriver/DualVirtualSerial/asf.xml | 62 - .../ClassDriver/DualVirtualSerial/doxyfile | 2364 ---------- .../ClassDriver/DualVirtualSerial/makefile | 38 - .../ClassDriver/GenericHID/Config/AppConfig.h | 48 - .../GenericHID/Config/LUFAConfig.h | 126 - .../ClassDriver/GenericHID/Descriptors.c | 220 - .../ClassDriver/GenericHID/Descriptors.h | 95 - .../ClassDriver/GenericHID/GenericHID.c | 202 - .../ClassDriver/GenericHID/GenericHID.h | 87 - .../ClassDriver/GenericHID/GenericHID.txt | 79 - .../HostTestApp/test_generic_hid_libusb.js | 143 - .../HostTestApp/test_generic_hid_libusb.py | 98 - .../HostTestApp/test_generic_hid_winusb.py | 96 - .../Device/ClassDriver/GenericHID/asf.xml | 63 - .../Device/ClassDriver/GenericHID/doxyfile | 2365 ---------- .../Device/ClassDriver/GenericHID/makefile | 38 - .../ClassDriver/Joystick/Config/LUFAConfig.h | 126 - .../Device/ClassDriver/Joystick/Descriptors.c | 220 - .../Device/ClassDriver/Joystick/Descriptors.h | 93 - .../Device/ClassDriver/Joystick/Joystick.c | 202 - .../Device/ClassDriver/Joystick/Joystick.h | 100 - .../Device/ClassDriver/Joystick/Joystick.txt | 77 - .../Demos/Device/ClassDriver/Joystick/asf.xml | 62 - .../Device/ClassDriver/Joystick/doxyfile | 2364 ---------- .../Device/ClassDriver/Joystick/makefile | 38 - .../ClassDriver/Keyboard/Config/LUFAConfig.h | 126 - .../Device/ClassDriver/Keyboard/Descriptors.c | 216 - .../Device/ClassDriver/Keyboard/Descriptors.h | 93 - .../Device/ClassDriver/Keyboard/Keyboard.c | 219 - .../Device/ClassDriver/Keyboard/Keyboard.h | 89 - .../Device/ClassDriver/Keyboard/Keyboard.txt | 76 - .../Demos/Device/ClassDriver/Keyboard/asf.xml | 62 - .../Device/ClassDriver/Keyboard/doxyfile | 2364 ---------- .../Device/ClassDriver/Keyboard/makefile | 38 - .../KeyboardMouse/Config/LUFAConfig.h | 126 - .../ClassDriver/KeyboardMouse/Descriptors.c | 289 -- .../ClassDriver/KeyboardMouse/Descriptors.h | 102 - .../ClassDriver/KeyboardMouse/KeyboardMouse.c | 276 -- .../ClassDriver/KeyboardMouse/KeyboardMouse.h | 84 - .../KeyboardMouse/KeyboardMouse.txt | 81 - .../Device/ClassDriver/KeyboardMouse/asf.xml | 62 - .../Device/ClassDriver/KeyboardMouse/doxyfile | 2364 ---------- .../Device/ClassDriver/KeyboardMouse/makefile | 38 - .../Config/LUFAConfig.h | 126 - .../KeyboardMouseMultiReport/Descriptors.c | 279 -- .../KeyboardMouseMultiReport/Descriptors.h | 101 - .../KeyboardMouseMultiReport.c | 237 - .../KeyboardMouseMultiReport.h | 84 - .../KeyboardMouseMultiReport.txt | 78 - .../KeyboardMouseMultiReport/asf.xml | 61 - .../KeyboardMouseMultiReport/doxyfile | 2364 ---------- .../KeyboardMouseMultiReport/makefile | 38 - .../ClassDriver/MIDI/Config/LUFAConfig.h | 126 - .../Device/ClassDriver/MIDI/Descriptors.c | 314 -- .../Device/ClassDriver/MIDI/Descriptors.h | 108 - .../Demos/Device/ClassDriver/MIDI/MIDI.c | 211 - .../Demos/Device/ClassDriver/MIDI/MIDI.h | 78 - .../Demos/Device/ClassDriver/MIDI/MIDI.txt | 78 - .../Demos/Device/ClassDriver/MIDI/asf.xml | 62 - .../Demos/Device/ClassDriver/MIDI/doxyfile | 2364 ---------- .../Demos/Device/ClassDriver/MIDI/makefile | 38 - .../MassStorage/Config/AppConfig.h | 50 - .../MassStorage/Config/LUFAConfig.h | 126 - .../ClassDriver/MassStorage/Descriptors.c | 194 - .../ClassDriver/MassStorage/Descriptors.h | 98 - .../MassStorage/Lib/DataflashManager.c | 534 --- .../MassStorage/Lib/DataflashManager.h | 89 - .../Device/ClassDriver/MassStorage/Lib/SCSI.c | 349 -- .../Device/ClassDriver/MassStorage/Lib/SCSI.h | 89 - .../ClassDriver/MassStorage/MassStorage.c | 162 - .../ClassDriver/MassStorage/MassStorage.h | 83 - .../ClassDriver/MassStorage/MassStorage.txt | 100 - .../Device/ClassDriver/MassStorage/asf.xml | 67 - .../Device/ClassDriver/MassStorage/doxyfile | 2364 ---------- .../Device/ClassDriver/MassStorage/makefile | 38 - .../MassStorageKeyboard/Config/AppConfig.h | 50 - .../MassStorageKeyboard/Config/LUFAConfig.h | 126 - .../MassStorageKeyboard/Descriptors.c | 254 - .../MassStorageKeyboard/Descriptors.h | 111 - .../Lib/DataflashManager.c | 534 --- .../Lib/DataflashManager.h | 87 - .../MassStorageKeyboard/Lib/SCSI.c | 349 -- .../MassStorageKeyboard/Lib/SCSI.h | 89 - .../MassStorageKeyboard/MassStorageKeyboard.c | 270 -- .../MassStorageKeyboard/MassStorageKeyboard.h | 100 - .../MassStorageKeyboard.txt | 100 - .../ClassDriver/MassStorageKeyboard/asf.xml | 70 - .../ClassDriver/MassStorageKeyboard/doxyfile | 2364 ---------- .../ClassDriver/MassStorageKeyboard/makefile | 38 - .../ClassDriver/Mouse/Config/LUFAConfig.h | 126 - .../Device/ClassDriver/Mouse/Descriptors.c | 221 - .../Device/ClassDriver/Mouse/Descriptors.h | 93 - .../Demos/Device/ClassDriver/Mouse/Mouse.c | 202 - .../Demos/Device/ClassDriver/Mouse/Mouse.h | 90 - .../Demos/Device/ClassDriver/Mouse/Mouse.txt | 76 - .../Demos/Device/ClassDriver/Mouse/asf.xml | 62 - .../Demos/Device/ClassDriver/Mouse/doxyfile | 2364 ---------- .../Demos/Device/ClassDriver/Mouse/makefile | 38 - .../RNDISEthernet/Config/AppConfig.h | 60 - .../RNDISEthernet/Config/LUFAConfig.h | 126 - .../ClassDriver/RNDISEthernet/Descriptors.c | 244 - .../ClassDriver/RNDISEthernet/Descriptors.h | 112 - .../ClassDriver/RNDISEthernet/LUFA RNDIS.inf | 59 - .../ClassDriver/RNDISEthernet/Lib/ARP.c | 87 - .../ClassDriver/RNDISEthernet/Lib/ARP.h | 76 - .../ClassDriver/RNDISEthernet/Lib/DHCP.c | 121 - .../ClassDriver/RNDISEthernet/Lib/DHCP.h | 128 - .../ClassDriver/RNDISEthernet/Lib/Ethernet.c | 132 - .../ClassDriver/RNDISEthernet/Lib/Ethernet.h | 101 - .../RNDISEthernet/Lib/EthernetProtocols.h | 92 - .../ClassDriver/RNDISEthernet/Lib/ICMP.c | 83 - .../ClassDriver/RNDISEthernet/Lib/ICMP.h | 83 - .../Device/ClassDriver/RNDISEthernet/Lib/IP.c | 116 - .../Device/ClassDriver/RNDISEthernet/Lib/IP.h | 93 - .../RNDISEthernet/Lib/ProtocolDecoders.c | 277 -- .../RNDISEthernet/Lib/ProtocolDecoders.h | 60 - .../ClassDriver/RNDISEthernet/Lib/TCP.c | 632 --- .../ClassDriver/RNDISEthernet/Lib/TCP.h | 260 -- .../ClassDriver/RNDISEthernet/Lib/UDP.c | 84 - .../ClassDriver/RNDISEthernet/Lib/UDP.h | 70 - .../ClassDriver/RNDISEthernet/Lib/Webserver.c | 203 - .../ClassDriver/RNDISEthernet/Lib/Webserver.h | 57 - .../ClassDriver/RNDISEthernet/RNDISEthernet.c | 179 - .../ClassDriver/RNDISEthernet/RNDISEthernet.h | 84 - .../RNDISEthernet/RNDISEthernet.txt | 146 - .../Device/ClassDriver/RNDISEthernet/asf.xml | 80 - .../Device/ClassDriver/RNDISEthernet/doxyfile | 2364 ---------- .../Device/ClassDriver/RNDISEthernet/makefile | 39 - .../VirtualSerial/Config/LUFAConfig.h | 126 - .../ClassDriver/VirtualSerial/Descriptors.c | 245 - .../ClassDriver/VirtualSerial/Descriptors.h | 110 - .../VirtualSerial/LUFA VirtualSerial.inf | 66 - .../ClassDriver/VirtualSerial/VirtualSerial.c | 187 - .../ClassDriver/VirtualSerial/VirtualSerial.h | 77 - .../VirtualSerial/VirtualSerial.txt | 76 - .../Device/ClassDriver/VirtualSerial/asf.xml | 62 - .../Device/ClassDriver/VirtualSerial/doxyfile | 2364 ---------- .../Device/ClassDriver/VirtualSerial/makefile | 38 - .../Config/AppConfig.h | 50 - .../Config/LUFAConfig.h | 126 - .../VirtualSerialMassStorage/Descriptors.c | 295 -- .../VirtualSerialMassStorage/Descriptors.h | 128 - .../LUFA VirtualSerialMassStorage.inf | 66 - .../Lib/DataflashManager.c | 534 --- .../Lib/DataflashManager.h | 89 - .../VirtualSerialMassStorage/Lib/SCSI.c | 349 -- .../VirtualSerialMassStorage/Lib/SCSI.h | 89 - .../VirtualSerialMassStorage.c | 241 - .../VirtualSerialMassStorage.h | 83 - .../VirtualSerialMassStorage.txt | 93 - .../VirtualSerialMassStorage/asf.xml | 70 - .../VirtualSerialMassStorage/doxyfile | 2364 ---------- .../VirtualSerialMassStorage/makefile | 38 - .../VirtualSerialMouse/Config/LUFAConfig.h | 126 - .../VirtualSerialMouse/Descriptors.c | 323 -- .../VirtualSerialMouse/Descriptors.h | 123 - .../LUFA VirtualSerialMouse.inf | 66 - .../VirtualSerialMouse/VirtualSerialMouse.c | 267 -- .../VirtualSerialMouse/VirtualSerialMouse.h | 88 - .../VirtualSerialMouse/VirtualSerialMouse.txt | 79 - .../ClassDriver/VirtualSerialMouse/asf.xml | 64 - .../ClassDriver/VirtualSerialMouse/doxyfile | 2364 ---------- .../ClassDriver/VirtualSerialMouse/makefile | 38 - .../Demos/Device/ClassDriver/makefile | 46 - .../TestAndMeasurement/Config/LUFAConfig.h | 126 - .../TestAndMeasurement/Descriptors.c | 205 - .../TestAndMeasurement/Descriptors.h | 104 - .../TestAndMeasurement/TestAndMeasurement.c | 476 -- .../TestAndMeasurement/TestAndMeasurement.h | 150 - .../Incomplete/TestAndMeasurement/makefile | 38 - .../Device/LowLevel/AudioInput/AudioInput.c | 259 -- .../Device/LowLevel/AudioInput/AudioInput.h | 82 - .../Device/LowLevel/AudioInput/AudioInput.txt | 87 - .../LowLevel/AudioInput/Config/AppConfig.h | 51 - .../LowLevel/AudioInput/Config/LUFAConfig.h | 93 - .../Device/LowLevel/AudioInput/Descriptors.c | 312 -- .../Device/LowLevel/AudioInput/Descriptors.h | 106 - .../Demos/Device/LowLevel/AudioInput/asf.xml | 52 - .../Demos/Device/LowLevel/AudioInput/doxyfile | 2364 ---------- .../Demos/Device/LowLevel/AudioInput/makefile | 38 - .../Device/LowLevel/AudioOutput/AudioOutput.c | 293 -- .../Device/LowLevel/AudioOutput/AudioOutput.h | 74 - .../LowLevel/AudioOutput/AudioOutput.txt | 92 - .../LowLevel/AudioOutput/Config/AppConfig.h | 50 - .../LowLevel/AudioOutput/Config/LUFAConfig.h | 93 - .../Device/LowLevel/AudioOutput/Descriptors.c | 312 -- .../Device/LowLevel/AudioOutput/Descriptors.h | 106 - .../Demos/Device/LowLevel/AudioOutput/asf.xml | 51 - .../Device/LowLevel/AudioOutput/doxyfile | 2364 ---------- .../Device/LowLevel/AudioOutput/makefile | 38 - .../Device/LowLevel/BulkVendor/BulkVendor.c | 136 - .../Device/LowLevel/BulkVendor/BulkVendor.h | 76 - .../Device/LowLevel/BulkVendor/BulkVendor.txt | 69 - .../LowLevel/BulkVendor/Config/LUFAConfig.h | 126 - .../Device/LowLevel/BulkVendor/Descriptors.c | 194 - .../Device/LowLevel/BulkVendor/Descriptors.h | 96 - .../HostTestApp/test_bulk_vendor.py | 67 - .../WindowsDriver/LUFA_Bulk_Vendor_Demo.inf | Bin 8150 -> 0 bytes .../WindowsDriver/amd64/libusb0.dll | Bin 76384 -> 0 bytes .../WindowsDriver/amd64/libusb0.sys | Bin 52832 -> 0 bytes .../BulkVendor/WindowsDriver/ia64/libusb0.dll | Bin 157792 -> 0 bytes .../BulkVendor/WindowsDriver/ia64/libusb0.sys | Bin 110176 -> 0 bytes .../WindowsDriver/installer_x64.exe | Bin 25088 -> 0 bytes .../WindowsDriver/installer_x86.exe | Bin 23552 -> 0 bytes .../license/libusb0/installer_license.txt | 851 ---- .../BulkVendor/WindowsDriver/x86/libusb0.sys | Bin 42592 -> 0 bytes .../WindowsDriver/x86/libusb0_x86.dll | Bin 67680 -> 0 bytes .../Demos/Device/LowLevel/BulkVendor/asf.xml | 61 - .../Demos/Device/LowLevel/BulkVendor/doxyfile | 2366 ---------- .../Demos/Device/LowLevel/BulkVendor/makefile | 38 - .../DualVirtualSerial/Config/LUFAConfig.h | 126 - .../LowLevel/DualVirtualSerial/Descriptors.c | 360 -- .../LowLevel/DualVirtualSerial/Descriptors.h | 135 - .../DualVirtualSerial/DualVirtualSerial.c | 299 -- .../DualVirtualSerial/DualVirtualSerial.h | 77 - .../DualVirtualSerial/DualVirtualSerial.txt | 89 - .../LUFA DualVirtualSerial.inf | 66 - .../Device/LowLevel/DualVirtualSerial/asf.xml | 62 - .../LowLevel/DualVirtualSerial/doxyfile | 2364 ---------- .../LowLevel/DualVirtualSerial/makefile | 38 - .../LowLevel/GenericHID/Config/AppConfig.h | 48 - .../LowLevel/GenericHID/Config/LUFAConfig.h | 126 - .../Device/LowLevel/GenericHID/Descriptors.c | 238 - .../Device/LowLevel/GenericHID/Descriptors.h | 99 - .../Device/LowLevel/GenericHID/GenericHID.c | 253 - .../Device/LowLevel/GenericHID/GenericHID.h | 81 - .../Device/LowLevel/GenericHID/GenericHID.txt | 79 - .../HostTestApp/test_generic_hid.py | 96 - .../Demos/Device/LowLevel/GenericHID/asf.xml | 63 - .../Demos/Device/LowLevel/GenericHID/doxyfile | 2365 ---------- .../Demos/Device/LowLevel/GenericHID/makefile | 38 - .../LowLevel/Joystick/Config/LUFAConfig.h | 126 - .../Device/LowLevel/Joystick/Descriptors.c | 240 - .../Device/LowLevel/Joystick/Descriptors.h | 99 - .../Demos/Device/LowLevel/Joystick/Joystick.c | 217 - .../Demos/Device/LowLevel/Joystick/Joystick.h | 91 - .../Device/LowLevel/Joystick/Joystick.txt | 77 - .../Demos/Device/LowLevel/Joystick/asf.xml | 62 - .../Demos/Device/LowLevel/Joystick/doxyfile | 2364 ---------- .../Demos/Device/LowLevel/Joystick/makefile | 38 - .../LowLevel/Keyboard/Config/LUFAConfig.h | 126 - .../Device/LowLevel/Keyboard/Descriptors.c | 255 - .../Device/LowLevel/Keyboard/Descriptors.h | 98 - .../Demos/Device/LowLevel/Keyboard/Keyboard.c | 383 -- .../Demos/Device/LowLevel/Keyboard/Keyboard.h | 85 - .../Device/LowLevel/Keyboard/Keyboard.txt | 76 - .../Demos/Device/LowLevel/Keyboard/asf.xml | 62 - .../Demos/Device/LowLevel/Keyboard/doxyfile | 2364 ---------- .../Demos/Device/LowLevel/Keyboard/makefile | 38 - .../KeyboardMouse/Config/LUFAConfig.h | 126 - .../LowLevel/KeyboardMouse/Descriptors.c | 346 -- .../LowLevel/KeyboardMouse/Descriptors.h | 107 - .../LowLevel/KeyboardMouse/KeyboardMouse.c | 321 -- .../LowLevel/KeyboardMouse/KeyboardMouse.h | 77 - .../LowLevel/KeyboardMouse/KeyboardMouse.txt | 81 - .../Device/LowLevel/KeyboardMouse/asf.xml | 62 - .../Device/LowLevel/KeyboardMouse/doxyfile | 2364 ---------- .../Device/LowLevel/KeyboardMouse/makefile | 38 - .../Device/LowLevel/MIDI/Config/LUFAConfig.h | 126 - .../Demos/Device/LowLevel/MIDI/Descriptors.c | 314 -- .../Demos/Device/LowLevel/MIDI/Descriptors.h | 108 - .../Demos/Device/LowLevel/MIDI/MIDI.c | 224 - .../Demos/Device/LowLevel/MIDI/MIDI.h | 76 - .../Demos/Device/LowLevel/MIDI/MIDI.txt | 78 - .../Demos/Device/LowLevel/MIDI/asf.xml | 62 - .../Demos/Device/LowLevel/MIDI/doxyfile | 2364 ---------- .../Demos/Device/LowLevel/MIDI/makefile | 38 - .../LowLevel/MassStorage/Config/AppConfig.h | 50 - .../LowLevel/MassStorage/Config/LUFAConfig.h | 126 - .../Device/LowLevel/MassStorage/Descriptors.c | 194 - .../Device/LowLevel/MassStorage/Descriptors.h | 98 - .../MassStorage/Lib/DataflashManager.c | 530 --- .../MassStorage/Lib/DataflashManager.h | 86 - .../Device/LowLevel/MassStorage/Lib/SCSI.c | 344 -- .../Device/LowLevel/MassStorage/Lib/SCSI.h | 150 - .../Device/LowLevel/MassStorage/MassStorage.c | 332 -- .../Device/LowLevel/MassStorage/MassStorage.h | 92 - .../LowLevel/MassStorage/MassStorage.txt | 100 - .../Demos/Device/LowLevel/MassStorage/asf.xml | 67 - .../Device/LowLevel/MassStorage/doxyfile | 2364 ---------- .../Device/LowLevel/MassStorage/makefile | 38 - .../Device/LowLevel/Mouse/Config/LUFAConfig.h | 126 - .../Demos/Device/LowLevel/Mouse/Descriptors.c | 240 - .../Demos/Device/LowLevel/Mouse/Descriptors.h | 93 - .../Demos/Device/LowLevel/Mouse/Mouse.c | 311 -- .../Demos/Device/LowLevel/Mouse/Mouse.h | 81 - .../Demos/Device/LowLevel/Mouse/Mouse.txt | 76 - .../Demos/Device/LowLevel/Mouse/asf.xml | 62 - .../Demos/Device/LowLevel/Mouse/doxyfile | 2364 ---------- .../Demos/Device/LowLevel/Mouse/makefile | 38 - .../LowLevel/RNDISEthernet/Config/AppConfig.h | 60 - .../RNDISEthernet/Config/LUFAConfig.h | 126 - .../LowLevel/RNDISEthernet/Descriptors.c | 244 - .../LowLevel/RNDISEthernet/Descriptors.h | 112 - .../LowLevel/RNDISEthernet/LUFA RNDIS.inf | 59 - .../Device/LowLevel/RNDISEthernet/Lib/ARP.c | 87 - .../Device/LowLevel/RNDISEthernet/Lib/ARP.h | 78 - .../Device/LowLevel/RNDISEthernet/Lib/DHCP.c | 121 - .../Device/LowLevel/RNDISEthernet/Lib/DHCP.h | 128 - .../LowLevel/RNDISEthernet/Lib/Ethernet.c | 136 - .../LowLevel/RNDISEthernet/Lib/Ethernet.h | 111 - .../RNDISEthernet/Lib/EthernetProtocols.h | 88 - .../Device/LowLevel/RNDISEthernet/Lib/ICMP.c | 81 - .../Device/LowLevel/RNDISEthernet/Lib/ICMP.h | 82 - .../Device/LowLevel/RNDISEthernet/Lib/IP.c | 113 - .../Device/LowLevel/RNDISEthernet/Lib/IP.h | 92 - .../RNDISEthernet/Lib/ProtocolDecoders.c | 276 -- .../RNDISEthernet/Lib/ProtocolDecoders.h | 60 - .../Device/LowLevel/RNDISEthernet/Lib/RNDIS.c | 394 -- .../Device/LowLevel/RNDISEthernet/Lib/RNDIS.h | 67 - .../Device/LowLevel/RNDISEthernet/Lib/TCP.c | 631 --- .../Device/LowLevel/RNDISEthernet/Lib/TCP.h | 260 -- .../Device/LowLevel/RNDISEthernet/Lib/UDP.c | 84 - .../Device/LowLevel/RNDISEthernet/Lib/UDP.h | 73 - .../LowLevel/RNDISEthernet/Lib/Webserver.c | 203 - .../LowLevel/RNDISEthernet/Lib/Webserver.h | 57 - .../LowLevel/RNDISEthernet/RNDISEthernet.c | 294 -- .../LowLevel/RNDISEthernet/RNDISEthernet.h | 87 - .../LowLevel/RNDISEthernet/RNDISEthernet.txt | 146 - .../Device/LowLevel/RNDISEthernet/asf.xml | 85 - .../Device/LowLevel/RNDISEthernet/doxyfile | 2364 ---------- .../Device/LowLevel/RNDISEthernet/makefile | 39 - .../VirtualSerial/Config/LUFAConfig.h | 126 - .../LowLevel/VirtualSerial/Descriptors.c | 245 - .../LowLevel/VirtualSerial/Descriptors.h | 110 - .../VirtualSerial/LUFA VirtualSerial.inf | 66 - .../LowLevel/VirtualSerial/VirtualSerial.c | 243 - .../LowLevel/VirtualSerial/VirtualSerial.h | 76 - .../LowLevel/VirtualSerial/VirtualSerial.txt | 76 - .../Device/LowLevel/VirtualSerial/asf.xml | 63 - .../Device/LowLevel/VirtualSerial/doxyfile | 2364 ---------- .../Device/LowLevel/VirtualSerial/makefile | 38 - .../LUFA-git/Demos/Device/LowLevel/makefile | 46 - protocol/lufa/LUFA-git/Demos/Device/makefile | 21 - .../MouseHostDevice/Config/LUFAConfig.h | 93 - .../ClassDriver/MouseHostDevice/Descriptors.c | 221 - .../ClassDriver/MouseHostDevice/Descriptors.h | 93 - .../MouseHostDevice/DeviceFunctions.c | 155 - .../MouseHostDevice/DeviceFunctions.h | 64 - .../MouseHostDevice/HostFunctions.c | 184 - .../MouseHostDevice/HostFunctions.h | 56 - .../MouseHostDevice/MouseHostDevice.c | 99 - .../MouseHostDevice/MouseHostDevice.h | 78 - .../MouseHostDevice/MouseHostDevice.txt | 80 - .../ClassDriver/MouseHostDevice/asf.xml | 56 - .../ClassDriver/MouseHostDevice/doxyfile | 2364 ---------- .../ClassDriver/MouseHostDevice/makefile | 38 - .../Demos/DualRole/ClassDriver/makefile | 46 - .../lufa/LUFA-git/Demos/DualRole/makefile | 20 - .../AndroidAccessoryHost.c | 239 - .../AndroidAccessoryHost.h | 79 - .../AndroidAccessoryHost.txt | 62 - .../AndroidHostApp/AndroidHostApp.zip | Bin 552813 -> 0 bytes .../AndroidAccessoryHost/Config/LUFAConfig.h | 93 - .../ClassDriver/AndroidAccessoryHost/asf.xml | 49 - .../ClassDriver/AndroidAccessoryHost/doxyfile | 2364 ---------- .../ClassDriver/AndroidAccessoryHost/makefile | 38 - .../AudioInputHost/AudioInputHost.c | 239 - .../AudioInputHost/AudioInputHost.h | 77 - .../AudioInputHost/AudioInputHost.txt | 66 - .../AudioInputHost/Config/LUFAConfig.h | 93 - .../Host/ClassDriver/AudioInputHost/asf.xml | 48 - .../Host/ClassDriver/AudioInputHost/doxyfile | 2364 ---------- .../Host/ClassDriver/AudioInputHost/makefile | 38 - .../AudioOutputHost/AudioOutputHost.c | 243 - .../AudioOutputHost/AudioOutputHost.h | 87 - .../AudioOutputHost/AudioOutputHost.txt | 83 - .../AudioOutputHost/Config/AppConfig.h | 51 - .../AudioOutputHost/Config/LUFAConfig.h | 93 - .../Host/ClassDriver/AudioOutputHost/asf.xml | 52 - .../Host/ClassDriver/AudioOutputHost/doxyfile | 2364 ---------- .../Host/ClassDriver/AudioOutputHost/makefile | 38 - .../Config/LUFAConfig.h | 93 - .../JoystickHostWithParser.c | 286 -- .../JoystickHostWithParser.h | 95 - .../JoystickHostWithParser.txt | 71 - .../JoystickHostWithParser/asf.xml | 48 - .../JoystickHostWithParser/doxyfile | 2364 ---------- .../JoystickHostWithParser/makefile | 38 - .../KeyboardHost/Config/LUFAConfig.h | 93 - .../ClassDriver/KeyboardHost/KeyboardHost.c | 244 - .../ClassDriver/KeyboardHost/KeyboardHost.h | 78 - .../ClassDriver/KeyboardHost/KeyboardHost.txt | 71 - .../Host/ClassDriver/KeyboardHost/asf.xml | 48 - .../Host/ClassDriver/KeyboardHost/doxyfile | 2364 ---------- .../Host/ClassDriver/KeyboardHost/makefile | 38 - .../Config/LUFAConfig.h | 93 - .../KeyboardHostWithParser.c | 287 -- .../KeyboardHostWithParser.h | 83 - .../KeyboardHostWithParser.txt | 71 - .../KeyboardHostWithParser/asf.xml | 48 - .../KeyboardHostWithParser/doxyfile | 2364 ---------- .../KeyboardHostWithParser/makefile | 38 - .../ClassDriver/MIDIHost/Config/LUFAConfig.h | 93 - .../Host/ClassDriver/MIDIHost/MIDIHost.c | 272 -- .../Host/ClassDriver/MIDIHost/MIDIHost.h | 81 - .../Host/ClassDriver/MIDIHost/MIDIHost.txt | 60 - .../Demos/Host/ClassDriver/MIDIHost/asf.xml | 50 - .../Demos/Host/ClassDriver/MIDIHost/doxyfile | 2364 ---------- .../Demos/Host/ClassDriver/MIDIHost/makefile | 38 - .../MassStorageHost/Config/LUFAConfig.h | 93 - .../MassStorageHost/MassStorageHost.c | 311 -- .../MassStorageHost/MassStorageHost.h | 82 - .../MassStorageHost/MassStorageHost.txt | 68 - .../Host/ClassDriver/MassStorageHost/asf.xml | 48 - .../Host/ClassDriver/MassStorageHost/doxyfile | 2364 ---------- .../Host/ClassDriver/MassStorageHost/makefile | 38 - .../ClassDriver/MouseHost/Config/LUFAConfig.h | 93 - .../Host/ClassDriver/MouseHost/MouseHost.c | 227 - .../Host/ClassDriver/MouseHost/MouseHost.h | 78 - .../Host/ClassDriver/MouseHost/MouseHost.txt | 74 - .../Demos/Host/ClassDriver/MouseHost/asf.xml | 48 - .../Demos/Host/ClassDriver/MouseHost/doxyfile | 2364 ---------- .../Demos/Host/ClassDriver/MouseHost/makefile | 38 - .../MouseHostWithParser/Config/LUFAConfig.h | 93 - .../MouseHostWithParser/MouseHostWithParser.c | 295 -- .../MouseHostWithParser/MouseHostWithParser.h | 98 - .../MouseHostWithParser.txt | 71 - .../ClassDriver/MouseHostWithParser/asf.xml | 48 - .../ClassDriver/MouseHostWithParser/doxyfile | 2364 ---------- .../ClassDriver/MouseHostWithParser/makefile | 38 - .../PrinterHost/Config/LUFAConfig.h | 93 - .../ClassDriver/PrinterHost/PrinterHost.c | 234 - .../ClassDriver/PrinterHost/PrinterHost.h | 81 - .../ClassDriver/PrinterHost/PrinterHost.txt | 66 - .../Host/ClassDriver/PrinterHost/asf.xml | 48 - .../Host/ClassDriver/PrinterHost/doxyfile | 2364 ---------- .../Host/ClassDriver/PrinterHost/makefile | 38 - .../RNDISEthernetHost/Config/LUFAConfig.h | 93 - .../RNDISEthernetHost/RNDISEthernetHost.c | 253 - .../RNDISEthernetHost/RNDISEthernetHost.h | 81 - .../RNDISEthernetHost/RNDISEthernetHost.txt | 63 - .../ClassDriver/RNDISEthernetHost/asf.xml | 48 - .../ClassDriver/RNDISEthernetHost/doxyfile | 2364 ---------- .../ClassDriver/RNDISEthernetHost/makefile | 38 - .../StillImageHost/Config/LUFAConfig.h | 93 - .../StillImageHost/StillImageHost.c | 230 - .../StillImageHost/StillImageHost.h | 78 - .../StillImageHost/StillImageHost.txt | 65 - .../Host/ClassDriver/StillImageHost/asf.xml | 48 - .../Host/ClassDriver/StillImageHost/doxyfile | 2364 ---------- .../Host/ClassDriver/StillImageHost/makefile | 38 - .../VirtualSerialHost/Config/LUFAConfig.h | 93 - .../VirtualSerialHost/VirtualSerialHost.c | 217 - .../VirtualSerialHost/VirtualSerialHost.h | 78 - .../VirtualSerialHost/VirtualSerialHost.txt | 66 - .../ClassDriver/VirtualSerialHost/asf.xml | 48 - .../ClassDriver/VirtualSerialHost/doxyfile | 2364 ---------- .../ClassDriver/VirtualSerialHost/makefile | 38 - .../LUFA-git/Demos/Host/ClassDriver/makefile | 46 - .../AndroidAccessoryHost.c | 263 -- .../AndroidAccessoryHost.h | 86 - .../AndroidAccessoryHost.txt | 62 - .../AndroidAccessoryHost/Config/LUFAConfig.h | 93 - .../AndroidAccessoryHost/ConfigDescriptor.c | 164 - .../AndroidAccessoryHost/ConfigDescriptor.h | 67 - .../AndroidAccessoryHost/DeviceDescriptor.c | 67 - .../AndroidAccessoryHost/DeviceDescriptor.h | 60 - .../Lib/AndroidAccessoryCommands.c | 84 - .../Lib/AndroidAccessoryCommands.h | 52 - .../LowLevel/AndroidAccessoryHost/asf.xml | 55 - .../LowLevel/AndroidAccessoryHost/doxyfile | 2364 ---------- .../LowLevel/AndroidAccessoryHost/makefile | 38 - .../LowLevel/AudioInputHost/AudioInputHost.c | 250 - .../LowLevel/AudioInputHost/AudioInputHost.h | 79 - .../AudioInputHost/AudioInputHost.txt | 66 - .../AudioInputHost/Config/LUFAConfig.h | 93 - .../AudioInputHost/ConfigDescriptor.c | 220 - .../AudioInputHost/ConfigDescriptor.h | 72 - .../Host/LowLevel/AudioInputHost/asf.xml | 50 - .../Host/LowLevel/AudioInputHost/doxyfile | 2364 ---------- .../Host/LowLevel/AudioInputHost/makefile | 38 - .../AudioOutputHost/AudioOutputHost.c | 250 - .../AudioOutputHost/AudioOutputHost.h | 88 - .../AudioOutputHost/AudioOutputHost.txt | 83 - .../AudioOutputHost/Config/AppConfig.h | 51 - .../AudioOutputHost/Config/LUFAConfig.h | 93 - .../AudioOutputHost/ConfigDescriptor.c | 220 - .../AudioOutputHost/ConfigDescriptor.h | 73 - .../Host/LowLevel/AudioOutputHost/asf.xml | 54 - .../Host/LowLevel/AudioOutputHost/doxyfile | 2364 ---------- .../Host/LowLevel/AudioOutputHost/makefile | 38 - .../GenericHIDHost/Config/LUFAConfig.h | 93 - .../GenericHIDHost/ConfigDescriptor.c | 183 - .../GenericHIDHost/ConfigDescriptor.h | 69 - .../LowLevel/GenericHIDHost/GenericHIDHost.c | 269 -- .../LowLevel/GenericHIDHost/GenericHIDHost.h | 93 - .../GenericHIDHost/GenericHIDHost.txt | 64 - .../Host/LowLevel/GenericHIDHost/asf.xml | 50 - .../Host/LowLevel/GenericHIDHost/doxyfile | 2364 ---------- .../Host/LowLevel/GenericHIDHost/makefile | 38 - .../Config/LUFAConfig.h | 93 - .../JoystickHostWithParser/ConfigDescriptor.c | 187 - .../JoystickHostWithParser/ConfigDescriptor.h | 69 - .../JoystickHostWithParser/HIDReport.c | 111 - .../JoystickHostWithParser/HIDReport.h | 79 - .../JoystickHostWithParser.c | 273 -- .../JoystickHostWithParser.h | 83 - .../JoystickHostWithParser.txt | 71 - .../LowLevel/JoystickHostWithParser/asf.xml | 52 - .../LowLevel/JoystickHostWithParser/doxyfile | 2364 ---------- .../LowLevel/JoystickHostWithParser/makefile | 38 - .../LowLevel/KeyboardHost/Config/LUFAConfig.h | 93 - .../LowLevel/KeyboardHost/ConfigDescriptor.c | 155 - .../LowLevel/KeyboardHost/ConfigDescriptor.h | 66 - .../Host/LowLevel/KeyboardHost/KeyboardHost.c | 264 -- .../Host/LowLevel/KeyboardHost/KeyboardHost.h | 80 - .../LowLevel/KeyboardHost/KeyboardHost.txt | 73 - .../Demos/Host/LowLevel/KeyboardHost/asf.xml | 50 - .../Demos/Host/LowLevel/KeyboardHost/doxyfile | 2364 ---------- .../Demos/Host/LowLevel/KeyboardHost/makefile | 38 - .../Config/LUFAConfig.h | 93 - .../KeyboardHostWithParser/ConfigDescriptor.c | 189 - .../KeyboardHostWithParser/ConfigDescriptor.h | 67 - .../KeyboardHostWithParser/HIDReport.c | 90 - .../KeyboardHostWithParser/HIDReport.h | 67 - .../KeyboardHostWithParser.c | 285 -- .../KeyboardHostWithParser.h | 78 - .../KeyboardHostWithParser.txt | 71 - .../LowLevel/KeyboardHostWithParser/asf.xml | 52 - .../LowLevel/KeyboardHostWithParser/doxyfile | 2364 ---------- .../LowLevel/KeyboardHostWithParser/makefile | 38 - .../LowLevel/MIDIHost/Config/LUFAConfig.h | 93 - .../Host/LowLevel/MIDIHost/ConfigDescriptor.c | 173 - .../Host/LowLevel/MIDIHost/ConfigDescriptor.h | 69 - .../Demos/Host/LowLevel/MIDIHost/MIDIHost.c | 266 -- .../Demos/Host/LowLevel/MIDIHost/MIDIHost.h | 82 - .../Demos/Host/LowLevel/MIDIHost/MIDIHost.txt | 60 - .../Demos/Host/LowLevel/MIDIHost/asf.xml | 52 - .../Demos/Host/LowLevel/MIDIHost/doxyfile | 2364 ---------- .../Demos/Host/LowLevel/MIDIHost/makefile | 38 - .../MassStorageHost/Config/LUFAConfig.h | 93 - .../MassStorageHost/ConfigDescriptor.c | 173 - .../MassStorageHost/ConfigDescriptor.h | 78 - .../MassStorageHost/Lib/MassStoreCommands.c | 635 --- .../MassStorageHost/Lib/MassStoreCommands.h | 86 - .../MassStorageHost/MassStorageHost.c | 373 -- .../MassStorageHost/MassStorageHost.h | 91 - .../MassStorageHost/MassStorageHost.txt | 68 - .../Host/LowLevel/MassStorageHost/asf.xml | 53 - .../Host/LowLevel/MassStorageHost/doxyfile | 2364 ---------- .../Host/LowLevel/MassStorageHost/makefile | 38 - .../LowLevel/MouseHost/Config/LUFAConfig.h | 93 - .../LowLevel/MouseHost/ConfigDescriptor.c | 159 - .../LowLevel/MouseHost/ConfigDescriptor.h | 66 - .../Demos/Host/LowLevel/MouseHost/MouseHost.c | 250 - .../Demos/Host/LowLevel/MouseHost/MouseHost.h | 82 - .../Host/LowLevel/MouseHost/MouseHost.txt | 74 - .../Demos/Host/LowLevel/MouseHost/asf.xml | 50 - .../Demos/Host/LowLevel/MouseHost/doxyfile | 2364 ---------- .../Demos/Host/LowLevel/MouseHost/makefile | 38 - .../MouseHostWithParser/Config/LUFAConfig.h | 93 - .../MouseHostWithParser/ConfigDescriptor.c | 187 - .../MouseHostWithParser/ConfigDescriptor.h | 67 - .../LowLevel/MouseHostWithParser/HIDReport.c | 111 - .../LowLevel/MouseHostWithParser/HIDReport.h | 82 - .../MouseHostWithParser/MouseHostWithParser.c | 289 -- .../MouseHostWithParser/MouseHostWithParser.h | 83 - .../MouseHostWithParser.txt | 71 - .../Host/LowLevel/MouseHostWithParser/asf.xml | 52 - .../LowLevel/MouseHostWithParser/doxyfile | 2364 ---------- .../LowLevel/MouseHostWithParser/makefile | 38 - .../LowLevel/PrinterHost/Config/LUFAConfig.h | 93 - .../LowLevel/PrinterHost/ConfigDescriptor.c | 177 - .../LowLevel/PrinterHost/ConfigDescriptor.h | 76 - .../PrinterHost/Lib/PrinterCommands.c | 162 - .../PrinterHost/Lib/PrinterCommands.h | 56 - .../Host/LowLevel/PrinterHost/PrinterHost.c | 226 - .../Host/LowLevel/PrinterHost/PrinterHost.h | 88 - .../Host/LowLevel/PrinterHost/PrinterHost.txt | 66 - .../Demos/Host/LowLevel/PrinterHost/asf.xml | 53 - .../Demos/Host/LowLevel/PrinterHost/doxyfile | 2364 ---------- .../Demos/Host/LowLevel/PrinterHost/makefile | 38 - .../RNDISEthernetHost/Config/LUFAConfig.h | 93 - .../RNDISEthernetHost/ConfigDescriptor.c | 235 - .../RNDISEthernetHost/ConfigDescriptor.h | 73 - .../RNDISEthernetHost/Lib/RNDISCommands.c | 311 -- .../RNDISEthernetHost/Lib/RNDISCommands.h | 70 - .../RNDISEthernetHost/RNDISEthernetHost.c | 249 - .../RNDISEthernetHost/RNDISEthernetHost.h | 85 - .../LowLevel/RNDISEthernetHost/RNDISHost.txt | 63 - .../Host/LowLevel/RNDISEthernetHost/asf.xml | 53 - .../Host/LowLevel/RNDISEthernetHost/doxyfile | 2364 ---------- .../Host/LowLevel/RNDISEthernetHost/makefile | 38 - .../StillImageHost/Config/LUFAConfig.h | 93 - .../StillImageHost/ConfigDescriptor.c | 190 - .../StillImageHost/ConfigDescriptor.h | 72 - .../LowLevel/StillImageHost/Lib/PIMACodes.h | 45 - .../StillImageHost/Lib/StillImageCommands.c | 268 -- .../StillImageHost/Lib/StillImageCommands.h | 65 - .../LowLevel/StillImageHost/StillImageHost.c | 365 -- .../LowLevel/StillImageHost/StillImageHost.h | 89 - .../StillImageHost/StillImageHost.txt | 65 - .../Host/LowLevel/StillImageHost/asf.xml | 54 - .../Host/LowLevel/StillImageHost/doxyfile | 2364 ---------- .../Host/LowLevel/StillImageHost/makefile | 38 - .../VirtualSerialHost/Config/LUFAConfig.h | 93 - .../VirtualSerialHost/ConfigDescriptor.c | 234 - .../VirtualSerialHost/ConfigDescriptor.h | 73 - .../VirtualSerialHost/VirtualSerialHost.c | 239 - .../VirtualSerialHost/VirtualSerialHost.h | 80 - .../VirtualSerialHost/VirtualSerialHost.txt | 66 - .../Host/LowLevel/VirtualSerialHost/asf.xml | 50 - .../Host/LowLevel/VirtualSerialHost/doxyfile | 2364 ---------- .../Host/LowLevel/VirtualSerialHost/makefile | 38 - .../LUFA-git/Demos/Host/LowLevel/makefile | 46 - protocol/lufa/LUFA-git/Demos/Host/makefile | 21 - protocol/lufa/LUFA-git/Demos/makefile | 22 - .../HID_EEPROM_Loader/HID_EEPROM_Loader.c | 61 - .../LUFA/Build/HID_EEPROM_Loader/makefile | 42 - .../LUFA-git/LUFA/Build/lufa_atprogram.mk | 103 - .../lufa/LUFA-git/LUFA/Build/lufa_avrdude.mk | 86 - .../lufa/LUFA-git/LUFA/Build/lufa_build.mk | 351 -- .../lufa/LUFA-git/LUFA/Build/lufa_core.mk | 175 - .../lufa/LUFA-git/LUFA/Build/lufa_cppcheck.mk | 107 - protocol/lufa/LUFA-git/LUFA/Build/lufa_dfu.mk | 95 - .../lufa/LUFA-git/LUFA/Build/lufa_doxygen.mk | 100 - protocol/lufa/LUFA-git/LUFA/Build/lufa_hid.mk | 96 - .../lufa/LUFA-git/LUFA/Build/lufa_sources.mk | 144 - .../DeviceTemplate/Descriptors.c | 180 - .../DeviceTemplate/Descriptors.h | 59 - .../DeviceTemplate/DeviceApplication.c | 106 - .../DeviceTemplate/DeviceApplication.h | 53 - .../LUFA/CodeTemplates/DeviceTemplate/asf.xml | 55 - .../LUFA/CodeTemplates/DriverStubs/Board.h | 82 - .../LUFA/CodeTemplates/DriverStubs/Buttons.h | 90 - .../CodeTemplates/DriverStubs/Dataflash.h | 223 - .../LUFA/CodeTemplates/DriverStubs/Joystick.h | 102 - .../LUFA/CodeTemplates/DriverStubs/LEDs.h | 130 - .../HostTemplate/HostApplication.c | 133 - .../HostTemplate/HostApplication.h | 56 - .../LUFA/CodeTemplates/HostTemplate/asf.xml | 41 - .../LUFA-git/LUFA/CodeTemplates/LUFAConfig.h | 167 - .../CodeTemplates/WindowsINF/LUFA CDC-ACM.inf | 64 - .../CodeTemplates/WindowsINF/LUFA RNDIS.inf | 59 - .../LUFA/CodeTemplates/makefile_template | 38 - .../LUFA/Common/ArchitectureSpecific.h | 185 - .../lufa/LUFA-git/LUFA/Common/Architectures.h | 84 - .../lufa/LUFA-git/LUFA/Common/Attributes.h | 150 - .../lufa/LUFA-git/LUFA/Common/BoardTypes.h | 254 - protocol/lufa/LUFA-git/LUFA/Common/Common.h | 393 -- .../LUFA-git/LUFA/Common/CompilerSpecific.h | 97 - .../lufa/LUFA-git/LUFA/Common/Endianness.h | 493 -- .../LUFA/DoxygenPages/BuildSystem.txt | 975 ---- .../BuildingLinkableLibraries.txt | 23 - .../LUFA-git/LUFA/DoxygenPages/ChangeLog.txt | 1597 ------- .../LUFA/DoxygenPages/CompileTimeTokens.txt | 223 - .../LUFA/DoxygenPages/CompilingApps.txt | 46 - .../LUFA/DoxygenPages/ConfiguringApps.txt | 157 - .../LUFA/DoxygenPages/DevelopingWithLUFA.txt | 24 - .../LUFA/DoxygenPages/DeviceSupport.txt | 422 -- .../LUFA/DoxygenPages/DirectorySummaries.txt | 80 - .../LUFA-git/LUFA/DoxygenPages/Donating.txt | 26 - .../LUFA/DoxygenPages/ExportingLibrary.txt | 112 - .../LUFA/DoxygenPages/FutureChanges.txt | 47 - .../LUFA/DoxygenPages/GettingStarted.txt | 37 - .../LUFA-git/LUFA/DoxygenPages/Groups.txt | 38 - .../AS5_AS6_Import/AS5_AS6_Import_Step1.png | Bin 98201 -> 0 bytes .../AS5_AS6_Import/AS5_AS6_Import_Step2.png | Bin 100532 -> 0 bytes .../AS5_AS6_Import/AS5_AS6_Import_Step3.png | Bin 32987 -> 0 bytes .../AS5_AS6_Import/AS5_AS6_Import_Step4.png | Bin 161824 -> 0 bytes .../AS5_AS6_Import/AS5_AS6_Import_Step5_1.png | Bin 43666 -> 0 bytes .../AS5_AS6_Import/AS5_AS6_Import_Step5_2.png | Bin 28918 -> 0 bytes .../AS5_AS6_Import/AS5_AS6_Import_Step5_3.png | Bin 23561 -> 0 bytes .../LUFA/DoxygenPages/Images/Author.jpg | Bin 28410 -> 0 bytes .../LUFA/DoxygenPages/Images/LUFA.png | Bin 10296 -> 0 bytes .../LUFA/DoxygenPages/Images/LUFA_thumb.png | Bin 3729 -> 0 bytes .../LUFA/DoxygenPages/KnownIssues.txt | 170 - .../LUFA/DoxygenPages/LUFAPoweredProjects.txt | 224 - .../LUFA/DoxygenPages/LibraryResources.txt | 33 - .../LUFA/DoxygenPages/LicenseInfo.txt | 43 - .../LUFA-git/LUFA/DoxygenPages/MainPage.txt | 52 - .../DoxygenPages/MigrationInformation.txt | 708 --- .../LUFA-git/LUFA/DoxygenPages/OSDrivers.txt | 111 - .../LUFA/DoxygenPages/ProgrammingApps.txt | 30 - .../DoxygenPages/SoftwareBootloaderJump.txt | 71 - .../LUFA/DoxygenPages/Style/Footer.htm | 35 - .../LUFA/DoxygenPages/Style/Style.css | 93 - .../LUFA/DoxygenPages/VIDAndPIDValues.txt | 199 - .../LUFA/DoxygenPages/WritingBoardDrivers.txt | 47 - .../Drivers/Board/AVR8/ADAFRUITU4/Board.h | 78 - .../LUFA/Drivers/Board/AVR8/ADAFRUITU4/LEDs.h | 135 - .../Drivers/Board/AVR8/ATAVRUSBRF01/Board.h | 82 - .../Drivers/Board/AVR8/ATAVRUSBRF01/Buttons.h | 103 - .../Drivers/Board/AVR8/ATAVRUSBRF01/LEDs.h | 139 - .../LUFA/Drivers/Board/AVR8/BENITO/Board.h | 82 - .../LUFA/Drivers/Board/AVR8/BENITO/Buttons.h | 103 - .../LUFA/Drivers/Board/AVR8/BENITO/LEDs.h | 139 - .../LUFA/Drivers/Board/AVR8/BIGMULTIO/Board.h | 78 - .../LUFA/Drivers/Board/AVR8/BIGMULTIO/LEDs.h | 161 - .../LUFA/Drivers/Board/AVR8/BLACKCAT/Board.h | 78 - .../LUFA/Drivers/Board/AVR8/BLACKCAT/LEDs.h | 139 - .../LUFA/Drivers/Board/AVR8/BUI/Board.h | 78 - .../LUFA/Drivers/Board/AVR8/BUI/LEDs.h | 143 - .../LUFA/Drivers/Board/AVR8/BUMBLEB/Board.h | 86 - .../LUFA/Drivers/Board/AVR8/BUMBLEB/Buttons.h | 105 - .../Drivers/Board/AVR8/BUMBLEB/Joystick.h | 123 - .../LUFA/Drivers/Board/AVR8/BUMBLEB/LEDs.h | 149 - .../LUFA/Drivers/Board/AVR8/CULV3/Board.h | 82 - .../LUFA/Drivers/Board/AVR8/CULV3/Buttons.h | 103 - .../LUFA/Drivers/Board/AVR8/CULV3/LEDs.h | 135 - .../LUFA/Drivers/Board/AVR8/DUCE/Board.h | 78 - .../LUFA/Drivers/Board/AVR8/DUCE/LEDs.h | 147 - .../LUFA/Drivers/Board/AVR8/EVK527/Board.h | 90 - .../LUFA/Drivers/Board/AVR8/EVK527/Buttons.h | 103 - .../Drivers/Board/AVR8/EVK527/Dataflash.h | 222 - .../LUFA/Drivers/Board/AVR8/EVK527/Joystick.h | 130 - .../LUFA/Drivers/Board/AVR8/EVK527/LEDs.h | 143 - .../LUFA/Drivers/Board/AVR8/JMDBU2/Board.h | 82 - .../LUFA/Drivers/Board/AVR8/JMDBU2/Buttons.h | 103 - .../LUFA/Drivers/Board/AVR8/JMDBU2/LEDs.h | 135 - .../LUFA/Drivers/Board/AVR8/LEONARDO/Board.h | 78 - .../LUFA/Drivers/Board/AVR8/LEONARDO/LEDs.h | 169 - .../LUFA/Drivers/Board/AVR8/MAXIMUS/Board.h | 78 - .../LUFA/Drivers/Board/AVR8/MAXIMUS/LEDs.h | 139 - .../LUFA/Drivers/Board/AVR8/MICRO/Board.h | 78 - .../LUFA/Drivers/Board/AVR8/MICRO/LEDs.h | 169 - .../Drivers/Board/AVR8/MICROPENDOUS/Board.h | 149 - .../Drivers/Board/AVR8/MICROPENDOUS/Buttons.h | 205 - .../Drivers/Board/AVR8/MICROPENDOUS/LEDs.h | 174 - .../Drivers/Board/AVR8/MICROSIN162/Board.h | 82 - .../Drivers/Board/AVR8/MICROSIN162/Buttons.h | 103 - .../Drivers/Board/AVR8/MICROSIN162/LEDs.h | 135 - .../LUFA/Drivers/Board/AVR8/MINIMUS/Board.h | 82 - .../LUFA/Drivers/Board/AVR8/MINIMUS/Buttons.h | 103 - .../LUFA/Drivers/Board/AVR8/MINIMUS/LEDs.h | 139 - .../LUFA/Drivers/Board/AVR8/MULTIO/Board.h | 78 - .../LUFA/Drivers/Board/AVR8/MULTIO/LEDs.h | 161 - .../LUFA/Drivers/Board/AVR8/OLIMEX162/Board.h | 82 - .../Drivers/Board/AVR8/OLIMEX162/Buttons.h | 103 - .../LUFA/Drivers/Board/AVR8/OLIMEX162/LEDs.h | 135 - .../Drivers/Board/AVR8/OLIMEX32U4/Board.h | 82 - .../Drivers/Board/AVR8/OLIMEX32U4/Buttons.h | 103 - .../LUFA/Drivers/Board/AVR8/OLIMEX32U4/LEDs.h | 179 - .../Drivers/Board/AVR8/OLIMEXISPMK2/Board.h | 82 - .../Drivers/Board/AVR8/OLIMEXISPMK2/Buttons.h | 103 - .../Drivers/Board/AVR8/OLIMEXISPMK2/LEDs.h | 143 - .../Drivers/Board/AVR8/OLIMEXT32U4/Board.h | 82 - .../Drivers/Board/AVR8/OLIMEXT32U4/Buttons.h | 103 - .../Drivers/Board/AVR8/OLIMEXT32U4/LEDs.h | 169 - .../Drivers/Board/AVR8/RZUSBSTICK/Board.h | 78 - .../LUFA/Drivers/Board/AVR8/RZUSBSTICK/LEDs.h | 175 - .../Drivers/Board/AVR8/SPARKFUN8U2/Board.h | 78 - .../Drivers/Board/AVR8/SPARKFUN8U2/LEDs.h | 135 - .../Drivers/Board/AVR8/STANGE_ISP/Board.h | 82 - .../Drivers/Board/AVR8/STANGE_ISP/Buttons.h | 103 - .../LUFA/Drivers/Board/AVR8/STANGE_ISP/LEDs.h | 138 - .../LUFA/Drivers/Board/AVR8/STK525/Board.h | 90 - .../LUFA/Drivers/Board/AVR8/STK525/Buttons.h | 103 - .../Drivers/Board/AVR8/STK525/Dataflash.h | 222 - .../LUFA/Drivers/Board/AVR8/STK525/Joystick.h | 130 - .../LUFA/Drivers/Board/AVR8/STK525/LEDs.h | 147 - .../LUFA/Drivers/Board/AVR8/STK526/Board.h | 90 - .../LUFA/Drivers/Board/AVR8/STK526/Buttons.h | 103 - .../Drivers/Board/AVR8/STK526/Dataflash.h | 222 - .../LUFA/Drivers/Board/AVR8/STK526/Joystick.h | 123 - .../LUFA/Drivers/Board/AVR8/STK526/LEDs.h | 147 - .../LUFA/Drivers/Board/AVR8/TEENSY/Board.h | 85 - .../LUFA/Drivers/Board/AVR8/TEENSY/LEDs.h | 176 - .../LUFA/Drivers/Board/AVR8/TUL/Board.h | 82 - .../LUFA/Drivers/Board/AVR8/TUL/Buttons.h | 103 - .../LUFA/Drivers/Board/AVR8/TUL/LEDs.h | 135 - .../LUFA/Drivers/Board/AVR8/U2S/Board.h | 82 - .../LUFA/Drivers/Board/AVR8/U2S/Buttons.h | 103 - .../LUFA/Drivers/Board/AVR8/U2S/LEDs.h | 135 - .../LUFA/Drivers/Board/AVR8/UDIP/Board.h | 82 - .../LUFA/Drivers/Board/AVR8/UDIP/Buttons.h | 103 - .../LUFA/Drivers/Board/AVR8/UDIP/LEDs.h | 163 - .../LUFA/Drivers/Board/AVR8/UNO/Board.h | 78 - .../LUFA/Drivers/Board/AVR8/UNO/LEDs.h | 139 - .../LUFA/Drivers/Board/AVR8/USB2AX/Board.h | 105 - .../LUFA/Drivers/Board/AVR8/USB2AX/Buttons.h | 120 - .../LUFA/Drivers/Board/AVR8/USB2AX/LEDs.h | 218 - .../LUFA/Drivers/Board/AVR8/USBFOO/Board.h | 82 - .../LUFA/Drivers/Board/AVR8/USBFOO/Buttons.h | 103 - .../LUFA/Drivers/Board/AVR8/USBFOO/LEDs.h | 135 - .../LUFA/Drivers/Board/AVR8/USBKEY/Board.h | 90 - .../LUFA/Drivers/Board/AVR8/USBKEY/Buttons.h | 103 - .../Drivers/Board/AVR8/USBKEY/Dataflash.h | 237 - .../LUFA/Drivers/Board/AVR8/USBKEY/Joystick.h | 130 - .../LUFA/Drivers/Board/AVR8/USBKEY/LEDs.h | 147 - .../Drivers/Board/AVR8/USBTINYMKII/Board.h | 82 - .../Drivers/Board/AVR8/USBTINYMKII/Buttons.h | 103 - .../Drivers/Board/AVR8/USBTINYMKII/LEDs.h | 143 - .../LUFA/Drivers/Board/AVR8/XPLAIN/Board.h | 89 - .../Drivers/Board/AVR8/XPLAIN/Dataflash.h | 245 - .../LUFA/Drivers/Board/AVR8/XPLAIN/LEDs.h | 142 - .../LUFA/Drivers/Board/AVR8/YUN/Board.h | 78 - .../LUFA/Drivers/Board/AVR8/YUN/LEDs.h | 169 - .../lufa/LUFA-git/LUFA/Drivers/Board/Board.h | 167 - .../LUFA-git/LUFA/Drivers/Board/Buttons.h | 188 - .../LUFA-git/LUFA/Drivers/Board/Dataflash.h | 264 -- .../LUFA-git/LUFA/Drivers/Board/Joystick.h | 151 - .../lufa/LUFA-git/LUFA/Drivers/Board/LEDs.h | 298 -- .../LUFA-git/LUFA/Drivers/Board/Temperature.c | 66 - .../LUFA-git/LUFA/Drivers/Board/Temperature.h | 147 - .../LUFA/Drivers/Board/UC3/EVK1100/Board.h | 86 - .../LUFA/Drivers/Board/UC3/EVK1100/Buttons.h | 117 - .../LUFA/Drivers/Board/UC3/EVK1100/Joystick.h | 122 - .../LUFA/Drivers/Board/UC3/EVK1100/LEDs.h | 173 - .../LUFA/Drivers/Board/UC3/EVK1101/Board.h | 86 - .../LUFA/Drivers/Board/UC3/EVK1101/Buttons.h | 113 - .../LUFA/Drivers/Board/UC3/EVK1101/Joystick.h | 131 - .../LUFA/Drivers/Board/UC3/EVK1101/LEDs.h | 156 - .../LUFA/Drivers/Board/UC3/EVK1104/Board.h | 82 - .../LUFA/Drivers/Board/UC3/EVK1104/Buttons.h | 109 - .../LUFA/Drivers/Board/UC3/EVK1104/LEDs.h | 174 - .../Drivers/Board/UC3/UC3A3_XPLAINED/Board.h | 82 - .../Board/UC3/UC3A3_XPLAINED/Buttons.h | 109 - .../Drivers/Board/UC3/UC3A3_XPLAINED/LEDs.h | 182 - .../Drivers/Board/XMEGA/A3BU_XPLAINED/Board.h | 86 - .../Board/XMEGA/A3BU_XPLAINED/Buttons.h | 119 - .../Board/XMEGA/A3BU_XPLAINED/Dataflash.h | 228 - .../Drivers/Board/XMEGA/A3BU_XPLAINED/LEDs.h | 181 - .../Drivers/Board/XMEGA/B1_XPLAINED/Board.h | 86 - .../Drivers/Board/XMEGA/B1_XPLAINED/Buttons.h | 119 - .../Board/XMEGA/B1_XPLAINED/Dataflash.h | 229 - .../Drivers/Board/XMEGA/B1_XPLAINED/LEDs.h | 183 - .../Drivers/Board/XMEGA/C3_XPLAINED/Board.h | 83 - .../Drivers/Board/XMEGA/C3_XPLAINED/Buttons.h | 109 - .../Drivers/Board/XMEGA/C3_XPLAINED/LEDs.h | 181 - .../LUFA-git/LUFA/Drivers/Misc/AT45DB321C.h | 100 - .../LUFA-git/LUFA/Drivers/Misc/AT45DB642D.h | 116 - .../LUFA-git/LUFA/Drivers/Misc/RingBuffer.h | 308 -- .../LUFA/Drivers/Misc/TerminalCodes.h | 231 - .../LUFA-git/LUFA/Drivers/Peripheral/ADC.h | 75 - .../LUFA/Drivers/Peripheral/AVR8/ADC_AVR8.h | 446 -- .../LUFA/Drivers/Peripheral/AVR8/SPI_AVR8.h | 258 - .../Drivers/Peripheral/AVR8/SerialSPI_AVR8.h | 208 - .../Drivers/Peripheral/AVR8/Serial_AVR8.c | 119 - .../Drivers/Peripheral/AVR8/Serial_AVR8.h | 270 -- .../LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.c | 209 - .../LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.h | 305 -- .../LUFA-git/LUFA/Drivers/Peripheral/SPI.h | 76 - .../LUFA-git/LUFA/Drivers/Peripheral/Serial.h | 76 - .../LUFA/Drivers/Peripheral/SerialSPI.h | 76 - .../LUFA-git/LUFA/Drivers/Peripheral/TWI.h | 76 - .../LUFA/Drivers/Peripheral/XMEGA/SPI_XMEGA.h | 251 - .../Peripheral/XMEGA/SerialSPI_XMEGA.h | 212 - .../Drivers/Peripheral/XMEGA/Serial_XMEGA.c | 122 - .../Drivers/Peripheral/XMEGA/Serial_XMEGA.h | 286 -- .../LUFA/Drivers/Peripheral/XMEGA/TWI_XMEGA.c | 185 - .../LUFA/Drivers/Peripheral/XMEGA/TWI_XMEGA.h | 302 -- .../Drivers/USB/Class/AndroidAccessoryClass.h | 77 - .../LUFA/Drivers/USB/Class/AudioClass.h | 81 - .../LUFA/Drivers/USB/Class/CDCClass.h | 81 - .../Common/AndroidAccessoryClassCommon.h | 129 - .../USB/Class/Common/AudioClassCommon.h | 780 ---- .../Drivers/USB/Class/Common/CDCClassCommon.h | 391 -- .../Drivers/USB/Class/Common/HIDClassCommon.h | 682 --- .../LUFA/Drivers/USB/Class/Common/HIDParser.c | 389 -- .../LUFA/Drivers/USB/Class/Common/HIDParser.h | 364 -- .../Drivers/USB/Class/Common/HIDReportData.h | 126 - .../USB/Class/Common/MIDIClassCommon.h | 363 -- .../USB/Class/Common/MassStorageClassCommon.h | 368 -- .../USB/Class/Common/PrinterClassCommon.h | 119 - .../USB/Class/Common/RNDISClassCommon.h | 411 -- .../USB/Class/Common/StillImageClassCommon.h | 161 - .../USB/Class/Device/AudioClassDevice.c | 197 - .../USB/Class/Device/AudioClassDevice.h | 396 -- .../Drivers/USB/Class/Device/CDCClassDevice.c | 341 -- .../Drivers/USB/Class/Device/CDCClassDevice.h | 352 -- .../Drivers/USB/Class/Device/HIDClassDevice.c | 211 - .../Drivers/USB/Class/Device/HIDClassDevice.h | 210 - .../USB/Class/Device/MIDIClassDevice.c | 131 - .../USB/Class/Device/MIDIClassDevice.h | 175 - .../USB/Class/Device/MassStorageClassDevice.c | 215 - .../USB/Class/Device/MassStorageClassDevice.h | 161 - .../USB/Class/Device/PrinterClassDevice.c | 314 -- .../USB/Class/Device/PrinterClassDevice.h | 293 -- .../USB/Class/Device/RNDISClassDevice.c | 508 -- .../USB/Class/Device/RNDISClassDevice.h | 207 - .../LUFA/Drivers/USB/Class/HIDClass.h | 82 - .../Class/Host/AndroidAccessoryClassHost.c | 422 -- .../Class/Host/AndroidAccessoryClassHost.h | 314 -- .../Drivers/USB/Class/Host/AudioClassHost.c | 223 - .../Drivers/USB/Class/Host/AudioClassHost.h | 411 -- .../Drivers/USB/Class/Host/CDCClassHost.c | 477 -- .../Drivers/USB/Class/Host/CDCClassHost.h | 351 -- .../Drivers/USB/Class/Host/HIDClassHost.c | 399 -- .../Drivers/USB/Class/Host/HIDClassHost.h | 313 -- .../Drivers/USB/Class/Host/MIDIClassHost.c | 231 - .../Drivers/USB/Class/Host/MIDIClassHost.h | 190 - .../USB/Class/Host/MassStorageClassHost.c | 579 --- .../USB/Class/Host/MassStorageClassHost.h | 335 -- .../Drivers/USB/Class/Host/PrinterClassHost.c | 400 -- .../Drivers/USB/Class/Host/PrinterClassHost.h | 285 -- .../Drivers/USB/Class/Host/RNDISClassHost.c | 476 -- .../Drivers/USB/Class/Host/RNDISClassHost.h | 270 -- .../USB/Class/Host/StillImageClassHost.c | 436 -- .../USB/Class/Host/StillImageClassHost.h | 317 -- .../LUFA/Drivers/USB/Class/MIDIClass.h | 84 - .../LUFA/Drivers/USB/Class/MassStorageClass.h | 81 - .../LUFA/Drivers/USB/Class/PrinterClass.h | 83 - .../LUFA/Drivers/USB/Class/RNDISClass.h | 81 - .../LUFA/Drivers/USB/Class/StillImageClass.h | 76 - .../LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c | 57 - .../LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h | 269 -- .../USB/Core/AVR8/EndpointStream_AVR8.c | 275 -- .../USB/Core/AVR8/EndpointStream_AVR8.h | 658 --- .../Drivers/USB/Core/AVR8/Endpoint_AVR8.c | 201 - .../Drivers/USB/Core/AVR8/Endpoint_AVR8.h | 819 ---- .../LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c | 297 -- .../LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h | 372 -- .../LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h | 159 - .../Drivers/USB/Core/AVR8/PipeStream_AVR8.c | 221 - .../Drivers/USB/Core/AVR8/PipeStream_AVR8.h | 442 -- .../LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c | 210 - .../LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h | 922 ---- .../Template/Template_Endpoint_Control_R.c | 84 - .../Template/Template_Endpoint_Control_W.c | 95 - .../Core/AVR8/Template/Template_Endpoint_RW.c | 89 - .../USB/Core/AVR8/Template/Template_Pipe_RW.c | 88 - .../USB/Core/AVR8/USBController_AVR8.c | 273 -- .../USB/Core/AVR8/USBController_AVR8.h | 432 -- .../Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c | 279 -- .../Drivers/USB/Core/AVR8/USBInterrupt_AVR8.h | 375 -- .../LUFA/Drivers/USB/Core/ConfigDescriptors.c | 146 - .../LUFA/Drivers/USB/Core/ConfigDescriptors.h | 287 -- .../LUFA-git/LUFA/Drivers/USB/Core/Device.h | 159 - .../LUFA/Drivers/USB/Core/DeviceStandardReq.c | 380 -- .../LUFA/Drivers/USB/Core/DeviceStandardReq.h | 158 - .../LUFA-git/LUFA/Drivers/USB/Core/Endpoint.h | 130 - .../LUFA/Drivers/USB/Core/EndpointStream.h | 124 - .../LUFA-git/LUFA/Drivers/USB/Core/Events.c | 39 - .../LUFA-git/LUFA/Drivers/USB/Core/Events.h | 372 -- .../LUFA-git/LUFA/Drivers/USB/Core/Host.h | 139 - .../LUFA/Drivers/USB/Core/HostStandardReq.c | 322 -- .../LUFA/Drivers/USB/Core/HostStandardReq.h | 292 -- .../lufa/LUFA-git/LUFA/Drivers/USB/Core/OTG.h | 80 - .../LUFA-git/LUFA/Drivers/USB/Core/Pipe.h | 144 - .../LUFA/Drivers/USB/Core/PipeStream.h | 100 - .../LUFA/Drivers/USB/Core/StdDescriptors.h | 765 --- .../LUFA/Drivers/USB/Core/StdRequestType.h | 258 - .../LUFA/Drivers/USB/Core/UC3/Device_UC3.c | 51 - .../LUFA/Drivers/USB/Core/UC3/Device_UC3.h | 267 -- .../Drivers/USB/Core/UC3/EndpointStream_UC3.c | 235 - .../Drivers/USB/Core/UC3/EndpointStream_UC3.h | 438 -- .../LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.c | 196 - .../LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h | 794 ---- .../LUFA/Drivers/USB/Core/UC3/Host_UC3.c | 297 -- .../LUFA/Drivers/USB/Core/UC3/Host_UC3.h | 363 -- .../Drivers/USB/Core/UC3/PipeStream_UC3.c | 166 - .../Drivers/USB/Core/UC3/PipeStream_UC3.h | 352 -- .../LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c | 209 - .../LUFA/Drivers/USB/Core/UC3/Pipe_UC3.h | 924 ---- .../Template/Template_Endpoint_Control_R.c | 84 - .../Template/Template_Endpoint_Control_W.c | 95 - .../Core/UC3/Template/Template_Endpoint_RW.c | 89 - .../USB/Core/UC3/Template/Template_Pipe_RW.c | 88 - .../Drivers/USB/Core/UC3/USBController_UC3.c | 222 - .../Drivers/USB/Core/UC3/USBController_UC3.h | 353 -- .../Drivers/USB/Core/UC3/USBInterrupt_UC3.c | 228 - .../Drivers/USB/Core/UC3/USBInterrupt_UC3.h | 376 -- .../LUFA/Drivers/USB/Core/USBController.h | 165 - .../LUFA/Drivers/USB/Core/USBInterrupt.h | 73 - .../LUFA-git/LUFA/Drivers/USB/Core/USBMode.h | 283 -- .../LUFA-git/LUFA/Drivers/USB/Core/USBTask.c | 89 - .../LUFA-git/LUFA/Drivers/USB/Core/USBTask.h | 200 - .../Drivers/USB/Core/XMEGA/Device_XMEGA.c | 49 - .../Drivers/USB/Core/XMEGA/Device_XMEGA.h | 266 -- .../USB/Core/XMEGA/EndpointStream_XMEGA.c | 275 -- .../USB/Core/XMEGA/EndpointStream_XMEGA.h | 658 --- .../Drivers/USB/Core/XMEGA/Endpoint_XMEGA.c | 268 -- .../Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h | 689 --- .../LUFA/Drivers/USB/Core/XMEGA/Host_XMEGA.c | 41 - .../Drivers/USB/Core/XMEGA/PipeStream_XMEGA.c | 41 - .../LUFA/Drivers/USB/Core/XMEGA/Pipe_XMEGA.c | 37 - .../Template/Template_Endpoint_Control_R.c | 86 - .../Template/Template_Endpoint_Control_W.c | 97 - .../XMEGA/Template/Template_Endpoint_RW.c | 89 - .../USB/Core/XMEGA/USBController_XMEGA.c | 204 - .../USB/Core/XMEGA/USBController_XMEGA.h | 313 -- .../USB/Core/XMEGA/USBInterrupt_XMEGA.c | 106 - .../USB/Core/XMEGA/USBInterrupt_XMEGA.h | 172 - protocol/lufa/LUFA-git/LUFA/Drivers/USB/USB.h | 422 -- protocol/lufa/LUFA-git/LUFA/License.txt | 24 - .../lufa/LUFA-git/LUFA/Platform/Platform.h | 80 - .../LUFA/Platform/UC3/ClockManagement.h | 338 -- .../LUFA-git/LUFA/Platform/UC3/Exception.S | 128 - .../LUFA/Platform/UC3/InterruptManagement.c | 62 - .../LUFA/Platform/UC3/InterruptManagement.h | 174 - .../LUFA/Platform/UC3/UC3ExperimentalInfo.txt | 1 - .../LUFA/Platform/XMEGA/ClockManagement.h | 397 -- .../Platform/XMEGA/XMEGAExperimentalInfo.txt | 1 - .../Docbook/mshelp/placeholder.txt | 1 - .../StudioIntegration/Docbook/placeholder.txt | 1 - .../HV1/helpcontentsetup.msha | 27 - .../HV1/lufa_docbook_transform.xslt | 808 ---- .../HV1/lufa_helpcontentsetup_transform.xslt | 43 - .../HV1/lufa_hv1_transform.xslt | 45 - .../HV1/lufa_studio_help_styling.css | 53 - .../ProjectGenerator/placeholder.txt | 1 - .../LUFA/StudioIntegration/VSIX/LUFA.dll | Bin 749056 -> 0 bytes .../LUFA/StudioIntegration/VSIX/LUFA.pkgdef | Bin 2242 -> 0 bytes .../VSIX/[Content_Types].xml | 13 - .../StudioIntegration/VSIX/asf-manifest.xml | 18 - .../VSIX/extension.vsixmanifest | 33 - .../StudioIntegration/VSIX/generate_caches.py | 38 - .../VSIX/lufa_asfmanifest_transform.xslt | 36 - .../VSIX/lufa_vsmanifest_transform.xslt | 33 - .../XDK/lufa_extension_transform.xslt | 68 - .../XDK/lufa_filelist_transform.xslt | 35 - .../XDK/lufa_indent_transform.xslt | 23 - .../XDK/lufa_module_transform.xslt | 66 - .../LUFA-git/LUFA/StudioIntegration/lufa.xml | 96 - .../LUFA/StudioIntegration/lufa_common.xml | 34 - .../StudioIntegration/lufa_drivers_board.xml | 114 - .../lufa_drivers_board_names.xml | 853 ---- .../StudioIntegration/lufa_drivers_misc.xml | 57 - .../lufa_drivers_peripheral.xml | 198 - .../StudioIntegration/lufa_drivers_usb.xml | 32 - .../lufa_drivers_usb_class.xml | 32 - .../lufa_drivers_usb_class_android.xml | 54 - .../lufa_drivers_usb_class_audio.xml | 109 - .../lufa_drivers_usb_class_cdc.xml | 99 - .../lufa_drivers_usb_class_hid.xml | 99 - .../lufa_drivers_usb_class_midi.xml | 99 - .../lufa_drivers_usb_class_ms.xml | 99 - .../lufa_drivers_usb_class_printer.xml | 99 - .../lufa_drivers_usb_class_rndis.xml | 99 - .../lufa_drivers_usb_class_si.xml | 56 - .../lufa_drivers_usb_core.xml | 85 - .../lufa_drivers_usb_core_avr8.xml | 43 - .../lufa_drivers_usb_core_uc3.xml | 42 - .../lufa_drivers_usb_core_xmega.xml | 36 - .../LUFA/StudioIntegration/lufa_platform.xml | 60 - .../StudioIntegration/lufa_platform_uc3.xml | 26 - .../StudioIntegration/lufa_platform_xmega.xml | 23 - .../LUFA/StudioIntegration/lufa_toolchain.xml | 43 - .../LUFA-git/LUFA/StudioIntegration/makefile | 140 - protocol/lufa/LUFA-git/LUFA/Version.h | 52 - protocol/lufa/LUFA-git/LUFA/doxyfile | 2368 ---------- protocol/lufa/LUFA-git/LUFA/makefile | 53 - .../lufa_functionlist_transform.xslt | 19 - protocol/lufa/LUFA-git/Maintenance/makefile | 94 - .../Projects/AVRISP-MKII/AVRISP-MKII.c | 156 - .../Projects/AVRISP-MKII/AVRISP-MKII.h | 91 - .../Projects/AVRISP-MKII/AVRISP-MKII.txt | 385 -- .../Projects/AVRISP-MKII/AVRISPDescriptors.c | 302 -- .../Projects/AVRISP-MKII/AVRISPDescriptors.h | 128 - .../Projects/AVRISP-MKII/Config/AppConfig.h | 70 - .../Projects/AVRISP-MKII/Config/LUFAConfig.h | 93 - .../AVRISP-MKII/Lib/ISP/ISPProtocol.c | 531 --- .../AVRISP-MKII/Lib/ISP/ISPProtocol.h | 81 - .../Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c | 370 -- .../Projects/AVRISP-MKII/Lib/ISP/ISPTarget.h | 147 - .../Projects/AVRISP-MKII/Lib/V2Protocol.c | 267 -- .../Projects/AVRISP-MKII/Lib/V2Protocol.h | 105 - .../AVRISP-MKII/Lib/V2ProtocolConstants.h | 90 - .../AVRISP-MKII/Lib/V2ProtocolParams.c | 207 - .../AVRISP-MKII/Lib/V2ProtocolParams.h | 91 - .../Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c | 274 -- .../Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.h | 86 - .../Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c | 468 -- .../Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.h | 140 - .../AVRISP-MKII/Lib/XPROG/XPROGProtocol.c | 480 -- .../AVRISP-MKII/Lib/XPROG/XPROGProtocol.h | 136 - .../AVRISP-MKII/Lib/XPROG/XPROGTarget.c | 209 - .../AVRISP-MKII/Lib/XPROG/XPROGTarget.h | 136 - .../LUFA-git/Projects/AVRISP-MKII/asf.xml | 90 - .../LUFA-git/Projects/AVRISP-MKII/doxyfile | 2364 ---------- .../LUFA-git/Projects/AVRISP-MKII/makefile | 39 - .../lufa/LUFA-git/Projects/Benito/Benito.c | 311 -- .../lufa/LUFA-git/Projects/Benito/Benito.h | 79 - .../lufa/LUFA-git/Projects/Benito/Benito.txt | 106 - .../Projects/Benito/Config/AppConfig.h | 57 - .../Projects/Benito/Config/LUFAConfig.h | 93 - .../LUFA-git/Projects/Benito/Descriptors.c | 244 - .../LUFA-git/Projects/Benito/Descriptors.h | 112 - .../Benito/LUFA Benito Programmer.inf | 66 - .../lufa/LUFA-git/Projects/Benito/asf.xml | 53 - .../lufa/LUFA-git/Projects/Benito/doxyfile | 2364 ---------- .../lufa/LUFA-git/Projects/Benito/makefile | 38 - .../HIDReportViewer/Config/LUFAConfig.h | 93 - .../HIDReportViewer/HIDReportViewer.c | 325 -- .../HIDReportViewer/HIDReportViewer.h | 87 - .../HIDReportViewer/HIDReportViewer.txt | 64 - .../LUFA-git/Projects/HIDReportViewer/asf.xml | 48 - .../Projects/HIDReportViewer/doxyfile | 2364 ---------- .../Projects/HIDReportViewer/makefile | 38 - .../CPUUsageApp/CPUMonitor.Designer.cs | 131 - .../LEDNotifier/CPUUsageApp/CPUMonitor.cs | 115 - .../LEDNotifier/CPUUsageApp/CPUMonitor.csproj | 95 - .../LEDNotifier/CPUUsageApp/CPUMonitor.resx | 132 - .../LEDNotifier/CPUUsageApp/Program.cs | 21 - .../CPUUsageApp/Properties/AssemblyInfo.cs | 36 - .../Properties/Resources.Designer.cs | 63 - .../CPUUsageApp/Properties/Resources.resx | 117 - .../Properties/Settings.Designer.cs | 26 - .../CPUUsageApp/Properties/Settings.settings | 7 - .../Projects/LEDNotifier/Config/LUFAConfig.h | 93 - .../Projects/LEDNotifier/Descriptors.c | 245 - .../Projects/LEDNotifier/Descriptors.h | 110 - .../LEDMixerApp/LEDMixer.Designer.cs | 149 - .../LEDNotifier/LEDMixerApp/LEDMixer.cs | 75 - .../LEDNotifier/LEDMixerApp/LEDMixer.csproj | 95 - .../LEDNotifier/LEDMixerApp/LEDMixer.resx | 123 - .../LEDNotifier/LEDMixerApp/Program.cs | 21 - .../LEDMixerApp/Properties/AssemblyInfo.cs | 36 - .../Properties/Resources.Designer.cs | 63 - .../LEDMixerApp/Properties/Resources.resx | 117 - .../Properties/Settings.Designer.cs | 26 - .../LEDMixerApp/Properties/Settings.settings | 7 - .../Projects/LEDNotifier/LEDNotifier.c | 176 - .../Projects/LEDNotifier/LEDNotifier.h | 60 - .../Projects/LEDNotifier/LEDNotifier.txt | 63 - .../LEDNotifier/LUFA LED Notifier.inf | 66 - .../LUFA-git/Projects/LEDNotifier/asf.xml | 51 - .../LUFA-git/Projects/LEDNotifier/doxyfile | 2366 ---------- .../LUFA-git/Projects/LEDNotifier/makefile | 38 - .../MIDIToneGenerator/Config/AppConfig.h | 48 - .../MIDIToneGenerator/Config/LUFAConfig.h | 93 - .../Projects/MIDIToneGenerator/Descriptors.c | 314 -- .../Projects/MIDIToneGenerator/Descriptors.h | 110 - .../MIDIToneGenerator/MIDIToneGenerator.c | 252 - .../MIDIToneGenerator/MIDIToneGenerator.h | 105 - .../MIDIToneGenerator/MIDIToneGenerator.txt | 73 - .../Projects/MIDIToneGenerator/asf.xml | 50 - .../Projects/MIDIToneGenerator/doxyfile | 2364 ---------- .../Projects/MIDIToneGenerator/makefile | 38 - .../Projects/Magstripe/Config/AppConfig.h | 58 - .../Projects/Magstripe/Config/LUFAConfig.h | 93 - .../LUFA-git/Projects/Magstripe/Descriptors.c | 216 - .../LUFA-git/Projects/Magstripe/Descriptors.h | 96 - .../Magstripe/Lib/CircularBitBuffer.c | 115 - .../Magstripe/Lib/CircularBitBuffer.h | 97 - .../Projects/Magstripe/Lib/MagstripeHW.h | 102 - .../LUFA-git/Projects/Magstripe/Magstripe.c | 228 - .../LUFA-git/Projects/Magstripe/Magstripe.h | 90 - .../LUFA-git/Projects/Magstripe/Magstripe.txt | 163 - .../lufa/LUFA-git/Projects/Magstripe/asf.xml | 52 - .../lufa/LUFA-git/Projects/Magstripe/doxyfile | 2364 ---------- .../lufa/LUFA-git/Projects/Magstripe/makefile | 38 - .../MediaController/Config/LUFAConfig.h | 93 - .../Projects/MediaController/Descriptors.c | 234 - .../Projects/MediaController/Descriptors.h | 93 - .../MediaController/MediaController.c | 184 - .../MediaController/MediaController.h | 110 - .../MediaController/MediaController.txt | 66 - .../LUFA-git/Projects/MediaController/asf.xml | 50 - .../Projects/MediaController/doxyfile | 2364 ---------- .../Projects/MediaController/makefile | 38 - .../MissileLauncher/Config/LUFAConfig.h | 93 - .../MissileLauncher/ConfigDescriptor.c | 185 - .../MissileLauncher/ConfigDescriptor.h | 72 - .../MissileLauncher/MissileLauncher.c | 323 -- .../MissileLauncher/MissileLauncher.h | 92 - .../MissileLauncher/MissileLauncher.txt | 60 - .../LUFA-git/Projects/MissileLauncher/asf.xml | 49 - .../Projects/MissileLauncher/doxyfile | 2364 ---------- .../Projects/MissileLauncher/makefile | 38 - .../Projects/RelayBoard/Config/LUFAConfig.h | 93 - .../Projects/RelayBoard/Descriptors.c | 188 - .../Projects/RelayBoard/Descriptors.h | 84 - .../LUFA-git/Projects/RelayBoard/RelayBoard.c | 145 - .../LUFA-git/Projects/RelayBoard/RelayBoard.h | 65 - .../Projects/RelayBoard/RelayBoard.txt | 106 - .../lufa/LUFA-git/Projects/RelayBoard/asf.xml | 47 - .../LUFA-git/Projects/RelayBoard/doxyfile | 2364 ---------- .../LUFA-git/Projects/RelayBoard/makefile | 38 - .../Projects/SerialToLCD/Config/LUFAConfig.h | 93 - .../Projects/SerialToLCD/Descriptors.c | 257 - .../Projects/SerialToLCD/Descriptors.h | 111 - .../Projects/SerialToLCD/Lib/HD44780.c | 127 - .../Projects/SerialToLCD/Lib/HD44780.h | 64 - .../Projects/SerialToLCD/SerialToLCD.c | 170 - .../Projects/SerialToLCD/SerialToLCD.h | 64 - .../Projects/SerialToLCD/SerialToLCD.txt | 109 - .../LUFA-git/Projects/SerialToLCD/asf.xml | 50 - .../LUFA-git/Projects/SerialToLCD/doxyfile | 2364 ---------- .../LUFA-git/Projects/SerialToLCD/makefile | 38 - .../TempDataLogger/Config/AppConfig.h | 48 - .../TempDataLogger/Config/LUFAConfig.h | 93 - .../Projects/TempDataLogger/Descriptors.c | 257 - .../Projects/TempDataLogger/Descriptors.h | 87 - .../TempDataLogger/Lib/DataflashManager.c | 534 --- .../TempDataLogger/Lib/DataflashManager.h | 86 - .../TempDataLogger/Lib/FATFs/00readme.txt | 135 - .../TempDataLogger/Lib/FATFs/diskio.c | 98 - .../TempDataLogger/Lib/FATFs/diskio.h | 55 - .../Projects/TempDataLogger/Lib/FATFs/ff.c | 4139 ----------------- .../Projects/TempDataLogger/Lib/FATFs/ff.h | 337 -- .../TempDataLogger/Lib/FATFs/ffconf.h | 191 - .../TempDataLogger/Lib/FATFs/integer.h | 38 - .../Projects/TempDataLogger/Lib/RTC.c | 159 - .../Projects/TempDataLogger/Lib/RTC.h | 126 - .../Projects/TempDataLogger/Lib/SCSI.c | 344 -- .../Projects/TempDataLogger/Lib/SCSI.h | 89 - .../Projects/TempDataLogger/TempDataLogger.c | 331 -- .../Projects/TempDataLogger/TempDataLogger.h | 112 - .../TempLogHostApp/COPYING.LESSER.txt | 166 - .../TempDataLogger/TempLogHostApp/COPYING.txt | 675 --- .../DataLoggerSettings.Designer.cs | 181 - .../TempLogHostApp/DataLoggerSettings.cs | 179 - .../TempLogHostApp/DataLoggerSettings.resx | 120 - .../TempLogHostApp/Hid.Linux.dll | Bin 9216 -> 0 bytes .../TempDataLogger/TempLogHostApp/Hid.Net.dll | Bin 24576 -> 0 bytes .../TempLogHostApp/Hid.Win32.dll | Bin 94208 -> 0 bytes .../TempDataLogger/TempLogHostApp/Program.cs | 21 - .../TempLogHostApp/Properties/AssemblyInfo.cs | 36 - .../Properties/Resources.Designer.cs | 63 - .../TempLogHostApp/Properties/Resources.resx | 117 - .../Properties/Settings.Designer.cs | 26 - .../Properties/Settings.settings | 7 - .../TempDataLogger/TempLogHostApp/README.txt | 24 - .../TempLogHostApp/TempLoggerHostApp.csproj | 99 - .../TempLogHostApp_Python/temp_log_config.py | 99 - .../TempDataLogger/TemperatureDataLogger.txt | 86 - .../LUFA-git/Projects/TempDataLogger/asf.xml | 72 - .../LUFA-git/Projects/TempDataLogger/doxyfile | 2366 ---------- .../LUFA-git/Projects/TempDataLogger/makefile | 39 - .../Projects/USBtoSerial/Config/LUFAConfig.h | 93 - .../Projects/USBtoSerial/Descriptors.c | 245 - .../Projects/USBtoSerial/Descriptors.h | 110 - .../Projects/USBtoSerial/LUFA USBtoSerial.inf | 66 - .../Projects/USBtoSerial/USBtoSerial.c | 254 - .../Projects/USBtoSerial/USBtoSerial.h | 77 - .../Projects/USBtoSerial/USBtoSerial.txt | 78 - .../LUFA-git/Projects/USBtoSerial/asf.xml | 51 - .../LUFA-git/Projects/USBtoSerial/doxyfile | 2364 ---------- .../LUFA-git/Projects/USBtoSerial/makefile | 38 - .../Projects/Webserver/Config/AppConfig.h | 73 - .../Projects/Webserver/Config/LUFAConfig.h | 93 - .../LUFA-git/Projects/Webserver/Descriptors.c | 295 -- .../LUFA-git/Projects/Webserver/Descriptors.h | 128 - .../Webserver/LUFA Webserver RNDIS.inf | 59 - .../Projects/Webserver/Lib/DHCPClientApp.c | 208 - .../Projects/Webserver/Lib/DHCPClientApp.h | 69 - .../Projects/Webserver/Lib/DHCPCommon.c | 103 - .../Projects/Webserver/Lib/DHCPCommon.h | 159 - .../Projects/Webserver/Lib/DHCPServerApp.c | 265 -- .../Projects/Webserver/Lib/DHCPServerApp.h | 64 - .../Projects/Webserver/Lib/DataflashManager.c | 534 --- .../Projects/Webserver/Lib/DataflashManager.h | 87 - .../Projects/Webserver/Lib/FATFs/00readme.txt | 135 - .../Projects/Webserver/Lib/FATFs/diskio.c | 65 - .../Projects/Webserver/Lib/FATFs/diskio.h | 52 - .../Projects/Webserver/Lib/FATFs/ff.c | 4139 ----------------- .../Projects/Webserver/Lib/FATFs/ff.h | 337 -- .../Projects/Webserver/Lib/FATFs/ffconf.h | 190 - .../Projects/Webserver/Lib/FATFs/integer.h | 38 - .../Projects/Webserver/Lib/HTTPServerApp.c | 284 -- .../Projects/Webserver/Lib/HTTPServerApp.h | 84 - .../LUFA-git/Projects/Webserver/Lib/SCSI.c | 344 -- .../LUFA-git/Projects/Webserver/Lib/SCSI.h | 87 - .../Projects/Webserver/Lib/TELNETServerApp.c | 163 - .../Projects/Webserver/Lib/TELNETServerApp.h | 71 - .../Projects/Webserver/Lib/uIPManagement.c | 298 -- .../Projects/Webserver/Lib/uIPManagement.h | 69 - .../Projects/Webserver/Lib/uip/clock.c | 37 - .../Projects/Webserver/Lib/uip/clock.h | 13 - .../Projects/Webserver/Lib/uip/timer.c | 128 - .../Projects/Webserver/Lib/uip/timer.h | 87 - .../Projects/Webserver/Lib/uip/uip-split.c | 151 - .../Projects/Webserver/Lib/uip/uip-split.h | 104 - .../LUFA-git/Projects/Webserver/Lib/uip/uip.c | 1941 -------- .../LUFA-git/Projects/Webserver/Lib/uip/uip.h | 2130 --------- .../Projects/Webserver/Lib/uip/uip_arp.c | 432 -- .../Projects/Webserver/Lib/uip/uip_arp.h | 146 - .../Projects/Webserver/Lib/uip/uipopt.h | 740 --- .../Projects/Webserver/USBDeviceMode.c | 162 - .../Projects/Webserver/USBDeviceMode.h | 62 - .../LUFA-git/Projects/Webserver/USBHostMode.c | 172 - .../LUFA-git/Projects/Webserver/USBHostMode.h | 60 - .../LUFA-git/Projects/Webserver/Webserver.c | 77 - .../LUFA-git/Projects/Webserver/Webserver.h | 76 - .../LUFA-git/Projects/Webserver/Webserver.txt | 126 - .../lufa/LUFA-git/Projects/Webserver/asf.xml | 96 - .../lufa/LUFA-git/Projects/Webserver/doxyfile | 2365 ---------- .../lufa/LUFA-git/Projects/Webserver/makefile | 41 - .../Projects/XPLAINBridge/Config/AppConfig.h | 66 - .../Projects/XPLAINBridge/Config/LUFAConfig.h | 93 - .../XPLAINBridge/LUFA XPLAIN Bridge.inf | 66 - .../Projects/XPLAINBridge/Lib/SoftUART.c | 156 - .../Projects/XPLAINBridge/Lib/SoftUART.h | 71 - .../Projects/XPLAINBridge/USARTDescriptors.c | 245 - .../Projects/XPLAINBridge/USARTDescriptors.h | 112 - .../Projects/XPLAINBridge/XPLAINBridge.c | 294 -- .../Projects/XPLAINBridge/XPLAINBridge.h | 104 - .../Projects/XPLAINBridge/XPLAINBridge.txt | 109 - .../LUFA-git/Projects/XPLAINBridge/asf.xml | 57 - .../LUFA-git/Projects/XPLAINBridge/doxyfile | 2364 ---------- .../LUFA-git/Projects/XPLAINBridge/makefile | 51 - protocol/lufa/LUFA-git/Projects/makefile | 47 - protocol/lufa/LUFA-git/README.txt | 56 - protocol/lufa/LUFA-git/makefile | 26 - 1418 files changed, 388431 deletions(-) delete mode 100644 protocol/lufa/LUFA-git/.gitignore delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPI.c delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPI.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPITable.S delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderCDC.c delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderCDC.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderCDC.txt delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/CDC/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/CDC/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/CDC/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/CDC/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/CDC/LUFA CDC Bootloader.inf delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/CDC/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/CDC/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/CDC/makefile delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/DFU/BootloaderAPI.c delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/DFU/BootloaderAPI.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/DFU/BootloaderAPITable.S delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/DFU/BootloaderDFU.c delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/DFU/BootloaderDFU.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/DFU/BootloaderDFU.txt delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/DFU/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/DFU/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/DFU/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/DFU/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/DFU/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/DFU/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/DFU/makefile delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/HID/BootloaderHID.c delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/HID/BootloaderHID.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/HID/BootloaderHID.txt delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/HID/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/HID/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/HID/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/HID/HostLoaderApp/Makefile delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/HID/HostLoaderApp/Makefile.bsd delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/HID/HostLoaderApp/gpl3.txt delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/HID/HostLoaderApp/hid_bootloader_cli.c delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/HID/HostLoaderApp_Python/hid_bootloader_loader.py delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/HID/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/HID/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/HID/makefile delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/MassStorage/BootloaderAPI.c delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/MassStorage/BootloaderAPI.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/MassStorage/BootloaderAPITable.S delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/MassStorage/BootloaderMassStorage.c delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/MassStorage/BootloaderMassStorage.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/MassStorage/BootloaderMassStorage.txt delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/MassStorage/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/MassStorage/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/MassStorage/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/MassStorage/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/MassStorage/Lib/SCSI.c delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/MassStorage/Lib/SCSI.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/MassStorage/Lib/VirtualFAT.c delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/MassStorage/Lib/VirtualFAT.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/MassStorage/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/MassStorage/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/MassStorage/makefile delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/Printer/BootloaderAPI.c delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/Printer/BootloaderAPI.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/Printer/BootloaderAPITable.S delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/Printer/BootloaderPrinter.c delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/Printer/BootloaderPrinter.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/Printer/BootloaderPrinter.txt delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/Printer/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/Printer/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/Printer/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/Printer/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/Printer/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/Printer/makefile delete mode 100644 protocol/lufa/LUFA-git/Bootloaders/makefile delete mode 100644 protocol/lufa/LUFA-git/BuildTests/BoardDriverTest/Board/Board.h delete mode 100644 protocol/lufa/LUFA-git/BuildTests/BoardDriverTest/Board/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/BuildTests/BoardDriverTest/Board/Dataflash.h delete mode 100644 protocol/lufa/LUFA-git/BuildTests/BoardDriverTest/Board/Joystick.h delete mode 100644 protocol/lufa/LUFA-git/BuildTests/BoardDriverTest/Board/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/BuildTests/BoardDriverTest/BoardDeviceMap.cfg delete mode 100644 protocol/lufa/LUFA-git/BuildTests/BoardDriverTest/Test.c delete mode 100644 protocol/lufa/LUFA-git/BuildTests/BoardDriverTest/makefile delete mode 100644 protocol/lufa/LUFA-git/BuildTests/BoardDriverTest/makefile.test delete mode 100644 protocol/lufa/LUFA-git/BuildTests/BootloaderTest/BootloaderDeviceMap.cfg delete mode 100644 protocol/lufa/LUFA-git/BuildTests/BootloaderTest/makefile delete mode 100644 protocol/lufa/LUFA-git/BuildTests/ModuleTest/Dummy.S delete mode 100644 protocol/lufa/LUFA-git/BuildTests/ModuleTest/Modules.h delete mode 100644 protocol/lufa/LUFA-git/BuildTests/ModuleTest/Test_C.c delete mode 100644 protocol/lufa/LUFA-git/BuildTests/ModuleTest/Test_CPP.cpp delete mode 100644 protocol/lufa/LUFA-git/BuildTests/ModuleTest/makefile delete mode 100644 protocol/lufa/LUFA-git/BuildTests/ModuleTest/makefile.test delete mode 100644 protocol/lufa/LUFA-git/BuildTests/SingleUSBModeTest/Dummy.S delete mode 100644 protocol/lufa/LUFA-git/BuildTests/SingleUSBModeTest/Test.c delete mode 100644 protocol/lufa/LUFA-git/BuildTests/SingleUSBModeTest/makefile delete mode 100644 protocol/lufa/LUFA-git/BuildTests/SingleUSBModeTest/makefile.test delete mode 100644 protocol/lufa/LUFA-git/BuildTests/StaticAnalysisTest/makefile delete mode 100644 protocol/lufa/LUFA-git/BuildTests/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/AudioInput.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/AudioInput.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/AudioInput.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioInput/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioOutput/AudioOutput.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioOutput/AudioOutput.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioOutput/AudioOutput.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioOutput/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioOutput/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioOutput/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioOutput/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioOutput/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioOutput/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/AudioOutput/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualMIDI/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualMIDI/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualMIDI/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualMIDI/DualMIDI.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualMIDI/DualMIDI.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualMIDI/DualMIDI.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualMIDI/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualMIDI/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualMIDI/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualVirtualSerial/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualVirtualSerial/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualVirtualSerial/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualVirtualSerial/DualVirtualSerial.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualVirtualSerial/DualVirtualSerial.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualVirtualSerial/DualVirtualSerial.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualVirtualSerial/LUFA DualVirtualSerial.inf delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualVirtualSerial/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualVirtualSerial/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/DualVirtualSerial/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/GenericHID/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/GenericHID/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/GenericHID/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/GenericHID/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/GenericHID/GenericHID.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/GenericHID/GenericHID.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/GenericHID/GenericHID.txt delete mode 100755 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/GenericHID/HostTestApp/test_generic_hid_libusb.js delete mode 100755 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/GenericHID/HostTestApp/test_generic_hid_libusb.py delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/GenericHID/HostTestApp/test_generic_hid_winusb.py delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/GenericHID/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/GenericHID/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/GenericHID/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Joystick/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Joystick/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Joystick/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Joystick/Joystick.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Joystick/Joystick.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Joystick/Joystick.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Joystick/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Joystick/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Joystick/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Keyboard/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Keyboard/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Keyboard/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Keyboard/Keyboard.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Keyboard/Keyboard.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Keyboard/Keyboard.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Keyboard/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Keyboard/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Keyboard/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/KeyboardMouse/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/KeyboardMouse/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/KeyboardMouse/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/KeyboardMouse/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/KeyboardMouse/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/KeyboardMouse/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/KeyboardMouseMultiReport/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/KeyboardMouseMultiReport/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/KeyboardMouseMultiReport/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/KeyboardMouseMultiReport/KeyboardMouseMultiReport.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/KeyboardMouseMultiReport/KeyboardMouseMultiReport.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/KeyboardMouseMultiReport/KeyboardMouseMultiReport.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/KeyboardMouseMultiReport/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/KeyboardMouseMultiReport/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/KeyboardMouseMultiReport/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MIDI/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MIDI/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MIDI/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MIDI/MIDI.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MIDI/MIDI.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MIDI/MIDI.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MIDI/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MIDI/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MIDI/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorage/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorage/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorage/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorage/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorage/MassStorage.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorage/MassStorage.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorage/MassStorage.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorage/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorage/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorage/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorageKeyboard/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorageKeyboard/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorageKeyboard/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorageKeyboard/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorageKeyboard/Lib/DataflashManager.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorageKeyboard/Lib/DataflashManager.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorageKeyboard/Lib/SCSI.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorageKeyboard/Lib/SCSI.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorageKeyboard/MassStorageKeyboard.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorageKeyboard/MassStorageKeyboard.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorageKeyboard/MassStorageKeyboard.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorageKeyboard/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorageKeyboard/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/MassStorageKeyboard/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Mouse/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Mouse/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Mouse/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Mouse/Mouse.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Mouse/Mouse.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Mouse/Mouse.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Mouse/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Mouse/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/Mouse/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/LUFA RNDIS.inf delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/ARP.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/ARP.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/DHCP.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/Ethernet.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/Ethernet.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/EthernetProtocols.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/ICMP.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/ICMP.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/IP.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/IP.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/ProtocolDecoders.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/ProtocolDecoders.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/TCP.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/UDP.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/UDP.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/Webserver.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/Lib/Webserver.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/RNDISEthernet.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/RNDISEthernet/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerial/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerial/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerial/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerial/LUFA VirtualSerial.inf delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerial/VirtualSerial.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerial/VirtualSerial.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerial/VirtualSerial.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerial/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerial/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerial/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMassStorage/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMassStorage/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMassStorage/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMassStorage/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMassStorage/LUFA VirtualSerialMassStorage.inf delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMassStorage/Lib/DataflashManager.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMassStorage/Lib/DataflashManager.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMassStorage/Lib/SCSI.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMassStorage/Lib/SCSI.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMassStorage/VirtualSerialMassStorage.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMassStorage/VirtualSerialMassStorage.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMassStorage/VirtualSerialMassStorage.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMassStorage/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMassStorage/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMassStorage/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMouse/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMouse/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMouse/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMouse/LUFA VirtualSerialMouse.inf delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMouse/VirtualSerialMouse.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMouse/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMouse/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/VirtualSerialMouse/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/ClassDriver/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/Incomplete/TestAndMeasurement/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/Incomplete/TestAndMeasurement/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/Incomplete/TestAndMeasurement/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/Incomplete/TestAndMeasurement/TestAndMeasurement.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/Incomplete/TestAndMeasurement/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioInput/AudioInput.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioInput/AudioInput.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioInput/AudioInput.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioInput/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioInput/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioInput/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioInput/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioInput/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioInput/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioInput/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioOutput/AudioOutput.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioOutput/AudioOutput.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioOutput/AudioOutput.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioOutput/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioOutput/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioOutput/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioOutput/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioOutput/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioOutput/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/AudioOutput/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/BulkVendor.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/BulkVendor.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/BulkVendor.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/HostTestApp/test_bulk_vendor.py delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/WindowsDriver/LUFA_Bulk_Vendor_Demo.inf delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/WindowsDriver/amd64/libusb0.dll delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/WindowsDriver/amd64/libusb0.sys delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/WindowsDriver/ia64/libusb0.dll delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/WindowsDriver/ia64/libusb0.sys delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/WindowsDriver/installer_x64.exe delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/WindowsDriver/installer_x86.exe delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/WindowsDriver/license/libusb0/installer_license.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/WindowsDriver/x86/libusb0.sys delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/WindowsDriver/x86/libusb0_x86.dll delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/BulkVendor/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/DualVirtualSerial/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/DualVirtualSerial/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/DualVirtualSerial/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/DualVirtualSerial/LUFA DualVirtualSerial.inf delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/DualVirtualSerial/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/DualVirtualSerial/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/DualVirtualSerial/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/GenericHID/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/GenericHID/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/GenericHID/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/GenericHID/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/GenericHID/GenericHID.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/GenericHID/GenericHID.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/GenericHID/GenericHID.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/GenericHID/HostTestApp/test_generic_hid.py delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/GenericHID/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/GenericHID/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/GenericHID/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Joystick/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Joystick/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Joystick/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Joystick/Joystick.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Joystick/Joystick.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Joystick/Joystick.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Joystick/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Joystick/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Joystick/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Keyboard/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Keyboard/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Keyboard/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Keyboard/Keyboard.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Keyboard/Keyboard.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Keyboard/Keyboard.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Keyboard/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Keyboard/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Keyboard/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/KeyboardMouse/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/KeyboardMouse/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/KeyboardMouse/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/KeyboardMouse/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/KeyboardMouse/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/KeyboardMouse/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MIDI/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MIDI/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MIDI/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MIDI/MIDI.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MIDI/MIDI.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MIDI/MIDI.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MIDI/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MIDI/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MIDI/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MassStorage/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MassStorage/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MassStorage/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MassStorage/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MassStorage/Lib/SCSI.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MassStorage/Lib/SCSI.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MassStorage/MassStorage.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MassStorage/MassStorage.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MassStorage/MassStorage.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MassStorage/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MassStorage/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/MassStorage/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Mouse/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Mouse/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Mouse/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Mouse/Mouse.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Mouse/Mouse.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Mouse/Mouse.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Mouse/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Mouse/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/Mouse/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/LUFA RNDIS.inf delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/ARP.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/ARP.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/DHCP.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/DHCP.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/Ethernet.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/Ethernet.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/EthernetProtocols.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/ICMP.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/ICMP.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/IP.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/IP.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/ProtocolDecoders.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/ProtocolDecoders.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/RNDIS.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/RNDIS.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/TCP.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/TCP.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/UDP.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/UDP.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/Webserver.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/Lib/Webserver.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/RNDISEthernet/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/VirtualSerial/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/VirtualSerial/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/VirtualSerial/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/VirtualSerial/LUFA VirtualSerial.inf delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/VirtualSerial/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/VirtualSerial/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/VirtualSerial/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/LowLevel/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Device/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/DualRole/ClassDriver/MouseHostDevice/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/DualRole/ClassDriver/MouseHostDevice/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Demos/DualRole/ClassDriver/MouseHostDevice/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Demos/DualRole/ClassDriver/MouseHostDevice/DeviceFunctions.c delete mode 100644 protocol/lufa/LUFA-git/Demos/DualRole/ClassDriver/MouseHostDevice/DeviceFunctions.h delete mode 100644 protocol/lufa/LUFA-git/Demos/DualRole/ClassDriver/MouseHostDevice/HostFunctions.c delete mode 100644 protocol/lufa/LUFA-git/Demos/DualRole/ClassDriver/MouseHostDevice/HostFunctions.h delete mode 100644 protocol/lufa/LUFA-git/Demos/DualRole/ClassDriver/MouseHostDevice/MouseHostDevice.c delete mode 100644 protocol/lufa/LUFA-git/Demos/DualRole/ClassDriver/MouseHostDevice/MouseHostDevice.h delete mode 100644 protocol/lufa/LUFA-git/Demos/DualRole/ClassDriver/MouseHostDevice/MouseHostDevice.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/DualRole/ClassDriver/MouseHostDevice/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/DualRole/ClassDriver/MouseHostDevice/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/DualRole/ClassDriver/MouseHostDevice/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/DualRole/ClassDriver/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/DualRole/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidAccessoryHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidAccessoryHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidAccessoryHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AndroidAccessoryHost/AndroidHostApp/AndroidHostApp.zip delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AndroidAccessoryHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AndroidAccessoryHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AndroidAccessoryHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AndroidAccessoryHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AudioInputHost/AudioInputHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AudioInputHost/AudioInputHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AudioInputHost/AudioInputHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AudioInputHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AudioInputHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AudioInputHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AudioInputHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AudioOutputHost/AudioOutputHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AudioOutputHost/AudioOutputHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AudioOutputHost/AudioOutputHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AudioOutputHost/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AudioOutputHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AudioOutputHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AudioOutputHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/AudioOutputHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/JoystickHostWithParser/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/JoystickHostWithParser/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/JoystickHostWithParser/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/JoystickHostWithParser/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/KeyboardHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/KeyboardHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/KeyboardHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/KeyboardHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/KeyboardHostWithParser/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/KeyboardHostWithParser/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/KeyboardHostWithParser/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/KeyboardHostWithParser/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MIDIHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MIDIHost/MIDIHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MIDIHost/MIDIHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MIDIHost/MIDIHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MIDIHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MIDIHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MIDIHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MassStorageHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MassStorageHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MassStorageHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MassStorageHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MouseHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MouseHost/MouseHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MouseHost/MouseHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MouseHost/MouseHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MouseHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MouseHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MouseHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MouseHostWithParser/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MouseHostWithParser/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MouseHostWithParser/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/MouseHostWithParser/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/PrinterHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/PrinterHost/PrinterHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/PrinterHost/PrinterHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/PrinterHost/PrinterHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/PrinterHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/PrinterHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/PrinterHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/RNDISEthernetHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/RNDISEthernetHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/RNDISEthernetHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/RNDISEthernetHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/StillImageHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/StillImageHost/StillImageHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/StillImageHost/StillImageHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/StillImageHost/StillImageHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/StillImageHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/StillImageHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/StillImageHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/VirtualSerialHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/VirtualSerialHost/VirtualSerialHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/VirtualSerialHost/VirtualSerialHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/VirtualSerialHost/VirtualSerialHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/VirtualSerialHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/VirtualSerialHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/VirtualSerialHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/ClassDriver/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AndroidAccessoryHost/AndroidAccessoryHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AndroidAccessoryHost/AndroidAccessoryHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AndroidAccessoryHost/AndroidAccessoryHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AndroidAccessoryHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AndroidAccessoryHost/ConfigDescriptor.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AndroidAccessoryHost/ConfigDescriptor.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AndroidAccessoryHost/DeviceDescriptor.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AndroidAccessoryHost/DeviceDescriptor.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AndroidAccessoryHost/Lib/AndroidAccessoryCommands.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AndroidAccessoryHost/Lib/AndroidAccessoryCommands.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AndroidAccessoryHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AndroidAccessoryHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AndroidAccessoryHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioInputHost/AudioInputHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioInputHost/AudioInputHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioInputHost/AudioInputHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioInputHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioInputHost/ConfigDescriptor.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioInputHost/ConfigDescriptor.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioInputHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioInputHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioInputHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioOutputHost/AudioOutputHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioOutputHost/AudioOutputHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioOutputHost/AudioOutputHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioOutputHost/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioOutputHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioOutputHost/ConfigDescriptor.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioOutputHost/ConfigDescriptor.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioOutputHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioOutputHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/AudioOutputHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/GenericHIDHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/GenericHIDHost/GenericHIDHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/GenericHIDHost/GenericHIDHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/GenericHIDHost/GenericHIDHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/GenericHIDHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/GenericHIDHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/GenericHIDHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/JoystickHostWithParser/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/JoystickHostWithParser/HIDReport.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/JoystickHostWithParser/HIDReport.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/JoystickHostWithParser/JoystickHostWithParser.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/JoystickHostWithParser/JoystickHostWithParser.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/JoystickHostWithParser/JoystickHostWithParser.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/JoystickHostWithParser/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/JoystickHostWithParser/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/JoystickHostWithParser/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHostWithParser/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHostWithParser/HIDReport.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHostWithParser/HIDReport.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHostWithParser/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHostWithParser/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/KeyboardHostWithParser/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MIDIHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MIDIHost/MIDIHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MIDIHost/MIDIHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MIDIHost/MIDIHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MIDIHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MIDIHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MIDIHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MassStorageHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MassStorageHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MassStorageHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MassStorageHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHost/ConfigDescriptor.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHost/ConfigDescriptor.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHost/MouseHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHost/MouseHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHost/MouseHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHostWithParser/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHostWithParser/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHostWithParser/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/MouseHostWithParser/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/PrinterHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/PrinterHost/PrinterHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/PrinterHost/PrinterHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/PrinterHost/PrinterHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/PrinterHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/PrinterHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/PrinterHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/RNDISEthernetHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/RNDISEthernetHost/ConfigDescriptor.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/RNDISEthernetHost/ConfigDescriptor.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/RNDISEthernetHost/Lib/RNDISCommands.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/RNDISEthernetHost/Lib/RNDISCommands.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/RNDISEthernetHost/RNDISEthernetHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/RNDISEthernetHost/RNDISEthernetHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/RNDISEthernetHost/RNDISHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/RNDISEthernetHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/RNDISEthernetHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/RNDISEthernetHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/StillImageHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/StillImageHost/Lib/PIMACodes.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/StillImageHost/StillImageHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/StillImageHost/StillImageHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/StillImageHost/StillImageHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/StillImageHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/StillImageHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/StillImageHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/VirtualSerialHost/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/VirtualSerialHost/ConfigDescriptor.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/VirtualSerialHost/ConfigDescriptor.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.c delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.h delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.txt delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/VirtualSerialHost/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/VirtualSerialHost/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/VirtualSerialHost/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/LowLevel/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/Host/makefile delete mode 100644 protocol/lufa/LUFA-git/Demos/makefile delete mode 100644 protocol/lufa/LUFA-git/LUFA/Build/HID_EEPROM_Loader/HID_EEPROM_Loader.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Build/HID_EEPROM_Loader/makefile delete mode 100644 protocol/lufa/LUFA-git/LUFA/Build/lufa_atprogram.mk delete mode 100644 protocol/lufa/LUFA-git/LUFA/Build/lufa_avrdude.mk delete mode 100644 protocol/lufa/LUFA-git/LUFA/Build/lufa_build.mk delete mode 100644 protocol/lufa/LUFA-git/LUFA/Build/lufa_core.mk delete mode 100644 protocol/lufa/LUFA-git/LUFA/Build/lufa_cppcheck.mk delete mode 100644 protocol/lufa/LUFA-git/LUFA/Build/lufa_dfu.mk delete mode 100644 protocol/lufa/LUFA-git/LUFA/Build/lufa_doxygen.mk delete mode 100644 protocol/lufa/LUFA-git/LUFA/Build/lufa_hid.mk delete mode 100644 protocol/lufa/LUFA-git/LUFA/Build/lufa_sources.mk delete mode 100644 protocol/lufa/LUFA-git/LUFA/CodeTemplates/DeviceTemplate/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/CodeTemplates/DeviceTemplate/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/CodeTemplates/DeviceTemplate/DeviceApplication.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/CodeTemplates/DeviceTemplate/DeviceApplication.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/CodeTemplates/DeviceTemplate/asf.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/CodeTemplates/DriverStubs/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/CodeTemplates/DriverStubs/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/CodeTemplates/DriverStubs/Dataflash.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/CodeTemplates/DriverStubs/Joystick.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/CodeTemplates/DriverStubs/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/CodeTemplates/HostTemplate/HostApplication.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/CodeTemplates/HostTemplate/HostApplication.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/CodeTemplates/HostTemplate/asf.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/CodeTemplates/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/CodeTemplates/WindowsINF/LUFA CDC-ACM.inf delete mode 100644 protocol/lufa/LUFA-git/LUFA/CodeTemplates/WindowsINF/LUFA RNDIS.inf delete mode 100644 protocol/lufa/LUFA-git/LUFA/CodeTemplates/makefile_template delete mode 100644 protocol/lufa/LUFA-git/LUFA/Common/ArchitectureSpecific.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Common/Architectures.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Common/Attributes.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Common/BoardTypes.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Common/Common.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Common/CompilerSpecific.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Common/Endianness.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/BuildSystem.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/BuildingLinkableLibraries.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/ChangeLog.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/CompileTimeTokens.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/CompilingApps.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/ConfiguringApps.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/DevelopingWithLUFA.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/DeviceSupport.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/DirectorySummaries.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/Donating.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/ExportingLibrary.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/FutureChanges.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/GettingStarted.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/Groups.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step1.png delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step2.png delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step3.png delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step4.png delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step5_1.png delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step5_2.png delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step5_3.png delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/Images/Author.jpg delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/Images/LUFA.png delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/Images/LUFA_thumb.png delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/KnownIssues.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/LUFAPoweredProjects.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/LibraryResources.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/LicenseInfo.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/MainPage.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/MigrationInformation.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/OSDrivers.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/ProgrammingApps.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/SoftwareBootloaderJump.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/Style/Footer.htm delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/Style/Style.css delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/VIDAndPIDValues.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/DoxygenPages/WritingBoardDrivers.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/ADAFRUITU4/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/ADAFRUITU4/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/ATAVRUSBRF01/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/ATAVRUSBRF01/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/ATAVRUSBRF01/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/BENITO/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/BENITO/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/BENITO/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/BIGMULTIO/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/BIGMULTIO/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/BLACKCAT/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/BLACKCAT/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/BUI/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/BUI/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/BUMBLEB/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/BUMBLEB/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/BUMBLEB/Joystick.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/BUMBLEB/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/CULV3/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/CULV3/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/CULV3/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/DUCE/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/DUCE/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/EVK527/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/EVK527/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/EVK527/Dataflash.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/EVK527/Joystick.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/EVK527/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/JMDBU2/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/JMDBU2/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/JMDBU2/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/LEONARDO/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/LEONARDO/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/MAXIMUS/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/MAXIMUS/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/MICRO/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/MICRO/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/MICROPENDOUS/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/MICROPENDOUS/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/MICROPENDOUS/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/MICROSIN162/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/MICROSIN162/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/MICROSIN162/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/MINIMUS/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/MINIMUS/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/MINIMUS/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/MULTIO/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/MULTIO/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/OLIMEX162/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/OLIMEX162/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/OLIMEX162/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/OLIMEX32U4/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/OLIMEX32U4/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/OLIMEX32U4/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/OLIMEXISPMK2/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/OLIMEXISPMK2/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/OLIMEXISPMK2/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/OLIMEXT32U4/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/OLIMEXT32U4/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/OLIMEXT32U4/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/RZUSBSTICK/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/RZUSBSTICK/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/SPARKFUN8U2/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/SPARKFUN8U2/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/STANGE_ISP/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/STANGE_ISP/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/STANGE_ISP/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/STK525/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/STK525/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/STK525/Dataflash.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/STK525/Joystick.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/STK525/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/STK526/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/STK526/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/STK526/Dataflash.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/STK526/Joystick.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/STK526/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/TEENSY/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/TEENSY/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/TUL/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/TUL/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/TUL/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/U2S/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/U2S/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/U2S/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/UDIP/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/UDIP/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/UDIP/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/UNO/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/UNO/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/USB2AX/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/USB2AX/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/USB2AX/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/USBFOO/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/USBFOO/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/USBFOO/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/USBKEY/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/USBKEY/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/USBKEY/Joystick.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/USBKEY/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/USBTINYMKII/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/USBTINYMKII/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/USBTINYMKII/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/XPLAIN/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/XPLAIN/Dataflash.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/XPLAIN/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/YUN/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/AVR8/YUN/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/Dataflash.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/Joystick.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/Temperature.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/Temperature.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/UC3/EVK1100/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/UC3/EVK1100/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/UC3/EVK1100/Joystick.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/UC3/EVK1100/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/UC3/EVK1101/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/UC3/EVK1101/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/UC3/EVK1101/Joystick.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/UC3/EVK1101/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/UC3/EVK1104/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/UC3/EVK1104/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/UC3/EVK1104/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/UC3/UC3A3_XPLAINED/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/UC3/UC3A3_XPLAINED/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/UC3/UC3A3_XPLAINED/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Dataflash.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/Dataflash.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/XMEGA/C3_XPLAINED/Board.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/XMEGA/C3_XPLAINED/Buttons.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Board/XMEGA/C3_XPLAINED/LEDs.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Misc/AT45DB321C.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Misc/AT45DB642D.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Misc/RingBuffer.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Misc/TerminalCodes.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Peripheral/ADC.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Peripheral/AVR8/ADC_AVR8.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Peripheral/AVR8/SPI_AVR8.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Peripheral/AVR8/SerialSPI_AVR8.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Peripheral/AVR8/Serial_AVR8.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Peripheral/AVR8/Serial_AVR8.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Peripheral/SPI.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Peripheral/Serial.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Peripheral/SerialSPI.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Peripheral/TWI.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Peripheral/XMEGA/SPI_XMEGA.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Peripheral/XMEGA/SerialSPI_XMEGA.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Peripheral/XMEGA/Serial_XMEGA.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Peripheral/XMEGA/Serial_XMEGA.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Peripheral/XMEGA/TWI_XMEGA.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/Peripheral/XMEGA/TWI_XMEGA.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/AndroidAccessoryClass.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/AudioClass.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/CDCClass.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Common/AndroidAccessoryClassCommon.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Common/AudioClassCommon.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Common/CDCClassCommon.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Common/HIDClassCommon.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Common/HIDParser.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Common/HIDParser.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Common/HIDReportData.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Common/MassStorageClassCommon.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Common/PrinterClassCommon.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Common/RNDISClassCommon.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Common/StillImageClassCommon.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Device/AudioClassDevice.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Device/AudioClassDevice.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Device/HIDClassDevice.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Device/PrinterClassDevice.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Device/PrinterClassDevice.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/HIDClass.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Host/AudioClassHost.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Host/AudioClassHost.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Host/CDCClassHost.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Host/CDCClassHost.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Host/HIDClassHost.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Host/HIDClassHost.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Host/MIDIClassHost.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Host/MIDIClassHost.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Host/MassStorageClassHost.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Host/MassStorageClassHost.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Host/PrinterClassHost.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Host/PrinterClassHost.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Host/RNDISClassHost.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Host/RNDISClassHost.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Host/StillImageClassHost.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/Host/StillImageClassHost.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/MIDIClass.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/MassStorageClass.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/PrinterClass.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/RNDISClass.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Class/StillImageClass.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_R.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_RW.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/Template/Template_Pipe_RW.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/ConfigDescriptors.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/ConfigDescriptors.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/Device.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/DeviceStandardReq.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/DeviceStandardReq.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/Endpoint.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/EndpointStream.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/Events.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/Events.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/Host.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/HostStandardReq.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/HostStandardReq.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/OTG.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/Pipe.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/PipeStream.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/StdDescriptors.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/StdRequestType.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/Device_UC3.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/Device_UC3.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/EndpointStream_UC3.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/EndpointStream_UC3.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/Host_UC3.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/Host_UC3.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/PipeStream_UC3.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/PipeStream_UC3.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_Control_R.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_Control_W.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_RW.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/Template/Template_Pipe_RW.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/USBController_UC3.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/USBController_UC3.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/USBController.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/USBInterrupt.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/USBMode.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/USBTask.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/USBTask.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/XMEGA/Device_XMEGA.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/XMEGA/Device_XMEGA.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/XMEGA/Host_XMEGA.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/XMEGA/PipeStream_XMEGA.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/XMEGA/Pipe_XMEGA.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_Control_R.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_Control_W.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_RW.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Drivers/USB/USB.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/License.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/Platform/Platform.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Platform/UC3/ClockManagement.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Platform/UC3/Exception.S delete mode 100644 protocol/lufa/LUFA-git/LUFA/Platform/UC3/InterruptManagement.c delete mode 100644 protocol/lufa/LUFA-git/LUFA/Platform/UC3/InterruptManagement.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Platform/UC3/UC3ExperimentalInfo.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/Platform/XMEGA/ClockManagement.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/Platform/XMEGA/XMEGAExperimentalInfo.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/Docbook/mshelp/placeholder.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/Docbook/placeholder.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/HV1/helpcontentsetup.msha delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/HV1/lufa_docbook_transform.xslt delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/HV1/lufa_helpcontentsetup_transform.xslt delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/HV1/lufa_hv1_transform.xslt delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/HV1/lufa_studio_help_styling.css delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/ProjectGenerator/placeholder.txt delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/VSIX/LUFA.dll delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/VSIX/LUFA.pkgdef delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/VSIX/[Content_Types].xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/VSIX/asf-manifest.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/VSIX/extension.vsixmanifest delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/VSIX/generate_caches.py delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/VSIX/lufa_asfmanifest_transform.xslt delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/VSIX/lufa_vsmanifest_transform.xslt delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/XDK/lufa_extension_transform.xslt delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/XDK/lufa_filelist_transform.xslt delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/XDK/lufa_indent_transform.xslt delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/XDK/lufa_module_transform.xslt delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_common.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_board.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_board_names.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_misc.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_peripheral.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_usb.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_usb_class.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_usb_class_android.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_usb_class_audio.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_usb_class_cdc.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_usb_class_hid.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_usb_class_midi.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_usb_class_ms.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_usb_class_printer.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_usb_class_rndis.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_usb_class_si.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_usb_core.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_usb_core_avr8.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_usb_core_uc3.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_drivers_usb_core_xmega.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_platform.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_platform_uc3.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_platform_xmega.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/lufa_toolchain.xml delete mode 100644 protocol/lufa/LUFA-git/LUFA/StudioIntegration/makefile delete mode 100644 protocol/lufa/LUFA-git/LUFA/Version.h delete mode 100644 protocol/lufa/LUFA-git/LUFA/doxyfile delete mode 100644 protocol/lufa/LUFA-git/LUFA/makefile delete mode 100644 protocol/lufa/LUFA-git/Maintenance/lufa_functionlist_transform.xslt delete mode 100644 protocol/lufa/LUFA-git/Maintenance/makefile delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/AVRISP-MKII.c delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/AVRISP-MKII.h delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/AVRISP-MKII.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/AVRISPDescriptors.c delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/AVRISPDescriptors.h delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.h delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.h delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/V2Protocol.c delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/V2Protocol.h delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/V2ProtocolConstants.h delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/V2ProtocolParams.c delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/V2ProtocolParams.h delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.h delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.h delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.h delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Projects/AVRISP-MKII/makefile delete mode 100644 protocol/lufa/LUFA-git/Projects/Benito/Benito.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Benito/Benito.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Benito/Benito.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/Benito/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Benito/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Benito/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Benito/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Benito/LUFA Benito Programmer.inf delete mode 100644 protocol/lufa/LUFA-git/Projects/Benito/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Projects/Benito/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Projects/Benito/makefile delete mode 100644 protocol/lufa/LUFA-git/Projects/HIDReportViewer/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/HIDReportViewer/HIDReportViewer.c delete mode 100644 protocol/lufa/LUFA-git/Projects/HIDReportViewer/HIDReportViewer.h delete mode 100644 protocol/lufa/LUFA-git/Projects/HIDReportViewer/HIDReportViewer.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/HIDReportViewer/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Projects/HIDReportViewer/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Projects/HIDReportViewer/makefile delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/CPUUsageApp/CPUMonitor.Designer.cs delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/CPUUsageApp/CPUMonitor.cs delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/CPUUsageApp/CPUMonitor.csproj delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/CPUUsageApp/CPUMonitor.resx delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/CPUUsageApp/Program.cs delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/CPUUsageApp/Properties/AssemblyInfo.cs delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/CPUUsageApp/Properties/Resources.Designer.cs delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/CPUUsageApp/Properties/Resources.resx delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/CPUUsageApp/Properties/Settings.Designer.cs delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/CPUUsageApp/Properties/Settings.settings delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/LEDMixerApp/LEDMixer.Designer.cs delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/LEDMixerApp/LEDMixer.cs delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/LEDMixerApp/LEDMixer.csproj delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/LEDMixerApp/LEDMixer.resx delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/LEDMixerApp/Program.cs delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/LEDMixerApp/Properties/AssemblyInfo.cs delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/LEDMixerApp/Properties/Resources.Designer.cs delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/LEDMixerApp/Properties/Resources.resx delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/LEDMixerApp/Properties/Settings.Designer.cs delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/LEDMixerApp/Properties/Settings.settings delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/LEDNotifier.c delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/LEDNotifier.h delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/LEDNotifier.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/LUFA LED Notifier.inf delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Projects/LEDNotifier/makefile delete mode 100644 protocol/lufa/LUFA-git/Projects/MIDIToneGenerator/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/MIDIToneGenerator/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/MIDIToneGenerator/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Projects/MIDIToneGenerator/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Projects/MIDIToneGenerator/MIDIToneGenerator.c delete mode 100644 protocol/lufa/LUFA-git/Projects/MIDIToneGenerator/MIDIToneGenerator.h delete mode 100644 protocol/lufa/LUFA-git/Projects/MIDIToneGenerator/MIDIToneGenerator.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/MIDIToneGenerator/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Projects/MIDIToneGenerator/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Projects/MIDIToneGenerator/makefile delete mode 100644 protocol/lufa/LUFA-git/Projects/Magstripe/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Magstripe/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Magstripe/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Magstripe/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Magstripe/Lib/CircularBitBuffer.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Magstripe/Lib/CircularBitBuffer.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Magstripe/Lib/MagstripeHW.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Magstripe/Magstripe.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Magstripe/Magstripe.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Magstripe/Magstripe.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/Magstripe/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Projects/Magstripe/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Projects/Magstripe/makefile delete mode 100644 protocol/lufa/LUFA-git/Projects/MediaController/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/MediaController/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Projects/MediaController/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Projects/MediaController/MediaController.c delete mode 100644 protocol/lufa/LUFA-git/Projects/MediaController/MediaController.h delete mode 100644 protocol/lufa/LUFA-git/Projects/MediaController/MediaController.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/MediaController/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Projects/MediaController/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Projects/MediaController/makefile delete mode 100644 protocol/lufa/LUFA-git/Projects/MissileLauncher/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/MissileLauncher/ConfigDescriptor.c delete mode 100644 protocol/lufa/LUFA-git/Projects/MissileLauncher/ConfigDescriptor.h delete mode 100644 protocol/lufa/LUFA-git/Projects/MissileLauncher/MissileLauncher.c delete mode 100644 protocol/lufa/LUFA-git/Projects/MissileLauncher/MissileLauncher.h delete mode 100644 protocol/lufa/LUFA-git/Projects/MissileLauncher/MissileLauncher.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/MissileLauncher/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Projects/MissileLauncher/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Projects/MissileLauncher/makefile delete mode 100644 protocol/lufa/LUFA-git/Projects/RelayBoard/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/RelayBoard/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Projects/RelayBoard/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Projects/RelayBoard/RelayBoard.c delete mode 100644 protocol/lufa/LUFA-git/Projects/RelayBoard/RelayBoard.h delete mode 100644 protocol/lufa/LUFA-git/Projects/RelayBoard/RelayBoard.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/RelayBoard/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Projects/RelayBoard/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Projects/RelayBoard/makefile delete mode 100644 protocol/lufa/LUFA-git/Projects/SerialToLCD/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/SerialToLCD/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Projects/SerialToLCD/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Projects/SerialToLCD/Lib/HD44780.c delete mode 100644 protocol/lufa/LUFA-git/Projects/SerialToLCD/Lib/HD44780.h delete mode 100644 protocol/lufa/LUFA-git/Projects/SerialToLCD/SerialToLCD.c delete mode 100644 protocol/lufa/LUFA-git/Projects/SerialToLCD/SerialToLCD.h delete mode 100644 protocol/lufa/LUFA-git/Projects/SerialToLCD/SerialToLCD.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/SerialToLCD/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Projects/SerialToLCD/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Projects/SerialToLCD/makefile delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/Lib/DataflashManager.c delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/Lib/DataflashManager.h delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/Lib/FATFs/00readme.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/Lib/FATFs/diskio.c delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/Lib/FATFs/diskio.h delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/Lib/FATFs/ff.c delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/Lib/FATFs/ff.h delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/Lib/FATFs/ffconf.h delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/Lib/FATFs/integer.h delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/Lib/RTC.c delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/Lib/RTC.h delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/Lib/SCSI.c delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/Lib/SCSI.h delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempDataLogger.c delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempDataLogger.h delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempLogHostApp/COPYING.LESSER.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempLogHostApp/COPYING.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempLogHostApp/DataLoggerSettings.Designer.cs delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempLogHostApp/DataLoggerSettings.cs delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempLogHostApp/DataLoggerSettings.resx delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempLogHostApp/Hid.Linux.dll delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempLogHostApp/Hid.Net.dll delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempLogHostApp/Hid.Win32.dll delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempLogHostApp/Program.cs delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempLogHostApp/Properties/AssemblyInfo.cs delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempLogHostApp/Properties/Resources.Designer.cs delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempLogHostApp/Properties/Resources.resx delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempLogHostApp/Properties/Settings.Designer.cs delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempLogHostApp/Properties/Settings.settings delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempLogHostApp/README.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempLogHostApp/TempLoggerHostApp.csproj delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TempLogHostApp_Python/temp_log_config.py delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/TemperatureDataLogger.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Projects/TempDataLogger/makefile delete mode 100644 protocol/lufa/LUFA-git/Projects/USBtoSerial/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/USBtoSerial/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Projects/USBtoSerial/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Projects/USBtoSerial/LUFA USBtoSerial.inf delete mode 100644 protocol/lufa/LUFA-git/Projects/USBtoSerial/USBtoSerial.c delete mode 100644 protocol/lufa/LUFA-git/Projects/USBtoSerial/USBtoSerial.h delete mode 100644 protocol/lufa/LUFA-git/Projects/USBtoSerial/USBtoSerial.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/USBtoSerial/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Projects/USBtoSerial/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Projects/USBtoSerial/makefile delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Descriptors.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Descriptors.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/LUFA Webserver RNDIS.inf delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/DHCPClientApp.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/DHCPClientApp.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/DHCPCommon.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/DHCPCommon.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/DHCPServerApp.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/DHCPServerApp.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/DataflashManager.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/DataflashManager.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/FATFs/00readme.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/FATFs/diskio.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/FATFs/diskio.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/FATFs/ff.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/FATFs/ff.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/FATFs/ffconf.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/FATFs/integer.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/HTTPServerApp.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/HTTPServerApp.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/SCSI.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/SCSI.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/TELNETServerApp.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/TELNETServerApp.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/uIPManagement.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/uIPManagement.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/uip/clock.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/uip/clock.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/uip/timer.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/uip/timer.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/uip/uip-split.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/uip/uip-split.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/uip/uip.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/uip/uip.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/uip/uip_arp.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/uip/uip_arp.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Lib/uip/uipopt.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/USBDeviceMode.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/USBDeviceMode.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/USBHostMode.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/USBHostMode.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Webserver.c delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Webserver.h delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/Webserver.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Projects/Webserver/makefile delete mode 100644 protocol/lufa/LUFA-git/Projects/XPLAINBridge/Config/AppConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/XPLAINBridge/Config/LUFAConfig.h delete mode 100644 protocol/lufa/LUFA-git/Projects/XPLAINBridge/LUFA XPLAIN Bridge.inf delete mode 100644 protocol/lufa/LUFA-git/Projects/XPLAINBridge/Lib/SoftUART.c delete mode 100644 protocol/lufa/LUFA-git/Projects/XPLAINBridge/Lib/SoftUART.h delete mode 100644 protocol/lufa/LUFA-git/Projects/XPLAINBridge/USARTDescriptors.c delete mode 100644 protocol/lufa/LUFA-git/Projects/XPLAINBridge/USARTDescriptors.h delete mode 100644 protocol/lufa/LUFA-git/Projects/XPLAINBridge/XPLAINBridge.c delete mode 100644 protocol/lufa/LUFA-git/Projects/XPLAINBridge/XPLAINBridge.h delete mode 100644 protocol/lufa/LUFA-git/Projects/XPLAINBridge/XPLAINBridge.txt delete mode 100644 protocol/lufa/LUFA-git/Projects/XPLAINBridge/asf.xml delete mode 100644 protocol/lufa/LUFA-git/Projects/XPLAINBridge/doxyfile delete mode 100644 protocol/lufa/LUFA-git/Projects/XPLAINBridge/makefile delete mode 100644 protocol/lufa/LUFA-git/Projects/makefile delete mode 100644 protocol/lufa/LUFA-git/README.txt delete mode 100644 protocol/lufa/LUFA-git/makefile diff --git a/protocol/lufa/LUFA-git/.gitignore b/protocol/lufa/LUFA-git/.gitignore deleted file mode 100644 index 045f9698..00000000 --- a/protocol/lufa/LUFA-git/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -*.o -*.d -*.elf -*.hex -*.eep -*.sym -*.bin -*.lss -*.map -*.bak -*.class -Documentation/ -LUFA/StudioIntegration/ProjectGenerator/* -LUFA/StudioIntegration/DocBook/* diff --git a/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPI.c b/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPI.c deleted file mode 100644 index f7564e98..00000000 --- a/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPI.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2014. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * - * Bootloader user application API functions. - */ - -#include "BootloaderAPI.h" - -void BootloaderAPI_ErasePage(const uint32_t Address) -{ - boot_page_erase_safe(Address); - boot_spm_busy_wait(); - boot_rww_enable(); -} - -void BootloaderAPI_WritePage(const uint32_t Address) -{ - boot_page_write_safe(Address); - boot_spm_busy_wait(); - boot_rww_enable(); -} - -void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word) -{ - boot_page_fill_safe(Address, Word); -} - -uint8_t BootloaderAPI_ReadSignature(const uint16_t Address) -{ - return boot_signature_byte_get(Address); -} - -uint8_t BootloaderAPI_ReadFuse(const uint16_t Address) -{ - return boot_lock_fuse_bits_get(Address); -} - -uint8_t BootloaderAPI_ReadLock(void) -{ - return boot_lock_fuse_bits_get(GET_LOCK_BITS); -} - -void BootloaderAPI_WriteLock(const uint8_t LockBits) -{ - boot_lock_bits_set_safe(LockBits); -} diff --git a/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPI.h b/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPI.h deleted file mode 100644 index 2462cacd..00000000 --- a/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPI.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2014. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * - * Header file for BootloaderAPI.c. - */ - -#ifndef _BOOTLOADER_API_H_ -#define _BOOTLOADER_API_H_ - - /* Includes: */ - #include - #include - #include - - #include - - #include "Config/AppConfig.h" - - /* Function Prototypes: */ - void BootloaderAPI_ErasePage(const uint32_t Address); - void BootloaderAPI_WritePage(const uint32_t Address); - void BootloaderAPI_FillWord(const uint32_t Address, const uint16_t Word); - uint8_t BootloaderAPI_ReadSignature(const uint16_t Address); - uint8_t BootloaderAPI_ReadFuse(const uint16_t Address); - uint8_t BootloaderAPI_ReadLock(void); - void BootloaderAPI_WriteLock(const uint8_t LockBits); - -#endif - diff --git a/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPITable.S b/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPITable.S deleted file mode 100644 index 69ebd387..00000000 --- a/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderAPITable.S +++ /dev/null @@ -1,91 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2014. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -; Trampolines to actual API implementations if the target address is outside the -; range of a rjmp instruction (can happen with large bootloader sections) -.section .apitable_trampolines, "ax" -.global BootloaderAPI_Trampolines -BootloaderAPI_Trampolines: - - BootloaderAPI_ErasePage_Trampoline: - jmp BootloaderAPI_ErasePage - BootloaderAPI_WritePage_Trampoline: - jmp BootloaderAPI_WritePage - BootloaderAPI_FillWord_Trampoline: - jmp BootloaderAPI_FillWord - BootloaderAPI_ReadSignature_Trampoline: - jmp BootloaderAPI_ReadSignature - BootloaderAPI_ReadFuse_Trampoline: - jmp BootloaderAPI_ReadFuse - BootloaderAPI_ReadLock_Trampoline: - jmp BootloaderAPI_ReadLock - BootloaderAPI_WriteLock_Trampoline: - jmp BootloaderAPI_WriteLock - BootloaderAPI_UNUSED1: - ret - BootloaderAPI_UNUSED2: - ret - BootloaderAPI_UNUSED3: - ret - BootloaderAPI_UNUSED4: - ret - BootloaderAPI_UNUSED5: - ret - - - -; API function jump table -.section .apitable_jumptable, "ax" -.global BootloaderAPI_JumpTable -BootloaderAPI_JumpTable: - - rjmp BootloaderAPI_ErasePage_Trampoline - rjmp BootloaderAPI_WritePage_Trampoline - rjmp BootloaderAPI_FillWord_Trampoline - rjmp BootloaderAPI_ReadSignature_Trampoline - rjmp BootloaderAPI_ReadFuse_Trampoline - rjmp BootloaderAPI_ReadLock_Trampoline - rjmp BootloaderAPI_WriteLock_Trampoline - rjmp BootloaderAPI_UNUSED1 ; UNUSED ENTRY 1 - rjmp BootloaderAPI_UNUSED2 ; UNUSED ENTRY 2 - rjmp BootloaderAPI_UNUSED3 ; UNUSED ENTRY 3 - rjmp BootloaderAPI_UNUSED4 ; UNUSED ENTRY 4 - rjmp BootloaderAPI_UNUSED5 ; UNUSED ENTRY 5 - - - -; Bootloader table signatures and information -.section .apitable_signatures, "ax" -.global BootloaderAPI_Signatures -BootloaderAPI_Signatures: - - .long BOOT_START_ADDR ; Start address of the bootloader - .word 0xDF00 ; Signature for the CDC class bootloader - .word 0xDCFB ; Signature for a LUFA class bootloader diff --git a/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderCDC.c b/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderCDC.c deleted file mode 100644 index f66a483e..00000000 --- a/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderCDC.c +++ /dev/null @@ -1,641 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2014. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * - * Main source file for the CDC class bootloader. This file contains the complete bootloader logic. - */ - -#define INCLUDE_FROM_BOOTLOADERCDC_C -#include "BootloaderCDC.h" - -/** Contains the current baud rate and other settings of the first virtual serial port. This must be retained as some - * operating systems will not open the port unless the settings can be set successfully. - */ -static CDC_LineEncoding_t LineEncoding = { .BaudRateBPS = 0, - .CharFormat = CDC_LINEENCODING_OneStopBit, - .ParityType = CDC_PARITY_None, - .DataBits = 8 }; - -/** Current address counter. This stores the current address of the FLASH or EEPROM as set by the host, - * and is used when reading or writing to the AVRs memory (either FLASH or EEPROM depending on the issued - * command.) - */ -static uint32_t CurrAddress; - -/** Flag to indicate if the bootloader should be running, or should exit and allow the application code to run - * via a watchdog reset. When cleared the bootloader will exit, starting the watchdog and entering an infinite - * loop until the AVR restarts and the application runs. - */ -static bool RunBootloader = true; - -/** Magic lock for forced application start. If the HWBE fuse is programmed and BOOTRST is unprogrammed, the bootloader - * will start if the /HWB line of the AVR is held low and the system is reset. However, if the /HWB line is still held - * low when the application attempts to start via a watchdog reset, the bootloader will re-start. If set to the value - * \ref MAGIC_BOOT_KEY the special init function \ref Application_Jump_Check() will force the application to start. - */ -uint16_t MagicBootKey ATTR_NO_INIT; - - -/** Special startup routine to check if the bootloader was started via a watchdog reset, and if the magic application - * start key has been loaded into \ref MagicBootKey. If the bootloader started via the watchdog and the key is valid, - * this will force the user application to start via a software jump. - */ -void Application_Jump_Check(void) -{ - bool JumpToApplication = false; - - #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1)) - /* Disable JTAG debugging */ - JTAG_DISABLE(); - - /* Enable pull-up on the JTAG TCK pin so we can use it to select the mode */ - PORTF |= (1 << 4); - Delay_MS(10); - - /* If the TCK pin is not jumpered to ground, start the user application instead */ - JumpToApplication |= ((PINF & (1 << 4)) != 0); - - /* Re-enable JTAG debugging */ - JTAG_ENABLE(); - #endif - - /* If the reset source was the bootloader and the key is correct, clear it and jump to the application */ - if ((MCUSR & (1 << WDRF)) && (MagicBootKey == MAGIC_BOOT_KEY)) - JumpToApplication |= true; - - /* If a request has been made to jump to the user application, honor it */ - if (JumpToApplication) - { - /* Turn off the watchdog */ - MCUSR &= ~(1< 0xFFFF) - WriteNextResponseByte(pgm_read_byte_far(CurrAddress | HighByte)); - #else - WriteNextResponseByte(pgm_read_byte(CurrAddress | HighByte)); - #endif - - /* If both bytes in current word have been read, increment the address counter */ - if (HighByte) - CurrAddress += 2; - - HighByte = !HighByte; - } - else - { - /* Read the next EEPROM byte into the endpoint */ - WriteNextResponseByte(eeprom_read_byte((uint8_t*)(intptr_t)(CurrAddress >> 1))); - - /* Increment the address counter after use */ - CurrAddress += 2; - } - } - } - else - { - uint32_t PageStartAddress = CurrAddress; - - if (MemoryType == MEMORY_TYPE_FLASH) - { - boot_page_erase(PageStartAddress); - boot_spm_busy_wait(); - } - - while (BlockSize--) - { - if (MemoryType == MEMORY_TYPE_FLASH) - { - /* If both bytes in current word have been written, increment the address counter */ - if (HighByte) - { - /* Write the next FLASH word to the current FLASH page */ - boot_page_fill(CurrAddress, ((FetchNextCommandByte() << 8) | LowByte)); - - /* Increment the address counter after use */ - CurrAddress += 2; - } - else - { - LowByte = FetchNextCommandByte(); - } - - HighByte = !HighByte; - } - else - { - /* Write the next EEPROM byte from the endpoint */ - eeprom_write_byte((uint8_t*)((intptr_t)(CurrAddress >> 1)), FetchNextCommandByte()); - - /* Increment the address counter after use */ - CurrAddress += 2; - } - } - - /* If in FLASH programming mode, commit the page after writing */ - if (MemoryType == MEMORY_TYPE_FLASH) - { - /* Commit the flash page to memory */ - boot_page_write(PageStartAddress); - - /* Wait until write operation has completed */ - boot_spm_busy_wait(); - } - - /* Send response byte back to the host */ - WriteNextResponseByte('\r'); - } -} -#endif - -/** Retrieves the next byte from the host in the CDC data OUT endpoint, and clears the endpoint bank if needed - * to allow reception of the next data packet from the host. - * - * \return Next received byte from the host in the CDC data OUT endpoint - */ -static uint8_t FetchNextCommandByte(void) -{ - /* Select the OUT endpoint so that the next data byte can be read */ - Endpoint_SelectEndpoint(CDC_RX_EPADDR); - - /* If OUT endpoint empty, clear it and wait for the next packet from the host */ - while (!(Endpoint_IsReadWriteAllowed())) - { - Endpoint_ClearOUT(); - - while (!(Endpoint_IsOUTReceived())) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return 0; - } - } - - /* Fetch the next byte from the OUT endpoint */ - return Endpoint_Read_8(); -} - -/** Writes the next response byte to the CDC data IN endpoint, and sends the endpoint back if needed to free up the - * bank when full ready for the next byte in the packet to the host. - * - * \param[in] Response Next response byte to send to the host - */ -static void WriteNextResponseByte(const uint8_t Response) -{ - /* Select the IN endpoint so that the next data byte can be written */ - Endpoint_SelectEndpoint(CDC_TX_EPADDR); - - /* If IN endpoint full, clear it and wait until ready for the next packet to the host */ - if (!(Endpoint_IsReadWriteAllowed())) - { - Endpoint_ClearIN(); - - while (!(Endpoint_IsINReady())) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - } - } - - /* Write the next byte to the IN endpoint */ - Endpoint_Write_8(Response); -} - -/** Task to read in AVR109 commands from the CDC data OUT endpoint, process them, perform the required actions - * and send the appropriate response back to the host. - */ -static void CDC_Task(void) -{ - /* Select the OUT endpoint */ - Endpoint_SelectEndpoint(CDC_RX_EPADDR); - - /* Check if endpoint has a command in it sent from the host */ - if (!(Endpoint_IsOUTReceived())) - return; - - /* Read in the bootloader command (first byte sent from host) */ - uint8_t Command = FetchNextCommandByte(); - - if (Command == AVR109_COMMAND_ExitBootloader) - { - RunBootloader = false; - - /* Send confirmation byte back to the host */ - WriteNextResponseByte('\r'); - } - else if ((Command == AVR109_COMMAND_SetLED) || (Command == AVR109_COMMAND_ClearLED) || - (Command == AVR109_COMMAND_SelectDeviceType)) - { - FetchNextCommandByte(); - - /* Send confirmation byte back to the host */ - WriteNextResponseByte('\r'); - } - else if ((Command == AVR109_COMMAND_EnterProgrammingMode) || (Command == AVR109_COMMAND_LeaveProgrammingMode)) - { - /* Send confirmation byte back to the host */ - WriteNextResponseByte('\r'); - } - else if (Command == AVR109_COMMAND_ReadPartCode) - { - /* Return ATMEGA128 part code - this is only to allow AVRProg to use the bootloader */ - WriteNextResponseByte(0x44); - WriteNextResponseByte(0x00); - } - else if (Command == AVR109_COMMAND_ReadAutoAddressIncrement) - { - /* Indicate auto-address increment is supported */ - WriteNextResponseByte('Y'); - } - else if (Command == AVR109_COMMAND_SetCurrentAddress) - { - /* Set the current address to that given by the host (translate 16-bit word address to byte address) */ - CurrAddress = (FetchNextCommandByte() << 9); - CurrAddress |= (FetchNextCommandByte() << 1); - - /* Send confirmation byte back to the host */ - WriteNextResponseByte('\r'); - } - else if (Command == AVR109_COMMAND_ReadBootloaderInterface) - { - /* Indicate serial programmer back to the host */ - WriteNextResponseByte('S'); - } - else if (Command == AVR109_COMMAND_ReadBootloaderIdentifier) - { - /* Write the 7-byte software identifier to the endpoint */ - for (uint8_t CurrByte = 0; CurrByte < 7; CurrByte++) - WriteNextResponseByte(SOFTWARE_IDENTIFIER[CurrByte]); - } - else if (Command == AVR109_COMMAND_ReadBootloaderSWVersion) - { - WriteNextResponseByte('0' + BOOTLOADER_VERSION_MAJOR); - WriteNextResponseByte('0' + BOOTLOADER_VERSION_MINOR); - } - else if (Command == AVR109_COMMAND_ReadSignature) - { - WriteNextResponseByte(AVR_SIGNATURE_3); - WriteNextResponseByte(AVR_SIGNATURE_2); - WriteNextResponseByte(AVR_SIGNATURE_1); - } - else if (Command == AVR109_COMMAND_EraseFLASH) - { - /* Clear the application section of flash */ - for (uint32_t CurrFlashAddress = 0; CurrFlashAddress < (uint32_t)BOOT_START_ADDR; CurrFlashAddress += SPM_PAGESIZE) - { - boot_page_erase(CurrFlashAddress); - boot_spm_busy_wait(); - boot_page_write(CurrFlashAddress); - boot_spm_busy_wait(); - } - - /* Send confirmation byte back to the host */ - WriteNextResponseByte('\r'); - } - #if !defined(NO_LOCK_BYTE_WRITE_SUPPORT) - else if (Command == AVR109_COMMAND_WriteLockbits) - { - /* Set the lock bits to those given by the host */ - boot_lock_bits_set(FetchNextCommandByte()); - - /* Send confirmation byte back to the host */ - WriteNextResponseByte('\r'); - } - #endif - else if (Command == AVR109_COMMAND_ReadLockbits) - { - WriteNextResponseByte(boot_lock_fuse_bits_get(GET_LOCK_BITS)); - } - else if (Command == AVR109_COMMAND_ReadLowFuses) - { - WriteNextResponseByte(boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS)); - } - else if (Command == AVR109_COMMAND_ReadHighFuses) - { - WriteNextResponseByte(boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS)); - } - else if (Command == AVR109_COMMAND_ReadExtendedFuses) - { - WriteNextResponseByte(boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS)); - } - #if !defined(NO_BLOCK_SUPPORT) - else if (Command == AVR109_COMMAND_GetBlockWriteSupport) - { - WriteNextResponseByte('Y'); - - /* Send block size to the host */ - WriteNextResponseByte(SPM_PAGESIZE >> 8); - WriteNextResponseByte(SPM_PAGESIZE & 0xFF); - } - else if ((Command == AVR109_COMMAND_BlockWrite) || (Command == AVR109_COMMAND_BlockRead)) - { - /* Delegate the block write/read to a separate function for clarity */ - ReadWriteMemoryBlock(Command); - } - #endif - #if !defined(NO_FLASH_BYTE_SUPPORT) - else if (Command == AVR109_COMMAND_FillFlashPageWordHigh) - { - /* Write the high byte to the current flash page */ - boot_page_fill(CurrAddress, FetchNextCommandByte()); - - /* Send confirmation byte back to the host */ - WriteNextResponseByte('\r'); - } - else if (Command == AVR109_COMMAND_FillFlashPageWordLow) - { - /* Write the low byte to the current flash page */ - boot_page_fill(CurrAddress | 0x01, FetchNextCommandByte()); - - /* Increment the address */ - CurrAddress += 2; - - /* Send confirmation byte back to the host */ - WriteNextResponseByte('\r'); - } - else if (Command == AVR109_COMMAND_WriteFlashPage) - { - /* Commit the flash page to memory */ - boot_page_write(CurrAddress); - - /* Wait until write operation has completed */ - boot_spm_busy_wait(); - - /* Send confirmation byte back to the host */ - WriteNextResponseByte('\r'); - } - else if (Command == AVR109_COMMAND_ReadFLASHWord) - { - #if (FLASHEND > 0xFFFF) - uint16_t ProgramWord = pgm_read_word_far(CurrAddress); - #else - uint16_t ProgramWord = pgm_read_word(CurrAddress); - #endif - - WriteNextResponseByte(ProgramWord >> 8); - WriteNextResponseByte(ProgramWord & 0xFF); - } - #endif - #if !defined(NO_EEPROM_BYTE_SUPPORT) - else if (Command == AVR109_COMMAND_WriteEEPROM) - { - /* Read the byte from the endpoint and write it to the EEPROM */ - eeprom_write_byte((uint8_t*)((intptr_t)(CurrAddress >> 1)), FetchNextCommandByte()); - - /* Increment the address after use */ - CurrAddress += 2; - - /* Send confirmation byte back to the host */ - WriteNextResponseByte('\r'); - } - else if (Command == AVR109_COMMAND_ReadEEPROM) - { - /* Read the EEPROM byte and write it to the endpoint */ - WriteNextResponseByte(eeprom_read_byte((uint8_t*)((intptr_t)(CurrAddress >> 1)))); - - /* Increment the address after use */ - CurrAddress += 2; - } - #endif - else if (Command != AVR109_COMMAND_Sync) - { - /* Unknown (non-sync) command, return fail code */ - WriteNextResponseByte('?'); - } - - /* Select the IN endpoint */ - Endpoint_SelectEndpoint(CDC_TX_EPADDR); - - /* Remember if the endpoint is completely full before clearing it */ - bool IsEndpointFull = !(Endpoint_IsReadWriteAllowed()); - - /* Send the endpoint data to the host */ - Endpoint_ClearIN(); - - /* If a full endpoint's worth of data was sent, we need to send an empty packet afterwards to signal end of transfer */ - if (IsEndpointFull) - { - while (!(Endpoint_IsINReady())) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - } - - Endpoint_ClearIN(); - } - - /* Wait until the data has been sent to the host */ - while (!(Endpoint_IsINReady())) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - } - - /* Select the OUT endpoint */ - Endpoint_SelectEndpoint(CDC_RX_EPADDR); - - /* Acknowledge the command from the host */ - Endpoint_ClearOUT(); -} - diff --git a/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderCDC.h b/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderCDC.h deleted file mode 100644 index 9b326abc..00000000 --- a/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderCDC.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2014. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * - * Header file for BootloaderCDC.c. - */ - -#ifndef _CDC_H_ -#define _CDC_H_ - - /* Includes: */ - #include - #include - #include - #include - #include - #include - #include - - #include "Descriptors.h" - #include "BootloaderAPI.h" - #include "Config/AppConfig.h" - - #include - #include - #include - - /* Preprocessor Checks: */ - #if !defined(__OPTIMIZE_SIZE__) - #error This bootloader requires that it be optimized for size, not speed, to fit into the target device. Change optimization settings and try again. - #endif - - /* Macros: */ - /** Version major of the CDC bootloader. */ - #define BOOTLOADER_VERSION_MAJOR 0x01 - - /** Version minor of the CDC bootloader. */ - #define BOOTLOADER_VERSION_MINOR 0x00 - - /** Hardware version major of the CDC bootloader. */ - #define BOOTLOADER_HWVERSION_MAJOR 0x01 - - /** Hardware version minor of the CDC bootloader. */ - #define BOOTLOADER_HWVERSION_MINOR 0x00 - - /** Eight character bootloader firmware identifier reported to the host when requested. */ - #define SOFTWARE_IDENTIFIER "LUFACDC" - - /** Magic bootloader key to unlock forced application start mode. */ - #define MAGIC_BOOT_KEY 0xDC42 - - /* Enums: */ - /** Possible memory types that can be addressed via the bootloader. */ - enum AVR109_Memories - { - MEMORY_TYPE_FLASH = 'F', - MEMORY_TYPE_EEPROM = 'E', - }; - - /** Possible commands that can be issued to the bootloader. */ - enum AVR109_Commands - { - AVR109_COMMAND_Sync = 27, - AVR109_COMMAND_ReadEEPROM = 'd', - AVR109_COMMAND_WriteEEPROM = 'D', - AVR109_COMMAND_ReadFLASHWord = 'R', - AVR109_COMMAND_WriteFlashPage = 'm', - AVR109_COMMAND_FillFlashPageWordLow = 'c', - AVR109_COMMAND_FillFlashPageWordHigh = 'C', - AVR109_COMMAND_GetBlockWriteSupport = 'b', - AVR109_COMMAND_BlockWrite = 'B', - AVR109_COMMAND_BlockRead = 'g', - AVR109_COMMAND_ReadExtendedFuses = 'Q', - AVR109_COMMAND_ReadHighFuses = 'N', - AVR109_COMMAND_ReadLowFuses = 'F', - AVR109_COMMAND_ReadLockbits = 'r', - AVR109_COMMAND_WriteLockbits = 'l', - AVR109_COMMAND_EraseFLASH = 'e', - AVR109_COMMAND_ReadSignature = 's', - AVR109_COMMAND_ReadBootloaderSWVersion = 'V', - AVR109_COMMAND_ReadBootloaderHWVersion = 'v', - AVR109_COMMAND_ReadBootloaderIdentifier = 'S', - AVR109_COMMAND_ReadBootloaderInterface = 'p', - AVR109_COMMAND_SetCurrentAddress = 'A', - AVR109_COMMAND_ReadAutoAddressIncrement = 'a', - AVR109_COMMAND_ReadPartCode = 't', - AVR109_COMMAND_EnterProgrammingMode = 'P', - AVR109_COMMAND_LeaveProgrammingMode = 'L', - AVR109_COMMAND_SelectDeviceType = 'T', - AVR109_COMMAND_SetLED = 'x', - AVR109_COMMAND_ClearLED = 'y', - AVR109_COMMAND_ExitBootloader = 'E', - }; - - /* Type Defines: */ - /** Type define for a non-returning pointer to the start of the loaded application in flash memory. */ - typedef void (*AppPtr_t)(void) ATTR_NO_RETURN; - - /* Function Prototypes: */ - static void CDC_Task(void); - static void SetupHardware(void); - - void Application_Jump_Check(void) ATTR_INIT_SECTION(3); - - void EVENT_USB_Device_ConfigurationChanged(void); - - #if defined(INCLUDE_FROM_BOOTLOADERCDC_C) || defined(__DOXYGEN__) - #if !defined(NO_BLOCK_SUPPORT) - static void ReadWriteMemoryBlock(const uint8_t Command); - #endif - static uint8_t FetchNextCommandByte(void); - static void WriteNextResponseByte(const uint8_t Response); - #endif - -#endif - diff --git a/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderCDC.txt b/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderCDC.txt deleted file mode 100644 index 55e5e55a..00000000 --- a/protocol/lufa/LUFA-git/Bootloaders/CDC/BootloaderCDC.txt +++ /dev/null @@ -1,240 +0,0 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** \mainpage CDC Class USB AVR Bootloader - * - * \section Sec_Compat Demo Compatibility: - * - * The following list indicates what microcontrollers are compatible with this demo. - * - * \li Series 7 USB AVRs (AT90USBxxx7) - * \li Series 6 USB AVRs (AT90USBxxx6) - * \li Series 4 USB AVRs (ATMEGAxxU4) - * \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) - * - * \section Sec_Info USB Information: - * - * The following table gives a rundown of the USB utilization of this demo. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
USB Mode:Device
USB Class:Communications Device Class (CDC)
USB Subclass:Abstract Control Model (ACM)
Relevant Standards:USBIF CDC Class Standard
Supported USB Speeds:Full Speed Mode
- * - * \section Sec_Description Project Description: - * - * This bootloader enumerates to the host as a CDC Class device (virtual serial port), allowing for AVR109 - * protocol compatible programming software to load firmware onto the AVR. - * - * Out of the box this bootloader builds for the AT90USB1287 with an 8KB bootloader section size, and will fit - * into 4KB of bootloader space. If you wish to alter this size and/or change the AVR model, you will need to - * edit the MCU, FLASH_SIZE_KB and BOOT_SECTION_SIZE_KB values in the accompanying makefile. - * - * When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the - * bootloader from the normal user application. - * - * \warning THIS BOOTLOADER IS NOT SECURE. Malicious entities can recover written data, even if the device - * lockbits are set. - * - * \section Sec_Running Running the Bootloader - * - * This bootloader is designed to be started via the HWB mechanism of the USB AVRs; ground the HWB pin (see device - * datasheet) then momentarily ground /RESET to start the bootloader. This assumes the HWBE fuse is set and the BOOTRST - * fuse is cleared. - * - * For board specific exceptions to the above, see below. - * - * \subsection SSec_XPLAIN Atmel Xplain Board - * Ground the USB AVR JTAG's \c TCK pin to ground when powering on the board to start the bootloader. This assumes the - * \c HWBE fuse is cleared and the \c BOOTRST fuse is set as the HWBE pin is not user accessible on this board. - * - * \subsection SSec_Leonardo Arduino Leonardo Board - * Ground \c IO13 when powering the board to start the bootloader. This assumes the \c HWBE fuse is cleared and the - * \c BOOTRST fuse is set as the HWBE pin is not user accessible on this board. - * - * \section Sec_Installation Driver Installation - * - * After running this bootloader for the first time on a new computer, you will need to supply the .INF - * file located in this bootloader project's directory as the device's driver when running under Windows. - * This will enable Windows to use its inbuilt CDC drivers, negating the need for custom drivers for the - * device. Other Operating Systems should automatically use their own inbuilt CDC-ACM drivers. - * - * \section Sec_HostApp Host Controller Application - * - * This bootloader is compatible with the open source application AVRDUDE, Atmel's AVRPROG, or other - * applications implementing the AVR109 protocol, which is documented on the Atmel website as an application - * note. - * - * \subsection SSec_AVRDude AVRDUDE (Windows, Mac, Linux) - * - * AVRDude is a free, cross-platform and open source command line programmer for Atmel and third party AVR - * programmers. It is available on the the Windows platform as part of the "WinAVR" package, or on other systems - * either from a build from the official source code, or in many distributions as a precompiled binary package. - * - * To load a new HEX file with AVRDude, specify "AVR109" as the programmer, with the allocated COM port. On Windows - * platforms this will be a COMx port name: - * \code - * avrdude -c AVR109 -p at90usb1287 -P COM0 -U flash:w:Mouse.hex - * \endcode - * - * On Linux systems, this will typically be a /dev/ttyACMx port name: - * \code - * avrdude -c AVR109 -p at90usb1287 -P /dev/ttyACM0 -U flash:w:Mouse.hex - * \endcode - * - * Refer to the AVRDude project documentation for additional usage instructions. - * - * \section Sec_API User Application API - * - * Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader, - * allowing the user application to call into the bootloader at runtime to read and write FLASH data. - * - * By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the - * following layout: - * - * \code - * #define BOOTLOADER_API_TABLE_SIZE 32 - * #define BOOTLOADER_API_TABLE_START ((FLASHEND + 1UL) - BOOTLOADER_API_TABLE_SIZE) - * #define BOOTLOADER_API_CALL(Index) (void*)((BOOTLOADER_API_TABLE_START + (Index * 2)) / 2) - * - * void (*BootloaderAPI_ErasePage)(uint32_t Address) = BOOTLOADER_API_CALL(0); - * void (*BootloaderAPI_WritePage)(uint32_t Address) = BOOTLOADER_API_CALL(1); - * void (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_CALL(2); - * uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address) = BOOTLOADER_API_CALL(3); - * uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address) = BOOTLOADER_API_CALL(4); - * uint8_t (*BootloaderAPI_ReadLock)(void) = BOOTLOADER_API_CALL(5); - * void (*BootloaderAPI_WriteLock)(uint8_t LockBits) = BOOTLOADER_API_CALL(6); - * - * #define BOOTLOADER_MAGIC_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 2)) - * #define BOOTLOADER_MAGIC_SIGNATURE 0xDCFB - * - * #define BOOTLOADER_CLASS_SIGNATURE_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 4)) - * #define BOOTLOADER_CDC_SIGNATURE 0xDF00 - * - * #define BOOTLOADER_ADDRESS_START (BOOTLOADER_API_TABLE_START + (BOOTLOADER_API_TABLE_SIZE - 8)) - * #define BOOTLOADER_ADDRESS_LENGTH 4 - * \endcode - * - * From the application the API support of the bootloader can be detected by reading the FLASH memory bytes located at address - * \c BOOTLOADER_MAGIC_SIGNATURE_START and comparing them to the value \c BOOTLOADER_MAGIC_SIGNATURE. The class of bootloader - * can be determined by reading the FLASH memory bytes located at address \c BOOTLOADER_CLASS_SIGNATURE_START and comparing them - * to the value \c BOOTLOADER_CDC_SIGNATURE. The start address of the bootloader can be retrieved by reading the bytes of FLASH - * memory starting from address \c BOOTLOADER_ADDRESS_START. - * - * \subsection SSec_API_MemLayout Device Memory Map - * The following illustration indicates the final memory map of the device when loaded with the bootloader. - * - * \verbatim - * +----------------------------+ 0x0000 - * | | - * | | - * | | - * | | - * | | - * | | - * | | - * | | - * | User Application | - * | | - * | | - * | | - * | | - * | | - * | | - * | | - * +----------------------------+ FLASHEND - BOOT_SECTION_SIZE - * | | - * | Bootloader Application | - * | (Not User App. Accessible) | - * | | - * +----------------------------+ FLASHEND - 96 - * | API Table Trampolines | - * | (Not User App. Accessible) | - * +----------------------------+ FLASHEND - 32 - * | Bootloader API Table | - * | (User App. Accessible) | - * +----------------------------+ FLASHEND - 8 - * | Bootloader ID Constants | - * | (User App. Accessible) | - * +----------------------------+ FLASHEND - * \endverbatim - * - * \section Sec_KnownIssues Known Issues: - * - * \par On Linux machines, the CDC bootloader is unstable or inaccessible. - * A change to the \c ModemManager module in many Linux distributions causes - * this module to try to take control over inserted CDC devices, corrupting the - * datastream. A UDEV rule is required to prevent this. - * See here for resolution steps. - * If the issue still persists then uninstall modemmanager by executing sudo apt-get remove modemmanager, or - * the equivalent using your chosen distribution's package manager. - * - * \par On Linux machines, the CDC bootloader is inaccessible. - * On many Linux systems, non-root users do not have automatic access to newly - * inserted CDC devices. Root privileges or a UDEV rule is required to gain - * access. - * See here for resolution steps. - * - * \par After loading an application, it is not run automatically on startup. - * Some USB AVR boards ship with the BOOTRST fuse set, causing the bootloader - * to run automatically when the device is reset. In most cases, the BOOTRST - * fuse should be disabled and the HWBE fuse used instead to run the bootloader - * when needed. - * - * \section Sec_Options Project Options - * - * The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Define Name:Location:Description:
NO_BLOCK_SUPPORTAppConfig.hDefine to disable memory block read/write support in the bootloader, requiring all reads and writes to be made - * using the byte-level commands.
NO_EEPROM_BYTE_SUPPORTAppConfig.hDefine to disable EEPROM memory byte read/write support in the bootloader, requiring all EEPROM reads and writes - * to be made using the block-level commands.
NO_FLASH_BYTE_SUPPORTAppConfig.hDefine to disable FLASH memory byte read/write support in the bootloader, requiring all FLASH reads and writes - * to be made using the block-level commands.
NO_LOCK_BYTE_WRITE_SUPPORTAppConfig.hDefine to disable lock byte write support in the bootloader, preventing the lock bits from being set programmatically.
- */ - diff --git a/protocol/lufa/LUFA-git/Bootloaders/CDC/Config/AppConfig.h b/protocol/lufa/LUFA-git/Bootloaders/CDC/Config/AppConfig.h deleted file mode 100644 index bbb5cb22..00000000 --- a/protocol/lufa/LUFA-git/Bootloaders/CDC/Config/AppConfig.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2014. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Application Configuration Header File - * - * This is a header file which is be used to configure LUFA's - * compile time options, as an alternative to the compile time - * constants supplied through a makefile. - * - * For information on what each token does, refer to the - * \ref Sec_Options section of the application documentation. - */ - -#ifndef _APP_CONFIG_H_ -#define _APP_CONFIG_H_ - -// #define NO_BLOCK_SUPPORT -// #define NO_EEPROM_BYTE_SUPPORT -// #define NO_FLASH_BYTE_SUPPORT -// #define NO_LOCK_BYTE_WRITE_SUPPORT - -#endif diff --git a/protocol/lufa/LUFA-git/Bootloaders/CDC/Config/LUFAConfig.h b/protocol/lufa/LUFA-git/Bootloaders/CDC/Config/LUFAConfig.h deleted file mode 100644 index af2dd306..00000000 --- a/protocol/lufa/LUFA-git/Bootloaders/CDC/Config/LUFAConfig.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2014. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief LUFA Library Configuration Header File - * - * This header file is used to configure LUFA's compile time options, - * as an alternative to the compile time constants supplied through - * a makefile. - * - * For information on what each token does, refer to the LUFA - * manual section "Summary of Compile Tokens". - */ - -#ifndef _LUFA_CONFIG_H_ -#define _LUFA_CONFIG_H_ - - #if (ARCH == ARCH_AVR8) - - /* Non-USB Related Configuration Tokens: */ -// #define DISABLE_TERMINAL_CODES - - /* USB Class Driver Related Tokens: */ -// #define HID_HOST_BOOT_PROTOCOL_ONLY -// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} -// #define HID_USAGE_STACK_DEPTH {Insert Value Here} -// #define HID_MAX_COLLECTIONS {Insert Value Here} -// #define HID_MAX_REPORTITEMS {Insert Value Here} -// #define HID_MAX_REPORT_IDS {Insert Value Here} -// #define NO_CLASS_DRIVER_AUTOFLUSH - - /* General USB Driver Related Tokens: */ - #define ORDERED_EP_CONFIG - #define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL) - #define USB_DEVICE_ONLY -// #define USB_HOST_ONLY -// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} -// #define NO_LIMITED_CONTROLLER_CONNECT - #define NO_SOF_EVENTS - - /* USB Device Mode Driver Related Tokens: */ - #define USE_RAM_DESCRIPTORS -// #define USE_FLASH_DESCRIPTORS -// #define USE_EEPROM_DESCRIPTORS - #define NO_INTERNAL_SERIAL - #define FIXED_CONTROL_ENDPOINT_SIZE 8 - #define DEVICE_STATE_AS_GPIOR 0 - #define FIXED_NUM_CONFIGURATIONS 1 -// #define CONTROL_ONLY_DEVICE -// #define INTERRUPT_CONTROL_ENDPOINT - #define NO_DEVICE_REMOTE_WAKEUP - #define NO_DEVICE_SELF_POWER - - /* USB Host Mode Driver Related Tokens: */ -// #define HOST_STATE_AS_GPIOR {Insert Value Here} -// #define USB_HOST_TIMEOUT_MS {Insert Value Here} -// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here} -// #define NO_AUTO_VBUS_MANAGEMENT -// #define INVERTED_VBUS_ENABLE_LINE - - #else - - #error Unsupported architecture for this LUFA configuration file. - - #endif -#endif diff --git a/protocol/lufa/LUFA-git/Bootloaders/CDC/Descriptors.c b/protocol/lufa/LUFA-git/Bootloaders/CDC/Descriptors.c deleted file mode 100644 index 2ff6b503..00000000 --- a/protocol/lufa/LUFA-git/Bootloaders/CDC/Descriptors.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2014. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * - * USB Device Descriptors, for library use when in USB device mode. Descriptors are special - * computer-readable structures which the host requests upon device enumeration, to determine - * the device's capabilities and functions. - */ - -#include "Descriptors.h" - -/** Device descriptor structure. This descriptor, located in SRAM memory, describes the overall - * device characteristics, including the supported USB version, control endpoint size and the - * number of device configurations. The descriptor is read out by the USB host when the enumeration - * process begins. - */ -const USB_Descriptor_Device_t DeviceDescriptor = -{ - .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, - - .USBSpecification = VERSION_BCD(1,1,0), - .Class = CDC_CSCP_CDCClass, - .SubClass = CDC_CSCP_NoSpecificSubclass, - .Protocol = CDC_CSCP_NoSpecificProtocol, - - .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, - - .VendorID = 0x03EB, - .ProductID = 0x204A, - .ReleaseNumber = VERSION_BCD(1,0,0), - - .ManufacturerStrIndex = STRING_ID_Manufacturer, - .ProductStrIndex = STRING_ID_Product, - .SerialNumStrIndex = NO_DESCRIPTOR, - - .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS -}; - -/** Configuration descriptor structure. This descriptor, located in SRAM memory, describes the usage - * of the device in one of its supported configurations, including information about any device interfaces - * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting - * a configuration so that the host may correctly communicate with the USB device. - */ -const USB_Descriptor_Configuration_t ConfigurationDescriptor = -{ - .Config = - { - .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, - - .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), - .TotalInterfaces = 2, - - .ConfigurationNumber = 1, - .ConfigurationStrIndex = NO_DESCRIPTOR, - - .ConfigAttributes = USB_CONFIG_ATTR_RESERVED, - - .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) - }, - - .CDC_CCI_Interface = - { - .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, - - .InterfaceNumber = INTERFACE_ID_CDC_CCI, - .AlternateSetting = 0, - - .TotalEndpoints = 1, - - .Class = CDC_CSCP_CDCClass, - .SubClass = CDC_CSCP_ACMSubclass, - .Protocol = CDC_CSCP_ATCommandProtocol, - - .InterfaceStrIndex = NO_DESCRIPTOR - }, - - .CDC_Functional_Header = - { - .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface}, - .Subtype = 0x00, - - .CDCSpecification = VERSION_BCD(1,1,0), - }, - - .CDC_Functional_ACM = - { - .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface}, - .Subtype = 0x02, - - .Capabilities = 0x02, - }, - - .CDC_Functional_Union = - { - .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface}, - .Subtype = 0x06, - - .MasterInterfaceNumber = INTERFACE_ID_CDC_CCI, - .SlaveInterfaceNumber = INTERFACE_ID_CDC_DCI, - }, - - .CDC_NotificationEndpoint = - { - .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - - .EndpointAddress = CDC_NOTIFICATION_EPADDR, - .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), - .EndpointSize = CDC_NOTIFICATION_EPSIZE, - .PollingIntervalMS = 0xFF - }, - - .CDC_DCI_Interface = - { - .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, - - .InterfaceNumber = INTERFACE_ID_CDC_DCI, - .AlternateSetting = 0, - - .TotalEndpoints = 2, - - .Class = CDC_CSCP_CDCDataClass, - .SubClass = CDC_CSCP_NoDataSubclass, - .Protocol = CDC_CSCP_NoDataProtocol, - - .InterfaceStrIndex = NO_DESCRIPTOR - }, - - .CDC_DataOutEndpoint = - { - .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - - .EndpointAddress = CDC_RX_EPADDR, - .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), - .EndpointSize = CDC_TXRX_EPSIZE, - .PollingIntervalMS = 0x05 - }, - - .CDC_DataInEndpoint = - { - .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - - .EndpointAddress = CDC_TX_EPADDR, - .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), - .EndpointSize = CDC_TXRX_EPSIZE, - .PollingIntervalMS = 0x05 - } -}; - -/** Language descriptor structure. This descriptor, located in SRAM memory, is returned when the host requests - * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate - * via the language ID table available at USB.org what languages the device supports for its string descriptors. - */ -const USB_Descriptor_String_t LanguageString = USB_STRING_DESCRIPTOR_ARRAY(LANGUAGE_ID_ENG); - -/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable - * form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device - * Descriptor. - */ -const USB_Descriptor_String_t ManufacturerString = USB_STRING_DESCRIPTOR(L"Dean Camera"); - -/** Product descriptor string. This is a Unicode string containing the product's details in human readable form, - * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device - * Descriptor. - */ -const USB_Descriptor_String_t ProductString = USB_STRING_DESCRIPTOR(L"LUFA CDC"); - -/** This function is called by the library when in device mode, and must be overridden (see LUFA library "USB Descriptors" - * documentation) by the application code so that the address and size of a requested descriptor can be given - * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function - * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the - * USB host. - */ -uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, - const uint8_t wIndex, - const void** const DescriptorAddress) -{ - const uint8_t DescriptorType = (wValue >> 8); - const uint8_t DescriptorNumber = (wValue & 0xFF); - - const void* Address = NULL; - uint16_t Size = NO_DESCRIPTOR; - - switch (DescriptorType) - { - case DTYPE_Device: - Address = &DeviceDescriptor; - Size = sizeof(USB_Descriptor_Device_t); - break; - case DTYPE_Configuration: - Address = &ConfigurationDescriptor; - Size = sizeof(USB_Descriptor_Configuration_t); - break; - case DTYPE_String: - if (DescriptorNumber == STRING_ID_Language) - { - Address = &LanguageString; - Size = LanguageString.Header.Size; - } - else if (DescriptorNumber == STRING_ID_Manufacturer) - { - Address = &ManufacturerString; - Size = ManufacturerString.Header.Size; - } - else if (DescriptorNumber == STRING_ID_Product) - { - Address = &ProductString; - Size = ProductString.Header.Size; - } - - break; - } - - *DescriptorAddress = Address; - return Size; -} - diff --git a/protocol/lufa/LUFA-git/Bootloaders/CDC/Descriptors.h b/protocol/lufa/LUFA-git/Bootloaders/CDC/Descriptors.h deleted file mode 100644 index ef043791..00000000 --- a/protocol/lufa/LUFA-git/Bootloaders/CDC/Descriptors.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2014. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaims all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * - * Header file for Descriptors.c. - */ - -#ifndef _DESCRIPTORS_H_ -#define _DESCRIPTORS_H_ - - /* Includes: */ - #include - - #include "Config/AppConfig.h" - - /* Macros: */ - #if defined(__AVR_AT90USB1287__) - #define AVR_SIGNATURE_1 0x1E - #define AVR_SIGNATURE_2 0x97 - #define AVR_SIGNATURE_3 0x82 - #elif defined(__AVR_AT90USB647__) - #define AVR_SIGNATURE_1 0x1E - #define AVR_SIGNATURE_2 0x96 - #define AVR_SIGNATURE_3 0x82 - #elif defined(__AVR_AT90USB1286__) - #define AVR_SIGNATURE_1 0x1E - #define AVR_SIGNATURE_2 0x97 - #define AVR_SIGNATURE_3 0x82 - #elif defined(__AVR_AT90USB646__) - #define AVR_SIGNATURE_1 0x1E - #define AVR_SIGNATURE_2 0x96 - #define AVR_SIGNATURE_3 0x82 - #elif defined(__AVR_ATmega32U4__) - #define AVR_SIGNATURE_1 0x1E - #define AVR_SIGNATURE_2 0x95 - #define AVR_SIGNATURE_3 0x87 - #elif defined(__AVR_ATmega16U4__) - #define AVR_SIGNATURE_1 0x1E - #define AVR_SIGNATURE_2 0x94 - #define AVR_SIGNATURE_3 0x88 - #elif defined(__AVR_ATmega32U2__) - #define AVR_SIGNATURE_1 0x1E - #define AVR_SIGNATURE_2 0x95 - #define AVR_SIGNATURE_3 0x8A - #elif defined(__AVR_ATmega16U2__) - #define AVR_SIGNATURE_1 0x1E - #define AVR_SIGNATURE_2 0x94 - #define AVR_SIGNATURE_3 0x89 - #elif defined(__AVR_AT90USB162__) - #define AVR_SIGNATURE_1 0x1E - #define AVR_SIGNATURE_2 0x94 - #define AVR_SIGNATURE_3 0x82 - #elif defined(__AVR_ATmega8U2__) - #define AVR_SIGNATURE_1 0x1E - #define AVR_SIGNATURE_2 0x93 - #define AVR_SIGNATURE_3 0x89 - #elif defined(__AVR_AT90USB82__) - #define AVR_SIGNATURE_1 0x1E - #define AVR_SIGNATURE_2 0x94 - #define AVR_SIGNATURE_3 0x82 - #else - #error The selected AVR part is not currently supported by this bootloader. - #endif - - /** Endpoint address for the CDC control interface event notification endpoint. */ - #define CDC_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | 2) - - /** Endpoint address for the CDC data interface TX (data IN) endpoint. */ - #define CDC_TX_EPADDR (ENDPOINT_DIR_IN | 3) - - /** Endpoint address for the CDC data interface RX (data OUT) endpoint. */ - #define CDC_RX_EPADDR (ENDPOINT_DIR_OUT | 4) - - /** Size of the CDC data interface TX and RX data endpoint banks, in bytes. */ - #define CDC_TXRX_EPSIZE 16 - - /** Size of the CDC control interface notification endpoint bank, in bytes. */ - #define CDC_NOTIFICATION_EPSIZE 8 - - /* Type Defines: */ - /** Type define for the device configuration descriptor structure. This must be defined in the - * application code, as the configuration descriptor contains several sub-descriptors which - * vary between devices, and which describe the device's usage to the host. - */ - typedef struct - { - USB_Descriptor_Configuration_Header_t Config; - - // CDC Control Interface - USB_Descriptor_Interface_t CDC_CCI_Interface; - USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header; - USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM; - USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union; - USB_Descriptor_Endpoint_t CDC_NotificationEndpoint; - - // CDC Data Interface - USB_Descriptor_Interface_t CDC_DCI_Interface; - USB_Descriptor_Endpoint_t CDC_DataOutEndpoint; - USB_Descriptor_Endpoint_t CDC_DataInEndpoint; - } USB_Descriptor_Configuration_t; - - /** Enum for the device interface descriptor IDs within the device. Each interface descriptor - * should have a unique ID index associated with it, which can be used to refer to the - * interface from other descriptors. - */ - enum InterfaceDescriptors_t - { - INTERFACE_ID_CDC_CCI = 0, /**< CDC CCI interface descriptor ID */ - INTERFACE_ID_CDC_DCI = 1, /**< CDC DCI interface descriptor ID */ - }; - - /** Enum for the device string descriptor IDs within the device. Each string descriptor should - * have a unique ID index associated with it, which can be used to refer to the string from - * other descriptors. - */ - enum StringDescriptors_t - { - STRING_ID_Language = 0, /**< Supported Languages string descriptor ID (must be zero) */ - STRING_ID_Manufacturer = 1, /**< Manufacturer string ID */ - STRING_ID_Product = 2, /**< Product string ID */ - }; - - /* Function Prototypes: */ - uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, - const uint8_t wIndex, - const void** const DescriptorAddress) - ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); - -#endif - diff --git a/protocol/lufa/LUFA-git/Bootloaders/CDC/LUFA CDC Bootloader.inf b/protocol/lufa/LUFA-git/Bootloaders/CDC/LUFA CDC Bootloader.inf deleted file mode 100644 index 61624c73..00000000 --- a/protocol/lufa/LUFA-git/Bootloaders/CDC/LUFA CDC Bootloader.inf +++ /dev/null @@ -1,66 +0,0 @@ -;************************************************************ -; Windows USB CDC ACM Setup File -; Copyright (c) 2000 Microsoft Corporation -;************************************************************ - -[DefaultInstall] -CopyINF="LUFA CDC Bootloader.inf" - -[Version] -Signature="$Windows NT$" -Class=Ports -ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} -Provider=%MFGNAME% -DriverVer=7/1/2012,10.0.0.0 - -[Manufacturer] -%MFGNAME%=DeviceList, NTx86, NTamd64, NTia64 - -[SourceDisksNames] - -[SourceDisksFiles] - -[DestinationDirs] -DefaultDestDir=12 - -[DriverInstall] -Include=mdmcpq.inf -CopyFiles=FakeModemCopyFileSection -AddReg=DriverInstall.AddReg - -[DriverInstall.Services] -Include=mdmcpq.inf -AddService=usbser, 0x00000002, LowerFilter_Service_Inst - -[DriverInstall.AddReg] -HKR,,EnumPropPages32,,"msports.dll,SerialPortPropPageProvider" - -;------------------------------------------------------------------------------ -; Vendor and Product ID Definitions -;------------------------------------------------------------------------------ -; When developing your USB device, the VID and PID used in the PC side -; application program and the firmware on the microcontroller must match. -; Modify the below line to use your VID and PID. Use the format as shown below. -; Note: One INF file can be used for multiple devices with different VID and PIDs. -; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line. -;------------------------------------------------------------------------------ -[DeviceList] -%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A - -[DeviceList.NTx86] -%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A - -[DeviceList.NTamd64] -%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A - -[DeviceList.NTia64] -%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A - -;------------------------------------------------------------------------------ -; String Definitions -;------------------------------------------------------------------------------ -;Modify these strings to customize your device -;------------------------------------------------------------------------------ -[Strings] -MFGNAME="http://www.lufa-lib.org" -DESCRIPTION="LUFA CDC Class Bootloader" diff --git a/protocol/lufa/LUFA-git/Bootloaders/CDC/asf.xml b/protocol/lufa/LUFA-git/Bootloaders/CDC/asf.xml deleted file mode 100644 index 72f3ff04..00000000 --- a/protocol/lufa/LUFA-git/Bootloaders/CDC/asf.xml +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CDC Class Bootloader, capable of reprogramming a device using avrdude or other AVR109 protocol compliant software when plugged into a host. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/protocol/lufa/LUFA-git/Bootloaders/CDC/doxyfile b/protocol/lufa/LUFA-git/Bootloaders/CDC/doxyfile deleted file mode 100644 index 2dfb2a08..00000000 --- a/protocol/lufa/LUFA-git/Bootloaders/CDC/doxyfile +++ /dev/null @@ -1,2365 +0,0 @@ -# Doxyfile 1.8.8 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a double hash (##) is considered a comment and is placed in -# front of the TAG it is preceding. -# -# All text after a single hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists, items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (\" \"). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all text -# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv -# for the list of possible encodings. -# The default value is: UTF-8. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by -# double-quotes, unless you are using Doxywizard) that should identify the -# project for which the documentation is generated. This name is used in the -# title of most generated pages and in a few other places. -# The default value is: My Project. - -PROJECT_NAME = "LUFA Library - CDC Class Bootloader" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. This -# could be handy for archiving the generated documentation or if some version -# control system is used. - -PROJECT_NUMBER = - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer a -# quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = - -# With the PROJECT_LOGO tag one can specify an logo or icon that is included in -# the documentation. The maximum height of the logo should not exceed 55 pixels -# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo -# to the output directory. - -PROJECT_LOGO = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path -# into which the generated documentation will be written. If a relative path is -# entered, it will be relative to the location where doxygen was started. If -# left blank the current directory will be used. - -OUTPUT_DIRECTORY = ./Documentation/ - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub- -# directories (in 2 levels) under the output directory of each output format and -# will distribute the generated files over these directories. Enabling this -# option can be useful when feeding doxygen a huge amount of source files, where -# putting all generated files in the same directory would otherwise causes -# performance problems for the file system. -# The default value is: NO. - -CREATE_SUBDIRS = NO - -# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII -# characters to appear in the names of generated files. If set to NO, non-ASCII -# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode -# U+3044. -# The default value is: NO. - -ALLOW_UNICODE_NAMES = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, -# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), -# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, -# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), -# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, -# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, -# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, -# Ukrainian and Vietnamese. -# The default value is: English. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member -# descriptions after the members that are listed in the file and class -# documentation (similar to Javadoc). Set to NO to disable this. -# The default value is: YES. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief -# description of a member or function before the detailed description -# -# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. -# The default value is: YES. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator that is -# used to form the text in various listings. Each string in this list, if found -# as the leading text of the brief description, will be stripped from the text -# and the result, after processing the whole list, is used as the annotated -# text. Otherwise, the brief description is used as-is. If left blank, the -# following values are used ($name is automatically replaced with the name of -# the entity):The $name class, The $name widget, The $name file, is, provides, -# specifies, contains, represents, a, an and the. - -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# doxygen will generate a detailed section even if there is only a brief -# description. -# The default value is: NO. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. -# The default value is: NO. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path -# before files name in the file list and in the header files. If set to NO the -# shortest path that makes the file name unique will be used -# The default value is: YES. - -FULL_PATH_NAMES = YES - -# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. -# Stripping is only done if one of the specified strings matches the left-hand -# part of the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the path to -# strip. -# -# Note that you can specify absolute paths here, but also relative paths, which -# will be relative from the directory where doxygen is started. -# This tag requires that the tag FULL_PATH_NAMES is set to YES. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the -# path mentioned in the documentation of a class, which tells the reader which -# header file to include in order to use a class. If left blank only the name of -# the header file containing the class definition is used. Otherwise one should -# specify the list of include paths that are normally passed to the compiler -# using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but -# less readable) file names. This can be useful is your file systems doesn't -# support long names like on DOS, Mac, or CD-ROM. -# The default value is: NO. - -SHORT_NAMES = YES - -# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the -# first line (until the first dot) of a Javadoc-style comment as the brief -# description. If set to NO, the Javadoc-style will behave just like regular Qt- -# style comments (thus requiring an explicit @brief command for a brief -# description.) -# The default value is: NO. - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first -# line (until the first dot) of a Qt-style comment as the brief description. If -# set to NO, the Qt-style will behave just like regular Qt-style comments (thus -# requiring an explicit \brief command for a brief description.) -# The default value is: NO. - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a -# multi-line C++ special comment block (i.e. a block of //! or /// comments) as -# a brief description. This used to be the default behavior. The new default is -# to treat a multi-line C++ comment block as a detailed description. Set this -# tag to YES if you prefer the old behavior instead. -# -# Note that setting this tag to YES also means that rational rose comments are -# not recognized any more. -# The default value is: NO. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the -# documentation from any documented member that it re-implements. -# The default value is: YES. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a -# new page for each member. If set to NO, the documentation of a member will be -# part of the file/class/namespace that contains it. -# The default value is: NO. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen -# uses this value to replace tabs by spaces in code fragments. -# Minimum value: 1, maximum value: 16, default value: 4. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that act as commands in -# the documentation. An alias has the form: -# name=value -# For example adding -# "sideeffect=@par Side Effects:\n" -# will allow you to put the command \sideeffect (or @sideeffect) in the -# documentation, which will result in a user-defined paragraph with heading -# "Side Effects:". You can put \n's in the value part of an alias to insert -# newlines. - -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. For -# instance, some of the names that are used will be different. The list of all -# members will be omitted, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or -# Python sources only. Doxygen will then generate output that is more tailored -# for that language. For instance, namespaces will be presented as packages, -# qualified scopes will look different, etc. -# The default value is: NO. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources. Doxygen will then generate output that is tailored for Fortran. -# The default value is: NO. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for VHDL. -# The default value is: NO. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given -# extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: -# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: -# Fortran. In the later case the parser tries to guess whether the code is fixed -# or free formatted code, this is the default for Fortran type files), VHDL. For -# instance to make doxygen treat .inc files as Fortran files (default is PHP), -# and .f files as C (default is Fortran), use: inc=Fortran f=C. -# -# Note For files without extension you can use no_extension as a placeholder. -# -# Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments -# according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you can -# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in -# case of backward compatibilities issues. -# The default value is: YES. - -MARKDOWN_SUPPORT = NO - -# When enabled doxygen tries to link words that correspond to documented -# classes, or namespaces to their corresponding documentation. Such a link can -# be prevented in individual cases by by putting a % sign in front of the word -# or globally by setting AUTOLINK_SUPPORT to NO. -# The default value is: YES. - -AUTOLINK_SUPPORT = YES - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should set this -# tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); -# versus func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. -# The default value is: NO. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. -# The default value is: NO. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen -# will parse them like normal C++ but will assume all classes use public instead -# of private inheritance when no explicit protection keyword is present. -# The default value is: NO. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate -# getter and setter methods for a property. Setting this option to YES will make -# doxygen to replace the get and set methods by a property in the documentation. -# This will only work if the methods are indeed getting or setting a simple -# type. If this is not the case, or you want to show the methods anyway, you -# should set this option to NO. -# The default value is: YES. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. -# The default value is: NO. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES to allow class member groups of the same type -# (for instance a group of public functions) to be put as a subgroup of that -# type (e.g. under the Public Functions section). Set it to NO to prevent -# subgrouping. Alternatively, this can be done per class using the -# \nosubgrouping command. -# The default value is: YES. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions -# are shown inside the group in which they are included (e.g. using \ingroup) -# instead of on a separate page (for HTML and Man pages) or section (for LaTeX -# and RTF). -# -# Note that this feature does not work in combination with -# SEPARATE_MEMBER_PAGES. -# The default value is: NO. - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions -# with only public data fields or simple typedef fields will be shown inline in -# the documentation of the scope in which they are defined (i.e. file, -# namespace, or group documentation), provided this scope is documented. If set -# to NO, structs, classes, and unions are shown on a separate page (for HTML and -# Man pages) or section (for LaTeX and RTF). -# The default value is: NO. - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or -# enum is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically be -# useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. -# The default value is: NO. - -TYPEDEF_HIDES_STRUCT = NO - -# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This -# cache is used to resolve symbols given their name and scope. Since this can be -# an expensive process and often the same symbol appears multiple times in the -# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small -# doxygen will become slower. If the cache is too large, memory is wasted. The -# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range -# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 -# symbols. At the end of a run doxygen will report the cache usage and suggest -# the optimal cache size from a speed point of view. -# Minimum value: 0, maximum value: 9, default value: 0. - -LOOKUP_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. Private -# class members and static file members will be hidden unless the -# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. -# Note: This will also disable the warnings about undocumented members that are -# normally produced when WARNINGS is set to YES. -# The default value is: NO. - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will -# be included in the documentation. -# The default value is: NO. - -EXTRACT_PRIVATE = YES - -# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal -# scope will be included in the documentation. -# The default value is: NO. - -EXTRACT_PACKAGE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file will be -# included in the documentation. -# The default value is: NO. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined -# locally in source files will be included in the documentation. If set to NO -# only classes defined in header files are included. Does not have any effect -# for Java sources. -# The default value is: YES. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local methods, -# which are defined in the implementation section but not in the interface are -# included in the documentation. If set to NO only methods in the interface are -# included. -# The default value is: NO. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base name of -# the file that contains the anonymous namespace. By default anonymous namespace -# are hidden. -# The default value is: NO. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all -# undocumented members inside documented classes or files. If set to NO these -# members will be included in the various overviews, but no documentation -# section is generated. This option has no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. If set -# to NO these classes will be included in the various overviews. This option has -# no effect if EXTRACT_ALL is enabled. -# The default value is: NO. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO these declarations will be -# included in the documentation. -# The default value is: NO. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any -# documentation blocks found inside the body of a function. If set to NO these -# blocks will be appended to the function's detailed documentation block. -# The default value is: NO. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation that is typed after a -# \internal command is included. If the tag is set to NO then the documentation -# will be excluded. Set it to YES to include the internal documentation. -# The default value is: NO. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. -# The default value is: system dependent. - -CASE_SENSE_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with -# their full class and namespace scopes in the documentation. If set to YES the -# scope will be hidden. -# The default value is: NO. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of -# the files that are included by a file in the documentation of that file. -# The default value is: YES. - -SHOW_INCLUDE_FILES = YES - -# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each -# grouped member an include statement to the documentation, telling the reader -# which file to include in order to use the member. -# The default value is: NO. - -SHOW_GROUPED_MEMB_INC = NO - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include -# files with double quotes in the documentation rather than with sharp brackets. -# The default value is: NO. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the -# documentation for inline members. -# The default value is: YES. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the -# (detailed) documentation of file and class members alphabetically by member -# name. If set to NO the members will appear in declaration order. -# The default value is: YES. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief -# descriptions of file, namespace and class members alphabetically by member -# name. If set to NO the members will appear in declaration order. Note that -# this will also influence the order of the classes in the class list. -# The default value is: NO. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the -# (brief and detailed) documentation of class members so that constructors and -# destructors are listed first. If set to NO the constructors will appear in the -# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. -# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief -# member documentation. -# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting -# detailed member documentation. -# The default value is: NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy -# of group names into alphabetical order. If set to NO the group names will -# appear in their defined order. -# The default value is: NO. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by -# fully-qualified names, including namespaces. If set to NO, the class list will -# be sorted only by class name, not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the alphabetical -# list. -# The default value is: NO. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper -# type resolution of all parameters of a function it will reject a match between -# the prototype and the implementation of a member function even if there is -# only one candidate or it is obvious which candidate to choose by doing a -# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still -# accept a match between prototype and implementation in such cases. -# The default value is: NO. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the -# todo list. This list is created by putting \todo commands in the -# documentation. -# The default value is: YES. - -GENERATE_TODOLIST = NO - -# The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the -# test list. This list is created by putting \test commands in the -# documentation. -# The default value is: YES. - -GENERATE_TESTLIST = NO - -# The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug -# list. This list is created by putting \bug commands in the documentation. -# The default value is: YES. - -GENERATE_BUGLIST = NO - -# The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO) -# the deprecated list. This list is created by putting \deprecated commands in -# the documentation. -# The default value is: YES. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional documentation -# sections, marked by \if ... \endif and \cond -# ... \endcond blocks. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the -# initial value of a variable or macro / define can have for it to appear in the -# documentation. If the initializer consists of more lines than specified here -# it will be hidden. Use a value of 0 to hide initializers completely. The -# appearance of the value of individual variables and macros / defines can be -# controlled using \showinitializer or \hideinitializer command in the -# documentation regardless of this setting. -# Minimum value: 0, maximum value: 10000, default value: 30. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at -# the bottom of the documentation of classes and structs. If set to YES the list -# will mention the files that were used to generate the documentation. -# The default value is: YES. - -SHOW_USED_FILES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This -# will remove the Files entry from the Quick Index and from the Folder Tree View -# (if specified). -# The default value is: YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces -# page. This will remove the Namespaces entry from the Quick Index and from the -# Folder Tree View (if specified). -# The default value is: YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command command input-file, where command is the value of the -# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided -# by doxygen. Whatever the program writes to standard output is used as the file -# version. For an example see the documentation. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. You can -# optionally specify a file name after the option, if omitted DoxygenLayout.xml -# will be used as the name of the layout file. -# -# Note that if you run doxygen from a directory containing a file called -# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE -# tag is left empty. - -LAYOUT_FILE = - -# The CITE_BIB_FILES tag can be used to specify one or more bib files containing -# the reference definitions. This must be a list of .bib files. The .bib -# extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. -# For LaTeX the style of the bibliography can be controlled using -# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the -# search path. See also \cite for info how to create references. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# Configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated to -# standard output by doxygen. If QUIET is set to YES this implies that the -# messages are off. -# The default value is: NO. - -QUIET = YES - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES -# this implies that the warnings are on. -# -# Tip: Turn warnings on while writing the documentation. -# The default value is: YES. - -WARNINGS = YES - -# If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate -# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag -# will automatically be disabled. -# The default value is: YES. - -WARN_IF_UNDOCUMENTED = YES - -# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some parameters -# in a documented function, or documenting parameters that don't exist or using -# markup commands wrongly. -# The default value is: YES. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that -# are documented, but have no documentation for their parameters or return -# value. If set to NO doxygen will only warn about wrong or incomplete parameter -# documentation, but not about the absence of documentation. -# The default value is: NO. - -WARN_NO_PARAMDOC = YES - -# The WARN_FORMAT tag determines the format of the warning messages that doxygen -# can produce. The string should contain the $file, $line, and $text tags, which -# will be replaced by the file and line number from which the warning originated -# and the warning text. Optionally the format may contain $version, which will -# be replaced by the version of the file (if it could be obtained via -# FILE_VERSION_FILTER) -# The default value is: $file:$line: $text. - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning and error -# messages should be written. If left blank the output is written to standard -# error (stderr). - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# Configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag is used to specify the files and/or directories that contain -# documented source files. You may enter file names like myfile.cpp or -# directories like /usr/src/myproject. Separate the files or directories with -# spaces. -# Note: If this tag is empty the current directory is searched. - -INPUT = ./ - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses -# libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: http://www.gnu.org/software/libiconv) for the list of -# possible encodings. -# The default value is: UTF-8. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and -# *.h) to filter out the source-files in the directories. If left blank the -# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii, -# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp, -# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown, -# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, -# *.qsf, *.as and *.js. - -FILE_PATTERNS = *.h \ - *.c \ - *.txt - -# The RECURSIVE tag can be used to specify whether or not subdirectories should -# be searched for input files as well. -# The default value is: NO. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = Documentation/ - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. -# The default value is: NO. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test -# -# Note that the wildcards are matched against the file with absolute path, so to -# exclude all test directories use the pattern */test/* - -EXCLUDE_SYMBOLS = __* \ - INCLUDE_FROM_* - -# The EXAMPLE_PATH tag can be used to specify one or more files or directories -# that contain example code fragments that are included (see the \include -# command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and -# *.h) to filter out the source-files in the directories. If left blank all -# files are included. - -EXAMPLE_PATTERNS = * - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude commands -# irrespective of the value of the RECURSIVE tag. -# The default value is: NO. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or directories -# that contain images that are to be included in the documentation (see the -# \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command: -# -# -# -# where is the value of the INPUT_FILTER tag, and is the -# name of an input file. Doxygen will then use the output that the filter -# program writes to standard output. If FILTER_PATTERNS is specified, this tag -# will be ignored. -# -# Note that the filter must not add or remove lines; it is applied before the -# code is scanned, but not when the output code is generated. If lines are added -# or removed, the anchors will not be placed correctly. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: pattern=filter -# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how -# filters are used. If the FILTER_PATTERNS tag is empty or if none of the -# patterns match the file name, INPUT_FILTER is applied. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER ) will also be used to filter the input files that are used for -# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). -# The default value is: NO. - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and -# it is also possible to disable source filtering for a specific pattern using -# *.ext= (so without naming a filter). -# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. - -FILTER_SOURCE_PATTERNS = - -# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that -# is part of the input, its contents will be placed on the main page -# (index.html). This can be useful if you have a project on for instance GitHub -# and want to reuse the introduction page also for the doxygen output. - -USE_MDFILE_AS_MAINPAGE = - -#--------------------------------------------------------------------------- -# Configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will be -# generated. Documented entities will be cross-referenced with these sources. -# -# Note: To get rid of all source code in the generated output, make sure that -# also VERBATIM_HEADERS is set to NO. -# The default value is: NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body of functions, -# classes and enums directly into the documentation. -# The default value is: NO. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any -# special comment blocks from generated source code fragments. Normal C, C++ and -# Fortran comments will always remain visible. -# The default value is: YES. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# function all documented functions referencing it will be listed. -# The default value is: NO. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES then for each documented function -# all documented entities called/used by that function will be listed. -# The default value is: NO. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set -# to YES, then the hyperlinks from functions in REFERENCES_RELATION and -# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will -# link to the documentation. -# The default value is: YES. - -REFERENCES_LINK_SOURCE = NO - -# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the -# source code will show a tooltip with additional information such as prototype, -# brief description and links to the definition and documentation. Since this -# will make the HTML file larger and loading of large files a bit slower, you -# can opt to disable this feature. -# The default value is: YES. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -SOURCE_TOOLTIPS = YES - -# If the USE_HTAGS tag is set to YES then the references to source code will -# point to the HTML generated by the htags(1) tool instead of doxygen built-in -# source browser. The htags tool is part of GNU's global source tagging system -# (see http://www.gnu.org/software/global/global.html). You will need version -# 4.8.6 or higher. -# -# To use it do the following: -# - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the config file -# - Make sure the INPUT points to the root of the source tree -# - Run doxygen as normal -# -# Doxygen will invoke htags (and that will in turn invoke gtags), so these -# tools must be available from the command line (i.e. in the search path). -# -# The result: instead of the source browser generated by doxygen, the links to -# source code will now point to the output of htags. -# The default value is: NO. -# This tag requires that the tag SOURCE_BROWSER is set to YES. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a -# verbatim copy of the header file for each class for which an include is -# specified. Set to NO to disable this. -# See also: Section \class. -# The default value is: YES. - -VERBATIM_HEADERS = NO - -# If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the -# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the -# cost of reduced performance. This can be particularly helpful with template -# rich C++ code for which doxygen's built-in parser lacks the necessary type -# information. -# Note: The availability of this option depends on whether or not doxygen was -# compiled with the --with-libclang option. -# The default value is: NO. - -CLANG_ASSISTED_PARSING = NO - -# If clang assisted parsing is enabled you can provide the compiler with command -# line options that you would normally use when invoking the compiler. Note that -# the include paths will already be set by doxygen for the files and directories -# specified with INPUT and INCLUDE_PATH. -# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. - -CLANG_OPTIONS = - -#--------------------------------------------------------------------------- -# Configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all -# compounds will be generated. Enable this if the project contains a lot of -# classes, structs, unions or interfaces. -# The default value is: YES. - -ALPHABETICAL_INDEX = YES - -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all classes will -# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag -# can be used to specify a prefix (or a list of prefixes) that should be ignored -# while generating the index headers. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output -# The default value is: YES. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a -# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of -# it. -# The default directory is: html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each -# generated HTML page (for example: .htm, .php, .asp). -# The default value is: .html. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a user-defined HTML header file for -# each generated HTML page. If the tag is left blank doxygen will generate a -# standard header. -# -# To get valid HTML the header file that includes any scripts and style sheets -# that doxygen needs, which is dependent on the configuration options used (e.g. -# the setting GENERATE_TREEVIEW). It is highly recommended to start with a -# default header using -# doxygen -w html new_header.html new_footer.html new_stylesheet.css -# YourConfigFile -# and then modify the file new_header.html. See also section "Doxygen usage" -# for information on how to generate the default header that doxygen normally -# uses. -# Note: The header is subject to change so you typically have to regenerate the -# default header when upgrading to a newer version of doxygen. For a description -# of the possible markers and block names see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each -# generated HTML page. If the tag is left blank doxygen will generate a standard -# footer. See HTML_HEADER for more information on how to generate a default -# footer and what special commands can be used inside the footer. See also -# section "Doxygen usage" for information on how to generate the default footer -# that doxygen normally uses. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style -# sheet that is used by each HTML page. It can be used to fine-tune the look of -# the HTML output. If left blank doxygen will generate a default style sheet. -# See also section "Doxygen usage" for information on how to generate the style -# sheet that doxygen normally uses. -# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as -# it is more robust and this tag (HTML_STYLESHEET) will in the future become -# obsolete. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_STYLESHEET = - -# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined -# cascading style sheets that are included after the standard style sheets -# created by doxygen. Using this option one can overrule certain style aspects. -# This is preferred over using HTML_STYLESHEET since it does not replace the -# standard style sheet and is therefor more robust against future updates. -# Doxygen will copy the style sheet files to the output directory. -# Note: The order of the extra stylesheet files is of importance (e.g. the last -# stylesheet in the list overrules the setting of the previous ones in the -# list). For an example see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_STYLESHEET = - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that the -# files will be copied as-is; there are no commands or markers available. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen -# will adjust the colors in the stylesheet and background images according to -# this color. Hue is specified as an angle on a colorwheel, see -# http://en.wikipedia.org/wiki/Hue for more information. For instance the value -# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 -# purple, and 360 is red again. -# Minimum value: 0, maximum value: 359, default value: 220. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors -# in the HTML output. For a value of 0 the output will use grayscales only. A -# value of 255 will produce the most vivid colors. -# Minimum value: 0, maximum value: 255, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the -# luminance component of the colors in the HTML output. Values below 100 -# gradually make the output lighter, whereas values above 100 make the output -# darker. The value divided by 100 is the actual gamma applied, so 80 represents -# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not -# change the gamma. -# Minimum value: 40, maximum value: 240, default value: 80. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting this -# to NO can help when comparing the output of multiple runs. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_TIMESTAMP = NO - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_DYNAMIC_SECTIONS = YES - -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries -# shown in the various tree structured indices initially; the user can expand -# and collapse entries dynamically later on. Doxygen will expand the tree to -# such a level that at most the specified number of entries are visible (unless -# a fully collapsed tree already exceeds this amount). So setting the number of -# entries 1 will produce a full collapsed tree by default. 0 is a special value -# representing an infinite number of entries and will result in a full expanded -# tree by default. -# Minimum value: 0, maximum value: 9999, default value: 100. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_INDEX_NUM_ENTRIES = 100 - -# If the GENERATE_DOCSET tag is set to YES, additional index files will be -# generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: http://developer.apple.com/tools/xcode/), introduced with -# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_DOCSET = NO - -# This tag determines the name of the docset feed. A documentation feed provides -# an umbrella under which multiple documentation sets from a single provider -# (such as a company or product suite) can be grouped. -# The default value is: Doxygen generated docs. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# This tag specifies a string that should uniquely identify the documentation -# set bundle. This should be a reverse domain-name style string, e.g. -# com.mycompany.MyDocSet. Doxygen will append .docset to the name. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. -# The default value is: org.doxygen.Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. -# The default value is: Publisher. -# This tag requires that the tag GENERATE_DOCSET is set to YES. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three -# additional HTML index files: index.hhp, index.hhc, and index.hhk. The -# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. -# -# The HTML Help Workshop contains a compiler that can convert all HTML output -# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML -# files are now used as the Windows 98 help format, and will replace the old -# Windows help format (.hlp) on all Windows platforms in the future. Compressed -# HTML files also contain an index, a table of contents, and you can search for -# words in the documentation. The HTML workshop also contains a viewer for -# compressed HTML files. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_HTMLHELP = NO - -# The CHM_FILE tag can be used to specify the file name of the resulting .chm -# file. You can add a path in front of the file if the result should not be -# written to the html output directory. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_FILE = - -# The HHC_LOCATION tag can be used to specify the location (absolute path -# including file name) of the HTML help compiler ( hhc.exe). If non-empty -# doxygen will try to run the HTML help compiler on the generated index.hhp. -# The file has to be specified with full path. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -HHC_LOCATION = - -# The GENERATE_CHI flag controls if a separate .chi index file is generated ( -# YES) or that it should be included in the master .chm file ( NO). -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -GENERATE_CHI = NO - -# The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc) -# and project file content. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -CHM_INDEX_ENCODING = - -# The BINARY_TOC flag controls whether a binary table of contents is generated ( -# YES) or a normal table of contents ( NO) in the .chm file. Furthermore it -# enables the Previous and Next buttons. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members to -# the table of contents of the HTML help documentation and to the tree view. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTMLHELP is set to YES. - -TOC_EXPAND = YES - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that -# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help -# (.qch) of the generated HTML documentation. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify -# the file name of the resulting .qch file. The path specified is relative to -# the HTML output folder. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help -# Project output. For more information please see Qt Help Project / Namespace -# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt -# Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- -# folders). -# The default value is: doc. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_VIRTUAL_FOLDER = doc - -# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom -# filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHP_SECT_FILTER_ATTRS = - -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. -# This tag requires that the tag GENERATE_QHP is set to YES. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be -# generated, together with the HTML files, they form an Eclipse help plugin. To -# install this plugin and make it available under the help contents menu in -# Eclipse, the contents of the directory containing the HTML and XML files needs -# to be copied into the plugins directory of eclipse. The name of the directory -# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. -# After copying Eclipse needs to be restarted before the help appears. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the Eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have this -# name. Each documentation set should have its own identifier. -# The default value is: org.doxygen.Project. -# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# If you want full control over the layout of the generated HTML pages it might -# be necessary to disable the index and replace it with your own. The -# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top -# of each HTML page. A value of NO enables the index and the value YES disables -# it. Since the tabs in the index contain the same information as the navigation -# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -DISABLE_INDEX = YES - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. If the tag -# value is set to YES, a side panel will be generated containing a tree-like -# index structure (just like the one that is generated for HTML Help). For this -# to work a browser that supports JavaScript, DHTML, CSS and frames is required -# (i.e. any modern browser). Windows users are probably better off using the -# HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can -# further fine-tune the look of the index. As an example, the default style -# sheet generated by doxygen has an example that shows how to put an image at -# the root of the tree instead of the PROJECT_NAME. Since the tree basically has -# the same information as the tab index, you could consider setting -# DISABLE_INDEX to YES when enabling this option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -GENERATE_TREEVIEW = YES - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that -# doxygen will group on one line in the generated HTML documentation. -# -# Note that a value of 0 will completely suppress the enum values from appearing -# in the overview section. -# Minimum value: 0, maximum value: 20, default value: 4. -# This tag requires that the tag GENERATE_HTML is set to YES. - -ENUM_VALUES_PER_LINE = 1 - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used -# to set the initial width (in pixels) of the frame in which the tree is shown. -# Minimum value: 0, maximum value: 1500, default value: 250. -# This tag requires that the tag GENERATE_HTML is set to YES. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to -# external symbols imported via tag files in a separate window. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of LaTeX formulas included as images in -# the HTML documentation. When you change the font size after a successful -# doxygen run you need to manually remove any form_*.png images from the HTML -# output directory to force them to be regenerated. -# Minimum value: 8, maximum value: 50, default value: 10. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are not -# supported properly for IE 6.0, but are supported on all modern browsers. -# -# Note that when changing this option you need to delete any form_*.png files in -# the HTML output directory before the changes have effect. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# http://www.mathjax.org) which uses client side Javascript for the rendering -# instead of using prerendered bitmaps. Use this if you do not have LaTeX -# installed or if you want to formulas look prettier in the HTML output. When -# enabled you may also need to install MathJax separately and configure the path -# to it using the MATHJAX_RELPATH option. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -USE_MATHJAX = NO - -# When MathJax is enabled you can set the default output format to be used for -# the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. -# Possible values are: HTML-CSS (which is slower, but has the best -# compatibility), NativeMML (i.e. MathML) and SVG. -# The default value is: HTML-CSS. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_FORMAT = HTML-CSS - -# When MathJax is enabled you need to specify the location relative to the HTML -# output directory using the MATHJAX_RELPATH option. The destination directory -# should contain the MathJax.js script. For instance, if the mathjax directory -# is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax -# Content Delivery Network so you can quickly see the result without installing -# MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest - -# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax -# extension names that should be enabled during MathJax rendering. For example -# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_EXTENSIONS = - -# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces -# of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an -# example see the documentation. -# This tag requires that the tag USE_MATHJAX is set to YES. - -MATHJAX_CODEFILE = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box for -# the HTML output. The underlying search engine uses javascript and DHTML and -# should work on any modern browser. Note that when using HTML help -# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) -# there is already a search function so this one should typically be disabled. -# For large projects the javascript based search engine can be slow, then -# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to -# search using the keyboard; to jump to the search box use + S -# (what the is depends on the OS and browser, but it is typically -# , /