Skip to content

Commit

Permalink
Incorporated fixes from @raghur's work to work on non-vendored TinyUS…
Browse files Browse the repository at this point in the history
…B and PICO-PIO-USB on QMK 0.24
  • Loading branch information
whyaaronbailey committed Dec 18, 2024
1 parent 3d15d18 commit 6d7bd8e
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 65 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "tinyusb"]
path = lib/tinyusb
url = https://github.com/hathach/tinyusb.git
[submodule "lib/Pico-PIO-USB"]
path = lib/Pico-PIO-USB
url = https://github.com/sekigon-gonnoc/Pico-PIO-USB.git
Expand Down
15 changes: 9 additions & 6 deletions c1_usbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@
#include "pio_usb_ll.h"
#include "hardware/sync.h"

// Correct pin definitions for Adafruit Feather RP2040 with USB Host
#define PIO_USB_PIN_DP 16 // D+ on GPIO 16
#define PIN_VBUS 18 // VBUS enable on GPIO 18

// dummy implementation
void alarm_pool_add_repeating_timer_us(void) {}
void alarm_pool_create(void) {}

// Initialize USB host stack on core1
void c1_usbh(void) {
pio_usb_configuration_t pio_cfg = PIO_USB_DEFAULT_CONFIG;
pio_cfg.pin_dp = 16;
// pio_cfg.extra_error_retry_count = 10;
pio_cfg.pin_dp = PIO_USB_PIN_DP; // D+ on GPIO 16
pio_cfg.skip_alarm_pool = true;
tuh_configure(1, TUH_CFGID_RPI_PIO_USB_CONFIGURATION, &pio_cfg);

gpio_init(18);
gpio_set_dir(18, GPIO_OUT);
gpio_put(18, 1);
gpio_init(PIN_VBUS); // Use correct VBUS enable pin
gpio_set_dir(PIN_VBUS, GPIO_OUT);
gpio_put(PIN_VBUS, 1);

tuh_init(1);
c1_start_timer();
Expand All @@ -30,4 +33,4 @@ void c1_usbh(void) {
// USB host stack main task
void c1_main_task(void) {
tuh_task();
}
}
4 changes: 2 additions & 2 deletions info.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
},
"processor": "RP2040",
"usb": {
"vid": "0x0554",
"pid": "0x1005",
"vid": "0x239A",
"pid": "0x0001",
"device_version": "1.0.0"
},
"layouts": {
Expand Down
59 changes: 10 additions & 49 deletions keymaps/tartarus_pacs/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ enum custom_keycodes {
ELLIPSE,
ROI,
INTERZOOM,
HANG,
MS_UR,
MS_DR,
MS_UL,
MS_DL
HANG
};

enum {
Expand Down Expand Up @@ -134,8 +130,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_NO, ANNOTATION, WL_SOFT, WL_LUNG, WL_VASCULAR, ZOOM, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
OPENEPIC, WL_BONE, SCROLLUP, WL_BRAIN, ARROW, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
COPYACC, FAST_UP, SCROLLDOWN, FAST_DOWN, MEASURE, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO,
OPENGE, SPINE_C, SPINE_T, SPINE_L, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, MS_UL, KC_MS_U, MS_UR, KC_NO, KC_NO, KC_NO,
KC_NO, KC_NO, MO(1), DICTATE, KC_NO, KC_NO, KC_NO, MS_DL, KC_MS_L, KC_MS_D, KC_MS_R, MS_DR, KC_NO
OPENGE, SPINE_C, SPINE_T, SPINE_L, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_MS_U, KC_NO, KC_NO, KC_NO, KC_NO,
KC_NO, KC_NO, MO(1), DICTATE, KC_NO, KC_NO, KC_NO, KC_NO, KC_MS_L, KC_MS_D, KC_MS_R, KC_NO, KC_NO
),

[1] = LAYOUT(
Expand All @@ -156,8 +152,8 @@ tap_dance_action_t tap_dance_actions[] = {
[TD_PAN_CINE] = ACTION_TAP_DANCE_DOUBLE(KC_P, KC_U) // tap once for P, twice for U
};

static uint16_t REP_DELAY = 275; // Common delay for both scroll up and down
static uint16_t REP_DELAY_FAST = 150; // Common delay for both scroll up and down
static uint16_t REP_DELAY = 290; // Common delay for both scroll up and down
static uint16_t REP_DELAY_FAST = 120; // Common delay for both scroll up and down

uint32_t wh_callback(uint32_t trigger_time, void* cb_arg) {
bool is_up = (bool)cb_arg;
Expand Down Expand Up @@ -266,11 +262,11 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
SEND_STRING(
SS_LCTL("2")
SS_DELAY(2000)
SS_DELAY(2500)
SS_LCTL("v")
SS_DELAY(250)
SS_DELAY(500)
SS_TAP(X_ENTER)
SS_DELAY(2000)
SS_DELAY(2500)
SS_LALT(SS_LSFT("a"))
);
}
Expand All @@ -280,11 +276,11 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
SEND_STRING(
SS_LCTL("f")
SS_DELAY(150)
SS_DELAY(500)
SS_TAP(X_BSPC)
SS_LCTL("v")
SS_TAP(X_ENTER)
SS_DELAY(150)
SS_DELAY(500)
SS_TAP(X_ENTER)
);
}
Expand Down Expand Up @@ -536,41 +532,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
return false;

case MS_DL: // Moves the mosue down and to the left
if (record->event.pressed) {
SEND_STRING(
SS_TAP(X_MS_WH_DOWN)
SS_TAP(X_MS_WH_LEFT)
);
}
return false;

case MS_DR: // Moves the mosue down and to the right
if (record->event.pressed) {
SEND_STRING(
SS_TAP(X_MS_WH_DOWN)
SS_TAP(X_MS_WH_RIGHT)
);
}
return false;

case MS_UL:
if (record->event.pressed) {
SEND_STRING(
SS_TAP(X_MS_WH_UP)
SS_TAP(X_MS_WH_LEFT)
);
}
return false;

case MS_UR:
if (record->event.pressed) {
SEND_STRING(
SS_TAP(X_MS_WH_UP)
SS_TAP(X_MS_WH_RIGHT)
);
}
return false;
}
return true; // Process all other keycodes normally.
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Pico-PIO-USB
Submodule Pico-PIO-USB updated 1 files
+2 −4 src/pio_usb.c
2 changes: 1 addition & 1 deletion lib/tinyusb
Submodule tinyusb updated 180 files
8 changes: 7 additions & 1 deletion tusb_os_custom.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ osal_mutex_t osal_mutex_create(osal_mutex_def_t *mdef) {
return mdef;
}

/* TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_delete(osal_mutex_t mutex_hdl) { */
bool osal_mutex_delete(osal_mutex_t mutex_hdl) {
(void) mutex_hdl;
return true; // nothing to do
}

#include <stdarg.h>

static char debug_buffer[(1 << 12)];
Expand Down Expand Up @@ -61,4 +67,4 @@ void tusb_print_debug_buffer(void) {
printf("%c", debug_buffer[read_index]);
read_index = (read_index + 1) & (sizeof(debug_buffer) - 1);
}
}
}
11 changes: 9 additions & 2 deletions tusb_os_custom.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* The MIT License (MIT)
*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
Expand Down Expand Up @@ -35,6 +35,7 @@ void osal_task_delay(uint32_t msec);
osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef);
bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec);
bool osal_mutex_unlock(osal_mutex_t mutex_hdl);
bool osal_mutex_delete(osal_mutex_t mutex_hdl);

//--------------------------------------------------------------------+
// QUEUE API
Expand Down Expand Up @@ -113,6 +114,12 @@ TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_empty(osal_queue_t qhdl)
// with interrupt disabled before going into low power mode
return tu_fifo_empty(&qhdl->ff);
}

TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_delete(osal_queue_t qhdl) {
(void) qhdl;
return true; // nothing to do
}

#ifdef __cplusplus
}
#endif
#endif

0 comments on commit 6d7bd8e

Please sign in to comment.