diff options
author | QMK Bot <hello@qmk.fm> | 2022-02-12 10:29:31 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-12 18:29:31 +0000 |
commit | 63646e8906e062d1c1de3925cba70c4e3426a855 (patch) | |
tree | 4e91648b77b838e1125cf86331d7e84bde6d07a9 /drivers/sensors | |
parent | afcdd7079c774dec2aa4b7f2d08adf8b7310919b (diff) | |
download | qmk_firmware-63646e8906e062d1c1de3925cba70c4e3426a855.tar.gz qmk_firmware-63646e8906e062d1c1de3925cba70c4e3426a855.zip |
Format code according to conventions (#16322)
Diffstat (limited to 'drivers/sensors')
-rw-r--r-- | drivers/sensors/adns5050.c | 10 | ||||
-rw-r--r-- | drivers/sensors/adns9800.c | 4 | ||||
-rw-r--r-- | drivers/sensors/analog_joystick.c | 2 | ||||
-rw-r--r-- | drivers/sensors/cirque_pinnacle.c | 38 | ||||
-rw-r--r-- | drivers/sensors/cirque_pinnacle.h | 8 | ||||
-rw-r--r-- | drivers/sensors/cirque_pinnacle_i2c.c | 4 | ||||
-rw-r--r-- | drivers/sensors/cirque_pinnacle_spi.c | 10 | ||||
-rw-r--r-- | drivers/sensors/pimoroni_trackball.c | 4 | ||||
-rw-r--r-- | drivers/sensors/pmw3360.c | 14 | ||||
-rw-r--r-- | drivers/sensors/pmw3360.h | 8 | ||||
-rw-r--r-- | drivers/sensors/pmw3389.c | 14 | ||||
-rw-r--r-- | drivers/sensors/pmw3389.h | 8 |
12 files changed, 71 insertions, 53 deletions
diff --git a/drivers/sensors/adns5050.c b/drivers/sensors/adns5050.c index c23d24d5af..b76268fba2 100644 --- a/drivers/sensors/adns5050.c +++ b/drivers/sensors/adns5050.c @@ -74,9 +74,13 @@ void adns5050_sync(void) { writePinHigh(ADNS5050_CS_PIN); } -void adns5050_cs_select(void) { writePinLow(ADNS5050_CS_PIN); } +void adns5050_cs_select(void) { + writePinLow(ADNS5050_CS_PIN); +} -void adns5050_cs_deselect(void) { writePinHigh(ADNS5050_CS_PIN); } +void adns5050_cs_deselect(void) { + writePinHigh(ADNS5050_CS_PIN); +} uint8_t adns5050_serial_read(void) { setPinInput(ADNS5050_SDIO_PIN); @@ -190,7 +194,7 @@ int8_t convert_twoscomp(uint8_t data) { // Don't forget to use the definitions for CPI in the header file. void adns5050_set_cpi(uint16_t cpi) { - uint8_t cpival = constrain((cpi / 125), 0x1, 0xD); // limits to 0--119 + uint8_t cpival = constrain((cpi / 125), 0x1, 0xD); // limits to 0--119 adns5050_write_reg(REG_MOUSE_CONTROL2, 0b10000 | cpival); } diff --git a/drivers/sensors/adns9800.c b/drivers/sensors/adns9800.c index d167841968..3633f23e52 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(); diff --git a/drivers/sensors/analog_joystick.c b/drivers/sensors/analog_joystick.c index 1666bed047..95f8cff23a 100644 --- a/drivers/sensors/analog_joystick.c +++ b/drivers/sensors/analog_joystick.c @@ -24,7 +24,7 @@ uint16_t minAxisValue = ANALOG_JOYSTICK_AXIS_MIN; uint16_t maxAxisValue = ANALOG_JOYSTICK_AXIS_MAX; uint8_t maxCursorSpeed = ANALOG_JOYSTICK_SPEED_MAX; -uint8_t speedRegulator = ANALOG_JOYSTICK_SPEED_REGULATOR; // Lower Values Create Faster Movement +uint8_t speedRegulator = ANALOG_JOYSTICK_SPEED_REGULATOR; // Lower Values Create Faster Movement int16_t xOrigin, yOrigin; diff --git a/drivers/sensors/cirque_pinnacle.c b/drivers/sensors/cirque_pinnacle.c index b807c4f076..2db7f916fe 100644 --- a/drivers/sensors/cirque_pinnacle.c +++ b/drivers/sensors/cirque_pinnacle.c @@ -54,7 +54,9 @@ void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count); void RAP_Write(uint8_t address, uint8_t data); #ifdef CONSOLE_ENABLE -void print_byte(uint8_t byte) { xprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); } +void print_byte(uint8_t byte) { + xprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); +} #endif /* Logical Scaling Functions */ @@ -73,8 +75,12 @@ void ClipCoordinates(pinnacle_data_t* coordinates) { } } -uint16_t cirque_pinnacle_get_scale(void) { return scale_data; } -void cirque_pinnacle_set_scale(uint16_t scale) { scale_data = scale; } +uint16_t cirque_pinnacle_get_scale(void) { + return scale_data; +} +void cirque_pinnacle_set_scale(uint16_t scale) { + scale_data = scale; +} // Scales data to desired X & Y resolution void cirque_pinnacle_scale_data(pinnacle_data_t* coordinates, uint16_t xResolution, uint16_t yResolution) { @@ -105,13 +111,13 @@ void cirque_pinnacle_clear_flags() { void cirque_pinnacle_enable_feed(bool feedEnable) { uint8_t temp; - RAP_ReadBytes(FEEDCONFIG_1, &temp, 1); // Store contents of FeedConfig1 register + RAP_ReadBytes(FEEDCONFIG_1, &temp, 1); // Store contents of FeedConfig1 register if (feedEnable) { - temp |= 0x01; // Set Feed Enable bit + temp |= 0x01; // Set Feed Enable bit RAP_Write(0x04, temp); } else { - temp &= ~0x01; // Clear Feed Enable bit + temp &= ~0x01; // Clear Feed Enable bit RAP_Write(0x04, temp); } } @@ -122,13 +128,13 @@ void cirque_pinnacle_enable_feed(bool feedEnable) { void ERA_ReadBytes(uint16_t address, uint8_t* data, uint16_t count) { uint8_t ERAControlValue = 0xFF; - cirque_pinnacle_enable_feed(false); // Disable feed + cirque_pinnacle_enable_feed(false); // Disable feed - RAP_Write(ERA_HIGH_BYTE, (uint8_t)(address >> 8)); // Send upper byte of ERA address - RAP_Write(ERA_LOW_BYTE, (uint8_t)(address & 0x00FF)); // Send lower byte of ERA address + RAP_Write(ERA_HIGH_BYTE, (uint8_t)(address >> 8)); // Send upper byte of ERA address + RAP_Write(ERA_LOW_BYTE, (uint8_t)(address & 0x00FF)); // Send lower byte of ERA address for (uint16_t i = 0; i < count; i++) { - RAP_Write(ERA_CONTROL, 0x05); // Signal ERA-read (auto-increment) to Pinnacle + RAP_Write(ERA_CONTROL, 0x05); // Signal ERA-read (auto-increment) to Pinnacle // Wait for status register 0x1E to clear do { @@ -145,14 +151,14 @@ void ERA_ReadBytes(uint16_t address, uint8_t* data, uint16_t count) { void ERA_WriteByte(uint16_t address, uint8_t data) { uint8_t ERAControlValue = 0xFF; - cirque_pinnacle_enable_feed(false); // Disable feed + cirque_pinnacle_enable_feed(false); // Disable feed - RAP_Write(ERA_VALUE, data); // Send data byte to be written + RAP_Write(ERA_VALUE, data); // Send data byte to be written - RAP_Write(ERA_HIGH_BYTE, (uint8_t)(address >> 8)); // Upper byte of ERA address - RAP_Write(ERA_LOW_BYTE, (uint8_t)(address & 0x00FF)); // Lower byte of ERA address + RAP_Write(ERA_HIGH_BYTE, (uint8_t)(address >> 8)); // Upper byte of ERA address + RAP_Write(ERA_LOW_BYTE, (uint8_t)(address & 0x00FF)); // Lower byte of ERA address - RAP_Write(ERA_CONTROL, 0x02); // Signal an ERA-write to Pinnacle + RAP_Write(ERA_CONTROL, 0x02); // Signal an ERA-write to Pinnacle // Wait for status register 0x1E to clear do { @@ -166,7 +172,7 @@ void cirque_pinnacle_set_adc_attenuation(uint8_t adcGain) { uint8_t temp = 0x00; ERA_ReadBytes(0x0187, &temp, 1); - temp &= 0x3F; // clear top two bits + temp &= 0x3F; // clear top two bits temp |= adcGain; ERA_WriteByte(0x0187, temp); ERA_ReadBytes(0x0187, &temp, 1); diff --git a/drivers/sensors/cirque_pinnacle.h b/drivers/sensors/cirque_pinnacle.h index db891122a6..c8cb360e03 100644 --- a/drivers/sensors/cirque_pinnacle.h +++ b/drivers/sensors/cirque_pinnacle.h @@ -26,16 +26,16 @@ void cirque_pinnacle_set_scale(uint16_t scale); // Coordinate scaling values #ifndef CIRQUE_PINNACLE_X_LOWER -# define CIRQUE_PINNACLE_X_LOWER 127 // min "reachable" X value +# define CIRQUE_PINNACLE_X_LOWER 127 // min "reachable" X value #endif #ifndef CIRQUE_PINNACLE_X_UPPER -# define CIRQUE_PINNACLE_X_UPPER 1919 // max "reachable" X value +# define CIRQUE_PINNACLE_X_UPPER 1919 // max "reachable" X value #endif #ifndef CIRQUE_PINNACLE_Y_LOWER -# define CIRQUE_PINNACLE_Y_LOWER 63 // min "reachable" Y value +# define CIRQUE_PINNACLE_Y_LOWER 63 // min "reachable" Y value #endif #ifndef CIRQUE_PINNACLE_Y_UPPER -# define CIRQUE_PINNACLE_Y_UPPER 1471 // max "reachable" Y value +# define CIRQUE_PINNACLE_Y_UPPER 1471 // max "reachable" Y value #endif #ifndef CIRQUE_PINNACLE_X_RANGE # define CIRQUE_PINNACLE_X_RANGE (CIRQUE_PINNACLE_X_UPPER - CIRQUE_PINNACLE_X_LOWER) diff --git a/drivers/sensors/cirque_pinnacle_i2c.c b/drivers/sensors/cirque_pinnacle_i2c.c index 81dd982b0c..8a38f1dcea 100644 --- a/drivers/sensors/cirque_pinnacle_i2c.c +++ b/drivers/sensors/cirque_pinnacle_i2c.c @@ -14,7 +14,7 @@ extern bool touchpad_init; /* 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 + uint8_t cmdByte = READ_MASK | address; // Form the READ command byte if (touchpad_init) { i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, NULL, 0, CIRQUE_PINNACLE_TIMEOUT); if (i2c_readReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, data, count, CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) { @@ -29,7 +29,7 @@ void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) { // Writes single-byte <data> to <address> void RAP_Write(uint8_t address, uint8_t data) { - uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte + uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte if (touchpad_init) { if (i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, &data, sizeof(data), CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) { diff --git a/drivers/sensors/cirque_pinnacle_spi.c b/drivers/sensors/cirque_pinnacle_spi.c index ed40abd9fa..e00e73eb8c 100644 --- a/drivers/sensors/cirque_pinnacle_spi.c +++ b/drivers/sensors/cirque_pinnacle_spi.c @@ -13,14 +13,14 @@ extern bool touchpad_init; /* 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 + 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)) { spi_write(cmdByte); - spi_read(); // filler - spi_read(); // filler + spi_read(); // filler + spi_read(); // filler for (uint8_t i = 0; i < count; i++) { - data[i] = spi_read(); // each sepsequent read gets another register's contents + data[i] = spi_read(); // each sepsequent read gets another register's contents } } else { #ifdef CONSOLE_ENABLE @@ -34,7 +34,7 @@ void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) { // Writes single-byte <data> to <address> void RAP_Write(uint8_t address, uint8_t data) { - uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte + 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)) { diff --git a/drivers/sensors/pimoroni_trackball.c b/drivers/sensors/pimoroni_trackball.c index 2867e763bc..333e017a06 100644 --- a/drivers/sensors/pimoroni_trackball.c +++ b/drivers/sensors/pimoroni_trackball.c @@ -33,7 +33,9 @@ static uint16_t precision = 128; -uint16_t pimoroni_trackball_get_cpi(void) { return (precision * 125); } +uint16_t pimoroni_trackball_get_cpi(void) { + return (precision * 125); +} /** * @brief Sets the scaling value for pimoroni trackball * diff --git a/drivers/sensors/pmw3360.c b/drivers/sensors/pmw3360.c index 8d1b08e22b..8c977be1c8 100644 --- a/drivers/sensors/pmw3360.c +++ b/drivers/sensors/pmw3360.c @@ -86,7 +86,9 @@ bool _inBurst = false; #ifdef CONSOLE_ENABLE -void print_byte(uint8_t byte) { dprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); } +void print_byte(uint8_t byte) { + dprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); +} #endif #define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt))) @@ -144,7 +146,7 @@ bool pmw3360_init(void) { pmw3360_spi_start(); spi_stop(); - pmw3360_write(REG_Shutdown, 0xb6); // Shutdown first + pmw3360_write(REG_Shutdown, 0xb6); // Shutdown first wait_ms(300); pmw3360_spi_start(); @@ -222,7 +224,7 @@ bool pmw3360_check_signature(void) { uint8_t pid = pmw3360_read(REG_Product_ID); uint8_t iv_pid = pmw3360_read(REG_Inverse_Product_ID); uint8_t SROM_ver = pmw3360_read(REG_SROM_ID); - return (pid == firmware_signature[0] && iv_pid == firmware_signature[1] && SROM_ver == firmware_signature[2]); // signature for SROM 0x04 + return (pid == firmware_signature[0] && iv_pid == firmware_signature[1] && SROM_ver == firmware_signature[2]); // signature for SROM 0x04 } uint16_t pmw3360_get_cpi(void) { @@ -248,17 +250,17 @@ report_pmw3360_t pmw3360_read_burst(void) { pmw3360_spi_start(); spi_write(REG_Motion_Burst); - wait_us(35); // waits for tSRAD_MOTBR + wait_us(35); // waits for tSRAD_MOTBR report.motion = spi_read(); - spi_read(); // skip Observation + spi_read(); // skip Observation // delta registers report.dx = spi_read(); report.mdx = spi_read(); report.dy = spi_read(); report.mdy = spi_read(); - if (report.motion & 0b111) { // panic recovery, sometimes burst mode works weird. + if (report.motion & 0b111) { // panic recovery, sometimes burst mode works weird. _inBurst = false; } diff --git a/drivers/sensors/pmw3360.h b/drivers/sensors/pmw3360.h index 4e17aa0c46..eec7295871 100644 --- a/drivers/sensors/pmw3360.h +++ b/drivers/sensors/pmw3360.h @@ -58,11 +58,11 @@ typedef struct { int8_t motion; - bool isMotion; // True if a motion is detected. - bool isOnSurface; // True when a chip is on a surface - int16_t dx; // displacement on x directions. Unit: Count. (CPI * Count = Inch value) + bool isMotion; // True if a motion is detected. + bool isOnSurface; // True when a chip is on a surface + int16_t dx; // displacement on x directions. Unit: Count. (CPI * Count = Inch value) int8_t mdx; - int16_t dy; // displacement on y directions. + int16_t dy; // displacement on y directions. int8_t mdy; } report_pmw3360_t; diff --git a/drivers/sensors/pmw3389.c b/drivers/sensors/pmw3389.c index 963925bd38..828dafa134 100644 --- a/drivers/sensors/pmw3389.c +++ b/drivers/sensors/pmw3389.c @@ -90,7 +90,9 @@ bool _inBurst = false; #ifdef CONSOLE_ENABLE -void print_byte(uint8_t byte) { dprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); } +void print_byte(uint8_t byte) { + dprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); +} #endif #define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt))) @@ -148,7 +150,7 @@ bool pmw3389_init(void) { pmw3389_spi_start(); spi_stop(); - pmw3389_write(REG_Shutdown, 0xb6); // Shutdown first + pmw3389_write(REG_Shutdown, 0xb6); // Shutdown first wait_ms(300); pmw3389_spi_start(); @@ -226,7 +228,7 @@ bool pmw3389_check_signature(void) { uint8_t pid = pmw3389_read(REG_Product_ID); uint8_t iv_pid = pmw3389_read(REG_Inverse_Product_ID); uint8_t SROM_ver = pmw3389_read(REG_SROM_ID); - return (pid == firmware_signature[0] && iv_pid == firmware_signature[1] && SROM_ver == firmware_signature[2]); // signature for SROM 0x04 + return (pid == firmware_signature[0] && iv_pid == firmware_signature[1] && SROM_ver == firmware_signature[2]); // signature for SROM 0x04 } uint16_t pmw3389_get_cpi(void) { @@ -254,17 +256,17 @@ report_pmw3389_t pmw3389_read_burst(void) { pmw3389_spi_start(); spi_write(REG_Motion_Burst); - wait_us(35); // waits for tSRAD_MOTBR + wait_us(35); // waits for tSRAD_MOTBR report.motion = spi_read(); - spi_read(); // skip Observation + spi_read(); // skip Observation // delta registers report.dx = spi_read(); report.mdx = spi_read(); report.dy = spi_read(); report.mdy = spi_read(); - if (report.motion & 0b111) { // panic recovery, sometimes burst mode works weird. + if (report.motion & 0b111) { // panic recovery, sometimes burst mode works weird. _inBurst = false; } diff --git a/drivers/sensors/pmw3389.h b/drivers/sensors/pmw3389.h index a7c95e6076..db4a763fe3 100644 --- a/drivers/sensors/pmw3389.h +++ b/drivers/sensors/pmw3389.h @@ -59,11 +59,11 @@ typedef struct { int8_t motion; - bool isMotion; // True if a motion is detected. - bool isOnSurface; // True when a chip is on a surface - int16_t dx; // displacement on x directions. Unit: Count. (CPI * Count = Inch value) + bool isMotion; // True if a motion is detected. + bool isOnSurface; // True when a chip is on a surface + int16_t dx; // displacement on x directions. Unit: Count. (CPI * Count = Inch value) int8_t mdx; - int16_t dy; // displacement on y directions. + int16_t dy; // displacement on y directions. int8_t mdy; } report_pmw3389_t; |