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

Adding ability to use more than one Cirque Pinnacle via SPI #24791

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions docs/features/pointing_device.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
7 changes: 5 additions & 2 deletions drivers/sensors/cirque_pinnacle_spi.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 Cirque Corp. Restrictions apply. See: www.cirque.com/sw-license

Check failure on line 1 in drivers/sensors/cirque_pinnacle_spi.c

View workflow job for this annotation

GitHub Actions / lint

Requires Formatting
#include "cirque_pinnacle.h"
#include "spi_master.h"

Expand All @@ -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; }
Comment on lines +12 to +13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
__attribute__((weak)) uint8_t cirque_pinnacle_spi_get_cs_pin(void) { return CIRQUE_PINNACLE_SPI_CS_PIN; }
__attribute__((weak)) pin_t cirque_pinnacle_spi_get_cs_pin(void) {
return CIRQUE_PINNACLE_SPI_CS_PIN;
}


/* RAP Functions */
// Reads <count> Pinnacle registers starting at <address>
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
Expand All @@ -34,7 +37,7 @@
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 {
Expand Down
Loading