summaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/protocol.mk5
-rw-r--r--tmk_core/protocol/arm_atsam/arm_atsam_protocol.h1
-rw-r--r--tmk_core/protocol/arm_atsam/md_bootloader.h24
-rw-r--r--tmk_core/protocol/arm_atsam/startup.c6
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udc.c5
-rw-r--r--tmk_core/protocol/chibios/chibios.c3
-rw-r--r--tmk_core/protocol/chibios/usb_main.c31
-rw-r--r--tmk_core/protocol/lufa/lufa.c103
-rw-r--r--tmk_core/protocol/usb_descriptor.c2
-rw-r--r--tmk_core/protocol/vusb/vusb.c1
10 files changed, 67 insertions, 114 deletions
diff --git a/tmk_core/protocol.mk b/tmk_core/protocol.mk
index 31a6de76f1..19fd7d2425 100644
--- a/tmk_core/protocol.mk
+++ b/tmk_core/protocol.mk
@@ -28,6 +28,11 @@ ifeq ($(strip $(EXTRAKEY_ENABLE)), yes)
SHARED_EP_ENABLE = yes
endif
+ifeq ($(strip $(PROGRAMMABLE_BUTTON_ENABLE)), yes)
+ TMK_COMMON_DEFS += -DPROGRAMMABLE_BUTTON_ENABLE
+ SHARED_EP_ENABLE = yes
+endif
+
ifeq ($(strip $(RAW_ENABLE)), yes)
TMK_COMMON_DEFS += -DRAW_ENABLE
endif
diff --git a/tmk_core/protocol/arm_atsam/arm_atsam_protocol.h b/tmk_core/protocol/arm_atsam/arm_atsam_protocol.h
index e1749f872d..319ff8487d 100644
--- a/tmk_core/protocol/arm_atsam/arm_atsam_protocol.h
+++ b/tmk_core/protocol/arm_atsam/arm_atsam_protocol.h
@@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define _ARM_ATSAM_PROTOCOL_H_
#include "samd51j18a.h"
-#include "md_bootloader.h"
#include "timer.h"
#include "d51_util.h"
diff --git a/tmk_core/protocol/arm_atsam/md_bootloader.h b/tmk_core/protocol/arm_atsam/md_bootloader.h
deleted file mode 100644
index 362b9bd52a..0000000000
--- a/tmk_core/protocol/arm_atsam/md_bootloader.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef _MD_BOOTLOADER_H_
-#define _MD_BOOTLOADER_H_
-
-extern uint32_t _srom;
-extern uint32_t _lrom;
-extern uint32_t _erom;
-
-#define BOOTLOADER_SERIAL_MAX_SIZE 20 // DO NOT MODIFY!
-
-#ifdef KEYBOARD_massdrop_ctrl
-// WARNING: These are only for CTRL bootloader release "v2.18Jun 22 2018 17:28:08" for bootloader_jump support
-extern uint32_t _eram;
-# define BOOTLOADER_MAGIC 0x3B9ACA00
-# define MAGIC_ADDR (uint32_t *)((intptr_t)(&_eram) - 4)
-#endif
-
-#ifdef MD_BOOTLOADER
-
-# define MCU_HZ 48000000
-# define I2C_HZ 0 // Not used
-
-#endif // MD_BOOTLOADER
-
-#endif //_MD_BOOTLOADER_H_
diff --git a/tmk_core/protocol/arm_atsam/startup.c b/tmk_core/protocol/arm_atsam/startup.c
index 7a5791ab55..ce043bad51 100644
--- a/tmk_core/protocol/arm_atsam/startup.c
+++ b/tmk_core/protocol/arm_atsam/startup.c
@@ -28,7 +28,6 @@
*/
#include "samd51.h"
-#include "md_bootloader.h"
/* Initialize segments */
extern uint32_t _sfixed;
@@ -496,6 +495,11 @@ __attribute__((section(".vectors"))) const DeviceVectors exception_table = {
#endif
};
+// WARNING: These are only for CTRL bootloader release "v2.18Jun 22 2018 17:28:08" for bootloader_jump support
+extern uint32_t _eram;
+#define BOOTLOADER_MAGIC 0x3B9ACA00
+#define MAGIC_ADDR (uint32_t *)((intptr_t)(&_eram) - 4)
+
/**
* \brief This is the code that gets called on processor reset.
* To initialize the device, and call the main() routine.
diff --git a/tmk_core/protocol/arm_atsam/usb/udc.c b/tmk_core/protocol/arm_atsam/usb/udc.c
index d04e9b7b28..1f0c0d95d6 100644
--- a/tmk_core/protocol/arm_atsam/usb/udc.c
+++ b/tmk_core/protocol/arm_atsam/usb/udc.c
@@ -51,7 +51,8 @@
#include "udi_device_conf.h"
#include "udi.h"
#include "udc.h"
-#include "md_bootloader.h"
+
+#define BOOTLOADER_SERIAL_MAX_SIZE 20 // DO NOT MODIFY!
/**
* \ingroup udc_group
@@ -122,6 +123,8 @@ static uint8_t udc_string_product_name[] = USB_DEVICE_PRODUCT_NAME;
# define USB_DEVICE_SERIAL_NAME_SIZE 0
#endif
+extern uint32_t _srom;
+
uint8_t usb_device_serial_name_size = 0;
#if defined USB_DEVICE_SERIAL_USE_BOOTLOADER_SERIAL
uint8_t bootloader_serial_number[BOOTLOADER_SERIAL_MAX_SIZE + 1] = "";
diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c
index 41752b2130..b6cff05e9f 100644
--- a/tmk_core/protocol/chibios/chibios.c
+++ b/tmk_core/protocol/chibios/chibios.c
@@ -60,10 +60,11 @@ void send_keyboard(report_keyboard_t *report);
void send_mouse(report_mouse_t *report);
void send_system(uint16_t data);
void send_consumer(uint16_t data);
+void send_programmable_button(uint32_t data);
void send_digitizer(report_digitizer_t *report);
/* host struct */
-host_driver_t chibios_driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer};
+host_driver_t chibios_driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer, send_programmable_button};
#ifdef VIRTSER_ENABLE
void virtser_task(void);
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index ac46a9312b..30bfac9f3e 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -734,7 +734,7 @@ void init_usb_driver(USBDriver *usbp) {
* after a reset.
*/
usbDisconnectBus(usbp);
- wait_ms(1500);
+ wait_ms(50);
usbStart(usbp, &usbcfg);
usbConnectBus(usbp);
@@ -975,6 +975,35 @@ void send_consumer(uint16_t data) {
#endif
}
+void send_programmable_button(uint32_t data) {
+#ifdef PROGRAMMABLE_BUTTON_ENABLE
+ osalSysLock();
+ if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) {
+ osalSysUnlock();
+ return;
+ }
+
+ if (usbGetTransmitStatusI(&USB_DRIVER, SHARED_IN_EPNUM)) {
+ /* 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 */
+ if (osalThreadSuspendTimeoutS(&(&USB_DRIVER)->epc[SHARED_IN_EPNUM]->in_state->thread, TIME_MS2I(10)) == MSG_TIMEOUT) {
+ osalSysUnlock();
+ return;
+ }
+ }
+ static report_programmable_button_t report = {
+ .report_id = REPORT_ID_PROGRAMMABLE_BUTTON,
+ };
+
+ report.usage = data;
+
+ usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)&report, sizeof(report));
+ osalSysUnlock();
+#endif
+}
+
void send_digitizer(report_digitizer_t *report) {
#ifdef DIGITIZER_ENABLE
# ifdef DIGITIZER_SHARED_EP
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index e3be96d93d..3943f8c92b 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -67,10 +67,10 @@ extern keymap_config_t keymap_config;
#ifdef BLUETOOTH_ENABLE
# include "outputselect.h"
-# ifdef MODULE_ADAFRUIT_BLE
-# include "adafruit_ble.h"
-# else
-# include "../serial.h"
+# ifdef BLUETOOTH_BLUEFRUIT_LE
+# include "bluefruit_le.h"
+# elif BLUETOOTH_RN42
+# include "rn42.h"
# endif
#endif
@@ -90,46 +90,6 @@ extern keymap_config_t keymap_config;
# include "joystick.h"
#endif
-// https://cdn.sparkfun.com/datasheets/Wireless/Bluetooth/bluetooth_cr_UG-v1.0r.pdf#G7.663734
-static inline uint16_t CONSUMER2RN42(uint16_t usage) {
- switch (usage) {
- case AC_HOME:
- return 0x0001;
- case AL_EMAIL:
- return 0x0002;
- case AC_SEARCH:
- return 0x0004;
- case AL_KEYBOARD_LAYOUT:
- return 0x0008;
- case AUDIO_VOL_UP:
- return 0x0010;
- case AUDIO_VOL_DOWN:
- return 0x0020;
- case AUDIO_MUTE:
- return 0x0040;
- case TRANSPORT_PLAY_PAUSE:
- return 0x0080;
- case TRANSPORT_NEXT_TRACK:
- return 0x0100;
- case TRANSPORT_PREV_TRACK:
- return 0x0200;
- case TRANSPORT_STOP:
- return 0x0400;
- case TRANSPORT_EJECT:
- return 0x0800;
- case TRANSPORT_FAST_FORWARD:
- return 0x1000;
- case TRANSPORT_REWIND:
- return 0x2000;
- case TRANSPORT_STOP_EJECT:
- return 0x4000;
- case AL_LOCAL_BROWSER:
- return 0x8000;
- default:
- return 0;
- }
-}
-
uint8_t keyboard_idle = 0;
/* 0: Boot Protocol, 1: Report Protocol(default) */
uint8_t keyboard_protocol = 1;
@@ -685,17 +645,10 @@ static void send_keyboard(report_keyboard_t *report) {
#ifdef BLUETOOTH_ENABLE
if (where_to_send() == OUTPUT_BLUETOOTH) {
-# ifdef MODULE_ADAFRUIT_BLE
- adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys));
-# elif MODULE_RN42
- serial_send(0xFD);
- serial_send(0x09);
- serial_send(0x01);
- serial_send(report->mods);
- serial_send(report->reserved);
- for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
- serial_send(report->keys[i]);
- }
+# ifdef BLUETOOTH_BLUEFRUIT_LE
+ bluefruit_le_send_keys(report->mods, report->keys, sizeof(report->keys));
+# elif BLUETOOTH_RN42
+ rn42_send_keyboard(report);
# endif
return;
}
@@ -738,19 +691,11 @@ static void send_mouse(report_mouse_t *report) {
# ifdef BLUETOOTH_ENABLE
if (where_to_send() == OUTPUT_BLUETOOTH) {
-# ifdef MODULE_ADAFRUIT_BLE
+# ifdef BLUETOOTH_BLUEFRUIT_LE
// FIXME: mouse buttons
- adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h, report->buttons);
-# else
- serial_send(0xFD);
- serial_send(0x00);
- serial_send(0x03);
- serial_send(report->buttons);
- serial_send(report->x);
- serial_send(report->y);
- serial_send(report->v); // should try sending the wheel v here
- serial_send(report->h); // should try sending the wheel h here
- serial_send(0x00);
+ bluefruit_le_send_mouse_move(report->x, report->y, report->v, report->h, report->buttons);
+# elif BLUETOOTH_RN42
+ rn42_send_mouse(report);
# endif
return;
}
@@ -818,18 +763,10 @@ static void send_consumer(uint16_t data) {
#ifdef EXTRAKEY_ENABLE
# ifdef BLUETOOTH_ENABLE
if (where_to_send() == OUTPUT_BLUETOOTH) {
-# ifdef MODULE_ADAFRUIT_BLE
- adafruit_ble_send_consumer_key(data);
-# elif MODULE_RN42
- static uint16_t last_data = 0;
- if (data == last_data) return;
- last_data = data;
- uint16_t bitmap = CONSUMER2RN42(data);
- serial_send(0xFD);
- serial_send(0x03);
- serial_send(0x03);
- serial_send(bitmap & 0xFF);
- serial_send((bitmap >> 8) & 0xFF);
+# ifdef BLUETOOTH_BLUEFRUIT_LE
+ bluefruit_le_send_consumer_key(data);
+# elif BLUETOOTH_RN42
+ rn42_send_consumer(data);
# endif
return;
}
@@ -1076,8 +1013,8 @@ void protocol_pre_init(void) {
setup_usb();
sei();
-#if defined(MODULE_RN42)
- serial_init();
+#if defined(BLUETOOTH_RN42)
+ rn42_init();
#endif
/* wait for USB startup & debug output */
@@ -1129,8 +1066,8 @@ void protocol_post_task(void) {
MIDI_Device_USBTask(&USB_MIDI_Interface);
#endif
-#ifdef MODULE_ADAFRUIT_BLE
- adafruit_ble_task();
+#ifdef BLUETOOTH_BLUEFRUIT_LE
+ bluefruit_le_task();
#endif
#ifdef VIRTSER_ENABLE
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c
index a43755f899..0b992ba6c5 100644
--- a/tmk_core/protocol/usb_descriptor.c
+++ b/tmk_core/protocol/usb_descriptor.c
@@ -450,7 +450,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = {
#endif
#ifndef USB_POLLING_INTERVAL_MS
-# define USB_POLLING_INTERVAL_MS 10
+# define USB_POLLING_INTERVAL_MS 1
#endif
/*
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index bd0f1c21aa..8bdcccc9c9 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -647,7 +647,6 @@ const PROGMEM uchar console_hid_report[] = {
# define USB_MAX_POWER_CONSUMPTION 500
#endif
-// TODO: change this to 10ms to match LUFA
#ifndef USB_POLLING_INTERVAL_MS
# define USB_POLLING_INTERVAL_MS 1
#endif