summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2022-02-12 10:29:31 -0800
committerGitHub <noreply@github.com>2022-02-12 18:29:31 +0000
commit63646e8906e062d1c1de3925cba70c4e3426a855 (patch)
tree4e91648b77b838e1125cf86331d7e84bde6d07a9 /drivers
parentafcdd7079c774dec2aa4b7f2d08adf8b7310919b (diff)
Format code according to conventions (#16322)
Diffstat (limited to 'drivers')
-rw-r--r--drivers/bluetooth/bluefruit_le.cpp26
-rw-r--r--drivers/bluetooth/outputselect.c2
-rw-r--r--drivers/bluetooth/rn42.c8
-rw-r--r--drivers/eeprom/eeprom_driver.c12
-rw-r--r--drivers/eeprom/eeprom_i2c.c6
-rw-r--r--drivers/eeprom/eeprom_spi.c12
-rw-r--r--drivers/eeprom/eeprom_transient.c8
-rw-r--r--drivers/eeprom/eeprom_transient.h2
-rw-r--r--drivers/flash/flash_spi.c12
-rw-r--r--drivers/gpio/mcp23018.c6
-rw-r--r--drivers/haptic/DRV2605L.c6
-rw-r--r--drivers/haptic/solenoid.c20
-rw-r--r--drivers/lcd/st7565.c25
-rw-r--r--drivers/lcd/st7565.h8
-rw-r--r--drivers/led/apa102.c10
-rw-r--r--drivers/led/aw20216.c14
-rw-r--r--drivers/led/issi/is31fl3731-simple.c6
-rw-r--r--drivers/led/issi/is31fl3731.c6
-rw-r--r--drivers/led/issi/is31fl3733-simple.c20
-rw-r--r--drivers/led/issi/is31fl3733-simple.h14
-rw-r--r--drivers/led/issi/is31fl3733.c20
-rw-r--r--drivers/led/issi/is31fl3733.h14
-rw-r--r--drivers/led/issi/is31fl3736.c20
-rw-r--r--drivers/led/issi/is31fl3736.h16
-rw-r--r--drivers/led/issi/is31fl3737.c20
-rw-r--r--drivers/led/issi/is31fl3737.h16
-rw-r--r--drivers/led/issi/is31fl3741.c20
-rw-r--r--drivers/led/issi/is31fl3741.h16
-rw-r--r--drivers/oled/oled_driver.h22
-rw-r--r--drivers/oled/ssd1306_sh1106.c49
-rw-r--r--drivers/ps2/ps2_busywait.c6
-rw-r--r--drivers/ps2/ps2_interrupt.c16
-rw-r--r--drivers/ps2/ps2_mouse.c28
-rw-r--r--drivers/sensors/adns5050.c10
-rw-r--r--drivers/sensors/adns9800.c4
-rw-r--r--drivers/sensors/analog_joystick.c2
-rw-r--r--drivers/sensors/cirque_pinnacle.c38
-rw-r--r--drivers/sensors/cirque_pinnacle.h8
-rw-r--r--drivers/sensors/cirque_pinnacle_i2c.c4
-rw-r--r--drivers/sensors/cirque_pinnacle_spi.c10
-rw-r--r--drivers/sensors/pimoroni_trackball.c4
-rw-r--r--drivers/sensors/pmw3360.c14
-rw-r--r--drivers/sensors/pmw3360.h8
-rw-r--r--drivers/sensors/pmw3389.c14
-rw-r--r--drivers/sensors/pmw3389.h8
-rw-r--r--drivers/usb2422.c14
-rw-r--r--drivers/ws2812.h8
47 files changed, 365 insertions, 267 deletions
diff --git a/drivers/bluetooth/bluefruit_le.cpp b/drivers/bluetooth/bluefruit_le.cpp
index 86581a1a48..19310767cf 100644
--- a/drivers/bluetooth/bluefruit_le.cpp
+++ b/drivers/bluetooth/bluefruit_le.cpp
@@ -29,7 +29,7 @@
29#endif 29#endif
30 30
31#ifndef BLUEFRUIT_LE_SCK_DIVISOR 31#ifndef BLUEFRUIT_LE_SCK_DIVISOR
32# define BLUEFRUIT_LE_SCK_DIVISOR 2 // 4MHz SCK/8MHz CPU, calculated for Feather 32U4 BLE 32# define BLUEFRUIT_LE_SCK_DIVISOR 2 // 4MHz SCK/8MHz CPU, calculated for Feather 32U4 BLE
33#endif 33#endif
34 34
35#define SAMPLE_BATTERY 35#define SAMPLE_BATTERY
@@ -77,10 +77,10 @@ struct sdep_msg {
77// information here. 77// information here.
78 78
79enum queue_type { 79enum queue_type {
80 QTKeyReport, // 1-byte modifier + 6-byte key report 80 QTKeyReport, // 1-byte modifier + 6-byte key report
81 QTConsumer, // 16-bit key code 81 QTConsumer, // 16-bit key code
82#ifdef MOUSE_ENABLE 82#ifdef MOUSE_ENABLE
83 QTMouseMove, // 4-byte mouse report 83 QTMouseMove, // 4-byte mouse report
84#endif 84#endif
85}; 85};
86 86
@@ -115,8 +115,8 @@ enum sdep_type {
115 SdepResponse = 0x20, 115 SdepResponse = 0x20,
116 SdepAlert = 0x40, 116 SdepAlert = 0x40,
117 SdepError = 0x80, 117 SdepError = 0x80,
118 SdepSlaveNotReady = 0xFE, // Try again later 118 SdepSlaveNotReady = 0xFE, // Try again later
119 SdepSlaveOverflow = 0xFF, // You read more data than is available 119 SdepSlaveOverflow = 0xFF, // You read more data than is available
120}; 120};
121 121
122enum ble_cmd { 122enum ble_cmd {
@@ -306,13 +306,15 @@ static bool ble_init(void) {
306 wait_ms(10); 306 wait_ms(10);
307 writePinHigh(BLUEFRUIT_LE_RST_PIN); 307 writePinHigh(BLUEFRUIT_LE_RST_PIN);
308 308
309 wait_ms(1000); // Give it a second to initialize 309 wait_ms(1000); // Give it a second to initialize
310 310
311 state.initialized = true; 311 state.initialized = true;
312 return state.initialized; 312 return state.initialized;
313} 313}
314 314
315static inline uint8_t min(uint8_t a, uint8_t b) { return a < b ? a : b; } 315static inline uint8_t min(uint8_t a, uint8_t b) {
316 return a < b ? a : b;
317}
316 318
317static bool read_response(char *resp, uint16_t resplen, bool verbose) { 319static bool read_response(char *resp, uint16_t resplen, bool verbose) {
318 char *dest = resp; 320 char *dest = resp;
@@ -424,7 +426,9 @@ bool at_command_P(const char *cmd, char *resp, uint16_t resplen, bool verbose) {
424 return at_command(cmdbuf, resp, resplen, verbose); 426 return at_command(cmdbuf, resp, resplen, verbose);
425} 427}
426 428
427bool bluefruit_le_is_connected(void) { return state.is_connected; } 429bool bluefruit_le_is_connected(void) {
430 return state.is_connected;
431}
428 432
429bool bluefruit_le_enable_keyboard(void) { 433bool bluefruit_le_enable_keyboard(void) {
430 char resbuf[128]; 434 char resbuf[128];
@@ -671,7 +675,9 @@ void bluefruit_le_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan,
671} 675}
672#endif 676#endif
673 677
674uint32_t bluefruit_le_read_battery_voltage(void) { return state.vbat; } 678uint32_t bluefruit_le_read_battery_voltage(void) {
679 return state.vbat;
680}
675 681
676bool bluefruit_le_set_mode_leds(bool on) { 682bool bluefruit_le_set_mode_leds(bool on) {
677 if (!state.configured) { 683 if (!state.configured) {
diff --git a/drivers/bluetooth/outputselect.c b/drivers/bluetooth/outputselect.c
index 44bc4a9aa3..b986ba274e 100644
--- a/drivers/bluetooth/outputselect.c
+++ b/drivers/bluetooth/outputselect.c
@@ -52,7 +52,7 @@ uint8_t auto_detect_output(void) {
52#endif 52#endif
53 53
54#ifdef BLUETOOTH_ENABLE 54#ifdef BLUETOOTH_ENABLE
55 return OUTPUT_BLUETOOTH; // should check if BT is connected here 55 return OUTPUT_BLUETOOTH; // should check if BT is connected here
56#endif 56#endif
57 57
58 return OUTPUT_NONE; 58 return OUTPUT_NONE;
diff --git a/drivers/bluetooth/rn42.c b/drivers/bluetooth/rn42.c
index 2ef40bb7e0..5d497cda20 100644
--- a/drivers/bluetooth/rn42.c
+++ b/drivers/bluetooth/rn42.c
@@ -61,7 +61,9 @@ static inline uint16_t rn42_consumer_usage_to_bitmap(uint16_t usage) {
61 } 61 }
62} 62}
63 63
64void rn42_init(void) { uart_init(RN42_BAUD_RATE); } 64void rn42_init(void) {
65 uart_init(RN42_BAUD_RATE);
66}
65 67
66void rn42_send_keyboard(report_keyboard_t *report) { 68void rn42_send_keyboard(report_keyboard_t *report) {
67 uart_write(0xFD); 69 uart_write(0xFD);
@@ -81,8 +83,8 @@ void rn42_send_mouse(report_mouse_t *report) {
81 uart_write(report->buttons); 83 uart_write(report->buttons);
82 uart_write(report->x); 84 uart_write(report->x);
83 uart_write(report->y); 85 uart_write(report->y);
84 uart_write(report->v); // should try sending the wheel v here 86 uart_write(report->v); // should try sending the wheel v here
85 uart_write(report->h); // should try sending the wheel h here 87 uart_write(report->h); // should try sending the wheel h here
86 uart_write(0x00); 88 uart_write(0x00);
87} 89}
88 90
diff --git a/drivers/eeprom/eeprom_driver.c b/drivers/eeprom/eeprom_driver.c
index 6ce47faf7d..885cf21981 100644
--- a/drivers/eeprom/eeprom_driver.c
+++ b/drivers/eeprom/eeprom_driver.c
@@ -37,11 +37,17 @@ uint32_t eeprom_read_dword(const uint32_t *addr) {
37 return ret; 37 return ret;
38} 38}
39 39
40void eeprom_write_byte(uint8_t *addr, uint8_t value) { eeprom_write_block(&value, addr, 1); } 40void eeprom_write_byte(uint8_t *addr, uint8_t value) {
41 eeprom_write_block(&value, addr, 1);
42}
41 43
42void eeprom_write_word(uint16_t *addr, uint16_t value) { eeprom_write_block(&value, addr, 2); } 44void eeprom_write_word(uint16_t *addr, uint16_t value) {
45 eeprom_write_block(&value, addr, 2);
46}
43 47
44void eeprom_write_dword(uint32_t *addr, uint32_t value) { eeprom_write_block(&value, addr, 4); } 48void eeprom_write_dword(uint32_t *addr, uint32_t value) {
49 eeprom_write_block(&value, addr, 4);
50}
45 51
46void eeprom_update_block(const void *buf, void *addr, size_t len) { 52void eeprom_update_block(const void *buf, void *addr, size_t len) {
47 uint8_t read_buf[len]; 53 uint8_t read_buf[len];
diff --git a/drivers/eeprom/eeprom_i2c.c b/drivers/eeprom/eeprom_i2c.c
index 8e80ff544f..a74a010415 100644
--- a/drivers/eeprom/eeprom_i2c.c
+++ b/drivers/eeprom/eeprom_i2c.c
@@ -43,7 +43,7 @@
43#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) 43#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT)
44# include "timer.h" 44# include "timer.h"
45# include "debug.h" 45# include "debug.h"
46#endif // DEBUG_EEPROM_OUTPUT 46#endif // DEBUG_EEPROM_OUTPUT
47 47
48static inline void fill_target_address(uint8_t *buffer, const void *addr) { 48static inline void fill_target_address(uint8_t *buffer, const void *addr) {
49 uintptr_t p = (uintptr_t)addr; 49 uintptr_t p = (uintptr_t)addr;
@@ -91,7 +91,7 @@ void eeprom_read_block(void *buf, const void *addr, size_t len) {
91 dprintf(" %02X", (int)(((uint8_t *)buf)[i])); 91 dprintf(" %02X", (int)(((uint8_t *)buf)[i]));
92 } 92 }
93 dprintf("\n"); 93 dprintf("\n");
94#endif // DEBUG_EEPROM_OUTPUT 94#endif // DEBUG_EEPROM_OUTPUT
95} 95}
96 96
97void eeprom_write_block(const void *buf, void *addr, size_t len) { 97void eeprom_write_block(const void *buf, void *addr, size_t len) {
@@ -122,7 +122,7 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) {
122 dprintf(" %02X", (int)(read_buf[i])); 122 dprintf(" %02X", (int)(read_buf[i]));
123 } 123 }
124 dprintf("\n"); 124 dprintf("\n");
125#endif // DEBUG_EEPROM_OUTPUT 125#endif // DEBUG_EEPROM_OUTPUT
126 126
127 i2c_transmit(EXTERNAL_EEPROM_I2C_ADDRESS((uintptr_t)addr), complete_packet, EXTERNAL_EEPROM_ADDRESS_SIZE + write_length, 100); 127 i2c_transmit(EXTERNAL_EEPROM_I2C_ADDRESS((uintptr_t)addr), complete_packet, EXTERNAL_EEPROM_ADDRESS_SIZE + write_length, 100);
128 wait_ms(EXTERNAL_EEPROM_WRITE_TIME); 128 wait_ms(EXTERNAL_EEPROM_WRITE_TIME);
diff --git a/drivers/eeprom/eeprom_spi.c b/drivers/eeprom/eeprom_spi.c
index e273090854..25955498c4 100644
--- a/drivers/eeprom/eeprom_spi.c
+++ b/drivers/eeprom/eeprom_spi.c
@@ -52,7 +52,9 @@
52# define EXTERNAL_EEPROM_SPI_TIMEOUT 100 52# define EXTERNAL_EEPROM_SPI_TIMEOUT 100
53#endif 53#endif
54 54
55static bool spi_eeprom_start(void) { return spi_start(EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN, EXTERNAL_EEPROM_SPI_LSBFIRST, EXTERNAL_EEPROM_SPI_MODE, EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR); } 55static bool spi_eeprom_start(void) {
56 return spi_start(EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN, EXTERNAL_EEPROM_SPI_LSBFIRST, EXTERNAL_EEPROM_SPI_MODE, EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR);
57}
56 58
57static spi_status_t spi_eeprom_wait_while_busy(int timeout) { 59static spi_status_t spi_eeprom_wait_while_busy(int timeout) {
58 uint32_t deadline = timer_read32() + timeout; 60 uint32_t deadline = timer_read32() + timeout;
@@ -80,7 +82,9 @@ static void spi_eeprom_transmit_address(uintptr_t addr) {
80 82
81//---------------------------------------------------------------------------------------------------------------------- 83//----------------------------------------------------------------------------------------------------------------------
82 84
83void eeprom_driver_init(void) { spi_init(); } 85void eeprom_driver_init(void) {
86 spi_init();
87}
84 88
85void eeprom_driver_erase(void) { 89void eeprom_driver_erase(void) {
86#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) 90#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT)
@@ -135,7 +139,7 @@ void eeprom_read_block(void *buf, const void *addr, size_t len) {
135 dprintf(" %02X", (int)(((uint8_t *)buf)[i])); 139 dprintf(" %02X", (int)(((uint8_t *)buf)[i]));
136 } 140 }
137 dprintf("\n"); 141 dprintf("\n");
138#endif // DEBUG_EEPROM_OUTPUT 142#endif // DEBUG_EEPROM_OUTPUT
139 143
140 spi_stop(); 144 spi_stop();
141} 145}
@@ -192,7 +196,7 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) {
192 dprintf(" %02X", (int)(uint8_t)(read_buf[i])); 196 dprintf(" %02X", (int)(uint8_t)(read_buf[i]));
193 } 197 }
194 dprintf("\n"); 198 dprintf("\n");
195#endif // DEBUG_EEPROM_OUTPUT 199#endif // DEBUG_EEPROM_OUTPUT
196 200
197 spi_write(CMD_WRITE); 201 spi_write(CMD_WRITE);
198 spi_eeprom_transmit_address(target_addr); 202 spi_eeprom_transmit_address(target_addr);
diff --git a/drivers/eeprom/eeprom_transient.c b/drivers/eeprom/eeprom_transient.c
index b4c78c6f40..9dc4289c27 100644
--- a/drivers/eeprom/eeprom_transient.c
+++ b/drivers/eeprom/eeprom_transient.c
@@ -30,9 +30,13 @@ size_t clamp_length(intptr_t offset, size_t len) {
30 return len; 30 return len;
31} 31}
32 32
33void eeprom_driver_init(void) { eeprom_driver_erase(); } 33void eeprom_driver_init(void) {
34 eeprom_driver_erase();
35}
34 36
35void eeprom_driver_erase(void) { memset(transientBuffer, 0x00, TRANSIENT_EEPROM_SIZE); } 37void eeprom_driver_erase(void) {
38 memset(transientBuffer, 0x00, TRANSIENT_EEPROM_SIZE);
39}
36 40
37void eeprom_read_block(void *buf, const void *addr, size_t len) { 41void eeprom_read_block(void *buf, const void *addr, size_t len) {
38 intptr_t offset = (intptr_t)addr; 42 intptr_t offset = (intptr_t)addr;
diff --git a/drivers/eeprom/eeprom_transient.h b/drivers/eeprom/eeprom_transient.h
index d06189b246..687b8619fe 100644
--- a/drivers/eeprom/eeprom_transient.h
+++ b/drivers/eeprom/eeprom_transient.h
@@ -21,5 +21,5 @@
21*/ 21*/
22#ifndef TRANSIENT_EEPROM_SIZE 22#ifndef TRANSIENT_EEPROM_SIZE
23# include "eeconfig.h" 23# include "eeconfig.h"
24# define TRANSIENT_EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO 24# define TRANSIENT_EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO
25#endif 25#endif
diff --git a/drivers/flash/flash_spi.c b/drivers/flash/flash_spi.c
index 2fa8891e38..f4cbf65159 100644
--- a/drivers/flash/flash_spi.c
+++ b/drivers/flash/flash_spi.c
@@ -65,7 +65,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
65 65
66// #define DEBUG_FLASH_SPI_OUTPUT 66// #define DEBUG_FLASH_SPI_OUTPUT
67 67
68static bool spi_flash_start(void) { return spi_start(EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN, EXTERNAL_FLASH_SPI_LSBFIRST, EXTERNAL_FLASH_SPI_MODE, EXTERNAL_FLASH_SPI_CLOCK_DIVISOR); } 68static bool spi_flash_start(void) {
69 return spi_start(EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN, EXTERNAL_FLASH_SPI_LSBFIRST, EXTERNAL_FLASH_SPI_MODE, EXTERNAL_FLASH_SPI_CLOCK_DIVISOR);
70}
69 71
70static flash_status_t spi_flash_wait_while_busy(void) { 72static flash_status_t spi_flash_wait_while_busy(void) {
71 uint32_t deadline = timer_read32() + EXTERNAL_FLASH_SPI_TIMEOUT; 73 uint32_t deadline = timer_read32() + EXTERNAL_FLASH_SPI_TIMEOUT;
@@ -160,7 +162,9 @@ static flash_status_t spi_flash_transaction(uint8_t cmd, uint32_t addr, uint8_t
160 return response; 162 return response;
161} 163}
162 164
163void flash_init(void) { spi_init(); } 165void flash_init(void) {
166 spi_init();
167}
164 168
165flash_status_t flash_erase_chip(void) { 169flash_status_t flash_erase_chip(void) {
166 flash_status_t response = FLASH_STATUS_SUCCESS; 170 flash_status_t response = FLASH_STATUS_SUCCESS;
@@ -304,7 +308,7 @@ flash_status_t flash_read_block(uint32_t addr, void *buf, size_t len) {
304 dprintf(" %02X", (int)(((uint8_t *)read_buf)[i])); 308 dprintf(" %02X", (int)(((uint8_t *)read_buf)[i]));
305 } 309 }
306 dprintf("\n"); 310 dprintf("\n");
307#endif // DEBUG_FLASH_SPI_OUTPUT 311#endif // DEBUG_FLASH_SPI_OUTPUT
308 312
309 return response; 313 return response;
310} 314}
@@ -340,7 +344,7 @@ flash_status_t flash_write_block(uint32_t addr, const void *buf, size_t len) {
340 dprintf(" %02X", (int)(uint8_t)(write_buf[i])); 344 dprintf(" %02X", (int)(uint8_t)(write_buf[i]));
341 } 345 }
342 dprintf("\n"); 346 dprintf("\n");
343#endif // DEBUG_FLASH_SPI_OUTPUT 347#endif // DEBUG_FLASH_SPI_OUTPUT
344 348
345 /* Perform the write. */ 349 /* Perform the write. */
346 response = spi_flash_transaction(FLASH_CMD_PP, addr, write_buf, write_length); 350 response = spi_flash_transaction(FLASH_CMD_PP, addr, write_buf, write_length);
diff --git a/drivers/gpio/mcp23018.c b/drivers/gpio/mcp23018.c
index dc8ab03c50..41cbfe087e 100644
--- a/drivers/gpio/mcp23018.c
+++ b/drivers/gpio/mcp23018.c
@@ -10,11 +10,11 @@
10#define TIMEOUT 100 10#define TIMEOUT 100
11 11
12enum { 12enum {
13 CMD_IODIRA = 0x00, // i/o direction register 13 CMD_IODIRA = 0x00, // i/o direction register
14 CMD_IODIRB = 0x01, 14 CMD_IODIRB = 0x01,
15 CMD_GPPUA = 0x0C, // GPIO pull-up resistor register 15 CMD_GPPUA = 0x0C, // GPIO pull-up resistor register
16 CMD_GPPUB = 0x0D, 16 CMD_GPPUB = 0x0D,
17 CMD_GPIOA = 0x12, // general purpose i/o port register (write modifies OLAT) 17 CMD_GPIOA = 0x12, // general purpose i/o port register (write modifies OLAT)
18 CMD_GPIOB = 0x13, 18 CMD_GPIOB = 0x13,
19}; 19};
20 20
diff --git a/drivers/haptic/DRV2605L.c b/drivers/haptic/DRV2605L.c
index 5de2b354c9..5a1d2ca0af 100644
--- a/drivers/haptic/DRV2605L.c
+++ b/drivers/haptic/DRV2605L.c
@@ -106,12 +106,14 @@ void DRV_init(void) {
106 106
107void DRV_rtp_init(void) { 107void DRV_rtp_init(void) {
108 DRV_write(DRV_GO, 0x00); 108 DRV_write(DRV_GO, 0x00);
109 DRV_write(DRV_RTP_INPUT, 20); // 20 is the lowest value I've found where haptics can still be felt. 109 DRV_write(DRV_RTP_INPUT, 20); // 20 is the lowest value I've found where haptics can still be felt.
110 DRV_write(DRV_MODE, 0x05); 110 DRV_write(DRV_MODE, 0x05);
111 DRV_write(DRV_GO, 0x01); 111 DRV_write(DRV_GO, 0x01);
112} 112}
113 113
114void DRV_amplitude(uint8_t amplitude) { DRV_write(DRV_RTP_INPUT, amplitude); } 114void DRV_amplitude(uint8_t amplitude) {
115 DRV_write(DRV_RTP_INPUT, amplitude);
116}
115 117
116void DRV_pulse(uint8_t sequence) { 118void DRV_pulse(uint8_t sequence) {
117 DRV_write(DRV_GO, 0x00); 119 DRV_write(DRV_GO, 0x00);
diff --git a/drivers/haptic/solenoid.c b/drivers/haptic/solenoid.c
index 7a09940f78..14d868bffe 100644
--- a/drivers/haptic/solenoid.c
+++ b/drivers/haptic/solenoid.c
@@ -28,13 +28,21 @@ uint8_t solenoid_dwell = SOLENOID_DEFAULT_DWELL;
28 28
29extern haptic_config_t haptic_config; 29extern haptic_config_t haptic_config;
30 30
31void solenoid_buzz_on(void) { haptic_set_buzz(1); } 31void solenoid_buzz_on(void) {
32 haptic_set_buzz(1);
33}
32 34
33void solenoid_buzz_off(void) { haptic_set_buzz(0); } 35void solenoid_buzz_off(void) {
36 haptic_set_buzz(0);
37}
34 38
35void solenoid_set_buzz(int buzz) { haptic_set_buzz(buzz); } 39void solenoid_set_buzz(int buzz) {
40 haptic_set_buzz(buzz);
41}
36 42
37void solenoid_set_dwell(uint8_t dwell) { solenoid_dwell = dwell; } 43void solenoid_set_dwell(uint8_t dwell) {
44 solenoid_dwell = dwell;
45}
38 46
39void solenoid_stop(void) { 47void solenoid_stop(void) {
40 SOLENOID_PIN_WRITE_INACTIVE(); 48 SOLENOID_PIN_WRITE_INACTIVE();
@@ -89,4 +97,6 @@ void solenoid_setup(void) {
89 } 97 }
90} 98}
91 99
92void solenoid_shutdown(void) { SOLENOID_PIN_WRITE_INACTIVE(); } 100void solenoid_shutdown(void) {
101 SOLENOID_PIN_WRITE_INACTIVE();
102}
diff --git a/drivers/lcd/st7565.c b/drivers/lcd/st7565.c
index 49b13c00f1..47ee02804b 100644
--- a/drivers/lcd/st7565.c
+++ b/drivers/lcd/st7565.c
@@ -39,7 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
39// Addressing Setting Commands 39// Addressing Setting Commands
40#define PAM_SETCOLUMN_LSB 0x00 40#define PAM_SETCOLUMN_LSB 0x00
41#define PAM_SETCOLUMN_MSB 0x10 41#define PAM_SETCOLUMN_MSB 0x10
42#define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7 42#define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7
43 43
44// Hardware Configuration Commands 44// Hardware Configuration Commands
45#define DISPLAY_START_LINE 0x40 45#define DISPLAY_START_LINE 0x40
@@ -138,7 +138,9 @@ bool st7565_init(display_rotation_t rotation) {
138 return true; 138 return true;
139} 139}
140 140
141__attribute__((weak)) display_rotation_t st7565_init_user(display_rotation_t rotation) { return rotation; } 141__attribute__((weak)) display_rotation_t st7565_init_user(display_rotation_t rotation) {
142 return rotation;
143}
142 144
143void st7565_clear(void) { 145void st7565_clear(void) {
144 memset(st7565_buffer, 0, sizeof(st7565_buffer)); 146 memset(st7565_buffer, 0, sizeof(st7565_buffer));
@@ -212,7 +214,8 @@ void st7565_advance_page(bool clearPageRemainder) {
212 remaining = remaining / ST7565_FONT_WIDTH; 214 remaining = remaining / ST7565_FONT_WIDTH;
213 215
214 // Write empty character until next line 216 // Write empty character until next line
215 while (remaining--) st7565_write_char(' ', false); 217 while (remaining--)
218 st7565_write_char(' ', false);
216 } else { 219 } else {
217 // Next page index out of bounds? 220 // Next page index out of bounds?
218 if (index + remaining >= ST7565_MATRIX_SIZE) { 221 if (index + remaining >= ST7565_MATRIX_SIZE) {
@@ -263,7 +266,7 @@ void st7565_write_char(const char data, bool invert) {
263 _Static_assert(sizeof(font) >= ((ST7565_FONT_END + 1 - ST7565_FONT_START) * ST7565_FONT_WIDTH), "ST7565_FONT_END references outside array"); 266 _Static_assert(sizeof(font) >= ((ST7565_FONT_END + 1 - ST7565_FONT_START) * ST7565_FONT_WIDTH), "ST7565_FONT_END references outside array");
264 267
265 // set the reder buffer data 268 // set the reder buffer data
266 uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index 269 uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index
267 if (cast_data < ST7565_FONT_START || cast_data > ST7565_FONT_END) { 270 if (cast_data < ST7565_FONT_START || cast_data > ST7565_FONT_END) {
268 memset(st7565_cursor, 0x00, ST7565_FONT_WIDTH); 271 memset(st7565_cursor, 0x00, ST7565_FONT_WIDTH);
269 } else { 272 } else {
@@ -389,7 +392,7 @@ void st7565_write_raw_P(const char *data, uint16_t size) {
389 st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << (i / ST7565_BLOCK_SIZE)); 392 st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << (i / ST7565_BLOCK_SIZE));
390 } 393 }
391} 394}
392#endif // defined(__AVR__) 395#endif // defined(__AVR__)
393 396
394bool st7565_on(void) { 397bool st7565_on(void) {
395 if (!st7565_initialized) { 398 if (!st7565_initialized) {
@@ -429,7 +432,9 @@ bool st7565_off(void) {
429 432
430__attribute__((weak)) void st7565_off_user(void) {} 433__attribute__((weak)) void st7565_off_user(void) {}
431 434
432bool st7565_is_on(void) { return st7565_active; } 435bool st7565_is_on(void) {
436 return st7565_active;
437}
433 438
434bool st7565_invert(bool invert) { 439bool st7565_invert(bool invert) {
435 if (!st7565_initialized) { 440 if (!st7565_initialized) {
@@ -445,9 +450,13 @@ bool st7565_invert(bool invert) {
445 return st7565_inverted; 450 return st7565_inverted;
446} 451}
447 452
448uint8_t st7565_max_chars(void) { return ST7565_DISPLAY_WIDTH / ST7565_FONT_WIDTH; } 453uint8_t st7565_max_chars(void) {
454 return ST7565_DISPLAY_WIDTH / ST7565_FONT_WIDTH;
455}
449 456
450uint8_t st7565_max_lines(void) { return ST7565_DISPLAY_HEIGHT / ST7565_FONT_HEIGHT; } 457uint8_t st7565_max_lines(void) {
458 return ST7565_DISPLAY_HEIGHT / ST7565_FONT_HEIGHT;
459}
451 460
452void st7565_task(void) { 461void st7565_task(void) {
453 if (!st7565_initialized) { 462 if (!st7565_initialized) {
diff --git a/drivers/lcd/st7565.h b/drivers/lcd/st7565.h
index d453dbe6da..0e42c8765b 100644
--- a/drivers/lcd/st7565.h
+++ b/drivers/lcd/st7565.h
@@ -29,16 +29,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
29# define ST7565_DISPLAY_HEIGHT 32 29# define ST7565_DISPLAY_HEIGHT 32
30#endif 30#endif
31#ifndef ST7565_MATRIX_SIZE 31#ifndef ST7565_MATRIX_SIZE
32# define ST7565_MATRIX_SIZE (ST7565_DISPLAY_HEIGHT / 8 * ST7565_DISPLAY_WIDTH) // 1024 (compile time mathed) 32# define ST7565_MATRIX_SIZE (ST7565_DISPLAY_HEIGHT / 8 * ST7565_DISPLAY_WIDTH) // 1024 (compile time mathed)
33#endif 33#endif
34#ifndef ST7565_BLOCK_TYPE 34#ifndef ST7565_BLOCK_TYPE
35# define ST7565_BLOCK_TYPE uint16_t 35# define ST7565_BLOCK_TYPE uint16_t
36#endif 36#endif
37#ifndef ST7565_BLOCK_COUNT 37#ifndef ST7565_BLOCK_COUNT
38# define ST7565_BLOCK_COUNT (sizeof(ST7565_BLOCK_TYPE) * 8) // 32 (compile time mathed) 38# define ST7565_BLOCK_COUNT (sizeof(ST7565_BLOCK_TYPE) * 8) // 32 (compile time mathed)
39#endif 39#endif
40#ifndef ST7565_BLOCK_SIZE 40#ifndef ST7565_BLOCK_SIZE
41# define ST7565_BLOCK_SIZE (ST7565_MATRIX_SIZE / ST7565_BLOCK_COUNT) // 32 (compile time mathed) 41# define ST7565_BLOCK_SIZE (ST7565_MATRIX_SIZE / ST7565_BLOCK_COUNT) // 32 (compile time mathed)
42#endif 42#endif
43 43
44// the column address corresponding to the first column in the display hardware 44// the column address corresponding to the first column in the display hardware
@@ -174,7 +174,7 @@ void st7565_write_raw_P(const char *data, uint16_t size);
174# define st7565_write_P(data, invert) st7565_write(data, invert) 174# define st7565_write_P(data, invert) st7565_write(data, invert)
175# define st7565_write_ln_P(data, invert) st7565_write_ln(data, invert) 175# define st7565_write_ln_P(data, invert) st7565_write_ln(data, invert)
176# define st7565_write_raw_P(data, size) st7565_write_raw(data, size) 176# define st7565_write_raw_P(data, size) st7565_write_raw(data, size)
177#endif // defined(__AVR__) 177#endif // defined(__AVR__)
178 178
179// Can be used to manually turn on the screen if it is off 179// Can be used to manually turn on the screen if it is off
180// Returns true if the screen was on or turns on 180// Returns true if the screen was on or turns on
diff --git a/drivers/led/apa102.c b/drivers/led/apa102.c
index 00e7eb4505..f291948975 100644
--- a/drivers/led/apa102.c
+++ b/drivers/led/apa102.c
@@ -20,15 +20,15 @@
20 20
21#ifndef APA102_NOPS 21#ifndef APA102_NOPS
22# if defined(__AVR__) 22# if defined(__AVR__)
23# define APA102_NOPS 0 // AVR at 16 MHz already spends 62.5 ns per clock, so no extra delay is needed 23# define APA102_NOPS 0 // AVR at 16 MHz already spends 62.5 ns per clock, so no extra delay is needed
24# elif defined(PROTOCOL_CHIBIOS) 24# elif defined(PROTOCOL_CHIBIOS)
25 25
26# include "hal.h" 26# include "hal.h"
27# if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) || defined(GD32VF103) 27# if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) || defined(GD32VF103)
28# define APA102_NOPS (100 / (1000000000L / (CPU_CLOCK / 4))) // This calculates how many loops of 4 nops to run to delay 100 ns 28# define APA102_NOPS (100 / (1000000000L / (CPU_CLOCK / 4))) // This calculates how many loops of 4 nops to run to delay 100 ns
29# else 29# else
30# error("APA102_NOPS configuration required") 30# error("APA102_NOPS configuration required")
31# define APA102_NOPS 0 // this just pleases the compile so the above error is easier to spot 31# define APA102_NOPS 0 // this just pleases the compile so the above error is easier to spot
32# endif 32# endif
33# endif 33# endif
34#endif 34#endif
@@ -72,7 +72,9 @@ void apa102_setleds(LED_TYPE *start_led, uint16_t num_leds) {
72} 72}
73 73
74// Overwrite the default rgblight_call_driver to use apa102 driver 74// Overwrite the default rgblight_call_driver to use apa102 driver
75void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { apa102_setleds(start_led, num_leds); } 75void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) {
76 apa102_setleds(start_led, num_leds);
77}
76 78
77void static apa102_init(void) { 79void static apa102_init(void) {
78 setPinOutput(RGB_DI_PIN); 80 setPinOutput(RGB_DI_PIN);
diff --git a/drivers/led/aw20216.c b/drivers/led/aw20216.c
index 2c7ff8f088..59389cdcd6 100644
--- a/drivers/led/aw20216.c
+++ b/drivers/led/aw20216.c
@@ -23,17 +23,17 @@
23 */ 23 */
24#define AWINIC_ID 0b1010 << 4 24#define AWINIC_ID 0b1010 << 4
25 25
26#define AW_PAGE_FUNCTION 0x00 << 1 // PG0, Function registers 26#define AW_PAGE_FUNCTION 0x00 << 1 // PG0, Function registers
27#define AW_PAGE_PWM 0x01 << 1 // PG1, LED PWM control 27#define AW_PAGE_PWM 0x01 << 1 // PG1, LED PWM control
28#define AW_PAGE_SCALING 0x02 << 1 // PG2, LED current scaling control 28#define AW_PAGE_SCALING 0x02 << 1 // PG2, LED current scaling control
29#define AW_PAGE_PATCHOICE 0x03 << 1 // PG3, Pattern choice? 29#define AW_PAGE_PATCHOICE 0x03 << 1 // PG3, Pattern choice?
30#define AW_PAGE_PWMSCALING 0x04 << 1 // PG4, LED PWM + Scaling control? 30#define AW_PAGE_PWMSCALING 0x04 << 1 // PG4, LED PWM + Scaling control?
31 31
32#define AW_WRITE 0 32#define AW_WRITE 0
33#define AW_READ 1 33#define AW_READ 1
34 34
35#define AW_REG_CONFIGURATION 0x00 // PG0 35#define AW_REG_CONFIGURATION 0x00 // PG0
36#define AW_REG_GLOBALCURRENT 0x01 // PG0 36#define AW_REG_GLOBALCURRENT 0x01 // PG0
37 37
38// Default value of AW_REG_CONFIGURATION 38// Default value of AW_REG_CONFIGURATION
39// D7:D4 = 1011, SWSEL (SW1~SW12 active) 39// D7:D4 = 1011, SWSEL (SW1~SW12 active)
diff --git a/drivers/led/issi/is31fl3731-simple.c b/drivers/led/issi/is31fl3731-simple.c
index f51e2e38af..3abe9ea337 100644
--- a/drivers/led/issi/is31fl3731-simple.c
+++ b/drivers/led/issi/is31fl3731-simple.c
@@ -42,13 +42,13 @@
42#define ISSI_REG_PICTUREFRAME 0x01 42#define ISSI_REG_PICTUREFRAME 0x01
43 43
44// Not defined in the datasheet -- See AN for IC 44// Not defined in the datasheet -- See AN for IC
45#define ISSI_REG_GHOST_IMAGE_PREVENTION 0xC2 // Set bit 4 to enable de-ghosting 45#define ISSI_REG_GHOST_IMAGE_PREVENTION 0xC2 // Set bit 4 to enable de-ghosting
46 46
47#define ISSI_REG_SHUTDOWN 0x0A 47#define ISSI_REG_SHUTDOWN 0x0A
48#define ISSI_REG_AUDIOSYNC 0x06 48#define ISSI_REG_AUDIOSYNC 0x06
49 49
50#define ISSI_COMMANDREGISTER 0xFD 50#define ISSI_COMMANDREGISTER 0xFD
51#define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine' 51#define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine'
52 52
53#ifndef ISSI_TIMEOUT 53#ifndef ISSI_TIMEOUT
54# define ISSI_TIMEOUT 100 54# define ISSI_TIMEOUT 100
@@ -148,7 +148,7 @@ void IS31FL3731_init(uint8_t addr) {
148 148
149 // enable software shutdown 149 // enable software shutdown
150 IS31FL3731_write_register(addr, ISSI_REG_SHUTDOWN, 0x00); 150 IS31FL3731_write_register(addr, ISSI_REG_SHUTDOWN, 0x00);
151#ifdef ISSI_3731_DEGHOST // set to enable de-ghosting of the array 151#ifdef ISSI_3731_DEGHOST // set to enable de-ghosting of the array
152 IS31FL3731_write_register(addr, ISSI_REG_GHOST_IMAGE_PREVENTION, 0x10); 152 IS31FL3731_write_register(addr, ISSI_REG_GHOST_IMAGE_PREVENTION, 0x10);
153#endif 153#endif
154 154
diff --git a/drivers/led/issi/is31fl3731.c b/drivers/led/issi/is31fl3731.c
index e6190a6b90..9c6c29f081 100644
--- a/drivers/led/issi/is31fl3731.c
+++ b/drivers/led/issi/is31fl3731.c
@@ -41,13 +41,13 @@
41#define ISSI_REG_PICTUREFRAME 0x01 41#define ISSI_REG_PICTUREFRAME 0x01
42 42
43// Not defined in the datasheet -- See AN for IC 43// Not defined in the datasheet -- See AN for IC
44#define ISSI_REG_GHOST_IMAGE_PREVENTION 0xC2 // Set bit 4 to enable de-ghosting 44#define ISSI_REG_GHOST_IMAGE_PREVENTION 0xC2 // Set bit 4 to enable de-ghosting
45 45
46#define ISSI_REG_SHUTDOWN 0x0A 46#define ISSI_REG_SHUTDOWN 0x0A
47#define ISSI_REG_AUDIOSYNC 0x06 47#define ISSI_REG_AUDIOSYNC 0x06
48 48
49#define ISSI_COMMANDREGISTER 0xFD 49#define ISSI_COMMANDREGISTER 0xFD
50#define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine' 50#define ISSI_BANK_FUNCTIONREG 0x0B // helpfully called 'page nine'
51 51
52#ifndef ISSI_TIMEOUT 52#ifndef ISSI_TIMEOUT
53# define ISSI_TIMEOUT 100 53# define ISSI_TIMEOUT 100
@@ -136,7 +136,7 @@ void IS31FL3731_init(uint8_t addr) {
136 136
137 // enable software shutdown 137 // enable software shutdown
138 IS31FL3731_write_register(addr, ISSI_REG_SHUTDOWN, 0x00); 138 IS31FL3731_write_register(addr, ISSI_REG_SHUTDOWN, 0x00);
139#ifdef ISSI_3731_DEGHOST // set to enable de-ghosting of the array 139#ifdef ISSI_3731_DEGHOST // set to enable de-ghosting of the array
140 IS31FL3731_write_register(addr, ISSI_REG_GHOST_IMAGE_PREVENTION, 0x10); 140 IS31FL3731_write_register(addr, ISSI_REG_GHOST_IMAGE_PREVENTION, 0x10);
141#endif 141#endif
142 142
diff --git a/drivers/led/issi/is31fl3733-simple.c b/drivers/led/issi/is31fl3733-simple.c
index 777895bf89..af006f756d 100644
--- a/drivers/led/issi/is31fl3733-simple.c
+++ b/drivers/led/issi/is31fl3733-simple.c
@@ -39,16 +39,16 @@
39#define ISSI_INTERRUPTMASKREGISTER 0xF0 39#define ISSI_INTERRUPTMASKREGISTER 0xF0
40#define ISSI_INTERRUPTSTATUSREGISTER 0xF1 40#define ISSI_INTERRUPTSTATUSREGISTER 0xF1
41 41
42#define ISSI_PAGE_LEDCONTROL 0x00 // PG0 42#define ISSI_PAGE_LEDCONTROL 0x00 // PG0
43#define ISSI_PAGE_PWM 0x01 // PG1 43#define ISSI_PAGE_PWM 0x01 // PG1
44#define ISSI_PAGE_AUTOBREATH 0x02 // PG2 44#define ISSI_PAGE_AUTOBREATH 0x02 // PG2
45#define ISSI_PAGE_FUNCTION 0x03 // PG3 45#define ISSI_PAGE_FUNCTION 0x03 // PG3
46 46
47#define ISSI_REG_CONFIGURATION 0x00 // PG3 47#define ISSI_REG_CONFIGURATION 0x00 // PG3
48#define ISSI_REG_GLOBALCURRENT 0x01 // PG3 48#define ISSI_REG_GLOBALCURRENT 0x01 // PG3
49#define ISSI_REG_RESET 0x11 // PG3 49#define ISSI_REG_RESET 0x11 // PG3
50#define ISSI_REG_SWPULLUP 0x0F // PG3 50#define ISSI_REG_SWPULLUP 0x0F // PG3
51#define ISSI_REG_CSPULLUP 0x10 // PG3 51#define ISSI_REG_CSPULLUP 0x10 // PG3
52 52
53#ifndef ISSI_TIMEOUT 53#ifndef ISSI_TIMEOUT
54# define ISSI_TIMEOUT 100 54# define ISSI_TIMEOUT 100
@@ -59,7 +59,7 @@
59#endif 59#endif
60 60
61#ifndef ISSI_PWM_FREQUENCY 61#ifndef ISSI_PWM_FREQUENCY
62# define ISSI_PWM_FREQUENCY 0b000 // PFS - IS31FL3733B only 62# define ISSI_PWM_FREQUENCY 0b000 // PFS - IS31FL3733B only
63#endif 63#endif
64 64
65#ifndef ISSI_SWPULLUP 65#ifndef ISSI_SWPULLUP
diff --git a/drivers/led/issi/is31fl3733-simple.h b/drivers/led/issi/is31fl3733-simple.h
index f071db5e40..f5253e3101 100644
--- a/drivers/led/issi/is31fl3733-simple.h
+++ b/drivers/led/issi/is31fl3733-simple.h
@@ -47,13 +47,13 @@ void IS31FL3733_set_led_control_register(uint8_t index, bool value);
47void IS31FL3733_update_pwm_buffers(uint8_t addr, uint8_t index); 47void IS31FL3733_update_pwm_buffers(uint8_t addr, uint8_t index);
48void IS31FL3733_update_led_control_registers(uint8_t addr, uint8_t index); 48void IS31FL3733_update_led_control_registers(uint8_t addr, uint8_t index);
49 49
50#define PUR_0R 0x00 // No PUR resistor 50#define PUR_0R 0x00 // No PUR resistor
51#define PUR_05KR 0x02 // 0.5k Ohm resistor in t_NOL 51#define PUR_05KR 0x02 // 0.5k Ohm resistor in t_NOL
52#define PUR_3KR 0x03 // 3.0k Ohm resistor on all the time 52#define PUR_3KR 0x03 // 3.0k Ohm resistor on all the time
53#define PUR_4KR 0x04 // 4.0k Ohm resistor on all the time 53#define PUR_4KR 0x04 // 4.0k Ohm resistor on all the time
54#define PUR_8KR 0x05 // 8.0k Ohm resistor on all the time 54#define PUR_8KR 0x05 // 8.0k Ohm resistor on all the time
55#define PUR_16KR 0x06 // 16k Ohm resistor on all the time 55#define PUR_16KR 0x06 // 16k Ohm resistor on all the time
56#define PUR_32KR 0x07 // 32k Ohm resistor in t_NOL 56#define PUR_32KR 0x07 // 32k Ohm resistor in t_NOL
57 57
58#define A_1 0x00 58#define A_1 0x00
59#define A_2 0x01 59#define A_2 0x01
diff --git a/drivers/led/issi/is31fl3733.c b/drivers/led/issi/is31fl3733.c
index 696491d070..a2fdaa90fa 100644
--- a/drivers/led/issi/is31fl3733.c
+++ b/drivers/led/issi/is31fl3733.c
@@ -38,16 +38,16 @@
38#define ISSI_INTERRUPTMASKREGISTER 0xF0 38#define ISSI_INTERRUPTMASKREGISTER 0xF0
39#define ISSI_INTERRUPTSTATUSREGISTER 0xF1 39#define ISSI_INTERRUPTSTATUSREGISTER 0xF1
40 40
41#define ISSI_PAGE_LEDCONTROL 0x00 // PG0 41#define ISSI_PAGE_LEDCONTROL 0x00 // PG0
42#define ISSI_PAGE_PWM 0x01 // PG1 42#define ISSI_PAGE_PWM 0x01 // PG1
43#define ISSI_PAGE_AUTOBREATH 0x02 // PG2 43#define ISSI_PAGE_AUTOBREATH 0x02 // PG2
44#define ISSI_PAGE_FUNCTION 0x03 // PG3 44#define ISSI_PAGE_FUNCTION 0x03 // PG3
45 45
46#define ISSI_REG_CONFIGURATION 0x00 // PG3 46#define ISSI_REG_CONFIGURATION 0x00 // PG3
47#define ISSI_REG_GLOBALCURRENT 0x01 // PG3 47#define ISSI_REG_GLOBALCURRENT 0x01 // PG3
48#define ISSI_REG_RESET 0x11 // PG3 48#define ISSI_REG_RESET 0x11 // PG3
49#define ISSI_REG_SWPULLUP 0x0F // PG3 49#define ISSI_REG_SWPULLUP 0x0F // PG3
50#define ISSI_REG_CSPULLUP 0x10 // PG3 50#define ISSI_REG_CSPULLUP 0x10 // PG3
51 51
52#ifndef ISSI_TIMEOUT 52#ifndef ISSI_TIMEOUT
53# define ISSI_TIMEOUT 100 53# define ISSI_TIMEOUT 100
@@ -58,7 +58,7 @@
58#endif 58#endif
59 59
60#ifndef ISSI_PWM_FREQUENCY 60#ifndef ISSI_PWM_FREQUENCY
61# define ISSI_PWM_FREQUENCY 0b000 // PFS - IS31FL3733B only 61# define ISSI_PWM_FREQUENCY 0b000 // PFS - IS31FL3733B only
62#endif 62#endif
63 63
64#ifndef ISSI_SWPULLUP 64#ifndef ISSI_SWPULLUP
diff --git a/drivers/led/issi/is31fl3733.h b/drivers/led/issi/is31fl3733.h
index c5d62fed85..7653dd17c0 100644
--- a/drivers/led/issi/is31fl3733.h
+++ b/drivers/led/issi/is31fl3733.h
@@ -48,13 +48,13 @@ void IS31FL3733_set_led_control_register(uint8_t index, bool red, bool green, bo
48void IS31FL3733_update_pwm_buffers(uint8_t addr, uint8_t index); 48void IS31FL3733_update_pwm_buffers(uint8_t addr, uint8_t index);
49void IS31FL3733_update_led_control_registers(uint8_t addr, uint8_t index); 49void IS31FL3733_update_led_control_registers(uint8_t addr, uint8_t index);
50 50
51#define PUR_0R 0x00 // No PUR resistor 51#define PUR_0R 0x00 // No PUR resistor
52#define PUR_05KR 0x02 // 0.5k Ohm resistor in t_NOL 52#define PUR_05KR 0x02 // 0.5k Ohm resistor in t_NOL
53#define PUR_3KR 0x03 // 3.0k Ohm resistor on all the time 53#define PUR_3KR 0x03 // 3.0k Ohm resistor on all the time
54#define PUR_4KR 0x04 // 4.0k Ohm resistor on all the time 54#define PUR_4KR 0x04 // 4.0k Ohm resistor on all the time
55#define PUR_8KR 0x05 // 8.0k Ohm resistor on all the time 55#define PUR_8KR 0x05 // 8.0k Ohm resistor on all the time
56#define PUR_16KR 0x06 // 16k Ohm resistor on all the time 56#define PUR_16KR 0x06 // 16k Ohm resistor on all the time
57#define PUR_32KR 0x07 // 32k Ohm resistor in t_NOL 57#define PUR_32KR 0x07 // 32k Ohm resistor in t_NOL
58 58
59#define A_1 0x00 59#define A_1 0x00
60#define A_2 0x01 60#define A_2 0x01
diff --git a/drivers/led/issi/is31fl3736.c b/drivers/led/issi/is31fl3736.c
index c9a871118d..7752a3f6cb 100644
--- a/drivers/led/issi/is31fl3736.c
+++ b/drivers/led/issi/is31fl3736.c
@@ -36,16 +36,16 @@
36#define ISSI_INTERRUPTMASKREGISTER 0xF0 36#define ISSI_INTERRUPTMASKREGISTER 0xF0
37#define ISSI_INTERRUPTSTATUSREGISTER 0xF1 37#define ISSI_INTERRUPTSTATUSREGISTER 0xF1
38 38
39#define ISSI_PAGE_LEDCONTROL 0x00 // PG0 39#define ISSI_PAGE_LEDCONTROL 0x00 // PG0
40#define ISSI_PAGE_PWM 0x01 // PG1 40#define ISSI_PAGE_PWM 0x01 // PG1
41#define ISSI_PAGE_AUTOBREATH 0x02 // PG2 41#define ISSI_PAGE_AUTOBREATH 0x02 // PG2
42#define ISSI_PAGE_FUNCTION 0x03 // PG3 42#define ISSI_PAGE_FUNCTION 0x03 // PG3
43 43
44#define ISSI_REG_CONFIGURATION 0x00 // PG3 44#define ISSI_REG_CONFIGURATION 0x00 // PG3
45#define ISSI_REG_GLOBALCURRENT 0x01 // PG3 45#define ISSI_REG_GLOBALCURRENT 0x01 // PG3
46#define ISSI_REG_RESET 0x11 // PG3 46#define ISSI_REG_RESET 0x11 // PG3
47#define ISSI_REG_SWPULLUP 0x0F // PG3 47#define ISSI_REG_SWPULLUP 0x0F // PG3
48#define ISSI_REG_CSPULLUP 0x10 // PG3 48#define ISSI_REG_CSPULLUP 0x10 // PG3
49 49
50#ifndef ISSI_TIMEOUT 50#ifndef ISSI_TIMEOUT
51# define ISSI_TIMEOUT 100 51# define ISSI_TIMEOUT 100
diff --git a/drivers/led/issi/is31fl3736.h b/drivers/led/issi/is31fl3736.h
index 9fbe1cc577..f126034615 100644
--- a/drivers/led/issi/is31fl3736.h
+++ b/drivers/led/issi/is31fl3736.h
@@ -61,14 +61,14 @@ void IS31FL3736_mono_set_led_control_register(uint8_t index, bool enabled);
61void IS31FL3736_update_pwm_buffers(uint8_t addr1, uint8_t addr2); 61void IS31FL3736_update_pwm_buffers(uint8_t addr1, uint8_t addr2);
62void IS31FL3736_update_led_control_registers(uint8_t addr1, uint8_t addr2); 62void IS31FL3736_update_led_control_registers(uint8_t addr1, uint8_t addr2);
63 63
64#define PUR_0R 0x00 // No PUR resistor 64#define PUR_0R 0x00 // No PUR resistor
65#define PUR_05KR 0x01 // 0.5k Ohm resistor 65#define PUR_05KR 0x01 // 0.5k Ohm resistor
66#define PUR_1KR 0x02 // 1.0k Ohm resistor 66#define PUR_1KR 0x02 // 1.0k Ohm resistor
67#define PUR_2KR 0x03 // 2.0k Ohm resistor 67#define PUR_2KR 0x03 // 2.0k Ohm resistor
68#define PUR_4KR 0x04 // 4.0k Ohm resistor 68#define PUR_4KR 0x04 // 4.0k Ohm resistor
69#define PUR_8KR 0x05 // 8.0k Ohm resistor 69#define PUR_8KR 0x05 // 8.0k Ohm resistor
70#define PUR_16KR 0x06 // 16k Ohm resistor 70#define PUR_16KR 0x06 // 16k Ohm resistor
71#define PUR_32KR 0x07 // 32k Ohm resistor 71#define PUR_32KR 0x07 // 32k Ohm resistor
72 72
73#define A_1 0x00 73#define A_1 0x00
74#define A_2 0x02 74#define A_2 0x02
diff --git a/drivers/led/issi/is31fl3737.c b/drivers/led/issi/is31fl3737.c
index 0722e18869..9f2a13de45 100644
--- a/drivers/led/issi/is31fl3737.c
+++ b/drivers/led/issi/is31fl3737.c
@@ -38,16 +38,16 @@
38#define ISSI_INTERRUPTMASKREGISTER 0xF0 38#define ISSI_INTERRUPTMASKREGISTER 0xF0
39#define ISSI_INTERRUPTSTATUSREGISTER 0xF1 39#define ISSI_INTERRUPTSTATUSREGISTER 0xF1
40 40
41#define ISSI_PAGE_LEDCONTROL 0x00 // PG0 41#define ISSI_PAGE_LEDCONTROL 0x00 // PG0
42#define ISSI_PAGE_PWM 0x01 // PG1 42#define ISSI_PAGE_PWM 0x01 // PG1
43#define ISSI_PAGE_AUTOBREATH 0x02 // PG2 43#define ISSI_PAGE_AUTOBREATH 0x02 // PG2
44#define ISSI_PAGE_FUNCTION 0x03 // PG3 44#define ISSI_PAGE_FUNCTION 0x03 // PG3
45 45
46#define ISSI_REG_CONFIGURATION 0x00 // PG3 46#define ISSI_REG_CONFIGURATION 0x00 // PG3
47#define ISSI_REG_GLOBALCURRENT 0x01 // PG3 47#define ISSI_REG_GLOBALCURRENT 0x01 // PG3
48#define ISSI_REG_RESET 0x11 // PG3 48#define ISSI_REG_RESET 0x11 // PG3
49#define ISSI_REG_SWPULLUP 0x0F // PG3 49#define ISSI_REG_SWPULLUP 0x0F // PG3
50#define ISSI_REG_CSPULLUP 0x10 // PG3 50#define ISSI_REG_CSPULLUP 0x10 // PG3
51 51
52#ifndef ISSI_TIMEOUT 52#ifndef ISSI_TIMEOUT
53# define ISSI_TIMEOUT 100 53# define ISSI_TIMEOUT 100
diff --git a/drivers/led/issi/is31fl3737.h b/drivers/led/issi/is31fl3737.h
index 31b1a22267..ddb70a9df5 100644
--- a/drivers/led/issi/is31fl3737.h
+++ b/drivers/led/issi/is31fl3737.h
@@ -48,14 +48,14 @@ void IS31FL3737_set_led_control_register(uint8_t index, bool red, bool green, bo
48void IS31FL3737_update_pwm_buffers(uint8_t addr1, uint8_t addr2); 48void IS31FL3737_update_pwm_buffers(uint8_t addr1, uint8_t addr2);
49void IS31FL3737_update_led_control_registers(uint8_t addr1, uint8_t addr2); 49void IS31FL3737_update_led_control_registers(uint8_t addr1, uint8_t addr2);
50 50
51#define PUR_0R 0x00 // No PUR resistor 51#define PUR_0R 0x00 // No PUR resistor
52#define PUR_05KR 0x01 // 0.5k Ohm resistor in t_NOL 52#define PUR_05KR 0x01 // 0.5k Ohm resistor in t_NOL
53#define PUR_1KR 0x02 // 1.0k Ohm resistor in t_NOL 53#define PUR_1KR 0x02 // 1.0k Ohm resistor in t_NOL
54#define PUR_2KR 0x03 // 2.0k Ohm resistor in t_NOL 54#define PUR_2KR 0x03 // 2.0k Ohm resistor in t_NOL
55#define PUR_4KR 0x04 // 4.0k Ohm resistor in t_NOL 55#define PUR_4KR 0x04 // 4.0k Ohm resistor in t_NOL
56#define PUR_8KR 0x05 // 8.0k Ohm resistor in t_NOL 56#define PUR_8KR 0x05 // 8.0k Ohm resistor in t_NOL
57#define PUR_16KR 0x06 // 16k Ohm resistor in t_NOL 57#define PUR_16KR 0x06 // 16k Ohm resistor in t_NOL
58#define PUR_32KR 0x07 // 32k Ohm resistor in t_NOL 58#define PUR_32KR 0x07 // 32k Ohm resistor in t_NOL
59 59
60#define A_1 0x00 60#define A_1 0x00
61#define A_2 0x01 61#define A_2 0x01
diff --git a/drivers/led/issi/is31fl3741.c b/drivers/led/issi/is31fl3741.c
index 8d347a5e60..393b0179b5 100644
--- a/drivers/led/issi/is31fl3741.c
+++ b/drivers/led/issi/is31fl3741.c
@@ -42,16 +42,16 @@
42#define ISSI_INTERRUPTSTATUSREGISTER 0xF1 42#define ISSI_INTERRUPTSTATUSREGISTER 0xF1
43#define ISSI_IDREGISTER 0xFC 43#define ISSI_IDREGISTER 0xFC
44 44
45#define ISSI_PAGE_PWM0 0x00 // PG0 45#define ISSI_PAGE_PWM0 0x00 // PG0
46#define ISSI_PAGE_PWM1 0x01 // PG1 46#define ISSI_PAGE_PWM1 0x01 // PG1
47#define ISSI_PAGE_SCALING_0 0x02 // PG2 47#define ISSI_PAGE_SCALING_0 0x02 // PG2
48#define ISSI_PAGE_SCALING_1 0x03 // PG3 48#define ISSI_PAGE_SCALING_1 0x03 // PG3
49#define ISSI_PAGE_FUNCTION 0x04 // PG4 49#define ISSI_PAGE_FUNCTION 0x04 // PG4
50 50
51#define ISSI_REG_CONFIGURATION 0x00 // PG4 51#define ISSI_REG_CONFIGURATION 0x00 // PG4
52#define ISSI_REG_GLOBALCURRENT 0x01 // PG4 52#define ISSI_REG_GLOBALCURRENT 0x01 // PG4
53#define ISSI_REG_PULLDOWNUP 0x02 // PG4 53#define ISSI_REG_PULLDOWNUP 0x02 // PG4
54#define ISSI_REG_RESET 0x3F // PG4 54#define ISSI_REG_RESET 0x3F // PG4
55 55
56#ifndef ISSI_TIMEOUT 56#ifndef ISSI_TIMEOUT
57# define ISSI_TIMEOUT 100 57# define ISSI_TIMEOUT 100
diff --git a/drivers/led/issi/is31fl3741.h b/drivers/led/issi/is31fl3741.h
index 8154f8be70..3bdb23bd2d 100644
--- a/drivers/led/issi/is31fl3741.h
+++ b/drivers/led/issi/is31fl3741.h
@@ -51,14 +51,14 @@ void IS31FL3741_set_scaling_registers(const is31_led *pled, uint8_t red, uint8_t
51 51
52void IS31FL3741_set_pwm_buffer(const is31_led *pled, uint8_t red, uint8_t green, uint8_t blue); 52void IS31FL3741_set_pwm_buffer(const is31_led *pled, uint8_t red, uint8_t green, uint8_t blue);
53 53
54#define PUR_0R 0x00 // No PUR resistor 54#define PUR_0R 0x00 // No PUR resistor
55#define PUR_05KR 0x01 // 0.5k Ohm resistor 55#define PUR_05KR 0x01 // 0.5k Ohm resistor
56#define PUR_1KR 0x02 // 1.0k Ohm resistor 56#define PUR_1KR 0x02 // 1.0k Ohm resistor
57#define PUR_2KR 0x03 // 2.0k Ohm resistor 57#define PUR_2KR 0x03 // 2.0k Ohm resistor
58#define PUR_4KR 0x04 // 4.0k Ohm resistor 58#define PUR_4KR 0x04 // 4.0k Ohm resistor
59#define PUR_8KR 0x05 // 8.0k Ohm resistor 59#define PUR_8KR 0x05 // 8.0k Ohm resistor
60#define PUR_16KR 0x06 // 16k Ohm resistor 60#define PUR_16KR 0x06 // 16k Ohm resistor
61#define PUR_32KR 0x07 // 32k Ohm resistor 61#define PUR_32KR 0x07 // 32k Ohm resistor
62 62
63#define CS1_SW1 0x00 63#define CS1_SW1 0x00
64#define CS2_SW1 0x01 64#define CS2_SW1 0x01
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h
index 3b56d370dc..918b837f07 100644
--- a/drivers/oled/oled_driver.h
+++ b/drivers/oled/oled_driver.h
@@ -34,16 +34,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
34# define OLED_DISPLAY_HEIGHT 64 34# define OLED_DISPLAY_HEIGHT 64
35# endif 35# endif
36# ifndef OLED_MATRIX_SIZE 36# ifndef OLED_MATRIX_SIZE
37# define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 1024 (compile time mathed) 37# define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 1024 (compile time mathed)
38# endif 38# endif
39# ifndef OLED_BLOCK_TYPE 39# ifndef OLED_BLOCK_TYPE
40# define OLED_BLOCK_TYPE uint16_t 40# define OLED_BLOCK_TYPE uint16_t
41# endif 41# endif
42# ifndef OLED_BLOCK_COUNT 42# ifndef OLED_BLOCK_COUNT
43# define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 32 (compile time mathed) 43# define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 32 (compile time mathed)
44# endif 44# endif
45# ifndef OLED_BLOCK_SIZE 45# ifndef OLED_BLOCK_SIZE
46# define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) 46# define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed)
47# endif 47# endif
48# ifndef OLED_COM_PINS 48# ifndef OLED_COM_PINS
49# define OLED_COM_PINS COM_PINS_ALT 49# define OLED_COM_PINS COM_PINS_ALT
@@ -68,7 +68,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
68// If OLED_BLOCK_TYPE is uint8_t, these tables would look like: 68// If OLED_BLOCK_TYPE is uint8_t, these tables would look like:
69// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 } 69// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 }
70// #define OLED_TARGET_MAP { 56, 120, 48, 112, 40, 104, 32, 96, 24, 88, 16, 80, 8, 72, 0, 64 } 70// #define OLED_TARGET_MAP { 56, 120, 48, 112, 40, 104, 32, 96, 24, 88, 16, 80, 8, 72, 0, 64 }
71#else // defined(OLED_DISPLAY_128X64) 71#else // defined(OLED_DISPLAY_128X64)
72// Default 128x32 72// Default 128x32
73# ifndef OLED_DISPLAY_WIDTH 73# ifndef OLED_DISPLAY_WIDTH
74# define OLED_DISPLAY_WIDTH 128 74# define OLED_DISPLAY_WIDTH 128
@@ -77,16 +77,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
77# define OLED_DISPLAY_HEIGHT 32 77# define OLED_DISPLAY_HEIGHT 32
78# endif 78# endif
79# ifndef OLED_MATRIX_SIZE 79# ifndef OLED_MATRIX_SIZE
80# define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 512 (compile time mathed) 80# define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 512 (compile time mathed)
81# endif 81# endif
82# ifndef OLED_BLOCK_TYPE 82# ifndef OLED_BLOCK_TYPE
83# define OLED_BLOCK_TYPE uint16_t // Type to use for segmenting the oled display for smart rendering, use unsigned types only 83# define OLED_BLOCK_TYPE uint16_t // Type to use for segmenting the oled display for smart rendering, use unsigned types only
84# endif 84# endif
85# ifndef OLED_BLOCK_COUNT 85# ifndef OLED_BLOCK_COUNT
86# define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 16 (compile time mathed) 86# define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 16 (compile time mathed)
87# endif 87# endif
88# ifndef OLED_BLOCK_SIZE 88# ifndef OLED_BLOCK_SIZE
89# define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) 89# define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed)
90# endif 90# endif
91# ifndef OLED_COM_PINS 91# ifndef OLED_COM_PINS
92# define OLED_COM_PINS COM_PINS_SEQ 92# define OLED_COM_PINS COM_PINS_SEQ
@@ -105,7 +105,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
105// If OLED_BLOCK_TYPE is uint8_t, these tables would look like: 105// If OLED_BLOCK_TYPE is uint8_t, these tables would look like:
106// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 } 106// #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 }
107// #define OLED_TARGET_MAP { 48, 32, 16, 0, 56, 40, 24, 8 } 107// #define OLED_TARGET_MAP { 48, 32, 16, 0, 56, 40, 24, 8 }
108#endif // defined(OLED_DISPLAY_CUSTOM) 108#endif // defined(OLED_DISPLAY_CUSTOM)
109 109
110#if !defined(OLED_IC) 110#if !defined(OLED_IC)
111# define OLED_IC OLED_IC_SSD1306 111# define OLED_IC OLED_IC_SSD1306
@@ -180,7 +180,7 @@ typedef enum {
180 OLED_ROTATION_0 = 0, 180 OLED_ROTATION_0 = 0,
181 OLED_ROTATION_90 = 1, 181 OLED_ROTATION_90 = 1,
182 OLED_ROTATION_180 = 2, 182 OLED_ROTATION_180 = 2,
183 OLED_ROTATION_270 = 3, // OLED_ROTATION_90 | OLED_ROTATION_180 183 OLED_ROTATION_270 = 3, // OLED_ROTATION_90 | OLED_ROTATION_180
184} oled_rotation_t; 184} oled_rotation_t;
185 185
186// Initialize the oled display, rotating the rendered output based on the define passed in. 186// Initialize the oled display, rotating the rendered output based on the define passed in.
@@ -262,7 +262,7 @@ void oled_write_raw_P(const char *data, uint16_t size);
262# define oled_write_P(data, invert) oled_write(data, invert) 262# define oled_write_P(data, invert) oled_write(data, invert)
263# define oled_write_ln_P(data, invert) oled_write(data, invert) 263# define oled_write_ln_P(data, invert) oled_write(data, invert)
264# define oled_write_raw_P(data, size) oled_write_raw(data, size) 264# define oled_write_raw_P(data, size) oled_write_raw(data, size)
265#endif // defined(__AVR__) 265#endif // defined(__AVR__)
266 266
267// Can be used to manually turn on the screen if it is off 267// Can be used to manually turn on the screen if it is off
268// Returns true if the screen was on or turns on 268// Returns true if the screen was on or turns on
diff --git a/drivers/oled/ssd1306_sh1106.c b/drivers/oled/ssd1306_sh1106.c
index d9bd3c14bd..30cfeb5648 100644
--- a/drivers/oled/ssd1306_sh1106.c
+++ b/drivers/oled/ssd1306_sh1106.c
@@ -53,7 +53,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
53#define PAGE_ADDR 0x22 53#define PAGE_ADDR 0x22
54#define PAM_SETCOLUMN_LSB 0x00 54#define PAM_SETCOLUMN_LSB 0x00
55#define PAM_SETCOLUMN_MSB 0x10 55#define PAM_SETCOLUMN_MSB 0x10
56#define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7 56#define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7
57 57
58// Hardware Configuration Commands 58// Hardware Configuration Commands
59#define DISPLAY_START_LINE 0x40 59#define DISPLAY_START_LINE 0x40
@@ -97,9 +97,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
97#define I2C_DATA 0x40 97#define I2C_DATA 0x40
98#if defined(__AVR__) 98#if defined(__AVR__)
99# define I2C_TRANSMIT_P(data) i2c_transmit_P((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT) 99# define I2C_TRANSMIT_P(data) i2c_transmit_P((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT)
100#else // defined(__AVR__) 100#else // defined(__AVR__)
101# define I2C_TRANSMIT_P(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT) 101# define I2C_TRANSMIT_P(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT)
102#endif // defined(__AVR__) 102#endif // defined(__AVR__)
103#define I2C_TRANSMIT(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT) 103#define I2C_TRANSMIT(data) i2c_transmit((OLED_DISPLAY_ADDRESS << 1), &data[0], sizeof(data), OLED_I2C_TIMEOUT)
104#define I2C_WRITE_REG(mode, data, size) i2c_writeReg((OLED_DISPLAY_ADDRESS << 1), mode, data, size, OLED_I2C_TIMEOUT) 104#define I2C_WRITE_REG(mode, data, size) i2c_writeReg((OLED_DISPLAY_ADDRESS << 1), mode, data, size, OLED_I2C_TIMEOUT)
105 105
@@ -119,7 +119,7 @@ bool oled_inverted = false;
119uint8_t oled_brightness = OLED_BRIGHTNESS; 119uint8_t oled_brightness = OLED_BRIGHTNESS;
120oled_rotation_t oled_rotation = 0; 120oled_rotation_t oled_rotation = 0;
121uint8_t oled_rotation_width = 0; 121uint8_t oled_rotation_width = 0;
122uint8_t oled_scroll_speed = 0; // this holds the speed after being remapped to ssd1306 internal values 122uint8_t oled_scroll_speed = 0; // this holds the speed after being remapped to ssd1306 internal values
123uint8_t oled_scroll_start = 0; 123uint8_t oled_scroll_start = 0;
124uint8_t oled_scroll_end = 7; 124uint8_t oled_scroll_end = 7;
125#if OLED_TIMEOUT > 0 125#if OLED_TIMEOUT > 0
@@ -190,7 +190,7 @@ bool oled_init(oled_rotation_t rotation) {
190#if (OLED_IC != OLED_IC_SH1106) 190#if (OLED_IC != OLED_IC_SH1106)
191 // MEMORY_MODE is unsupported on SH1106 (Page Addressing only) 191 // MEMORY_MODE is unsupported on SH1106 (Page Addressing only)
192 MEMORY_MODE, 192 MEMORY_MODE,
193 0x00, // Horizontal addressing mode 193 0x00, // Horizontal addressing mode
194#endif 194#endif
195 }; 195 };
196 if (I2C_TRANSMIT_P(display_setup1) != I2C_STATUS_SUCCESS) { 196 if (I2C_TRANSMIT_P(display_setup1) != I2C_STATUS_SUCCESS) {
@@ -232,8 +232,12 @@ bool oled_init(oled_rotation_t rotation) {
232 return true; 232 return true;
233} 233}
234 234
235__attribute__((weak)) oled_rotation_t oled_init_kb(oled_rotation_t rotation) { return rotation; } 235__attribute__((weak)) oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
236__attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) { return rotation; } 236 return rotation;
237}
238__attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) {
239 return rotation;
240}
237 241
238void oled_clear(void) { 242void oled_clear(void) {
239 memset(oled_buffer, 0, sizeof(oled_buffer)); 243 memset(oled_buffer, 0, sizeof(oled_buffer));
@@ -306,9 +310,9 @@ void oled_render(void) {
306 // Set column & page position 310 // Set column & page position
307 static uint8_t display_start[] = {I2C_CMD, COLUMN_ADDR, 0, OLED_DISPLAY_WIDTH - 1, PAGE_ADDR, 0, OLED_DISPLAY_HEIGHT / 8 - 1}; 311 static uint8_t display_start[] = {I2C_CMD, COLUMN_ADDR, 0, OLED_DISPLAY_WIDTH - 1, PAGE_ADDR, 0, OLED_DISPLAY_HEIGHT / 8 - 1};
308 if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { 312 if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) {
309 calc_bounds(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start 313 calc_bounds(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start
310 } else { 314 } else {
311 calc_bounds_90(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start 315 calc_bounds_90(update_start, &display_start[1]); // Offset from I2C_CMD byte at the start
312 } 316 }
313 317
314 // Send column & page position 318 // Send column & page position
@@ -368,7 +372,8 @@ void oled_advance_page(bool clearPageRemainder) {
368 remaining = remaining / OLED_FONT_WIDTH; 372 remaining = remaining / OLED_FONT_WIDTH;
369 373
370 // Write empty character until next line 374 // Write empty character until next line
371 while (remaining--) oled_write_char(' ', false); 375 while (remaining--)
376 oled_write_char(' ', false);
372 } else { 377 } else {
373 // Next page index out of bounds? 378 // Next page index out of bounds?
374 if (index + remaining >= OLED_MATRIX_SIZE) { 379 if (index + remaining >= OLED_MATRIX_SIZE) {
@@ -419,7 +424,7 @@ void oled_write_char(const char data, bool invert) {
419 _Static_assert(sizeof(font) >= ((OLED_FONT_END + 1 - OLED_FONT_START) * OLED_FONT_WIDTH), "OLED_FONT_END references outside array"); 424 _Static_assert(sizeof(font) >= ((OLED_FONT_END + 1 - OLED_FONT_START) * OLED_FONT_WIDTH), "OLED_FONT_END references outside array");
420 425
421 // set the reder buffer data 426 // set the reder buffer data
422 uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index 427 uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index
423 if (cast_data < OLED_FONT_START || cast_data > OLED_FONT_END) { 428 if (cast_data < OLED_FONT_START || cast_data > OLED_FONT_END) {
424 memset(oled_cursor, 0x00, OLED_FONT_WIDTH); 429 memset(oled_cursor, 0x00, OLED_FONT_WIDTH);
425 } else { 430 } else {
@@ -545,7 +550,7 @@ void oled_write_raw_P(const char *data, uint16_t size) {
545 oled_dirty |= ((OLED_BLOCK_TYPE)1 << (i / OLED_BLOCK_SIZE)); 550 oled_dirty |= ((OLED_BLOCK_TYPE)1 << (i / OLED_BLOCK_SIZE));
546 } 551 }
547} 552}
548#endif // defined(__AVR__) 553#endif // defined(__AVR__)
549 554
550bool oled_on(void) { 555bool oled_on(void) {
551 if (!oled_initialized) { 556 if (!oled_initialized) {
@@ -595,7 +600,9 @@ bool oled_off(void) {
595 return !oled_active; 600 return !oled_active;
596} 601}
597 602
598bool is_oled_on(void) { return oled_active; } 603bool is_oled_on(void) {
604 return oled_active;
605}
599 606
600uint8_t oled_set_brightness(uint8_t level) { 607uint8_t oled_set_brightness(uint8_t level) {
601 if (!oled_initialized) { 608 if (!oled_initialized) {
@@ -613,7 +620,9 @@ uint8_t oled_set_brightness(uint8_t level) {
613 return oled_brightness; 620 return oled_brightness;
614} 621}
615 622
616uint8_t oled_get_brightness(void) { return oled_brightness; } 623uint8_t oled_get_brightness(void) {
624 return oled_brightness;
625}
617 626
618// Set the specific 8 lines rows of the screen to scroll. 627// Set the specific 8 lines rows of the screen to scroll.
619// 0 is the default for start, and 7 for end, which is the entire 628// 0 is the default for start, and 7 for end, which is the entire
@@ -693,7 +702,9 @@ bool oled_scroll_off(void) {
693 return !oled_scrolling; 702 return !oled_scrolling;
694} 703}
695 704
696bool is_oled_scrolling(void) { return oled_scrolling; } 705bool is_oled_scrolling(void) {
706 return oled_scrolling;
707}
697 708
698bool oled_invert(bool invert) { 709bool oled_invert(bool invert) {
699 if (!oled_initialized) { 710 if (!oled_initialized) {
@@ -777,5 +788,9 @@ void oled_task(void) {
777#endif 788#endif
778} 789}
779 790
780__attribute__((weak)) bool oled_task_kb(void) { return oled_task_user(); } 791__attribute__((weak)) bool oled_task_kb(void) {
781__attribute__((weak)) bool oled_task_user(void) { return true; } 792 return oled_task_user();
793}
794__attribute__((weak)) bool oled_task_user(void) {
795 return true;
796}
diff --git a/drivers/ps2/ps2_busywait.c b/drivers/ps2/ps2_busywait.c
index 983194eea8..c5a0183bb7 100644
--- a/drivers/ps2/ps2_busywait.c
+++ b/drivers/ps2/ps2_busywait.c
@@ -71,12 +71,12 @@ uint8_t ps2_host_send(uint8_t data) {
71 71
72 /* terminate a transmission if we have */ 72 /* terminate a transmission if we have */
73 inhibit(); 73 inhibit();
74 wait_us(100); // 100us [4]p.13, [5]p.50 74 wait_us(100); // 100us [4]p.13, [5]p.50
75 75
76 /* 'Request to Send' and Start bit */ 76 /* 'Request to Send' and Start bit */
77 data_lo(); 77 data_lo();
78 clock_hi(); 78 clock_hi();
79 WAIT(clock_lo, 10000, 10); // 10ms [5]p.50 79 WAIT(clock_lo, 10000, 10); // 10ms [5]p.50
80 80
81 /* Data bit */ 81 /* Data bit */
82 for (uint8_t i = 0; i < 8; i++) { 82 for (uint8_t i = 0; i < 8; i++) {
@@ -143,7 +143,7 @@ uint8_t ps2_host_recv(void) {
143 idle(); 143 idle();
144 144
145 /* start bit [1] */ 145 /* start bit [1] */
146 WAIT(clock_lo, 100, 1); // TODO: this is enough? 146 WAIT(clock_lo, 100, 1); // TODO: this is enough?
147 WAIT(data_lo, 1, 2); 147 WAIT(data_lo, 1, 2);
148 WAIT(clock_hi, 50, 3); 148 WAIT(clock_hi, 50, 3);
149 149
diff --git a/drivers/ps2/ps2_interrupt.c b/drivers/ps2/ps2_interrupt.c
index 70debd02f7..c49b4f8b75 100644
--- a/drivers/ps2/ps2_interrupt.c
+++ b/drivers/ps2/ps2_interrupt.c
@@ -43,7 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
43 43
44#if defined(__AVR__) 44#if defined(__AVR__)
45# include <avr/interrupt.h> 45# include <avr/interrupt.h>
46#elif defined(PROTOCOL_CHIBIOS) // TODO: or STM32 ? 46#elif defined(PROTOCOL_CHIBIOS) // TODO: or STM32 ?
47// chibiOS headers 47// chibiOS headers
48# include "ch.h" 48# include "ch.h"
49# include "hal.h" 49# include "hal.h"
@@ -71,7 +71,9 @@ static inline void pbuf_clear(void);
71 71
72#if defined(PROTOCOL_CHIBIOS) 72#if defined(PROTOCOL_CHIBIOS)
73void ps2_interrupt_service_routine(void); 73void ps2_interrupt_service_routine(void);
74void palCallback(void *arg) { ps2_interrupt_service_routine(); } 74void palCallback(void *arg) {
75 ps2_interrupt_service_routine();
76}
75 77
76# define PS2_INT_INIT() \ 78# define PS2_INT_INIT() \
77 { palSetLineMode(PS2_CLOCK_PIN, PAL_MODE_INPUT); } \ 79 { palSetLineMode(PS2_CLOCK_PIN, PAL_MODE_INPUT); } \
@@ -85,7 +87,7 @@ void palCallback(void *arg) { ps2_interrupt_service_routine(); }
85# define PS2_INT_OFF() \ 87# define PS2_INT_OFF() \
86 { palDisableLineEvent(PS2_CLOCK_PIN); } \ 88 { palDisableLineEvent(PS2_CLOCK_PIN); } \
87 while (0) 89 while (0)
88#endif // PROTOCOL_CHIBIOS 90#endif // PROTOCOL_CHIBIOS
89 91
90void ps2_host_init(void) { 92void ps2_host_init(void) {
91 idle(); 93 idle();
@@ -103,12 +105,12 @@ uint8_t ps2_host_send(uint8_t data) {
103 105
104 /* terminate a transmission if we have */ 106 /* terminate a transmission if we have */
105 inhibit(); 107 inhibit();
106 wait_us(100); // 100us [4]p.13, [5]p.50 108 wait_us(100); // 100us [4]p.13, [5]p.50
107 109
108 /* 'Request to Send' and Start bit */ 110 /* 'Request to Send' and Start bit */
109 data_lo(); 111 data_lo();
110 clock_hi(); 112 clock_hi();
111 WAIT(clock_lo, 10000, 10); // 10ms [5]p.50 113 WAIT(clock_lo, 10000, 10); // 10ms [5]p.50
112 114
113 /* Data bit[2-9] */ 115 /* Data bit[2-9] */
114 for (uint8_t i = 0; i < 8; i++) { 116 for (uint8_t i = 0; i < 8; i++) {
@@ -244,7 +246,9 @@ RETURN:
244} 246}
245 247
246#if defined(__AVR__) 248#if defined(__AVR__)
247ISR(PS2_INT_VECT) { ps2_interrupt_service_routine(); } 249ISR(PS2_INT_VECT) {
250 ps2_interrupt_service_routine();
251}
248#endif 252#endif
249 253
250/* send LED state to keyboard */ 254/* send LED state to keyboard */
diff --git a/drivers/ps2/ps2_mouse.c b/drivers/ps2/ps2_mouse.c
index 8a6668b410..ccb0a929ae 100644
--- a/drivers/ps2/ps2_mouse.c
+++ b/drivers/ps2/ps2_mouse.c
@@ -42,7 +42,7 @@ static inline void ps2_mouse_scroll_button_task(report_mouse_t *mouse_report);
42void ps2_mouse_init(void) { 42void ps2_mouse_init(void) {
43 ps2_host_init(); 43 ps2_host_init();
44 44
45 wait_ms(PS2_MOUSE_INIT_DELAY); // wait for powering up 45 wait_ms(PS2_MOUSE_INIT_DELAY); // wait for powering up
46 46
47 PS2_MOUSE_SEND(PS2_MOUSE_RESET, "ps2_mouse_init: sending reset"); 47 PS2_MOUSE_SEND(PS2_MOUSE_RESET, "ps2_mouse_init: sending reset");
48 48
@@ -113,9 +113,13 @@ void ps2_mouse_task(void) {
113 ps2_mouse_clear_report(&mouse_report); 113 ps2_mouse_clear_report(&mouse_report);
114} 114}
115 115
116void ps2_mouse_disable_data_reporting(void) { PS2_MOUSE_SEND(PS2_MOUSE_DISABLE_DATA_REPORTING, "ps2 mouse disable data reporting"); } 116void ps2_mouse_disable_data_reporting(void) {
117 PS2_MOUSE_SEND(PS2_MOUSE_DISABLE_DATA_REPORTING, "ps2 mouse disable data reporting");
118}
117 119
118void ps2_mouse_enable_data_reporting(void) { PS2_MOUSE_SEND(PS2_MOUSE_ENABLE_DATA_REPORTING, "ps2 mouse enable data reporting"); } 120void ps2_mouse_enable_data_reporting(void) {
121 PS2_MOUSE_SEND(PS2_MOUSE_ENABLE_DATA_REPORTING, "ps2 mouse enable data reporting");
122}
119 123
120void ps2_mouse_set_remote_mode(void) { 124void ps2_mouse_set_remote_mode(void) {
121 PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_REMOTE_MODE, "ps2 mouse set remote mode"); 125 PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_REMOTE_MODE, "ps2 mouse set remote mode");
@@ -127,13 +131,21 @@ void ps2_mouse_set_stream_mode(void) {
127 ps2_mouse_mode = PS2_MOUSE_STREAM_MODE; 131 ps2_mouse_mode = PS2_MOUSE_STREAM_MODE;
128} 132}
129 133
130void ps2_mouse_set_scaling_2_1(void) { PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_2_1, "ps2 mouse set scaling 2:1"); } 134void ps2_mouse_set_scaling_2_1(void) {
135 PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_2_1, "ps2 mouse set scaling 2:1");
136}
131 137
132void ps2_mouse_set_scaling_1_1(void) { PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_1_1, "ps2 mouse set scaling 1:1"); } 138void ps2_mouse_set_scaling_1_1(void) {
139 PS2_MOUSE_SEND_SAFE(PS2_MOUSE_SET_SCALING_1_1, "ps2 mouse set scaling 1:1");
140}
133 141
134void ps2_mouse_set_resolution(ps2_mouse_resolution_t resolution) { PS2_MOUSE_SET_SAFE(PS2_MOUSE_SET_RESOLUTION, resolution, "ps2 mouse set resolution"); } 142void ps2_mouse_set_resolution(ps2_mouse_resolution_t resolution) {
143 PS2_MOUSE_SET_SAFE(PS2_MOUSE_SET_RESOLUTION, resolution, "ps2 mouse set resolution");
144}
135 145
136void ps2_mouse_set_sample_rate(ps2_mouse_sample_rate_t sample_rate) { PS2_MOUSE_SET_SAFE(PS2_MOUSE_SET_SAMPLE_RATE, sample_rate, "ps2 mouse set sample rate"); } 146void ps2_mouse_set_sample_rate(ps2_mouse_sample_rate_t sample_rate) {
147 PS2_MOUSE_SET_SAFE(PS2_MOUSE_SET_SAMPLE_RATE, sample_rate, "ps2 mouse set sample rate");
148}
137 149
138/* ============================= HELPERS ============================ */ 150/* ============================= HELPERS ============================ */
139 151
@@ -165,7 +177,7 @@ static inline void ps2_mouse_convert_report_to_hid(report_mouse_t *mouse_report)
165#ifdef PS2_MOUSE_INVERT_X 177#ifdef PS2_MOUSE_INVERT_X
166 mouse_report->x = -mouse_report->x; 178 mouse_report->x = -mouse_report->x;
167#endif 179#endif
168#ifndef PS2_MOUSE_INVERT_Y // NOTE if not! 180#ifndef PS2_MOUSE_INVERT_Y // NOTE if not!
169 // invert coordinate of y to conform to USB HID mouse 181 // invert coordinate of y to conform to USB HID mouse
170 mouse_report->y = -mouse_report->y; 182 mouse_report->y = -mouse_report->y;
171#endif 183#endif
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) {
74 writePinHigh(ADNS5050_CS_PIN); 74 writePinHigh(ADNS5050_CS_PIN);
75} 75}
76 76
77void adns5050_cs_select(void) { writePinLow(ADNS5050_CS_PIN); } 77void adns5050_cs_select(void) {
78 writePinLow(ADNS5050_CS_PIN);
79}
78 80
79void adns5050_cs_deselect(void) { writePinHigh(ADNS5050_CS_PIN); } 81void adns5050_cs_deselect(void) {
82 writePinHigh(ADNS5050_CS_PIN);
83}
80 84
81uint8_t adns5050_serial_read(void) { 85uint8_t adns5050_serial_read(void) {
82 setPinInput(ADNS5050_SDIO_PIN); 86 setPinInput(ADNS5050_SDIO_PIN);
@@ -190,7 +194,7 @@ int8_t convert_twoscomp(uint8_t data) {
190 194
191// Don't forget to use the definitions for CPI in the header file. 195// Don't forget to use the definitions for CPI in the header file.
192void adns5050_set_cpi(uint16_t cpi) { 196void adns5050_set_cpi(uint16_t cpi) {
193 uint8_t cpival = constrain((cpi / 125), 0x1, 0xD); // limits to 0--119 197 uint8_t cpival = constrain((cpi / 125), 0x1, 0xD); // limits to 0--119
194 198
195 adns5050_write_reg(REG_MOUSE_CONTROL2, 0b10000 | cpival); 199 adns5050_write_reg(REG_MOUSE_CONTROL2, 0b10000 | cpival);
196} 200}
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 @@
77#define MSB1 0x80 77#define MSB1 0x80
78// clang-format on 78// clang-format on
79 79
80void adns9800_spi_start(void) { spi_start(ADNS9800_CS_PIN, false, ADNS9800_SPI_MODE, ADNS9800_SPI_DIVISOR); } 80void adns9800_spi_start(void) {
81 spi_start(ADNS9800_CS_PIN, false, ADNS9800_SPI_MODE, ADNS9800_SPI_DIVISOR);
82}
81 83
82void adns9800_write(uint8_t reg_addr, uint8_t data) { 84void adns9800_write(uint8_t reg_addr, uint8_t data) {
83 adns9800_spi_start(); 85 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;
24uint16_t maxAxisValue = ANALOG_JOYSTICK_AXIS_MAX; 24uint16_t maxAxisValue = ANALOG_JOYSTICK_AXIS_MAX;
25 25
26uint8_t maxCursorSpeed = ANALOG_JOYSTICK_SPEED_MAX; 26uint8_t maxCursorSpeed = ANALOG_JOYSTICK_SPEED_MAX;
27uint8_t speedRegulator = ANALOG_JOYSTICK_SPEED_REGULATOR; // Lower Values Create Faster Movement 27uint8_t speedRegulator = ANALOG_JOYSTICK_SPEED_REGULATOR; // Lower Values Create Faster Movement
28 28
29int16_t xOrigin, yOrigin; 29int16_t xOrigin, yOrigin;
30 30
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);
54void RAP_Write(uint8_t address, uint8_t data); 54void RAP_Write(uint8_t address, uint8_t data);
55 55
56#ifdef CONSOLE_ENABLE 56#ifdef CONSOLE_ENABLE
57void 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')); } 57void print_byte(uint8_t byte) {
58 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'));
59}
58#endif 60#endif
59 61
60/* Logical Scaling Functions */ 62/* Logical Scaling Functions */
@@ -73,8 +75,12 @@ void ClipCoordinates(pinnacle_data_t* coordinates) {
73 } 75 }
74} 76}
75 77
76uint16_t cirque_pinnacle_get_scale(void) { return scale_data; } 78uint16_t cirque_pinnacle_get_scale(void) {
77void cirque_pinnacle_set_scale(uint16_t scale) { scale_data = scale; } 79 return scale_data;
80}
81void cirque_pinnacle_set_scale(uint16_t scale) {
82 scale_data = scale;
83}
78 84
79// Scales data to desired X & Y resolution 85// Scales data to desired X & Y resolution
80void cirque_pinnacle_scale_data(pinnacle_data_t* coordinates, uint16_t xResolution, uint16_t yResolution) { 86void cirque_pinnacle_scale_data(pinnacle_data_t* coordinates, uint16_t xResolution, uint16_t yResolution) {
@@ -105,13 +111,13 @@ void cirque_pinnacle_clear_flags() {
105void cirque_pinnacle_enable_feed(bool feedEnable) { 111void cirque_pinnacle_enable_feed(bool feedEnable) {
106 uint8_t temp; 112 uint8_t temp;
107 113
108 RAP_ReadBytes(FEEDCONFIG_1, &temp, 1); // Store contents of FeedConfig1 register 114 RAP_ReadBytes(FEEDCONFIG_1, &temp, 1); // Store contents of FeedConfig1 register
109 115
110 if (feedEnable) { 116 if (feedEnable) {
111 temp |= 0x01; // Set Feed Enable bit 117 temp |= 0x01; // Set Feed Enable bit
112 RAP_Write(0x04, temp); 118 RAP_Write(0x04, temp);
113 } else { 119 } else {
114 temp &= ~0x01; // Clear Feed Enable bit 120 temp &= ~0x01; // Clear Feed Enable bit
115 RAP_Write(0x04, temp); 121 RAP_Write(0x04, temp);
116 } 122 }
117} 123}
@@ -122,13 +128,13 @@ void cirque_pinnacle_enable_feed(bool feedEnable) {
122void ERA_ReadBytes(uint16_t address, uint8_t* data, uint16_t count) { 128void ERA_ReadBytes(uint16_t address, uint8_t* data, uint16_t count) {
123 uint8_t ERAControlValue = 0xFF; 129 uint8_t ERAControlValue = 0xFF;
124 130
125 cirque_pinnacle_enable_feed(false); // Disable feed 131 cirque_pinnacle_enable_feed(false); // Disable feed
126 132
127 RAP_Write(ERA_HIGH_BYTE, (uint8_t)(address >> 8)); // Send upper byte of ERA address 133 RAP_Write(ERA_HIGH_BYTE, (uint8_t)(address >> 8)); // Send upper byte of ERA address
128 RAP_Write(ERA_LOW_BYTE, (uint8_t)(address & 0x00FF)); // Send lower byte of ERA address 134 RAP_Write(ERA_LOW_BYTE, (uint8_t)(address & 0x00FF)); // Send lower byte of ERA address
129 135
130 for (uint16_t i = 0; i < count; i++) { 136 for (uint16_t i = 0; i < count; i++) {
131 RAP_Write(ERA_CONTROL, 0x05); // Signal ERA-read (auto-increment) to Pinnacle 137 RAP_Write(ERA_CONTROL, 0x05); // Signal ERA-read (auto-increment) to Pinnacle
132 138
133 // Wait for status register 0x1E to clear 139 // Wait for status register 0x1E to clear
134 do { 140 do {
@@ -145,14 +151,14 @@ void ERA_ReadBytes(uint16_t address, uint8_t* data, uint16_t count) {
145void ERA_WriteByte(uint16_t address, uint8_t data) { 151void ERA_WriteByte(uint16_t address, uint8_t data) {
146 uint8_t ERAControlValue = 0xFF; 152 uint8_t ERAControlValue = 0xFF;
147 153
148 cirque_pinnacle_enable_feed(false); // Disable feed 154 cirque_pinnacle_enable_feed(false); // Disable feed
149 155
150 RAP_Write(ERA_VALUE, data); // Send data byte to be written 156 RAP_Write(ERA_VALUE, data); // Send data byte to be written
151 157
152 RAP_Write(ERA_HIGH_BYTE, (uint8_t)(address >> 8)); // Upper byte of ERA address 158 RAP_Write(ERA_HIGH_BYTE, (uint8_t)(address >> 8)); // Upper byte of ERA address
153 RAP_Write(ERA_LOW_BYTE, (uint8_t)(address & 0x00FF)); // Lower byte of ERA address 159 RAP_Write(ERA_LOW_BYTE, (uint8_t)(address & 0x00FF)); // Lower byte of ERA address
154 160
155 RAP_Write(ERA_CONTROL, 0x02); // Signal an ERA-write to Pinnacle 161 RAP_Write(ERA_CONTROL, 0x02); // Signal an ERA-write to Pinnacle
156 162
157 // Wait for status register 0x1E to clear 163 // Wait for status register 0x1E to clear
158 do { 164 do {
@@ -166,7 +172,7 @@ void cirque_pinnacle_set_adc_attenuation(uint8_t adcGain) {
166 uint8_t temp = 0x00; 172 uint8_t temp = 0x00;
167 173
168 ERA_ReadBytes(0x0187, &temp, 1); 174 ERA_ReadBytes(0x0187, &temp, 1);
169 temp &= 0x3F; // clear top two bits 175 temp &= 0x3F; // clear top two bits
170 temp |= adcGain; 176 temp |= adcGain;
171 ERA_WriteByte(0x0187, temp); 177 ERA_WriteByte(0x0187, temp);
172 ERA_ReadBytes(0x0187, &temp, 1); 178 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);
26 26
27// Coordinate scaling values 27// Coordinate scaling values
28#ifndef CIRQUE_PINNACLE_X_LOWER 28#ifndef CIRQUE_PINNACLE_X_LOWER
29# define CIRQUE_PINNACLE_X_LOWER 127 // min "reachable" X value 29# define CIRQUE_PINNACLE_X_LOWER 127 // min "reachable" X value
30#endif 30#endif
31#ifndef CIRQUE_PINNACLE_X_UPPER 31#ifndef CIRQUE_PINNACLE_X_UPPER
32# define CIRQUE_PINNACLE_X_UPPER 1919 // max "reachable" X value 32# define CIRQUE_PINNACLE_X_UPPER 1919 // max "reachable" X value
33#endif 33#endif
34#ifndef CIRQUE_PINNACLE_Y_LOWER 34#ifndef CIRQUE_PINNACLE_Y_LOWER
35# define CIRQUE_PINNACLE_Y_LOWER 63 // min "reachable" Y value 35# define CIRQUE_PINNACLE_Y_LOWER 63 // min "reachable" Y value
36#endif 36#endif
37#ifndef CIRQUE_PINNACLE_Y_UPPER 37#ifndef CIRQUE_PINNACLE_Y_UPPER
38# define CIRQUE_PINNACLE_Y_UPPER 1471 // max "reachable" Y value 38# define CIRQUE_PINNACLE_Y_UPPER 1471 // max "reachable" Y value
39#endif 39#endif
40#ifndef CIRQUE_PINNACLE_X_RANGE 40#ifndef CIRQUE_PINNACLE_X_RANGE
41# define CIRQUE_PINNACLE_X_RANGE (CIRQUE_PINNACLE_X_UPPER - CIRQUE_PINNACLE_X_LOWER) 41# 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;
14/* RAP Functions */ 14/* RAP Functions */
15// Reads <count> Pinnacle registers starting at <address> 15// Reads <count> Pinnacle registers starting at <address>
16void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) { 16void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) {
17 uint8_t cmdByte = READ_MASK | address; // Form the READ command byte 17 uint8_t cmdByte = READ_MASK | address; // Form the READ command byte
18 if (touchpad_init) { 18 if (touchpad_init) {
19 i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, NULL, 0, CIRQUE_PINNACLE_TIMEOUT); 19 i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, NULL, 0, CIRQUE_PINNACLE_TIMEOUT);
20 if (i2c_readReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, data, count, CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) { 20 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) {
29 29
30// Writes single-byte <data> to <address> 30// Writes single-byte <data> to <address>
31void RAP_Write(uint8_t address, uint8_t data) { 31void RAP_Write(uint8_t address, uint8_t data) {
32 uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte 32 uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte
33 33
34 if (touchpad_init) { 34 if (touchpad_init) {
35 if (i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, &data, sizeof(data), CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) { 35 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;
13/* RAP Functions */ 13/* RAP Functions */
14// Reads <count> Pinnacle registers starting at <address> 14// Reads <count> Pinnacle registers starting at <address>
15void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) { 15void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) {
16 uint8_t cmdByte = READ_MASK | address; // Form the READ command byte 16 uint8_t cmdByte = READ_MASK | address; // Form the READ command byte
17 if (touchpad_init) { 17 if (touchpad_init) {
18 if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) { 18 if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) {
19 spi_write(cmdByte); 19 spi_write(cmdByte);
20 spi_read(); // filler 20 spi_read(); // filler
21 spi_read(); // filler 21 spi_read(); // filler
22 for (uint8_t i = 0; i < count; i++) { 22 for (uint8_t i = 0; i < count; i++) {
23 data[i] = spi_read(); // each sepsequent read gets another register's contents 23 data[i] = spi_read(); // each sepsequent read gets another register's contents
24 } 24 }
25 } else { 25 } else {
26#ifdef CONSOLE_ENABLE 26#ifdef CONSOLE_ENABLE
@@ -34,7 +34,7 @@ void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) {
34 34
35// Writes single-byte <data> to <address> 35// Writes single-byte <data> to <address>
36void RAP_Write(uint8_t address, uint8_t data) { 36void RAP_Write(uint8_t address, uint8_t data) {
37 uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte 37 uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte
38 38
39 if (touchpad_init) { 39 if (touchpad_init) {
40 if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) { 40 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 @@
33 33
34static uint16_t precision = 128; 34static uint16_t precision = 128;
35 35
36uint16_t pimoroni_trackball_get_cpi(void) { return (precision * 125); } 36uint16_t pimoroni_trackball_get_cpi(void) {
37 return (precision * 125);
38}
37/** 39/**
38 * @brief Sets the scaling value for pimoroni trackball 40 * @brief Sets the scaling value for pimoroni trackball
39 * 41 *
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 @@
86bool _inBurst = false; 86bool _inBurst = false;
87 87
88#ifdef CONSOLE_ENABLE 88#ifdef CONSOLE_ENABLE
89void 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')); } 89void print_byte(uint8_t byte) {
90 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'));
91}
90#endif 92#endif
91#define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt))) 93#define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt)))
92 94
@@ -144,7 +146,7 @@ bool pmw3360_init(void) {
144 pmw3360_spi_start(); 146 pmw3360_spi_start();
145 spi_stop(); 147 spi_stop();
146 148
147 pmw3360_write(REG_Shutdown, 0xb6); // Shutdown first 149 pmw3360_write(REG_Shutdown, 0xb6); // Shutdown first
148 wait_ms(300); 150 wait_ms(300);
149 151
150 pmw3360_spi_start(); 152 pmw3360_spi_start();
@@ -222,7 +224,7 @@ bool pmw3360_check_signature(void) {
222 uint8_t pid = pmw3360_read(REG_Product_ID); 224 uint8_t pid = pmw3360_read(REG_Product_ID);
223 uint8_t iv_pid = pmw3360_read(REG_Inverse_Product_ID); 225 uint8_t iv_pid = pmw3360_read(REG_Inverse_Product_ID);
224 uint8_t SROM_ver = pmw3360_read(REG_SROM_ID); 226 uint8_t SROM_ver = pmw3360_read(REG_SROM_ID);
225 return (pid == firmware_signature[0] && iv_pid == firmware_signature[1] && SROM_ver == firmware_signature[2]); // signature for SROM 0x04 227 return (pid == firmware_signature[0] && iv_pid == firmware_signature[1] && SROM_ver == firmware_signature[2]); // signature for SROM 0x04
226} 228}
227 229
228uint16_t pmw3360_get_cpi(void) { 230uint16_t pmw3360_get_cpi(void) {
@@ -248,17 +250,17 @@ report_pmw3360_t pmw3360_read_burst(void) {
248 250
249 pmw3360_spi_start(); 251 pmw3360_spi_start();
250 spi_write(REG_Motion_Burst); 252 spi_write(REG_Motion_Burst);
251 wait_us(35); // waits for tSRAD_MOTBR 253 wait_us(35); // waits for tSRAD_MOTBR
252 254
253 report.motion = spi_read(); 255 report.motion = spi_read();
254 spi_read(); // skip Observation 256 spi_read(); // skip Observation
255 // delta registers 257 // delta registers
256 report.dx = spi_read(); 258 report.dx = spi_read();
257 report.mdx = spi_read(); 259 report.mdx = spi_read();
258 report.dy = spi_read(); 260 report.dy = spi_read();
259 report.mdy = spi_read(); 261 report.mdy = spi_read();
260 262
261 if (report.motion & 0b111) { // panic recovery, sometimes burst mode works weird. 263 if (report.motion & 0b111) { // panic recovery, sometimes burst mode works weird.
262 _inBurst = false; 264 _inBurst = false;
263 } 265 }
264 266
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 @@
58 58
59typedef struct { 59typedef struct {
60 int8_t motion; 60 int8_t motion;
61 bool isMotion; // True if a motion is detected. 61 bool isMotion; // True if a motion is detected.
62 bool isOnSurface; // True when a chip is on a surface 62 bool isOnSurface; // True when a chip is on a surface
63 int16_t dx; // displacement on x directions. Unit: Count. (CPI * Count = Inch value) 63 int16_t dx; // displacement on x directions. Unit: Count. (CPI * Count = Inch value)
64 int8_t mdx; 64 int8_t mdx;
65 int16_t dy; // displacement on y directions. 65 int16_t dy; // displacement on y directions.
66 int8_t mdy; 66 int8_t mdy;
67} report_pmw3360_t; 67} report_pmw3360_t;
68 68
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 @@
90bool _inBurst = false; 90bool _inBurst = false;
91 91
92#ifdef CONSOLE_ENABLE 92#ifdef CONSOLE_ENABLE
93void 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')); } 93void print_byte(uint8_t byte) {
94 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'));
95}
94#endif 96#endif
95#define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt))) 97#define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt)))
96 98
@@ -148,7 +150,7 @@ bool pmw3389_init(void) {
148 pmw3389_spi_start(); 150 pmw3389_spi_start();
149 spi_stop(); 151 spi_stop();
150 152
151 pmw3389_write(REG_Shutdown, 0xb6); // Shutdown first 153 pmw3389_write(REG_Shutdown, 0xb6); // Shutdown first
152 wait_ms(300); 154 wait_ms(300);
153 155
154 pmw3389_spi_start(); 156 pmw3389_spi_start();
@@ -226,7 +228,7 @@ bool pmw3389_check_signature(void) {
226 uint8_t pid = pmw3389_read(REG_Product_ID); 228 uint8_t pid = pmw3389_read(REG_Product_ID);
227 uint8_t iv_pid = pmw3389_read(REG_Inverse_Product_ID); 229 uint8_t iv_pid = pmw3389_read(REG_Inverse_Product_ID);
228 uint8_t SROM_ver = pmw3389_read(REG_SROM_ID); 230 uint8_t SROM_ver = pmw3389_read(REG_SROM_ID);
229 return (pid == firmware_signature[0] && iv_pid == firmware_signature[1] && SROM_ver == firmware_signature[2]); // signature for SROM 0x04 231 return (pid == firmware_signature[0] && iv_pid == firmware_signature[1] && SROM_ver == firmware_signature[2]); // signature for SROM 0x04
230} 232}
231 233
232uint16_t pmw3389_get_cpi(void) { 234uint16_t pmw3389_get_cpi(void) {
@@ -254,17 +256,17 @@ report_pmw3389_t pmw3389_read_burst(void) {
254 256
255 pmw3389_spi_start(); 257 pmw3389_spi_start();
256 spi_write(REG_Motion_Burst); 258 spi_write(REG_Motion_Burst);
257 wait_us(35); // waits for tSRAD_MOTBR 259 wait_us(35); // waits for tSRAD_MOTBR
258 260
259 report.motion = spi_read(); 261 report.motion = spi_read();
260 spi_read(); // skip Observation 262 spi_read(); // skip Observation
261 // delta registers 263 // delta registers
262 report.dx = spi_read(); 264 report.dx = spi_read();
263 report.mdx = spi_read(); 265 report.mdx = spi_read();
264 report.dy = spi_read(); 266 report.dy = spi_read();
265 report.mdy = spi_read(); 267 report.mdy = spi_read();
266 268
267 if (report.motion & 0b111) { // panic recovery, sometimes burst mode works weird. 269 if (report.motion & 0b111) { // panic recovery, sometimes burst mode works weird.
268 _inBurst = false; 270 _inBurst = false;
269 } 271 }
270 272
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 @@
59 59
60typedef struct { 60typedef struct {
61 int8_t motion; 61 int8_t motion;
62 bool isMotion; // True if a motion is detected. 62 bool isMotion; // True if a motion is detected.
63 bool isOnSurface; // True when a chip is on a surface 63 bool isOnSurface; // True when a chip is on a surface
64 int16_t dx; // displacement on x directions. Unit: Count. (CPI * Count = Inch value) 64 int16_t dx; // displacement on x directions. Unit: Count. (CPI * Count = Inch value)
65 int8_t mdx; 65 int8_t mdx;
66 int16_t dy; // displacement on y directions. 66 int16_t dy; // displacement on y directions.
67 int8_t mdy; 67 int8_t mdy;
68} report_pmw3389_t; 68} report_pmw3389_t;
69 69
diff --git a/drivers/usb2422.c b/drivers/usb2422.c
index 62b919093b..8ee54b24ee 100644
--- a/drivers/usb2422.c
+++ b/drivers/usb2422.c
@@ -352,7 +352,7 @@ void USB2422_init() {
352 setPinInput(USB2422_ACTIVE_PIN); 352 setPinInput(USB2422_ACTIVE_PIN);
353#endif 353#endif
354 354
355 i2c_init(); // IC2 clk must be high at USB2422 reset release time to signal SMB configuration 355 i2c_init(); // IC2 clk must be high at USB2422 reset release time to signal SMB configuration
356} 356}
357 357
358void USB2422_configure() { 358void USB2422_configure() {
@@ -363,14 +363,14 @@ void USB2422_configure() {
363 // configure Usb2422 registers 363 // configure Usb2422 registers
364 config.VID.reg = USB2422_VENDOR_ID; 364 config.VID.reg = USB2422_VENDOR_ID;
365 config.PID.reg = USB2422_PRODUCT_ID; 365 config.PID.reg = USB2422_PRODUCT_ID;
366 config.DID.reg = USB2422_DEVICE_VER; // BCD format, eg 01.01 366 config.DID.reg = USB2422_DEVICE_VER; // BCD format, eg 01.01
367 config.CFG1.bit.SELF_BUS_PWR = 1; // self powered for now 367 config.CFG1.bit.SELF_BUS_PWR = 1; // self powered for now
368 config.CFG1.bit.HS_DISABLE = 1; // full or high speed 368 config.CFG1.bit.HS_DISABLE = 1; // full or high speed
369 // config.CFG2.bit.COMPOUND = 0; // compound device 369 // config.CFG2.bit.COMPOUND = 0; // compound device
370 config.CFG3.bit.STRING_EN = 1; // strings enabled 370 config.CFG3.bit.STRING_EN = 1; // strings enabled
371 // config.NRD.bit.PORT2_NR = 0; // MCU is non-removable 371 // config.NRD.bit.PORT2_NR = 0; // MCU is non-removable
372 config.MAXPB.reg = 20; // 0mA 372 config.MAXPB.reg = 20; // 0mA
373 config.HCMCB.reg = 20; // 0mA 373 config.HCMCB.reg = 20; // 0mA
374 config.MFRSL.reg = sizeof(USB2422_MANUFACTURER); 374 config.MFRSL.reg = sizeof(USB2422_MANUFACTURER);
375 config.PRDSL.reg = sizeof(USB2422_PRODUCT); 375 config.PRDSL.reg = sizeof(USB2422_PRODUCT);
376 config.SERSL.reg = sizeof(SERNAME); 376 config.SERSL.reg = sizeof(SERNAME);
diff --git a/drivers/ws2812.h b/drivers/ws2812.h
index 945b3d0728..5985b5340c 100644
--- a/drivers/ws2812.h
+++ b/drivers/ws2812.h
@@ -33,19 +33,19 @@
33#endif 33#endif
34 34
35#ifndef WS2812_T1H 35#ifndef WS2812_T1H
36# define WS2812_T1H 900 // Width of a 1 bit in ns 36# define WS2812_T1H 900 // Width of a 1 bit in ns
37#endif 37#endif
38 38
39#ifndef WS2812_T1L 39#ifndef WS2812_T1L
40# define WS2812_T1L (WS2812_TIMING - WS2812_T1H) // Width of a 1 bit in ns 40# define WS2812_T1L (WS2812_TIMING - WS2812_T1H) // Width of a 1 bit in ns
41#endif 41#endif
42 42
43#ifndef WS2812_T0H 43#ifndef WS2812_T0H
44# define WS2812_T0H 350 // Width of a 0 bit in ns 44# define WS2812_T0H 350 // Width of a 0 bit in ns
45#endif 45#endif
46 46
47#ifndef WS2812_T0L 47#ifndef WS2812_T0L
48# define WS2812_T0L (WS2812_TIMING - WS2812_T0H) // Width of a 0 bit in ns 48# define WS2812_T0L (WS2812_TIMING - WS2812_T0H) // Width of a 0 bit in ns
49#endif 49#endif
50 50
51/* 51/*