Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge ChibiOS and LUFA descriptor support #2362

Merged
merged 31 commits into from
Feb 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fe0be19
Move lufa descriptor to protocol/usb_descriptor
fredizzimo Dec 2, 2017
0fefb3c
Try to compile usb_descriptor on ChibiOS
fredizzimo Dec 2, 2017
cdaa810
Add lufa_utils for ChibiOS
fredizzimo Dec 2, 2017
33b5b9a
More lufa_util compatibility fixes
fredizzimo Dec 2, 2017
7ea56b1
First compiling version of shared USB descriptor
fredizzimo Dec 2, 2017
629a293
Send the usb descriptors
fredizzimo Dec 2, 2017
02724ad
Fix the CONSOLE output on ChibiOS
fredizzimo Dec 3, 2017
de007ea
Add errors for unsupported interfaces
fredizzimo Dec 3, 2017
669b132
Enable support for vitual serial port USB descriptors
fredizzimo Dec 3, 2017
7dc858c
Implement virtual serial port for ChibiOS
fredizzimo Dec 4, 2017
95f49a3
Cleanup the lufa_utils
fredizzimo Dec 6, 2017
1d97c9b
Add raw hid support for ChibiOS
fredizzimo Dec 6, 2017
a6720ac
Enable midi compilation on ChibiOS
fredizzimo Dec 6, 2017
98979a0
Move midi functionality out of lufa.c
fredizzimo Dec 7, 2017
35b727c
Don't register sysex callback when not needed
fredizzimo Dec 7, 2017
6b3ded2
ChibiOS compilation fixes
fredizzimo Dec 7, 2017
aeb5045
Update ChibiOS submodule
fredizzimo Dec 13, 2017
9d1aa6a
Fix the Midi USB descriptor
fredizzimo Dec 13, 2017
423174a
Add MIDI support for ChibiOS
fredizzimo Dec 13, 2017
232d893
Fix USB descriptor strings on ChibiOS
fredizzimo Dec 13, 2017
3f44fb9
Use serial usb driver for raw hid
fredizzimo Dec 13, 2017
9ae3393
Generalize the ChibiOS stream like drivers
fredizzimo Dec 14, 2017
4e2e224
Convert console output to chibios stream driver
fredizzimo Dec 18, 2017
2c11f8c
Fixes for ChibiOS update
fredizzimo Feb 3, 2018
b852787
Update the ChibiOS contrib submodule
fredizzimo Feb 8, 2018
8296573
Fix duplicate reset enumeration on ChibiOS
fredizzimo Feb 8, 2018
0419402
Add missing include
fredizzimo Feb 8, 2018
c6ee2c7
Add number of endpoints check for ChibiOS
fredizzimo Feb 8, 2018
18861d4
Enable serial USB driver on all keyboards
fredizzimo Feb 8, 2018
320b82b
Add missing includes when API is enabled withot midi
fredizzimo Feb 8, 2018
6d04238
Add another missing inlcude
fredizzimo Feb 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions build_keyboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ else
endif

ifeq ($(PLATFORM),CHIBIOS)
include $(TMK_PATH)/protocol/chibios.mk
include $(TMK_PATH)/chibios.mk
OPT_OS = chibios
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/bootloader_defs.h)","")
Expand Down Expand Up @@ -197,7 +196,7 @@ else ifneq ("$(wildcard $(MAIN_KEYMAP_PATH_1)/keymap.c)","")
KEYMAP_PATH := $(MAIN_KEYMAP_PATH_1)
else ifneq ($(LAYOUTS),)
include build_layout.mk
else
else
$(error Could not find keymap)
# this state should never be reached
endif
Expand Down Expand Up @@ -247,6 +246,10 @@ endif
include $(TMK_PATH)/avr.mk
endif

ifeq ($(PLATFORM),CHIBIOS)
include $(TMK_PATH)/protocol/chibios.mk
endif

ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
VISUALIZER_DIR = $(QUANTUM_DIR)/visualizer
VISUALIZER_PATH = $(QUANTUM_PATH)/visualizer
Expand Down
8 changes: 3 additions & 5 deletions keyboards/chibios_test/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER "QMK"
#define USBSTR_MANUFACTURER 'T', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00', '\xc6', '\x00'
#define PRODUCT "ChibiOS QMK test"
#define USBSTR_PRODUCT 'C', '\x00', 'h', '\x00', 'i', '\x00', 'b', '\x00', 'i', '\x00', 'O', '\x00', 'S', '\x00', ' ', '\x00', 'Q', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00', 't', '\x00', 'e', '\x00', 's', '\x00', 't', '\x00'
#define DESCRIPTION "QMK keyboard firmware test for ChibiOS"
#define MANUFACTURER QMK
#define PRODUCT ChibiOS QMK test
#define DESCRIPTION QMK keyboard firmware test for ChibiOS

