summaryrefslogtreecommitdiff
path: root/drivers/sensors/adns9800.c
diff options
context:
space:
mode:
authoruqs <uqs@FreeBSD.org>2021-12-27 11:26:09 +0100
committerGitHub <noreply@github.com>2021-12-27 21:26:09 +1100
commitd3952523fe67ca22defe0d889e6fc77f76c3afd9 (patch)
treebb955e974d38a5fcaf024dc22ead48d7189153f7 /drivers/sensors/adns9800.c
parent0709d208dbf0aa1ea39b7fa3a6938e2b3d5b5249 (diff)
downloadqmk_firmware-d3952523fe67ca22defe0d889e6fc77f76c3afd9.tar.gz
qmk_firmware-d3952523fe67ca22defe0d889e6fc77f76c3afd9.zip
pwm3360 driver cleanup and diff reduction to adns9800 (#15559)
* Diff reduction between ADNS9800 and PMW3360 drivers. They are very similar devices. This (somewhat) unreadable diff is essentially a no-op, but it makes a `vimdiff` between the 2 drivers much more readable. * Cleanup pwm3360 driver some more. Remove redundant calls to spi_start() and spi_stop(), as pmw3360_write() will already call these.
Diffstat (limited to 'drivers/sensors/adns9800.c')
-rw-r--r--drivers/sensors/adns9800.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/sensors/adns9800.c b/drivers/sensors/adns9800.c
index c52f991804..995c9e8614 100644
--- a/drivers/sensors/adns9800.c
+++ b/drivers/sensors/adns9800.c
@@ -77,7 +77,9 @@
#define MSB1 0x80
// clang-format on
-void adns9800_spi_start(void) { spi_start(ADNS9800_CS_PIN, false, ADNS9800_SPI_MODE, ADNS9800_SPI_DIVISOR); }
+void adns9800_spi_start(void) {
+ spi_start(ADNS9800_CS_PIN, false, ADNS9800_SPI_MODE, ADNS9800_SPI_DIVISOR);
+}
void adns9800_write(uint8_t reg_addr, uint8_t data) {
adns9800_spi_start();
@@ -154,8 +156,8 @@ void adns9800_init() {
}
config_adns9800_t adns9800_get_config(void) {
- uint8_t config_1 = adns9800_read(REG_Configuration_I);
- return (config_adns9800_t){(config_1 & 0xFF) * CPI_STEP};
+ uint8_t cpival = adns9800_read(REG_Configuration_I);
+ return (config_adns9800_t){(cpival & 0xFF) * CPI_STEP};
}
void adns9800_set_config(config_adns9800_t config) {
@@ -164,8 +166,8 @@ void adns9800_set_config(config_adns9800_t config) {
}
uint16_t adns9800_get_cpi(void) {
- uint8_t config_1 = adns9800_read(REG_Configuration_I);
- return (uint16_t){(config_1 & 0xFF) * CPI_STEP};
+ uint8_t cpival = adns9800_read(REG_Configuration_I);
+ return (uint16_t)(cpival & 0xFF) * CPI_STEP;
}
void adns9800_set_cpi(uint16_t cpi) {
@@ -184,7 +186,7 @@ static int16_t convertDeltaToInt(uint8_t high, uint8_t low) {
}
report_adns9800_t adns9800_get_report(void) {
- report_adns9800_t report = {0, 0};
+ report_adns9800_t report = {0};
adns9800_spi_start();