Skip to content

Commit

Permalink
Merge pull request qmk#1 from wigingtont2/master
Browse files Browse the repository at this point in the history
Add basic support for Pimoroni trackball and PMW33XX pointing devices.
  • Loading branch information
morganvenable authored Sep 10, 2023
2 parents 64405d4 + 56898d7 commit b24afd2
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 1 deletion.
40 changes: 39 additions & 1 deletion keyboards/svalboard/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,45 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define SERIAL_USART_TX_PIN GP0
#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET
#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT 500 // Timeout window in ms in which the double tap can occur.


#if defined(POINTING_DEVICE_ENABLE)

// Pointing device stuff
#define SPLIT_POINTING_ENABLE
#define POINTING_DEVICE_COMBINED

#if defined(POINTING_DEVICE_IS_PIMORONI)

#define I2C_DRIVER I2CD1
#define I2C1_SDA_PIN GP18
#define I2C1_SCL_PIN GP19
#define PIMORONI_TRACKBALL_SCALE 5

#endif

#if (defined(POINTING_DEVICE_IS_PMW3360) || defined(POINTING_DEVICE_IS_PMW3389))

// SPI stuff
#define SPI_DRIVER SPID0
// Use SCK# pin from SPI set.
#define SPI_SCK_PIN GP18
// Use TX# pin from SPI set.
#define SPI_MOSI_PIN GP19
// Use RX# pin from SPI set.
#define SPI_MISO_PIN GP16
// PMW33XX stuff
// Use CS# pin from SPI set. Might not actually have to be the CS# pin, since
// there's supposed to be support for multiple PMW33XX sensors, with different
// CS pins.
#define PMW33XX_CS_PIN GP17
#define PMW33XX_CS_DIVISOR 4
#define PMW33XX_CPI 3200
#define POINTING_DEVICE_INVERT_X_RIGHT
/* #define ROTATIONAL_TRANSFORM_ANGLE_RIGHT 75 */

#endif
#endif

//#define USB_POLLING_INTERVAL_MS 1


Expand Down
26 changes: 26 additions & 0 deletions keyboards/svalboard/halconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include_next <halconf.h>

#if defined(POINTING_DEVICE_DRIVER)

#if defined(POINTING_DEVICE_IS_PIMORONI)

#undef HAL_USE_I2C
#define HAL_USE_I2C TRUE

#endif

#if (defined(POINTING_DEVICE_IS_PMW3360) || defined(POINTING_DEVICE_IS_PMW3389))

#undef HAL_USE_SPI
#define HAL_USE_SPI TRUE

#undef SPI_USE_WAIT
#define SPI_USE_WAIT TRUE

#undef SPI_SELECT_MODE
#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD

#endif
#endif
20 changes: 20 additions & 0 deletions keyboards/svalboard/mcuconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include_next "mcuconf.h"

#if defined(POINTING_DEVICE_DRIVER)

#if defined(POINTING_DEVICE_IS_PIMORONI)
// TODO I2C0 does not work, for some reason.
#undef RP_I2C_USE_I2C1
#define RP_I2C_USE_I2C1 TRUE

#endif

#if (defined(POINTING_DEVICE_IS_PMW3360) || defined(POINTING_DEVICE_IS_PMW3389))

#undef RP_SPI_USE_SPI0
#define RP_SPI_USE_SPI0 TRUE

#endif
#endif
16 changes: 16 additions & 0 deletions keyboards/svalboard/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,19 @@ CUSTOM_MATRIX = lite
SRC += matrix.c

SERIAL_DRIVER = vendor

POINTING_DEVICE_ENABLE = yes

POINTING_DEVICE_DRIVER = pimoroni_trackball

ifeq ($(strip $(POINTING_DEVICE_DRIVER)), pimoroni_trackball)
OPT_DEFS += -DPOINTING_DEVICE_IS_PIMORONI
endif

ifeq ($(strip $(POINTING_DEVICE_DRIVER)), pmw3360)
OPT_DEFS += -DPOINTING_DEVICE_IS_PMW3360
endif

ifeq ($(strip $(POINTING_DEVICE_DRIVER)), pmw3389)
OPT_DEFS += -DPOINTING_DEVICE_IS_PMW3389
endif

0 comments on commit b24afd2

Please sign in to comment.