/* key matrix size */
#define MATRIX_ROWS 1
Expand Down
2 changes: 1 addition & 1 deletion keyboards/chibios_test/stm32_f072_onekey/halconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
* @brief Enables the SERIAL over USB subsystem.
*/
#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
#define HAL_USE_SERIAL_USB FALSE
#define HAL_USE_SERIAL_USB TRUE
#endif

/**
Expand Down
2 changes: 1 addition & 1 deletion keyboards/chibios_test/stm32_f103_onekey/halconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
* @brief Enables the SERIAL over USB subsystem.
*/
#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
#define HAL_USE_SERIAL_USB FALSE
#define HAL_USE_SERIAL_USB TRUE
#endif

/**
Expand Down
2 changes: 1 addition & 1 deletion keyboards/chibios_test/teensy_lc_onekey/halconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
* @brief Enables the SERIAL over USB subsystem.
*/
#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
#define HAL_USE_SERIAL_USB FALSE
#define HAL_USE_SERIAL_USB TRUE
#endif

/**
Expand Down
8 changes: 3 additions & 5 deletions keyboards/clueboard/60/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
#define VENDOR_ID 0xC1ED
#define PRODUCT_ID 0x2350
#define DEVICE_VER 0x0001
#define MANUFACTURER "Clueboard"
#define USBSTR_MANUFACTURER 'C', '\x00', 'l', '\x00', 'u', '\x00', 'e', '\x00', 'b', '\x00', 'o', '\x00', 'a', '\x00', 'r', '\x00', 'd', '\x00'
#define PRODUCT "Clueboard60"
#define USBSTR_PRODUCT 'C', '\x00', 'l', '\x00', 'u', '\x00', 'e', '\x00', 'b', '\x00', 'o', '\x00', 'a', '\x00', 'r', '\x00', 'd', '\x00', ' ', '\x00', '6', '\x00', '0', '\x00', '%', '\x00'
#define DESCRIPTION "Clueboard 60%"
#define MANUFACTURER Clueboard
#define PRODUCT Clueboard 60%
#define DESCRIPTION Clueboard 60%

/* key matrix size */
#define MATRIX_ROWS 5
Expand Down
8 changes: 2 additions & 6 deletions keyboards/ergodox_infinity/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x6464
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER "TMK"
#define USBSTR_MANUFACTURER 'T', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00'
#define PRODUCT "Infinity keyboard/TMK"
#define USBSTR_PRODUCT 'I', '\x00', 'n', '\x00', 'f', '\x00', 'i', '\x00', 'n', '\x00', 'i', '\x00', 't', '\x00', 'y', '\x00', ' ', '\x00', 'k', '\x00', 'e', '\x00', 'y', '\x00', 'b', '\x00', 'o', '\x00', 'a', '\x00', 'r', '\x00', 'd', '\x00', '/', '\x00', 'T', '\x00', 'M', '\x00', 'K', '\x00'
#define MANUFACTURER Input Club
#define PRODUCT Ergodox Infinity (QMK)

#define MOUSEKEY_INTERVAL 20
#define MOUSEKEY_DELAY 0
Expand Down
6 changes: 2 additions & 4 deletions keyboards/infinity60/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER "Input Club"
#define USBSTR_MANUFACTURER 'I', '\x00', 'n', '\x00', 'p', '\x00', 'u', '\x00', 't', '\x00', ' ', '\x00', 'C', '\x00', 'l', '\x00', 'u', '\x00', 'b', '\x00'
#define PRODUCT "Infinity keyboard/QMK"
#define USBSTR_PRODUCT 'I', '\x00', 'n', '\x00', 'f', '\x00', 'i', '\x00', 'n', '\x00', 'i', '\x00', 't', '\x00', 'y', '\x00', ' ', '\x00', 'k', '\x00', 'e', '\x00', 'y', '\x00', 'b', '\x00', 'o', '\x00', 'a', '\x00', 'r', '\x00', 'd', '\x00', '/', '\x00', 'Q', '\x00', 'M', '\x00', 'K', '\x00'
#define MANUFACTURER Input Club
#define PRODUCT Infinity 60% keyboard (QMK)
/* key matrix size */
#define MATRIX_ROWS 9
#define MATRIX_COLS 7
Expand Down
2 changes: 1 addition & 1 deletion keyboards/infinity60/halconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
* @brief Enables the SERIAL over USB subsystem.
*/
#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
#define HAL_USE_SERIAL_USB FALSE
#define HAL_USE_SERIAL_USB TRUE
#endif

