forked from forks/qmk_firmware
USB-USB converter cleanup (#16618)
This commit is contained in:
parent
8fe3864fe7
commit
df3770551a
|
@ -1,3 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "usb_usb.h"
|
||||
|
|
|
@ -3,11 +3,4 @@
|
|||
#undef PRODUCT
|
||||
#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
|
||||
|
||||
|
|
|
@ -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
|
||||
```
|
|
@ -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
|
||||
|
|
|
@ -17,6 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#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 <http://www.gnu.org/licenses/>.
|
|||
//#define NO_ACTION_LAYER
|
||||
//#define NO_ACTION_TAPPING
|
||||
//#define NO_ACTION_ONESHOT
|
||||
//#define NO_ACTION_MACRO
|
||||
//#define NO_ACTION_FUNCTION
|
||||
|
|
|
@ -63,17 +63,16 @@ extern "C" {
|
|||
#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;
|
||||
USBHub hub1(&usb_host);
|
||||
USBHub hub2(&usb_host);
|
||||
HIDBoot<HID_PROTOCOL_KEYBOARD> kbd1(&usb_host);
|
||||
HIDBoot<HID_PROTOCOL_KEYBOARD> kbd2(&usb_host);
|
||||
HIDBoot<HID_PROTOCOL_KEYBOARD> kbd3(&usb_host);
|
||||
|
@ -82,12 +81,8 @@ 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);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "usb_usb.h"
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
#include <avr/io.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/power.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
// 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;
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "usb_usb.h"
|
||||
|
|
|
@ -8,15 +8,17 @@ BOOTLOADER = caterina
|
|||
# change yes to no to disable
|
||||
#
|
||||
BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite
|
||||
#MOUSEKEY_ENABLE = yes # Mouse keys
|
||||
MOUSEKEY_ENABLE = no # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
#CONSOLE_ENABLE = yes # Console for debug
|
||||
#COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
CONSOLE_ENABLE = no # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = no # Enable N-Key Rollover
|
||||
#BACKLIGHT_ENABLE = 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
|
||||
|
|
|
@ -19,6 +19,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#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
|
||||
|
|
Loading…
Reference in a new issue