diff --git a/docs/features/pointing_device.md b/docs/features/pointing_device.md index 0ecf82c8df67..3a6f401fb824 100644 --- a/docs/features/pointing_device.md +++ b/docs/features/pointing_device.md @@ -217,6 +217,11 @@ Default Scaling is 1024. Actual CPI depends on trackpad diameter. Also see the `POINTING_DEVICE_TASK_THROTTLE_MS`, which defaults to 10ms when using Cirque Pinnacle, which matches the internal update rate of the position registers (in standard configuration). Advanced configuration for pen/stylus usage might require lower values. + +#### Multiple devices + +If you wish to use more than one Cirque Pinnacle via SPI, you will need to share the common SPI pins and provide a different CS pin for each device. Then implement `cirque_pinnacle_spi_get_cs_pin` and change the pin prior to making any device calls (e.g. `cirque_pinnacle_init` or `cirque_pinnacle_read_data`). + #### Absolute mode settings | Setting | Description | Default | diff --git a/drivers/sensors/cirque_pinnacle_spi.c b/drivers/sensors/cirque_pinnacle_spi.c index 5cb39aebb02c..45263ac6854e 100644 --- a/drivers/sensors/cirque_pinnacle_spi.c +++ b/drivers/sensors/cirque_pinnacle_spi.c @@ -9,12 +9,15 @@ extern bool touchpad_init; + +__attribute__((weak)) uint8_t cirque_pinnacle_spi_get_cs_pin(void) { return CIRQUE_PINNACLE_SPI_CS_PIN; } + /* RAP Functions */ // Reads Pinnacle registers starting at
void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) { uint8_t cmdByte = READ_MASK | address; // Form the READ command byte if (touchpad_init) { - if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) { + if (spi_start(cirque_pinnacle_spi_get_cs_pin(), CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) { spi_write(cmdByte); // write command byte, receive filler spi_write(FILLER_BYTE); // write & receive filler spi_write(FILLER_BYTE); // write & receive filler @@ -34,7 +37,7 @@ void RAP_Write(uint8_t address, uint8_t data) { uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte if (touchpad_init) { - if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) { + if (spi_start(cirque_pinnacle_spi_get_cs_pin(), CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) { spi_write(cmdByte); spi_write(data); } else {