/**
Expand Down
8 changes: 3 additions & 5 deletions keyboards/jm60/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER "JMWS"
#define USBSTR_MANUFACTURER 'J', '\x00', 'M', '\x00', 'W', '\x00', 'S', '\x00'
#define PRODUCT "JM60 RGB Keyboard(QMK)"
#define USBSTR_PRODUCT 'J', '\x00', 'M', '\x00', '6', '\x00', '0', '\x00', ' ', '\x00', 'R', '\x00', 'G', '\x00', 'B', '\x00', ' ', '\x00', 'K', '\x00', 'e', '\x00', 'y', '\x00', 'b', '\x00', 'o', '\x00', 'a', '\x00', 'r', '\x00', 'd', '\x00', '(', '\x00', 'Q', '\x00', 'M', '\x00', 'K', '\x00', ')', '\x00'
#define DESCRIPTION "QMK keyboard firmware for JM60 RGB Keyboard"
#define MANUFACTURER JMWS
#define PRODUCT JM60 RGB Keyboard(QMK)
#define DESCRIPTION QMK keyboard firmware for JM60 RGB Keyboard

/* key matrix size */
#define MATRIX_ROWS 5
Expand Down
2 changes: 1 addition & 1 deletion keyboards/jm60/halconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
* @brief Enables the SERIAL over USB subsystem.
*/
#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
#define HAL_USE_SERIAL_USB FALSE
#define HAL_USE_SERIAL_USB TRUE
#endif

/**
Expand Down
8 changes: 3 additions & 5 deletions keyboards/whitefox/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEVICE_VER 0x0001
/* in python2: list(u"whatever".encode('utf-16-le')) */
/* at most 32 characters or the ugly hack in usb_main.c borks */
#define MANUFACTURER "Input Club"
#define USBSTR_MANUFACTURER 'I', '\x00', 'n', '\x00', 'p', '\x00', 'u', '\x00', 't', '\x00', ' ', '\x00', 'C', '\x00', 'l', '\x00', 'u', '\x00', 'b', '\x00'
#define PRODUCT "WhiteFox/QMK"
#define USBSTR_PRODUCT 'W', '\x00', 'h', '\x00', 'i', '\x00', 't', '\x00', 'e', '\x00', 'F', '\x00', 'o', '\x00', 'x', '\x00', ' ', '\x00'
#define MANUFACTURER Input Club
#define PRODUCT WhiteFox (QMK)

/* key matrix size */
#define MATRIX_ROWS 9
Expand Down Expand Up @@ -81,4 +79,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION

#endif
#endif
2 changes: 1 addition & 1 deletion lib/chibios
1 change: 1 addition & 0 deletions quantum/api/api_sysex.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "api_sysex.h"
#include "sysex_tools.h"
#include "print.h"
#include "qmk_midi.h"

