Skip to content

Commit

Permalink
[Core] Fix Sensor driver code (#15484)
Browse files Browse the repository at this point in the history
  • Loading branch information
drashna authored Dec 15, 2021
1 parent 3fa592a commit aed64aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions drivers/sensors/cirque_pinnacle_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extern bool touchpad_init;
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_TRACKPAD_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) {
if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) {
spi_write(cmdByte);
spi_read(); // filler
spi_read(); // filler
Expand All @@ -27,7 +27,6 @@ void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) {
dprintf("error right touchpad\n");
#endif
touchpad_init = false;
j
}
spi_stop();
}
Expand All @@ -38,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_TRACKPAD_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) {
if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) {
spi_write(cmdByte);
spi_write(data);
} else {
Expand Down
2 changes: 1 addition & 1 deletion drivers/sensors/pmw3360.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void pmw3360_set_cpi(uint16_t cpi) {

uint16_t pmw3360_get_cpi(void) {
uint8_t cpival = spi_read_adv(REG_Config1);
return (uint16_t)(cpival & 0xFF) * 100;
return (uint16_t)((cpival + 1) & 0xFF) * 100;
}

bool pmw3360_init(void) {
Expand Down

0 comments on commit aed64aa

Please sign in to comment.