From df3770551a4dcbf8188a16453dd64fe1787f83d8 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 14 Mar 2022 10:46:13 +1100 Subject: USB-USB converter cleanup (#16618) --- keyboards/converter/usb_usb/ble/ble.h | 2 +- keyboards/converter/usb_usb/ble/config.h | 9 +- keyboards/converter/usb_usb/ble/readme.md | 11 --- keyboards/converter/usb_usb/ble/rules.mk | 12 +-- keyboards/converter/usb_usb/config.h | 4 +- keyboards/converter/usb_usb/custom_matrix.cpp | 40 ++++----- keyboards/converter/usb_usb/hasu/hasu.h | 2 +- keyboards/converter/usb_usb/main.c | 102 ---------------------- keyboards/converter/usb_usb/pro_micro/pro_micro.h | 2 +- keyboards/converter/usb_usb/rules.mk | 18 ++-- keyboards/converter/usb_usb/usb_usb.h | 8 ++ 11 files changed, 41 insertions(+), 169 deletions(-) delete mode 100644 keyboards/converter/usb_usb/main.c (limited to 'keyboards/converter') diff --git a/keyboards/converter/usb_usb/ble/ble.h b/keyboards/converter/usb_usb/ble/ble.h index 3dccc23a41..3351176047 100644 --- a/keyboards/converter/usb_usb/ble/ble.h +++ b/keyboards/converter/usb_usb/ble/ble.h @@ -1,3 +1,3 @@ #pragma once -#include QMK_KEYBOARD_H +#include "usb_usb.h" diff --git a/keyboards/converter/usb_usb/ble/config.h b/keyboards/converter/usb_usb/ble/config.h index 92df24d003..675183f082 100644 --- a/keyboards/converter/usb_usb/ble/config.h +++ b/keyboards/converter/usb_usb/ble/config.h @@ -1,13 +1,6 @@ #pragma once #undef PRODUCT -#define PRODUCT QMK BLE Adapter +#define PRODUCT QMK BLE Adapter -// Turn off the mode leds on the BLE module -#define BLUEFRUIT_LE_ENABLE_MODE_LEDS 0 -#define BLUEFRUIT_LE_ENABLE_POWER_LED 0 - -#define NO_ACTION_MACRO -#define NO_ACTION_FUNCTION #define NO_ACTION_ONESHOT - diff --git a/keyboards/converter/usb_usb/ble/readme.md b/keyboards/converter/usb_usb/ble/readme.md index 0ee7223fd4..05cf437399 100644 --- a/keyboards/converter/usb_usb/ble/readme.md +++ b/keyboards/converter/usb_usb/ble/readme.md @@ -17,14 +17,3 @@ Part list: * [Pololu 5V Step-Up Voltage Regulator U3V12F5](https://www.pololu.com/product/2115) * [Lithium Ion Battery - 3.7v 2000mAh](https://www.adafruit.com/product/2011) * Some sort of switch to be able to turn it off - -Building and Flashing ---------------------- - -``` -make converter-usb_usb-ble -``` - -``` -make converter-usb_usb-ble-avrdude -``` \ No newline at end of file diff --git a/keyboards/converter/usb_usb/ble/rules.mk b/keyboards/converter/usb_usb/ble/rules.mk index df5bc36635..86a4e15ffe 100644 --- a/keyboards/converter/usb_usb/ble/rules.mk +++ b/keyboards/converter/usb_usb/ble/rules.mk @@ -1,17 +1,7 @@ # Processor frequency F_CPU = 8000000 -BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite -MOUSEKEY_ENABLE = no # Mouse keys -EXTRAKEY_ENABLE = no # Audio control and System control -CONSOLE_ENABLE = no # Console for debug -COMMAND_ENABLE = no # Commands for debug and configuration -NKRO_ENABLE = no # Enable N-Key Rollover -BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality -RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow -AUDIO_ENABLE = no # Audio output - +EXTRAKEY_ENABLE = no BLUETOOTH_ENABLE = yes BLUETOOTH_DRIVER = BluefruitLE - LTO_ENABLE = yes diff --git a/keyboards/converter/usb_usb/config.h b/keyboards/converter/usb_usb/config.h index d2488336a5..5f791eaa34 100644 --- a/keyboards/converter/usb_usb/config.h +++ b/keyboards/converter/usb_usb/config.h @@ -17,6 +17,8 @@ along with this program. If not, see . #pragma once +#include "config_common.h" + /* USB Device descriptor parameter */ #define VENDOR_ID 0xFEED #define PRODUCT_ID 0x005B @@ -43,5 +45,3 @@ along with this program. If not, see . //#define NO_ACTION_LAYER //#define NO_ACTION_TAPPING //#define NO_ACTION_ONESHOT -//#define NO_ACTION_MACRO -//#define NO_ACTION_FUNCTION diff --git a/keyboards/converter/usb_usb/custom_matrix.cpp b/keyboards/converter/usb_usb/custom_matrix.cpp index 00b5bc5053..a92feeb6c1 100644 --- a/keyboards/converter/usb_usb/custom_matrix.cpp +++ b/keyboards/converter/usb_usb/custom_matrix.cpp @@ -58,36 +58,31 @@ extern "C" { */ #define ROW_MASK 0xF0 #define COL_MASK 0x0F -#define CODE(row, col) (((row) << 4) | (col)) -#define ROW(code) (((code) & ROW_MASK) >> 4) -#define COL(code) ((code) & COL_MASK) -#define ROW_BITS(code) (1 << COL(code)) - +#define CODE(row, col) (((row) << 4) | (col)) +#define ROW(code) (((code) & ROW_MASK) >> 4) +#define COL(code) ((code) & COL_MASK) +#define ROW_BITS(code) (1 << COL(code)) // Integrated key state of all keyboards static report_keyboard_t local_keyboard_report; -static bool matrix_is_mod = false; - /* * USB Host Shield HID keyboards * This supports two cascaded hubs and four keyboards */ USB usb_host; -HIDBoot kbd1(&usb_host); -HIDBoot kbd2(&usb_host); -HIDBoot kbd3(&usb_host); -HIDBoot kbd4(&usb_host); +USBHub hub1(&usb_host); +USBHub hub2(&usb_host); +HIDBoot kbd1(&usb_host); +HIDBoot kbd2(&usb_host); +HIDBoot kbd3(&usb_host); +HIDBoot kbd4(&usb_host); KBDReportParser kbd_parser1; KBDReportParser kbd_parser2; KBDReportParser kbd_parser3; KBDReportParser kbd_parser4; -USBHub hub1(&usb_host); -USBHub hub2(&usb_host); - -extern "C" -{ +extern "C" { uint8_t matrix_rows(void) { return MATRIX_ROWS; } uint8_t matrix_cols(void) { return MATRIX_COLS; } bool matrix_has_ghost(void) { return false; } @@ -135,6 +130,7 @@ extern "C" } uint8_t matrix_scan(void) { + bool changed = false; static uint16_t last_time_stamp1 = 0; static uint16_t last_time_stamp2 = 0; static uint16_t last_time_stamp3 = 0; @@ -158,15 +154,13 @@ extern "C" or_report(kbd_parser3.report); or_report(kbd_parser4.report); - matrix_is_mod = true; + changed = true; dprintf("state: %02X %02X", local_keyboard_report.mods, local_keyboard_report.reserved); for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { dprintf(" %02X", local_keyboard_report.keys[i]); } dprint("\r\n"); - } else { - matrix_is_mod = false; } uint16_t timer; @@ -189,7 +183,7 @@ extern "C" } } matrix_scan_quantum(); - return 1; + return changed; } bool matrix_is_on(uint8_t row, uint8_t col) { @@ -234,13 +228,11 @@ extern "C" } } - void led_set(uint8_t usb_led) - { + void led_set(uint8_t usb_led) { if (kbd1.isReady()) kbd1.SetReport(0, 0, 2, 0, 1, &usb_led); if (kbd2.isReady()) kbd2.SetReport(0, 0, 2, 0, 1, &usb_led); if (kbd3.isReady()) kbd3.SetReport(0, 0, 2, 0, 1, &usb_led); if (kbd4.isReady()) kbd4.SetReport(0, 0, 2, 0, 1, &usb_led); led_set_kb(usb_led); } - -}; +} diff --git a/keyboards/converter/usb_usb/hasu/hasu.h b/keyboards/converter/usb_usb/hasu/hasu.h index 3dccc23a41..3351176047 100644 --- a/keyboards/converter/usb_usb/hasu/hasu.h +++ b/keyboards/converter/usb_usb/hasu/hasu.h @@ -1,3 +1,3 @@ #pragma once -#include QMK_KEYBOARD_H +#include "usb_usb.h" diff --git a/keyboards/converter/usb_usb/main.c b/keyboards/converter/usb_usb/main.c deleted file mode 100644 index 76e88922cb..0000000000 --- a/keyboards/converter/usb_usb/main.c +++ /dev/null @@ -1,102 +0,0 @@ -#include -#include -#include -#include - -// LUFA -#include "lufa.h" - -#include "sendchar.h" -#include "debug.h" -#include "keyboard.h" -#include "led.h" - - -/* LED ping configuration */ -#define TMK_LED -//#define LEONARDO_LED -#if defined(TMK_LED) -// For TMK converter and Teensy -#define LED_TX_INIT (DDRD |= (1<<6)) -#define LED_TX_ON (PORTD |= (1<<6)) -#define LED_TX_OFF (PORTD &= ~(1<<6)) -#define LED_TX_TOGGLE (PORTD ^= (1<<6)) -#elif defined(LEONARDO_LED) -// For Leonardo(TX LED) -#define LED_TX_INIT (DDRD |= (1<<5)) -#define LED_TX_ON (PORTD &= ~(1<<5)) -#define LED_TX_OFF (PORTD |= (1<<5)) -#define LED_TX_TOGGLE (PORTD ^= (1<<5)) -#else -#define LED_TX_INIT -#define LED_TX_ON -#define LED_TX_OFF -#define LED_TX_TOGGLE -#endif - - -static void LUFA_setup(void) -{ - /* Disable watchdog if enabled by bootloader/fuses */ - MCUSR &= ~(1 << WDRF); - wdt_disable(); - - /* Disable clock division */ -#if (F_CPU == 8000000) - clock_prescale_set(clock_div_2); // 16MHz crystal divided by 2 -#else - clock_prescale_set(clock_div_1); -#endif - - // Leonardo needs. Without this USB device is not recognized. - USB_Disable(); - - USB_Init(); - - // for Console_Task - USB_Device_EnableSOFEvents(); - print_set_sendchar(sendchar); -} - - - -int main(void) -{ - // LED for debug - LED_TX_INIT; - LED_TX_ON; - - debug_enable = true; - debug_keyboard = true; - - host_set_driver(&lufa_driver); - keyboard_init(); - - LUFA_setup(); - - /* NOTE: Don't insert time consuming job here. - * It'll cause unclear initialization failure when DFU reset(worm start). - */ - sei(); - -/* Some keyboards bootup quickly and cannot be initialized with this startup wait. - // wait for startup of sendchar routine - while (USB_DeviceState != DEVICE_STATE_Configured) ; - if (debug_enable) { - _delay_ms(1000); - } -*/ - - debug("init: done\n"); - - for (;;) { - keyboard_task(); - -#if !defined(INTERRUPT_CONTROL_ENDPOINT) - // LUFA Task for control request - USB_USBTask(); -#endif - } - - return 0; -} diff --git a/keyboards/converter/usb_usb/pro_micro/pro_micro.h b/keyboards/converter/usb_usb/pro_micro/pro_micro.h index 3dccc23a41..3351176047 100644 --- a/keyboards/converter/usb_usb/pro_micro/pro_micro.h +++ b/keyboards/converter/usb_usb/pro_micro/pro_micro.h @@ -1,3 +1,3 @@ #pragma once -#include QMK_KEYBOARD_H +#include "usb_usb.h" diff --git a/keyboards/converter/usb_usb/rules.mk b/keyboards/converter/usb_usb/rules.mk index 19903ed331..a33c0aaa54 100644 --- a/keyboards/converter/usb_usb/rules.mk +++ b/keyboards/converter/usb_usb/rules.mk @@ -8,15 +8,17 @@ BOOTLOADER = caterina # change yes to no to disable # BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite -#MOUSEKEY_ENABLE = yes # Mouse keys -EXTRAKEY_ENABLE = yes # Audio control and System control -#CONSOLE_ENABLE = yes # Console for debug -#COMMAND_ENABLE = yes # Commands for debug and configuration +MOUSEKEY_ENABLE = no # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = no # Commands for debug and configuration NKRO_ENABLE = no # Enable N-Key Rollover -#BACKLIGHT_ENABLE = yes -USB_HID_ENABLE = yes -CUSTOM_MATRIX = yes +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow +AUDIO_ENABLE = no # Audio output +USB_HID_ENABLE = yes +CUSTOM_MATRIX = yes -SRC = custom_matrix.cpp +SRC += custom_matrix.cpp DEFAULT_FOLDER = converter/usb_usb/hasu diff --git a/keyboards/converter/usb_usb/usb_usb.h b/keyboards/converter/usb_usb/usb_usb.h index 3acd67634a..4a25cf5d2e 100644 --- a/keyboards/converter/usb_usb/usb_usb.h +++ b/keyboards/converter/usb_usb/usb_usb.h @@ -19,6 +19,14 @@ along with this program. If not, see . #include "quantum.h" +#if defined(KEYBOARD_converter_usb_usb_ble) +# include "ble.h" +#elif defined(KEYBOARD_converter_usb_usb_hasu) +# include "hasu.h" +#elif defined(KEYBOARD_converter_usb_usb_pro_micro) +# include "pro_micro.h" +#endif + #define XXX KC_NO #define ______ KC_TRNS -- cgit v1.2.1