void send_bytes_sysex(uint8_t message_type, uint8_t data_type, uint8_t * bytes, uint16_t length) {
// SEND_STRING("\nTX: ");
Expand Down
3 changes: 3 additions & 0 deletions quantum/keymap.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "action.h"
#if defined(__AVR__)
#include <avr/pgmspace.h>
#elif defined PROTOCOL_CHIBIOS
//We need to ensure that chibios is include before redefining reset
#include "ch.h"
#endif
#include "keycode.h"
#include "action_macro.h"
Expand Down
58 changes: 33 additions & 25 deletions quantum/process_keycode/process_midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
#include "process_midi.h"

#ifdef MIDI_ENABLE
#include <LUFA/Drivers/USB/USB.h>
#include "midi.h"
#include "qmk_midi.h"

#ifdef MIDI_BASIC

void process_midi_basic_noteon(uint8_t note)
void process_midi_basic_noteon(uint8_t note)
{
midi_send_noteon(&midi_device, 0, note, 128);
}
Expand All @@ -46,6 +48,7 @@ static uint8_t tone_status[MIDI_TONE_COUNT];
static uint8_t midi_modulation;
static int8_t midi_modulation_step;
static uint16_t midi_modulation_timer;
midi_config_t midi_config;

inline uint8_t compute_velocity(uint8_t setting)
{
Expand All @@ -70,30 +73,6 @@ void midi_init(void)
midi_modulation_timer = 0;
}

void midi_task(void)
{
if (timer_elapsed(midi_modulation_timer) < midi_config.modulation_interval)
return;
midi_modulation_timer = timer_read();

if (midi_modulation_step != 0)
{
dprintf("midi modulation %d\n", midi_modulation);
midi_send_cc(&midi_device, midi_config.channel, 0x1, midi_modulation);

if (midi_modulation_step < 0 && midi_modulation < -midi_modulation_step) {
midi_modulation = 0;
midi_modulation_step = 0;
return;
}

midi_modulation += midi_modulation_step;

if (midi_modulation > 127)
midi_modulation = 127;
}
}

uint8_t midi_compute_note(uint16_t keycode)
{
return 12 * midi_config.octave + (keycode - MIDI_TONE_MIN) + midi_config.transpose;
Expand Down Expand Up @@ -250,4 +229,33 @@ bool process_midi(uint16_t keycode, keyrecord_t *record)

#endif // MIDI_ADVANCED

void midi_task(void)
{
midi_device_process(&midi_device);
#ifdef MIDI_ADVANCED
if (timer_elapsed(midi_modulation_timer) < midi_config.modulation_interval)
return;
midi_modulation_timer = timer_read();

if (midi_modulation_step != 0)
{
dprintf("midi modulation %d\n", midi_modulation);
midi_send_cc(&midi_device, midi_config.channel, 0x1, midi_modulation);

if (midi_modulation_step < 0 && midi_modulation < -midi_modulation_step) {
midi_modulation = 0;
midi_modulation_step = 0;
return;
}

midi_modulation += midi_modulation_step;

if (midi_modulation > 127)
midi_modulation = 127;
}
#endif
}



#endif // MIDI_ENABLE
5 changes: 3 additions & 2 deletions quantum/process_keycode/process_midi.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ void process_midi_basic_noteoff(uint8_t note);
void process_midi_all_notes_off(void);
#endif

void midi_task(void);

#ifdef MIDI_ADVANCED
typedef union {
uint32_t raw;
Expand All @@ -39,10 +41,9 @@ typedef union {
};
} midi_config_t;

midi_config_t midi_config;
extern midi_config_t midi_config;

void midi_init(void);
void midi_task(void);
bool process_midi(uint16_t keycode, keyrecord_t *record);

#define MIDI_INVALID_NOTE 0xFF
Expand Down
8 changes: 8 additions & 0 deletions quantum/quantum.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ extern backlight_config_t backlight_config;
#include "fauxclicky.h"
#endif

#ifdef API_ENABLE
#include "api.h"
#endif

#ifdef MIDI_ENABLE
#include "process_midi.h"
#endif

#ifdef AUDIO_ENABLE
#ifndef GOODBYE_SONG
#define GOODBYE_SONG SONG(GOODBYE_SOUND)
Expand Down
1 change: 0 additions & 1 deletion quantum/quantum.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ extern uint32_t default_layer_state;
#endif

#ifdef MIDI_ENABLE
#include <lufa.h>
#ifdef MIDI_ADVANCED
#include "process_midi.h"
#endif
Expand Down
2 changes: 2 additions & 0 deletions tmk_core/chibios.mk
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ COMPILEFLAGS += -falign-functions=16
COMPILEFLAGS += -ffunction-sections
COMPILEFLAGS += -fdata-sections
COMPILEFLAGS += -fno-common
COMPILEFLAGS += -fshort-wchar
COMPILEFLAGS += $(THUMBFLAGS)

CFLAGS += $(COMPILEFLAGS)
Expand All @@ -159,6 +160,7 @@ CPPFLAGS += $(COMPILEFLAGS)
CPPFLAGS += -fno-rtti

LDFLAGS +=-Wl,--gc-sections
LDFLAGS +=-Wl,--no-wchar-size-warning
LDFLAGS += -mno-thumb-interwork -mthumb
LDSYMBOLS =,--defsym=__process_stack_size__=$(USE_PROCESS_STACKSIZE)
LDSYMBOLS :=$(LDSYMBOLS),--defsym=__main_stack_size__=$(USE_EXCEPTIONS_STACKSIZE)
Expand Down
5 changes: 0 additions & 5 deletions tmk_core/common/host_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ typedef struct {
void (*send_mouse)(report_mouse_t *);
void (*send_system)(uint16_t);
void (*send_consumer)(uint16_t);
#ifdef MIDI_ENABLE
void (*usb_send_func)(MidiDevice *, uint16_t, uint8_t, uint8_t, uint8_t);
void (*usb_get_midi)(MidiDevice *);
void (*midi_usb_init)(MidiDevice *);
#endif
} host_driver_t;

#endif
7 changes: 7 additions & 0 deletions tmk_core/common/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef POINTING_DEVICE_ENABLE
# include "pointing_device.h"
#endif
#ifdef MIDI_ENABLE
# include "process_midi.h"
#endif

#ifdef MATRIX_HAS_GHOST
extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
Expand Down Expand Up @@ -260,6 +263,10 @@ void keyboard_task(void)
pointing_device_task();
#endif

#ifdef MIDI_ENABLE
midi_task();
#endif

// update LED
if (led_status != host_keyboard_leds()) {
led_status = host_keyboard_leds();
Expand Down
Loading