aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/battery/battery.c41
-rw-r--r--drivers/battery/battery.h46
-rw-r--r--drivers/battery/battery_adc.c55
-rw-r--r--drivers/battery/battery_driver.h29
-rw-r--r--drivers/bluetooth/bluefruit_le.cpp21
-rw-r--r--drivers/bluetooth/bluefruit_le.h4
-rw-r--r--drivers/bluetooth/bluetooth.c72
-rw-r--r--drivers/bluetooth/bluetooth.h31
-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/eeprom/eeprom_transient.h2
-rw-r--r--drivers/painter/gc9xxx/qp_gc9a01_opcodes.h2
-rw-r--r--drivers/painter/ili9xxx/qp_ili9486.c16
-rw-r--r--drivers/painter/ld7032/qp_ld7032.h2
-rw-r--r--drivers/painter/ld7032/qp_ld7032_opcodes.h2
-rw-r--r--drivers/sensors/pimoroni_trackball.c12
-rw-r--r--drivers/usbpd.h2
18 files changed, 322 insertions, 180 deletions
diff --git a/drivers/battery/battery.c b/drivers/battery/battery.c
new file mode 100644
index 0000000000..faf3c5a214
--- /dev/null
+++ b/drivers/battery/battery.c
@@ -0,0 +1,41 @@
+// Copyright 2025 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "battery_driver.h"
+#include "battery.h"
+#include "timer.h"
+
+#ifndef BATTERY_SAMPLE_INTERVAL
+# define BATTERY_SAMPLE_INTERVAL 30000
+#endif
+
+static uint8_t last_bat_level = 100;
+
+void battery_init(void) {
+ battery_driver_init();
+
+ 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();
+ }
+}
+
+uint8_t battery_get_percent(void) {
+ return last_bat_level;
+}
diff --git a/drivers/battery/battery.h b/drivers/battery/battery.h
new file mode 100644
index 0000000000..0985723eaa
--- /dev/null
+++ b/drivers/battery/battery.h
@@ -0,0 +1,46 @@
+// Copyright 2025 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <stdint.h>
+
+/**
+ * \file
+ *
+ * \defgroup battery Battery API
+ *
+ * \brief API to query battery status.
+ * \{
+ */
+
+/**
+ * \brief Initialize the battery driver.
+ */
+void battery_init(void);
+
+/**
+ * \brief Perform housekeeping tasks.
+ */
+void battery_task(void);
+
+/**
+ * \brief Sample battery level.
+ *
+ * \return The battery percentage, in the range 0-100.
+ */
+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/battery/battery_adc.c b/drivers/battery/battery_adc.c
new file mode 100644
index 0000000000..cf0e69cb48
--- /dev/null
+++ b/drivers/battery/battery_adc.c
@@ -0,0 +1,55 @@
+// Copyright 2025 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "analog.h"
+#include "gpio.h"
+
+#ifndef BATTERY_PIN
+# error("BATTERY_PIN not configured!")
+#endif
+
+#ifndef BATTERY_REF_VOLTAGE_MV
+# define BATTERY_REF_VOLTAGE_MV 3300
+#endif
+
+#ifndef BATTERY_VOLTAGE_DIVIDER_R1
+# define BATTERY_VOLTAGE_DIVIDER_R1 100
+#endif
+
+#ifndef BATTERY_VOLTAGE_DIVIDER_R2
+# define BATTERY_VOLTAGE_DIVIDER_R2 100
+#endif
+
+// TODO: infer from adc config?
+#ifndef BATTERY_ADC_RESOLUTION
+# define BATTERY_ADC_RESOLUTION 10
+#endif
+
+void battery_driver_init(void) {
+ gpio_set_pin_input(BATTERY_PIN);
+}
+
+uint16_t battery_driver_get_mv(void) {
+ uint32_t raw = analogReadPin(BATTERY_PIN);
+
+ uint32_t bat_mv = raw * BATTERY_REF_VOLTAGE_MV / (1 << BATTERY_ADC_RESOLUTION);
+
+#if BATTERY_VOLTAGE_DIVIDER_R1 > 0 && BATTERY_VOLTAGE_DIVIDER_R2 > 0
+ bat_mv = bat_mv * (BATTERY_VOLTAGE_DIVIDER_R1 + BATTERY_VOLTAGE_DIVIDER_R2) / BATTERY_VOLTAGE_DIVIDER_R2;
+#endif
+
+ return bat_mv;
+}
+
+uint8_t battery_driver_sample_percent(void) {
+ uint16_t bat_mv = battery_driver_get_mv();
+
+ // https://github.com/zmkfirmware/zmk/blob/3f7c9d7cc4f46617faad288421025ea2a6b0bd28/app/module/drivers/sensor/battery/battery_common.c#L33
+ if (bat_mv >= 4200) {
+ return 100;
+ } else if (bat_mv <= 3450) {
+ return 0;
+ }
+
+ return bat_mv * 2 / 15 - 459;
+}
diff --git a/drivers/battery/battery_driver.h b/drivers/battery/battery_driver.h
new file mode 100644
index 0000000000..c2ee75e966
--- /dev/null
+++ b/drivers/battery/battery_driver.h
@@ -0,0 +1,29 @@
+// Copyright 2025 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <stdint.h>
+
+/**
+ * \file
+ *
+ * \defgroup battery Battery Driver API
+ *
+ * \brief API to query battery status.
+ * \{
+ */
+
+/**
+ * \brief Initialize the battery driver. This function must be called only once, before any of the below functions can be called.
+ */
+void battery_driver_init(void);
+
+/**
+ * \brief Sample battery level.
+ *
+ * \return The battery percentage, in the range 0-100.
+ */
+uint8_t battery_driver_sample_percent(void);
+
+/** \} */
diff --git a/drivers/bluetooth/bluefruit_le.cpp b/drivers/bluetooth/bluefruit_le.cpp
index 218eca2195..5fdd104dcf 100644
--- a/drivers/bluetooth/bluefruit_le.cpp
+++ b/drivers/bluetooth/bluefruit_le.cpp
@@ -32,13 +32,8 @@
# define BLUEFRUIT_LE_SCK_DIVISOR 2 // 4MHz SCK/8MHz CPU, calculated for Feather 32U4 BLE
#endif
-#define SAMPLE_BATTERY
#define ConnectionUpdateInterval 1000 /* milliseconds */
-#ifndef BATTERY_LEVEL_PIN
-# define BATTERY_LEVEL_PIN B5
-#endif
-
static struct {
bool is_connected;
bool initialized;
@@ -48,10 +43,6 @@ static struct {
#define UsingEvents 2
bool event_flags;
-#ifdef SAMPLE_BATTERY
- uint16_t last_battery_update;
- uint32_t vbat;
-#endif
uint16_t last_connection_update;
} state;
@@ -549,14 +540,6 @@ void bluefruit_le_task(void) {
set_connected(atoi(resbuf));
}
}
-
-#ifdef SAMPLE_BATTERY
- if (timer_elapsed(state.last_battery_update) > BatteryUpdateInterval && resp_buf.empty()) {
- state.last_battery_update = timer_read();
-
- state.vbat = analogReadPin(BATTERY_LEVEL_PIN);
- }
-#endif
}
static bool process_queue_item(struct queue_item *item, uint16_t timeout) {
@@ -655,10 +638,6 @@ void bluefruit_le_send_mouse(report_mouse_t *report) {
}
}
-uint32_t bluefruit_le_read_battery_voltage(void) {
- return state.vbat;
-}
-
bool bluefruit_le_set_mode_leds(bool on) {
if (!state.configured) {
return false;
diff --git a/drivers/bluetooth/bluefruit_le.h b/drivers/bluetooth/bluefruit_le.h
index a3de03c35c..5efe92b6e0 100644
--- a/drivers/bluetooth/bluefruit_le.h
+++ b/drivers/bluetooth/bluefruit_le.h
@@ -45,10 +45,6 @@ extern void bluefruit_le_send_consumer(uint16_t usage);
* change. */
extern void bluefruit_le_send_mouse(report_mouse_t *report);
-/* Compute battery voltage by reading an analog pin.
- * Returns the integer number of millivolts */
-extern uint32_t bluefruit_le_read_battery_voltage(void);
-
extern bool bluefruit_le_set_mode_leds(bool on);
extern bool bluefruit_le_set_power_level(int8_t level);
diff --git a/drivers/bluetooth/bluetooth.c b/drivers/bluetooth/bluetooth.c
index d5382401e7..61a3f0f32a 100644
--- a/drivers/bluetooth/bluetooth.c
+++ b/drivers/bluetooth/bluetooth.c
@@ -1,62 +1,30 @@
-/*
- * 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) {}
diff --git a/drivers/bluetooth/bluetooth.h b/drivers/bluetooth/bluetooth.h
index 2e4d0df538..e50b588db2 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,10 @@ 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);
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/eeprom/eeprom_transient.h b/drivers/eeprom/eeprom_transient.h
index 687b8619fe..0483fd58b9 100644
--- a/drivers/eeprom/eeprom_transient.h
+++ b/drivers/eeprom/eeprom_transient.h
@@ -20,6 +20,6 @@
The size of the transient EEPROM buffer size.
*/
#ifndef TRANSIENT_EEPROM_SIZE
-# include "eeconfig.h"
+# include "nvm_eeprom_eeconfig_internal.h"
# define TRANSIENT_EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO
#endif
diff --git a/drivers/painter/gc9xxx/qp_gc9a01_opcodes.h b/drivers/painter/gc9xxx/qp_gc9a01_opcodes.h
index 5853902e68..31de5ee9e3 100644
--- a/drivers/painter/gc9xxx/qp_gc9a01_opcodes.h
+++ b/drivers/painter/gc9xxx/qp_gc9a01_opcodes.h
@@ -101,4 +101,4 @@
#define GC9A01_GRAM_INTERFACE_RGB 0b00000010
#define GC9A01_RGB_INTERFACE_MODE_1_TRANSFER 0b00000000
-#define GC9A01_RGB_INTERFACE_MODE_3_TRANSFER 0b00000001 \ No newline at end of file
+#define GC9A01_RGB_INTERFACE_MODE_3_TRANSFER 0b00000001
diff --git a/drivers/painter/ili9xxx/qp_ili9486.c b/drivers/painter/ili9xxx/qp_ili9486.c
index c4f3c15cec..48db779c04 100644
--- a/drivers/painter/ili9xxx/qp_ili9486.c
+++ b/drivers/painter/ili9xxx/qp_ili9486.c
@@ -75,9 +75,9 @@ static void qp_comms_spi_dc_reset_send_command_odd_cs_pulse(painter_device_t dev
painter_driver_t * driver = (painter_driver_t *)device;
qp_comms_spi_dc_reset_config_t *comms_config = (qp_comms_spi_dc_reset_config_t *)driver->comms_config;
- writePinLow(comms_config->spi_config.chip_select_pin);
+ gpio_write_pin_low(comms_config->spi_config.chip_select_pin);
qp_comms_spi_dc_reset_send_command(device, cmd);
- writePinHigh(comms_config->spi_config.chip_select_pin);
+ gpio_write_pin_high(comms_config->spi_config.chip_select_pin);
}
static uint32_t qp_comms_spi_send_data_odd_cs_pulse(painter_device_t device, const void *data, uint32_t byte_count) {
@@ -88,20 +88,20 @@ static uint32_t qp_comms_spi_send_data_odd_cs_pulse(painter_device_t device, con
const uint8_t *p = (const uint8_t *)data;
uint32_t max_msg_length = 1024;
- writePinHigh(comms_config->dc_pin);
+ gpio_write_pin_high(comms_config->dc_pin);
while (bytes_remaining > 0) {
uint32_t bytes_this_loop = QP_MIN(bytes_remaining, max_msg_length);
bool odd_bytes = bytes_this_loop & 1;
// send data
- writePinLow(comms_config->spi_config.chip_select_pin);
+ gpio_write_pin_low(comms_config->spi_config.chip_select_pin);
spi_transmit(p, bytes_this_loop);
p += bytes_this_loop;
// extra CS toggle, for alignment
if (odd_bytes) {
- writePinHigh(comms_config->spi_config.chip_select_pin);
- writePinLow(comms_config->spi_config.chip_select_pin);
+ gpio_write_pin_high(comms_config->spi_config.chip_select_pin);
+ gpio_write_pin_low(comms_config->spi_config.chip_select_pin);
}
bytes_remaining -= bytes_this_loop;
@@ -116,9 +116,9 @@ static uint32_t qp_ili9486_send_data_toggling(painter_device_t device, const uin
uint32_t ret;
for (uint8_t j = 0; j < byte_count; ++j) {
- writePinLow(comms_config->spi_config.chip_select_pin);
+ gpio_write_pin_low(comms_config->spi_config.chip_select_pin);
ret = qp_comms_spi_dc_reset_send_data(device, &data[j], 1);
- writePinHigh(comms_config->spi_config.chip_select_pin);
+ gpio_write_pin_high(comms_config->spi_config.chip_select_pin);
}
return ret;
diff --git a/drivers/painter/ld7032/qp_ld7032.h b/drivers/painter/ld7032/qp_ld7032.h
index 967eb7999c..9af80dd468 100644
--- a/drivers/painter/ld7032/qp_ld7032.h
+++ b/drivers/painter/ld7032/qp_ld7032.h
@@ -63,4 +63,4 @@ painter_device_t qp_ld7032_make_spi_device(uint16_t panel_width, uint16_t panel_
*/
painter_device_t qp_ld7032_make_i2c_device(uint16_t panel_width, uint16_t panel_height, uint8_t i2c_address);
-#endif // QUANTUM_PAINTER_LD7032_I2C_ENABLE \ No newline at end of file
+#endif // QUANTUM_PAINTER_LD7032_I2C_ENABLE
diff --git a/drivers/painter/ld7032/qp_ld7032_opcodes.h b/drivers/painter/ld7032/qp_ld7032_opcodes.h
index 08ab77d6f8..ed8b397c67 100644
--- a/drivers/painter/ld7032/qp_ld7032_opcodes.h
+++ b/drivers/painter/ld7032/qp_ld7032_opcodes.h
@@ -42,4 +42,4 @@ typedef enum {
LD7032_S_START_STOP = 0xCD,
LD7032_S_SELECT = 0xCE,
LD7032_TESTCNT1 = 0xF0, //-0xFF
-} ld7032_opcodes; \ No newline at end of file
+} ld7032_opcodes;
diff --git a/drivers/sensors/pimoroni_trackball.c b/drivers/sensors/pimoroni_trackball.c
index afbe3d5b77..06e5042953 100644
--- a/drivers/sensors/pimoroni_trackball.c
+++ b/drivers/sensors/pimoroni_trackball.c
@@ -101,12 +101,12 @@ int16_t pimoroni_trackball_get_offsets(uint8_t negative_dir, uint8_t positive_di
}
mouse_xy_report_t pimoroni_trackball_adapt_values(xy_clamp_range_t *offset) {
- if (*offset > XY_REPORT_MAX) {
- *offset -= XY_REPORT_MAX;
- return (mouse_xy_report_t)XY_REPORT_MAX;
- } else if (*offset < XY_REPORT_MIN) {
- *offset += XY_REPORT_MAX;
- return (mouse_xy_report_t)XY_REPORT_MIN;
+ if (*offset > MOUSE_REPORT_XY_MAX) {
+ *offset -= MOUSE_REPORT_XY_MAX;
+ return (mouse_xy_report_t)MOUSE_REPORT_XY_MAX;
+ } else if (*offset < MOUSE_REPORT_XY_MIN) {
+ *offset += MOUSE_REPORT_XY_MAX;
+ return (mouse_xy_report_t)MOUSE_REPORT_XY_MIN;
} else {
mouse_xy_report_t temp_return = *offset;
*offset = 0;
diff --git a/drivers/usbpd.h b/drivers/usbpd.h
index df4f29bb9d..e9dca67f66 100644
--- a/drivers/usbpd.h
+++ b/drivers/usbpd.h
@@ -26,4 +26,4 @@ typedef enum {
void usbpd_init(void);
// Gets the current state of the USBPD allowance
-usbpd_allowance_t usbpd_get_allowance(void); \ No newline at end of file
+usbpd_allowance_t usbpd_get_allowance(void);