aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/battery/battery.c10
-rw-r--r--drivers/battery/battery.h12
-rw-r--r--drivers/bluetooth/bluetooth.c74
-rw-r--r--drivers/bluetooth/bluetooth.h39
-rw-r--r--drivers/bluetooth/bluetooth_drivers.c71
-rw-r--r--drivers/bluetooth/outputselect.c70
-rw-r--r--drivers/bluetooth/outputselect.h24
-rw-r--r--drivers/lcd/st7565.c3
-rw-r--r--drivers/oled/oled_driver.c4
-rw-r--r--drivers/sensors/adns5050.c6
-rw-r--r--drivers/sensors/adns5050.h2
-rw-r--r--drivers/sensors/adns9800.c11
-rw-r--r--drivers/sensors/adns9800.h2
-rw-r--r--drivers/sensors/analog_joystick.c4
-rw-r--r--drivers/sensors/analog_joystick.h2
-rw-r--r--drivers/sensors/azoteq_iqs5xx.c100
-rw-r--r--drivers/sensors/azoteq_iqs5xx.h9
-rw-r--r--drivers/sensors/cirque_pinnacle.c7
-rw-r--r--drivers/sensors/cirque_pinnacle.h2
-rw-r--r--drivers/sensors/cirque_pinnacle_i2c.c21
-rw-r--r--drivers/sensors/cirque_pinnacle_spi.c41
-rw-r--r--drivers/sensors/paw3204.c16
-rw-r--r--drivers/sensors/paw3204.h2
-rw-r--r--drivers/sensors/pimoroni_trackball.c7
-rw-r--r--drivers/sensors/pimoroni_trackball.h2
-rw-r--r--drivers/sensors/pmw3320.c6
-rw-r--r--drivers/sensors/pmw3320.h2
-rw-r--r--drivers/sensors/pmw3389.c2
-rw-r--r--drivers/sensors/pmw33xx_common.c6
-rw-r--r--drivers/sensors/pmw33xx_common.h7
-rw-r--r--drivers/wear_leveling/wear_leveling_flash_spi.c1
31 files changed, 305 insertions, 260 deletions
diff --git a/drivers/battery/battery.c b/drivers/battery/battery.c
index 65497399e8..faf3c5a214 100644
--- a/drivers/battery/battery.c
+++ b/drivers/battery/battery.c
@@ -17,11 +17,21 @@ void battery_init(void) {
last_bat_level = battery_driver_sample_percent();
}
+__attribute__((weak)) void battery_percent_changed_user(uint8_t level) {}
+__attribute__((weak)) void battery_percent_changed_kb(uint8_t level) {}
+
+static void handle_percent_changed(void) {
+ battery_percent_changed_user(last_bat_level);
+ battery_percent_changed_kb(last_bat_level);
+}
+
void battery_task(void) {
static uint32_t bat_timer = 0;
if (timer_elapsed32(bat_timer) > BATTERY_SAMPLE_INTERVAL) {
last_bat_level = battery_driver_sample_percent();
+ handle_percent_changed();
+
bat_timer = timer_read32();
}
}
diff --git a/drivers/battery/battery.h b/drivers/battery/battery.h
index 831b1f07e5..0985723eaa 100644
--- a/drivers/battery/battery.h
+++ b/drivers/battery/battery.h
@@ -31,4 +31,16 @@ void battery_task(void);
*/
uint8_t battery_get_percent(void);
+/**
+ * \brief user hook called when battery level changed.
+ *
+ */
+void battery_percent_changed_user(uint8_t level);
+
+/**
+ * \brief keyboard hook called when battery level changed.
+ *
+ */
+void battery_percent_changed_kb(uint8_t level);
+
/** \} */
diff --git a/drivers/bluetooth/bluetooth.c b/drivers/bluetooth/bluetooth.c
index d5382401e7..e61e24e1f2 100644
--- a/drivers/bluetooth/bluetooth.c
+++ b/drivers/bluetooth/bluetooth.c
@@ -1,62 +1,32 @@
-/*
- * Copyright 2022
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+// Copyright 2025 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
#include "bluetooth.h"
-#if defined(BLUETOOTH_BLUEFRUIT_LE)
-# include "bluefruit_le.h"
-#elif defined(BLUETOOTH_RN42)
-# include "rn42.h"
-#endif
-
-void bluetooth_init(void) {
-#if defined(BLUETOOTH_BLUEFRUIT_LE)
- bluefruit_le_init();
-#elif defined(BLUETOOTH_RN42)
- rn42_init();
-#endif
-}
+__attribute__((weak)) void bluetooth_init(void) {}
-void bluetooth_task(void) {
-#if defined(BLUETOOTH_BLUEFRUIT_LE)
- bluefruit_le_task();
-#endif
-}
+__attribute__((weak)) void bluetooth_task(void) {}
-void bluetooth_send_keyboard(report_keyboard_t *report) {
-#if defined(BLUETOOTH_BLUEFRUIT_LE)
- bluefruit_le_send_keyboard(report);
-#elif defined(BLUETOOTH_RN42)
- rn42_send_keyboard(report);
-#endif
+__attribute__((weak)) bool bluetooth_is_connected(void) {
+ return true;
}
-void bluetooth_send_mouse(report_mouse_t *report) {
-#if defined(BLUETOOTH_BLUEFRUIT_LE)
- bluefruit_le_send_mouse(report);
-#elif defined(BLUETOOTH_RN42)
- rn42_send_mouse(report);
-#endif
+__attribute__((weak)) bool bluetooth_can_send_nkro(void) {
+ return false;
}
-void bluetooth_send_consumer(uint16_t usage) {
-#if defined(BLUETOOTH_BLUEFRUIT_LE)
- bluefruit_le_send_consumer(usage);
-#elif defined(BLUETOOTH_RN42)
- rn42_send_consumer(usage);
-#endif
+__attribute__((weak)) uint8_t bluetooth_keyboard_leds(void) {
+ return 0;
}
+
+__attribute__((weak)) void bluetooth_send_keyboard(report_keyboard_t *report) {}
+
+__attribute__((weak)) void bluetooth_send_nkro(report_nkro_t *report) {}
+
+__attribute__((weak)) void bluetooth_send_mouse(report_mouse_t *report) {}
+
+__attribute__((weak)) void bluetooth_send_consumer(uint16_t usage) {}
+
+__attribute__((weak)) void bluetooth_send_system(uint16_t usage) {}
+
+__attribute__((weak)) void bluetooth_send_raw_hid(uint8_t *data, uint8_t length) {}
diff --git a/drivers/bluetooth/bluetooth.h b/drivers/bluetooth/bluetooth.h
index 2e4d0df538..bbd41a9194 100644
--- a/drivers/bluetooth/bluetooth.h
+++ b/drivers/bluetooth/bluetooth.h
@@ -31,6 +31,23 @@ void bluetooth_init(void);
void bluetooth_task(void);
/**
+ * \brief Detects if Bluetooth is connected.
+ *
+ * \return `true` if connected, `false` otherwise.
+ */
+bool bluetooth_is_connected(void);
+
+/**
+ * \brief Detects if `bluetooth_send_nkro` should be used over `bluetooth_send_keyboard`.
+ */
+bool bluetooth_can_send_nkro(void);
+
+/**
+ * \brief Get current LED state.
+ */
+uint8_t bluetooth_keyboard_leds(void);
+
+/**
* \brief Send a keyboard report.
*
* \param report The keyboard report to send.
@@ -38,6 +55,13 @@ void bluetooth_task(void);
void bluetooth_send_keyboard(report_keyboard_t *report);
/**
+ * \brief Send a nkro report.
+ *
+ * \param report The nkro report to send.
+ */
+void bluetooth_send_nkro(report_nkro_t *report);
+
+/**
* \brief Send a mouse report.
*
* \param report The mouse report to send.
@@ -50,3 +74,18 @@ void bluetooth_send_mouse(report_mouse_t *report);
* \param usage The consumer usage to send.
*/
void bluetooth_send_consumer(uint16_t usage);
+
+/**
+ * \brief Send a system usage.
+ *
+ * \param usage The system usage to send.
+ */
+void bluetooth_send_system(uint16_t usage);
+
+/**
+ * \brief Send a raw_hid packet.
+ *
+ * \param data A pointer to the buffer to be sent. Always 32 bytes in length.
+ * \param length The length of the buffer. Always 32.
+ */
+void bluetooth_send_raw_hid(uint8_t *data, uint8_t length);
diff --git a/drivers/bluetooth/bluetooth_drivers.c b/drivers/bluetooth/bluetooth_drivers.c
new file mode 100644
index 0000000000..b91d4501e6
--- /dev/null
+++ b/drivers/bluetooth/bluetooth_drivers.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2022
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "bluetooth.h"
+
+#if defined(BLUETOOTH_BLUEFRUIT_LE)
+# include "bluefruit_le.h"
+#elif defined(BLUETOOTH_RN42)
+# include "rn42.h"
+#endif
+
+void bluetooth_init(void) {
+#if defined(BLUETOOTH_BLUEFRUIT_LE)
+ bluefruit_le_init();
+#elif defined(BLUETOOTH_RN42)
+ rn42_init();
+#endif
+}
+
+void bluetooth_task(void) {
+#if defined(BLUETOOTH_BLUEFRUIT_LE)
+ bluefruit_le_task();
+#endif
+}
+
+bool bluetooth_is_connected(void) {
+#if defined(BLUETOOTH_BLUEFRUIT_LE)
+ return bluefruit_le_is_connected();
+#else
+ // TODO: drivers should check if BT is connected here
+ return true;
+#endif
+}
+
+void bluetooth_send_keyboard(report_keyboard_t *report) {
+#if defined(BLUETOOTH_BLUEFRUIT_LE)
+ bluefruit_le_send_keyboard(report);
+#elif defined(BLUETOOTH_RN42)
+ rn42_send_keyboard(report);
+#endif
+}
+
+void bluetooth_send_mouse(report_mouse_t *report) {
+#if defined(BLUETOOTH_BLUEFRUIT_LE)
+ bluefruit_le_send_mouse(report);
+#elif defined(BLUETOOTH_RN42)
+ rn42_send_mouse(report);
+#endif
+}
+
+void bluetooth_send_consumer(uint16_t usage) {
+#if defined(BLUETOOTH_BLUEFRUIT_LE)
+ bluefruit_le_send_consumer(usage);
+#elif defined(BLUETOOTH_RN42)
+ rn42_send_consumer(usage);
+#endif
+}
diff --git a/drivers/bluetooth/outputselect.c b/drivers/bluetooth/outputselect.c
deleted file mode 100644
index b986ba274e..0000000000
--- a/drivers/bluetooth/outputselect.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-Copyright 2017 Priyadi Iman Nurcahyo
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "outputselect.h"
-#include "usb_util.h"
-
-#ifdef BLUETOOTH_BLUEFRUIT_LE
-# include "bluefruit_le.h"
-#endif
-
-uint8_t desired_output = OUTPUT_DEFAULT;
-
-/** \brief Set Output
- *
- * FIXME: Needs doc
- */
-void set_output(uint8_t output) {
- set_output_user(output);
- desired_output = output;
-}
-
-/** \brief Set Output User
- *
- * FIXME: Needs doc
- */
-__attribute__((weak)) void set_output_user(uint8_t output) {}
-
-/** \brief Auto Detect Output
- *
- * FIXME: Needs doc
- */
-uint8_t auto_detect_output(void) {
- if (usb_connected_state()) {
- return OUTPUT_USB;
- }
-
-#ifdef BLUETOOTH_BLUEFRUIT_LE
- if (bluefruit_le_is_connected()) {
- return OUTPUT_BLUETOOTH;
- }
-#endif
-
-#ifdef BLUETOOTH_ENABLE
- return OUTPUT_BLUETOOTH; // should check if BT is connected here
-#endif
-
- return OUTPUT_NONE;
-}
-
-/** \brief Where To Send
- *
- * FIXME: Needs doc
- */
-uint8_t where_to_send(void) {
- if (desired_output == OUTPUT_AUTO) {
- return auto_detect_output();
- }
- return desired_output;
-}
diff --git a/drivers/bluetooth/outputselect.h b/drivers/bluetooth/outputselect.h
index c4548e1122..25f063bbff 100644
--- a/drivers/bluetooth/outputselect.h
+++ b/drivers/bluetooth/outputselect.h
@@ -14,21 +14,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
-#include <stdint.h>
+#include "connection.h"
-enum outputs {
- OUTPUT_AUTO,
+// DEPRECATED - DO NOT USE
- OUTPUT_NONE,
- OUTPUT_USB,
- OUTPUT_BLUETOOTH
-};
+#define OUTPUT_AUTO CONNECTION_HOST_AUTO
+#define OUTPUT_NONE CONNECTION_HOST_NONE
+#define OUTPUT_USB CONNECTION_HOST_USB
+#define OUTPUT_BLUETOOTH CONNECTION_HOST_BLUETOOTH
-#ifndef OUTPUT_DEFAULT
-# define OUTPUT_DEFAULT OUTPUT_AUTO
-#endif
+#define set_output connection_set_host_noeeprom
+#define where_to_send connection_get_host
+#define auto_detect_output connection_auto_detect_host
-void set_output(uint8_t output);
-void set_output_user(uint8_t output);
-uint8_t auto_detect_output(void);
-uint8_t where_to_send(void);
+void set_output_user(uint8_t output);
diff --git a/drivers/lcd/st7565.c b/drivers/lcd/st7565.c
index cf71c5e5a3..f24bb78048 100644
--- a/drivers/lcd/st7565.c
+++ b/drivers/lcd/st7565.c
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <string.h>
+#include "compiler_support.h"
#include "keyboard.h"
#include "progmem.h"
#include "timer.h"
@@ -265,7 +266,7 @@ void st7565_write_char(const char data, bool invert) {
static uint8_t st7565_temp_buffer[ST7565_FONT_WIDTH];
memcpy(&st7565_temp_buffer, st7565_cursor, ST7565_FONT_WIDTH);
- _Static_assert(sizeof(font) >= ((ST7565_FONT_END + 1 - ST7565_FONT_START) * ST7565_FONT_WIDTH), "ST7565_FONT_END references outside array");
+ STATIC_ASSERT(sizeof(font) >= ((ST7565_FONT_END + 1 - ST7565_FONT_START) * ST7565_FONT_WIDTH), "ST7565_FONT_END references outside array");
// set the reder buffer data
uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index
diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c
index 1d1c2a90c4..7e46bcb3f7 100644
--- a/drivers/oled/oled_driver.c
+++ b/drivers/oled/oled_driver.c
@@ -23,6 +23,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "keyboard.h"
# endif
#endif
+
+#include "compiler_support.h"
#include "oled_driver.h"
#include OLED_FONT_H
#include "timer.h"
@@ -601,7 +603,7 @@ void oled_write_char(const char data, bool invert) {
static uint8_t oled_temp_buffer[OLED_FONT_WIDTH];
memcpy(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH);
- _Static_assert(sizeof(font) >= ((OLED_FONT_END + 1 - OLED_FONT_START) * OLED_FONT_WIDTH), "OLED_FONT_END references outside array");
+ STATIC_ASSERT(sizeof(font) >= ((OLED_FONT_END + 1 - OLED_FONT_START) * OLED_FONT_WIDTH), "OLED_FONT_END references outside array");
// set the reder buffer data
uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index
diff --git a/drivers/sensors/adns5050.c b/drivers/sensors/adns5050.c
index 1768c9f3b4..ac4c95b0c2 100644
--- a/drivers/sensors/adns5050.c
+++ b/drivers/sensors/adns5050.c
@@ -55,7 +55,7 @@ const pointing_device_driver_t adns5050_pointing_device_driver = {
static bool powered_down = false;
-void adns5050_init(void) {
+bool adns5050_init(void) {
// Initialize the ADNS serial pins.
gpio_set_pin_output(ADNS5050_SCLK_PIN);
gpio_set_pin_output(ADNS5050_SDIO_PIN);
@@ -75,6 +75,8 @@ void adns5050_init(void) {
// gets the adns ready for write commands
// (for example, setting the dpi).
adns5050_read_burst();
+
+ return adns5050_check_signature();
}
// Perform a synchronization with the ADNS.
@@ -220,7 +222,7 @@ uint16_t adns5050_get_cpi(void) {
return (uint16_t)((cpival & 0b10000) * 125);
}
-bool adns5050_check_signature(void) {
+bool __attribute__((weak)) adns5050_check_signature(void) {
uint8_t pid = adns5050_read_reg(REG_PRODUCT_ID);
uint8_t rid = adns5050_read_reg(REG_REVISION_ID);
uint8_t pid2 = adns5050_read_reg(REG_PRODUCT_ID2);
diff --git a/drivers/sensors/adns5050.h b/drivers/sensors/adns5050.h
index 4dfcbc3c70..004c54f560 100644
--- a/drivers/sensors/adns5050.h
+++ b/drivers/sensors/adns5050.h
@@ -75,7 +75,7 @@ const pointing_device_driver_t adns5050_pointing_device_driver;
// A bunch of functions to implement the ADNS5050-specific serial protocol.
// Note that the "serial.h" driver is insufficient, because it does not
// manually manipulate a serial clock signal.
-void adns5050_init(void);
+bool adns5050_init(void);
void adns5050_sync(void);
uint8_t adns5050_serial_read(void);
void adns5050_serial_write(uint8_t data);
diff --git a/drivers/sensors/adns9800.c b/drivers/sensors/adns9800.c
index 0dbc528351..f5958dd350 100644
--- a/drivers/sensors/adns9800.c
+++ b/drivers/sensors/adns9800.c
@@ -115,7 +115,14 @@ uint8_t adns9800_read(uint8_t reg_addr) {
return data;
}
-void adns9800_init(void) {
+bool __attribute__((weak)) adns9800_check_signature(void) {
+ if (adns9800_read(REG_Product_ID) != 0x33) {
+ return false;
+ }
+ return true;
+}
+
+bool adns9800_init(void) {
gpio_set_pin_output(ADNS9800_CS_PIN);
spi_init();
@@ -178,6 +185,8 @@ void adns9800_init(void) {
adns9800_write(REG_LASER_CTRL0, laser_ctrl0 & 0xf0);
adns9800_set_cpi(ADNS9800_CPI);
+
+ return adns9800_check_signature();
}
config_adns9800_t adns9800_get_config(void) {
diff --git a/drivers/sensors/adns9800.h b/drivers/sensors/adns9800.h
index 023f31b132..797aaf3cd0 100644
--- a/drivers/sensors/adns9800.h
+++ b/drivers/sensors/adns9800.h
@@ -63,7 +63,7 @@ typedef struct {
const pointing_device_driver_t adns9800_pointing_device_driver;
-void adns9800_init(void);
+bool adns9800_init(void);
config_adns9800_t adns9800_get_config(void);
void adns9800_set_config(config_adns9800_t);
uint16_t adns9800_get_cpi(void);
diff --git a/drivers/sensors/analog_joystick.c b/drivers/sensors/analog_joystick.c
index 93bbaa1b51..eec97e8eed 100644
--- a/drivers/sensors/analog_joystick.c
+++ b/drivers/sensors/analog_joystick.c
@@ -135,7 +135,7 @@ report_analog_joystick_t analog_joystick_read(void) {
return report;
}
-void analog_joystick_init(void) {
+bool analog_joystick_init(void) {
gpio_set_pin_input_high(ANALOG_JOYSTICK_X_AXIS_PIN);
gpio_set_pin_input_high(ANALOG_JOYSTICK_Y_AXIS_PIN);
@@ -152,6 +152,8 @@ void analog_joystick_init(void) {
maxAxisValues[0] = xOrigin + 100;
maxAxisValues[1] = yOrigin + 100;
#endif
+
+ return true;
}
report_mouse_t analog_joystick_get_report(report_mouse_t mouse_report) {
diff --git a/drivers/sensors/analog_joystick.h b/drivers/sensors/analog_joystick.h
index c84da83db1..4838f502f1 100644
--- a/drivers/sensors/analog_joystick.h
+++ b/drivers/sensors/analog_joystick.h
@@ -51,5 +51,5 @@ typedef struct {
bool button;
} report_analog_joystick_t;
report_analog_joystick_t analog_joystick_read(void);
-void analog_joystick_init(void);
+bool analog_joystick_init(void);
report_mouse_t analog_joystick_get_report(report_mouse_t mouse_report);
diff --git a/drivers/sensors/azoteq_iqs5xx.c b/drivers/sensors/azoteq_iqs5xx.c
index ae26ee60cf..7586ac52d1 100644
--- a/drivers/sensors/azoteq_iqs5xx.c
+++ b/drivers/sensors/azoteq_iqs5xx.c
@@ -321,7 +321,7 @@ void azoteq_iqs5xx_setup_resolution(void) {
static i2c_status_t azoteq_iqs5xx_init_status = 1;
-void azoteq_iqs5xx_init(void) {
+bool azoteq_iqs5xx_init(void) {
i2c_init();
i2c_ping_address(AZOTEQ_IQS5XX_ADDRESS, 1); // wake
azoteq_iqs5xx_reset_suspend(true, false, true);
@@ -349,67 +349,65 @@ void azoteq_iqs5xx_init(void) {
azoteq_iqs5xx_init_status |= azoteq_iqs5xx_set_gesture_config(true);
wait_ms(AZOTEQ_IQS5XX_REPORT_RATE + 1);
}
+
+ return azoteq_iqs5xx_init_status == I2C_STATUS_SUCCESS;
};
report_mouse_t azoteq_iqs5xx_get_report(report_mouse_t mouse_report) {
report_mouse_t temp_report = {0};
- if (azoteq_iqs5xx_init_status == I2C_STATUS_SUCCESS) {
- azoteq_iqs5xx_base_data_t base_data = {0};
- i2c_status_t status = azoteq_iqs5xx_get_base_data(&base_data);
- bool ignore_movement = false;
+ azoteq_iqs5xx_base_data_t base_data = {0};
+ i2c_status_t status = azoteq_iqs5xx_get_base_data(&base_data);
+ bool ignore_movement = false;
- if (status == I2C_STATUS_SUCCESS) {
+ if (status == I2C_STATUS_SUCCESS) {
#ifdef POINTING_DEVICE_DEBUG
- if (base_data.previous_cycle_time > AZOTEQ_IQS5XX_REPORT_RATE) {
- pd_dprintf("IQS5XX - previous cycle time missed, took: %dms\n", base_data.previous_cycle_time);
- }
+ if (base_data.previous_cycle_time > AZOTEQ_IQS5XX_REPORT_RATE) {
+ pd_dprintf("IQS5XX - previous cycle time missed, took: %dms\n", base_data.previous_cycle_time);
+ }
#endif
- if (base_data.gesture_events_0.single_tap || base_data.gesture_events_0.press_and_hold) {
- pd_dprintf("IQS5XX - Single tap/hold.\n");
- temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON1);
- } else if (base_data.gesture_events_1.two_finger_tap) {
- pd_dprintf("IQS5XX - Two finger tap.\n");
- temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON2);
- } else if (base_data.gesture_events_0.swipe_x_neg) {
- pd_dprintf("IQS5XX - X-.\n");
- temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON4);
- ignore_movement = true;
- } else if (base_data.gesture_events_0.swipe_x_pos) {
- pd_dprintf("IQS5XX - X+.\n");
- temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON5);
- ignore_movement = true;
- } else if (base_data.gesture_events_0.swipe_y_neg) {
- pd_dprintf("IQS5XX - Y-.\n");
- temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON6);
- ignore_movement = true;
- } else if (base_data.gesture_events_0.swipe_y_pos) {
- pd_dprintf("IQS5XX - Y+.\n");
- temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON3);
- ignore_movement = true;
- } else if (base_data.gesture_events_1.zoom) {
- if (AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.x.h, base_data.x.l) < 0) {
- pd_dprintf("IQS5XX - Zoom out.\n");
- temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON7);
- } else if (AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.x.h, base_data.x.l) > 0) {
- pd_dprintf("IQS5XX - Zoom in.\n");
- temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON8);
- }
- } else if (base_data.gesture_events_1.scroll) {
- pd_dprintf("IQS5XX - Scroll.\n");
- temp_report.h = CONSTRAIN_HID(AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.x.h, base_data.x.l));
- temp_report.v = CONSTRAIN_HID(AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.y.h, base_data.y.l));
+ if (base_data.gesture_events_0.single_tap || base_data.gesture_events_0.press_and_hold) {
+ pd_dprintf("IQS5XX - Single tap/hold.\n");
+ temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON1);
+ } else if (base_data.gesture_events_1.two_finger_tap) {
+ pd_dprintf("IQS5XX - Two finger tap.\n");
+ temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON2);
+ } else if (base_data.gesture_events_0.swipe_x_neg) {
+ pd_dprintf("IQS5XX - X-.\n");
+ temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON4);
+ ignore_movement = true;
+ } else if (base_data.gesture_events_0.swipe_x_pos) {
+ pd_dprintf("IQS5XX - X+.\n");
+ temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON5);
+ ignore_movement = true;
+ } else if (base_data.gesture_events_0.swipe_y_neg) {
+ pd_dprintf("IQS5XX - Y-.\n");
+ temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON6);
+ ignore_movement = true;
+ } else if (base_data.gesture_events_0.swipe_y_pos) {
+ pd_dprintf("IQS5XX - Y+.\n");
+ temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON3);
+ ignore_movement = true;
+ } else if (base_data.gesture_events_1.zoom) {
+ if (AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.x.h, base_data.x.l) < 0) {
+ pd_dprintf("IQS5XX - Zoom out.\n");
+ temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON7);
+ } else if (AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.x.h, base_data.x.l) > 0) {
+ pd_dprintf("IQS5XX - Zoom in.\n");
+ temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON8);
}
- if (base_data.number_of_fingers == 1 && !ignore_movement) {
- temp_report.x = CONSTRAIN_HID_XY(AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.x.h, base_data.x.l));
- temp_report.y = CONSTRAIN_HID_XY(AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.y.h, base_data.y.l));
- }
-
- } else {
- pd_dprintf("IQS5XX - get report failed, i2c status: %d \n", status);
+ } else if (base_data.gesture_events_1.scroll) {
+ pd_dprintf("IQS5XX - Scroll.\n");
+ temp_report.h = CONSTRAIN_HID(AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.x.h, base_data.x.l));
+ temp_report.v = CONSTRAIN_HID(AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.y.h, base_data.y.l));
}
+ if (base_data.number_of_fingers == 1 && !ignore_movement) {
+ temp_report.x = CONSTRAIN_HID_XY(AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.x.h, base_data.x.l));
+ temp_report.y = CONSTRAIN_HID_XY(AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.y.h, base_data.y.l));
+ }
+
} else {
- pd_dprintf("IQS5XX - Init failed, i2c status: %d \n", azoteq_iqs5xx_init_status);
+ pd_dprintf("IQS5XX - get report failed, i2c status: %d \n", status);
}
return temp_report;
diff --git a/drivers/sensors/azoteq_iqs5xx.h b/drivers/sensors/azoteq_iqs5xx.h
index e1e8b67b31..1a70ac6149 100644
--- a/drivers/sensors/azoteq_iqs5xx.h
+++ b/drivers/sensors/azoteq_iqs5xx.h
@@ -4,6 +4,7 @@
#pragma once
+#include "compiler_support.h"
#include "i2c_master.h"
#include "pointing_device.h"
#include "util.h"
@@ -79,7 +80,7 @@ typedef struct {
azoteq_iqs5xx_relative_xy_t y;
} azoteq_iqs5xx_base_data_t;
-_Static_assert(sizeof(azoteq_iqs5xx_base_data_t) == 10, "azoteq_iqs5xx_basic_report_t should be 10 bytes");
+STATIC_ASSERT(sizeof(azoteq_iqs5xx_base_data_t) == 10, "azoteq_iqs5xx_basic_report_t should be 10 bytes");
typedef struct {
uint8_t number_of_fingers;
@@ -87,7 +88,7 @@ typedef struct {
azoteq_iqs5xx_relative_xy_t y;
} azoteq_iqs5xx_report_data_t;
-_Static_assert(sizeof(azoteq_iqs5xx_report_data_t) == 5, "azoteq_iqs5xx_report_data_t should be 5 bytes");
+STATIC_ASSERT(sizeof(azoteq_iqs5xx_report_data_t) == 5, "azoteq_iqs5xx_report_data_t should be 5 bytes");
typedef struct PACKED {
bool sw_input : 1;
@@ -159,7 +160,7 @@ typedef struct PACKED {
uint16_t zoom_consecutive_distance;
} azoteq_iqs5xx_gesture_config_t;
-_Static_assert(sizeof(azoteq_iqs5xx_gesture_config_t) == 24, "azoteq_iqs5xx_gesture_config_t should be 24 bytes");
+STATIC_ASSERT(sizeof(azoteq_iqs5xx_gesture_config_t) == 24, "azoteq_iqs5xx_gesture_config_t should be 24 bytes");
typedef struct {
uint16_t x_resolution;
@@ -179,7 +180,7 @@ typedef struct {
const pointing_device_driver_t azoteq_iqs5xx_pointing_device_driver;
-void azoteq_iqs5xx_init(void);
+bool azoteq_iqs5xx_init(void);
i2c_status_t azoteq_iqs5xx_wake(void);
report_mouse_t azoteq_iqs5xx_get_report(report_mouse_t mouse_report);
i2c_status_t azoteq_iqs5xx_get_report_rate(azoteq_iqs5xx_report_rate_t *report_rate, azoteq_iqs5xx_charging_modes_t mode, bool end_session);
diff --git a/drivers/sensors/cirque_pinnacle.c b/drivers/sensors/cirque_pinnacle.c
index 893cb98bf0..45072ae874 100644
--- a/drivers/sensors/cirque_pinnacle.c
+++ b/drivers/sensors/cirque_pinnacle.c
@@ -18,7 +18,6 @@
# endif
#endif
-bool touchpad_init;
uint16_t scale_data = CIRQUE_PINNACLE_DEFAULT_SCALE;
void cirque_pinnacle_clear_flags(void);
@@ -232,14 +231,14 @@ bool cirque_pinnacle_connected(void) {
}
/* Pinnacle-based TM040040/TM035035/TM023023 Functions */
-void cirque_pinnacle_init(void) {
+bool cirque_pinnacle_init(void) {
#if defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_spi)
spi_init();
#elif defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_i2c)
i2c_init();
#endif
- touchpad_init = true;
+ bool touchpad_init = true;
// send a RESET command now, in case QMK had a soft-reset without a power cycle
RAP_Write(HOSTREG__SYSCONFIG1, HOSTREG__SYSCONFIG1__RESET);
@@ -293,6 +292,8 @@ void cirque_pinnacle_init(void) {
#ifndef CIRQUE_PINNACLE_SKIP_SENSOR_CHECK
touchpad_init = cirque_pinnacle_connected();
#endif
+
+ return touchpad_init;
}
pinnacle_data_t cirque_pinnacle_read_data(void) {
diff --git a/drivers/sensors/cirque_pinnacle.h b/drivers/sensors/cirque_pinnacle.h
index 1a17e539a4..3541d62463 100644
--- a/drivers/sensors/cirque_pinnacle.h
+++ b/drivers/sensors/cirque_pinnacle.h
@@ -114,7 +114,7 @@ typedef struct {
#define cirque_pinnacle_spi_pointing_device_driver cirque_pinnacle_pointing_device_driver
const pointing_device_driver_t cirque_pinnacle_pointing_device_driver;
-void cirque_pinnacle_init(void);
+bool cirque_pinnacle_init(void);
void cirque_pinnacle_calibrate(void);
void cirque_pinnacle_cursor_smoothing(bool enable);
pinnacle_data_t cirque_pinnacle_read_data(void);
diff --git a/drivers/sensors/cirque_pinnacle_i2c.c b/drivers/sensors/cirque_pinnacle_i2c.c
index a3622e9d60..8d766c69d9 100644
--- a/drivers/sensors/cirque_pinnacle_i2c.c
+++ b/drivers/sensors/cirque_pinnacle_i2c.c
@@ -7,29 +7,22 @@
#define WRITE_MASK 0x80
#define READ_MASK 0xA0
-extern bool touchpad_init;
-
/* RAP Functions */
// Reads <count> Pinnacle registers starting at <address>
void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) {
uint8_t cmdByte = READ_MASK | address; // Form the READ command byte
- if (touchpad_init) {
- i2c_write_register(CIRQUE_PINNACLE_ADDR << 1, cmdByte, NULL, 0, CIRQUE_PINNACLE_TIMEOUT);
- if (i2c_read_register(CIRQUE_PINNACLE_ADDR << 1, cmdByte, data, count, CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) {
- pd_dprintf("error cirque_pinnacle i2c_read_register\n");
- touchpad_init = false;
- }
+ i2c_write_register(CIRQUE_PINNACLE_ADDR << 1, cmdByte, NULL, 0, CIRQUE_PINNACLE_TIMEOUT);
+ if (i2c_read_register(CIRQUE_PINNACLE_ADDR << 1, cmdByte, data, count, CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) {
+ pd_dprintf("error cirque_pinnacle i2c_read_register\n");
+ pointing_device_set_status(POINTING_DEVICE_STATUS_FAILED);
}
}
// Writes single-byte <data> to <address>
void RAP_Write(uint8_t address, uint8_t data) {
uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte
-
- if (touchpad_init) {
- if (i2c_write_register(CIRQUE_PINNACLE_ADDR << 1, cmdByte, &data, sizeof(data), CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) {
- pd_dprintf("error cirque_pinnacle i2c_write_register\n");
- touchpad_init = false;
- }
+ if (i2c_write_register(CIRQUE_PINNACLE_ADDR << 1, cmdByte, &data, sizeof(data), CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) {
+ pd_dprintf("error cirque_pinnacle i2c_write_register\n");
+ pointing_device_set_status(POINTING_DEVICE_STATUS_FAILED);
}
}
diff --git a/drivers/sensors/cirque_pinnacle_spi.c b/drivers/sensors/cirque_pinnacle_spi.c
index 5cb39aebb0..eefdb4d0a7 100644
--- a/drivers/sensors/cirque_pinnacle_spi.c
+++ b/drivers/sensors/cirque_pinnacle_spi.c
@@ -7,40 +7,35 @@
#define READ_MASK 0xA0
#define FILLER_BYTE 0xFC
-extern bool touchpad_init;
-
/* RAP Functions */
// Reads <count> Pinnacle registers starting at <address>
void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) {
uint8_t cmdByte = READ_MASK | address; // Form the READ command byte
- if (touchpad_init) {
- if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) {
- spi_write(cmdByte); // write command byte, receive filler
- spi_write(FILLER_BYTE); // write & receive filler
- spi_write(FILLER_BYTE); // write & receive filler
- for (uint8_t i = 0; i < count; i++) {
- data[i] = spi_write(FILLER_BYTE); // write filler, receive data on the third filler send
- }
- } else {
- pd_dprintf("error cirque_pinnacle spi_start read\n");
- touchpad_init = false;
+
+ if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) {
+ spi_write(cmdByte); // write command byte, receive filler
+ spi_write(FILLER_BYTE); // write & receive filler
+ spi_write(FILLER_BYTE); // write & receive filler
+ for (uint8_t i = 0; i < count; i++) {
+ data[i] = spi_write(FILLER_BYTE); // write filler, receive data on the third filler send
}
- spi_stop();
+ } else {
+ pd_dprintf("error cirque_pinnacle spi_start read\n");
+ pointing_device_set_status(POINTING_DEVICE_STATUS_FAILED);
}
+ spi_stop();
}
// Writes single-byte <data> to <address>
void RAP_Write(uint8_t address, uint8_t data) {
uint8_t cmdByte = WRITE_MASK | address; // Form the WRITE command byte
- if (touchpad_init) {
- if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) {
- spi_write(cmdByte);
- spi_write(data);
- } else {
- pd_dprintf("error cirque_pinnacle spi_start write\n");
- touchpad_init = false;
- }
- spi_stop();
+ if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) {
+ spi_write(cmdByte);
+ spi_write(data);
+ } else {
+ pd_dprintf("error cirque_pinnacle spi_start write\n");
+ pointing_device_set_status(POINTING_DEVICE_STATUS_FAILED);
}
+ spi_stop();
}
diff --git a/drivers/sensors/paw3204.c b/drivers/sensors/paw3204.c
index 475821f175..228b7fa986 100644
--- a/drivers/sensors/paw3204.c
+++ b/drivers/sensors/paw3204.c
@@ -58,7 +58,15 @@ const pointing_device_driver_t paw3204_pointing_device_driver = {
.get_cpi = paw3204_get_cpi,
};
-void paw3204_init(void) {
+uint8_t read_pid_paw3204(void) {
+ return paw3204_read_reg(REG_PID1);
+}
+
+bool __attribute__((weak)) paw3204_check_signature(void) {
+ return (read_pid_paw3204() == 0x30);
+}
+
+bool paw3204_init(void) {
gpio_set_pin_output(PAW3204_SCLK_PIN); // setclockpin to output
gpio_set_pin_input_high(PAW3204_SDIO_PIN); // set datapin input high
@@ -69,6 +77,8 @@ void paw3204_init(void) {
paw3204_read_reg(0x01); // read id2
// PAW3204_write_reg(REG_SETUP,0x06); // dont reset sensor and set cpi 1600
paw3204_write_reg(REG_IMGTRASH, 0x32); // write image trashhold
+
+ return paw3204_check_signature();
}
uint8_t paw3204_serial_read(void) {
@@ -175,10 +185,6 @@ uint16_t paw3204_get_cpi(void) {
return cpival;
}
-uint8_t read_pid_paw3204(void) {
- return paw3204_read_reg(REG_PID1);
-}
-
report_mouse_t paw3204_get_report(report_mouse_t mouse_report) {
report_paw3204_t data = paw3204_read();
if (data.isMotion) {
diff --git a/drivers/sensors/paw3204.h b/drivers/sensors/paw3204.h
index a4bb8e16a6..11759d64c3 100644
--- a/drivers/sensors/paw3204.h
+++ b/drivers/sensors/paw3204.h
@@ -50,7 +50,7 @@ const pointing_device_driver_t paw3204_pointing_device_driver;
* @return true Initialization was a success
* @return false Initialization failed, do not proceed operation
*/
-void paw3204_init(void);
+bool paw3204_init(void);
/**
* @brief Reads and clears the current delta, and motion register values on the
diff --git a/drivers/sensors/pimoroni_trackball.c b/drivers/sensors/pimoroni_trackball.c
index 06e5042953..daa5786554 100644
--- a/drivers/sensors/pimoroni_trackball.c
+++ b/drivers/sensors/pimoroni_trackball.c
@@ -82,9 +82,12 @@ i2c_status_t read_pimoroni_trackball(pimoroni_data_t *data) {
return status;
}
-__attribute__((weak)) void pimoroni_trackball_device_init(void) {
+__attribute__((weak)) bool pimoroni_trackball_device_init(void) {
i2c_init();
- pimoroni_trackball_set_rgbw(0x00, 0x00, 0x00, 0x00);
+ uint8_t rgbw_data[4] = {0};
+ i2c_status_t status = i2c_write_register(PIMORONI_TRACKBALL_ADDRESS << 1, PIMORONI_TRACKBALL_REG_LED_RED, rgbw_data, sizeof(rgbw_data), PIMORONI_TRACKBALL_TIMEOUT);
+
+ return (status == I2C_STATUS_SUCCESS);
}
int16_t pimoroni_trackball_get_offsets(uint8_t negative_dir, uint8_t positive_dir, uint8_t scale) {
diff --git a/drivers/sensors/pimoroni_trackball.h b/drivers/sensors/pimoroni_trackball.h
index 1904214a74..4b8a2548ae 100644
--- a/drivers/sensors/pimoroni_trackball.h
+++ b/drivers/sensors/pimoroni_trackball.h
@@ -52,7 +52,7 @@ typedef struct {
const pointing_device_driver_t pimoroni_trackball_pointing_device_driver;
-void pimoroni_trackball_device_init(void);
+bool pimoroni_trackball_device_init(void);
void pimoroni_trackball_set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white);
int16_t pimoroni_trackball_get_offsets(uint8_t negative_dir, uint8_t positive_dir, uint8_t scale);
uint16_t pimoroni_trackball_get_cpi(void);
diff --git a/drivers/sensors/pmw3320.c b/drivers/sensors/pmw3320.c
index 74fefd4c53..db74540ec1 100644
--- a/drivers/sensors/pmw3320.c
+++ b/drivers/sensors/pmw3320.c
@@ -30,7 +30,7 @@ const pointing_device_driver_t pmw3320_pointing_device_drivera = {
.get_cpi = pmw3320_get_cpi,
};
-void pmw3320_init(void) {
+bool pmw3320_init(void) {
// Initialize sensor serial pins.
gpio_set_pin_output(PMW3320_SCLK_PIN);
gpio_set_pin_output(PMW3320_SDIO_PIN);
@@ -56,6 +56,8 @@ void pmw3320_init(void) {
pmw3320_write_reg(REG_Led_Control, 0x4);
// Disable rest mode
pmw3320_write_reg(REG_Performance, 0x80);
+
+ return pmw3320_check_signature();
}
// Perform a synchronization with sensor.
@@ -192,7 +194,7 @@ void pmw3320_set_cpi(uint16_t cpi) {
pmw3320_write_reg(REG_Resolution, 0x20 | cpival);
}
-bool pmw3320_check_signature(void) {
+bool __attribute__((weak)) pmw3320_check_signature(void) {
uint8_t pid = pmw3320_read_reg(REG_Product_ID);
uint8_t pid2 = pmw3320_read_reg(REG_Inverse_Product_ID);
diff --git a/drivers/sensors/pmw3320.h b/drivers/sensors/pmw3320.h
index cfff25bd8a..42fd72a52c 100644
--- a/drivers/sensors/pmw3320.h
+++ b/drivers/sensors/pmw3320.h
@@ -61,7 +61,7 @@ const pointing_device_driver_t pmw3320_pointing_device_driver;
// Mostly taken from ADNS5050 driver.
// Note that the "serial.h" driver is insufficient, because it does not
// manually manipulate a serial clock signal.
-void pmw3320_init(void);
+bool pmw3320_init(void);
void pmw3320_sync(void);
uint8_t pmw3320_serial_read(void);
void pmw3320_serial_write(uint8_t data);
diff --git a/drivers/sensors/pmw3389.c b/drivers/sensors/pmw3389.c
index 85d2c8a429..efa90c2100 100644
--- a/drivers/sensors/pmw3389.c
+++ b/drivers/sensors/pmw3389.c
@@ -29,4 +29,4 @@ void pmw33xx_set_cpi(uint8_t sensor, uint16_t cpi) {
}
// PID, Inverse PID
-const uint8_t pmw33xx_firmware_signature[2] PROGMEM = {0x42, 0xBD};
+const uint8_t pmw33xx_firmware_signature[2] PROGMEM = {0x47, 0xB8};
diff --git a/drivers/sensors/pmw33xx_common.c b/drivers/sensors/pmw33xx_common.c
index f3285ec497..61e309ea27 100644
--- a/drivers/sensors/pmw33xx_common.c
+++ b/drivers/sensors/pmw33xx_common.c
@@ -102,7 +102,7 @@ uint8_t pmw33xx_read(uint8_t sensor, uint8_t reg_addr) {
return data;
}
-bool pmw33xx_check_signature(uint8_t sensor) {
+__attribute__((weak)) bool pmw33xx_check_signature(uint8_t sensor) {
uint8_t signature_dump[2] = {
pmw33xx_read(sensor, REG_Product_ID),
pmw33xx_read(sensor, REG_Inverse_Product_ID),
@@ -236,8 +236,8 @@ pmw33xx_report_t pmw33xx_read_burst(uint8_t sensor) {
return report;
}
-void pmw33xx_init_wrapper(void) {
- pmw33xx_init(0);
+bool pmw33xx_init_wrapper(void) {
+ return pmw33xx_init(0);
}
void pmw33xx_set_cpi_wrapper(uint16_t cpi) {
diff --git a/drivers/sensors/pmw33xx_common.h b/drivers/sensors/pmw33xx_common.h
index 22e35c3327..8fb10b1b2f 100644
--- a/drivers/sensors/pmw33xx_common.h
+++ b/drivers/sensors/pmw33xx_common.h
@@ -10,6 +10,7 @@
#pragma once
+#include "compiler_support.h"
#include "keyboard.h"
#include <stdint.h>
#include "spi_master.h"
@@ -39,8 +40,8 @@ typedef struct __attribute__((packed)) {
int16_t delta_y; // displacement on y directions.
} pmw33xx_report_t;
-_Static_assert(sizeof(pmw33xx_report_t) == 6, "pmw33xx_report_t must be 6 bytes in size");
-_Static_assert(sizeof((pmw33xx_report_t){0}.motion) == 1, "pmw33xx_report_t.motion must be 1 byte in size");
+STATIC_ASSERT(sizeof(pmw33xx_report_t) == 6, "pmw33xx_report_t must be 6 bytes in size");
+STATIC_ASSERT(sizeof((pmw33xx_report_t){0}.motion) == 1, "pmw33xx_report_t.motion must be 1 byte in size");
#if !defined(PMW33XX_CLOCK_SPEED)
# define PMW33XX_CLOCK_SPEED 2000000
@@ -176,7 +177,7 @@ uint8_t pmw33xx_read(uint8_t sensor, uint8_t reg_addr);
*/
bool pmw33xx_write(uint8_t sensor, uint8_t reg_addr, uint8_t data);
-void pmw33xx_init_wrapper(void);
+bool pmw33xx_init_wrapper(void);
void pmw33xx_set_cpi_wrapper(uint16_t cpi);
uint16_t pmw33xx_get_cpi_wrapper(void);
report_mouse_t pmw33xx_get_report(report_mouse_t mouse_report);
diff --git a/drivers/wear_leveling/wear_leveling_flash_spi.c b/drivers/wear_leveling/wear_leveling_flash_spi.c
index 304aed1641..ca2c174580 100644
--- a/drivers/wear_leveling/wear_leveling_flash_spi.c
+++ b/drivers/wear_leveling/wear_leveling_flash_spi.c
@@ -5,6 +5,7 @@
#include "util.h"
#include "timer.h"
#include "wear_leveling.h"
+#include "wear_leveling_flash_spi_config.h"
#include "wear_leveling_internal.h"
#ifndef WEAR_LEVELING_EXTERNAL_FLASH_BULK_COUNT