summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/eeprom/eeprom_i2c.h5
-rw-r--r--drivers/led/aw20216.c6
-rw-r--r--drivers/led/issi/is31fl3737.c6
-rw-r--r--drivers/ps2/ps2.h1
-rw-r--r--drivers/ps2/ps2_interrupt.c4
-rw-r--r--drivers/ps2/ps2_mouse.c19
-rw-r--r--drivers/sensors/pimoroni_trackball.c13
-rw-r--r--drivers/sensors/pimoroni_trackball.h1
-rw-r--r--drivers/serial.h10
9 files changed, 45 insertions, 20 deletions
diff --git a/drivers/eeprom/eeprom_i2c.h b/drivers/eeprom/eeprom_i2c.h
index 77eea66d63..85317c9ea5 100644
--- a/drivers/eeprom/eeprom_i2c.h
+++ b/drivers/eeprom/eeprom_i2c.h
@@ -54,6 +54,11 @@
# define EXTERNAL_EEPROM_PAGE_SIZE 32
# define EXTERNAL_EEPROM_ADDRESS_SIZE 2
# define EXTERNAL_EEPROM_WRITE_TIME 5
+#elif defined(EEPROM_I2C_24LC32A)
+# define EXTERNAL_EEPROM_BYTE_COUNT 4096
+# define EXTERNAL_EEPROM_PAGE_SIZE 32
+# define EXTERNAL_EEPROM_ADDRESS_SIZE 2
+# define EXTERNAL_EEPROM_WRITE_TIME 5
#elif defined(EEPROM_I2C_MB85RC256V)
# define EXTERNAL_EEPROM_BYTE_COUNT 32768
# define EXTERNAL_EEPROM_PAGE_SIZE 128
diff --git a/drivers/led/aw20216.c b/drivers/led/aw20216.c
index 448accdcd3..55083936ef 100644
--- a/drivers/led/aw20216.c
+++ b/drivers/led/aw20216.c
@@ -53,6 +53,10 @@
# define AW_GLOBAL_CURRENT_MAX 150
#endif
+#ifndef AW_SPI_MODE
+# define AW_SPI_MODE 0
+#endif
+
#ifndef AW_SPI_DIVISOR
# define AW_SPI_DIVISOR 4
#endif
@@ -63,7 +67,7 @@ bool g_pwm_buffer_update_required[DRIVER_COUNT] = {false};
bool AW20216_write(pin_t cs_pin, uint8_t page, uint8_t reg, uint8_t* data, uint8_t len) {
static uint8_t s_spi_transfer_buffer[2] = {0};
- if (!spi_start(cs_pin, false, 3, AW_SPI_DIVISOR)) {
+ if (!spi_start(cs_pin, false, AW_SPI_MODE, AW_SPI_DIVISOR)) {
spi_stop();
return false;
}
diff --git a/drivers/led/issi/is31fl3737.c b/drivers/led/issi/is31fl3737.c
index bce0c34b2c..932530ac0a 100644
--- a/drivers/led/issi/is31fl3737.c
+++ b/drivers/led/issi/is31fl3737.c
@@ -69,6 +69,10 @@
# define ISSI_CSPULLUP PUR_0R
#endif
+#ifndef ISSI_GLOBALCURRENT
+# define ISSI_GLOBALCURRENT 0xFF
+#endif
+
// Transfer buffer for TWITransmitData()
uint8_t g_twi_transfer_buffer[20];
@@ -161,7 +165,7 @@ void IS31FL3737_init(uint8_t addr) {
// Set de-ghost pull-down resistors (CSx)
IS31FL3737_write_register(addr, ISSI_REG_CSPULLUP, ISSI_CSPULLUP);
// Set global current to maximum.
- IS31FL3737_write_register(addr, ISSI_REG_GLOBALCURRENT, 0xFF);
+ IS31FL3737_write_register(addr, ISSI_REG_GLOBALCURRENT, ISSI_GLOBALCURRENT);
// Disable software shutdown.
IS31FL3737_write_register(addr, ISSI_REG_CONFIGURATION, ((ISSI_PWM_FREQUENCY & 0b111) << 3) | 0x01);
diff --git a/drivers/ps2/ps2.h b/drivers/ps2/ps2.h
index f123192852..2465e16235 100644
--- a/drivers/ps2/ps2.h
+++ b/drivers/ps2/ps2.h
@@ -89,6 +89,7 @@ uint8_t ps2_host_send(uint8_t data);
uint8_t ps2_host_recv_response(void);
uint8_t ps2_host_recv(void);
void ps2_host_set_led(uint8_t usb_led);
+bool pbuf_has_data(void);
/*--------------------------------------------------------------------
* static functions
diff --git a/drivers/ps2/ps2_interrupt.c b/drivers/ps2/ps2_interrupt.c
index c49b4f8b75..c9a9f1e1ec 100644
--- a/drivers/ps2/ps2_interrupt.c
+++ b/drivers/ps2/ps2_interrupt.c
@@ -66,8 +66,8 @@ uint8_t ps2_error = PS2_ERR_NONE;
static inline uint8_t pbuf_dequeue(void);
static inline void pbuf_enqueue(uint8_t data);
-static inline bool pbuf_has_data(void);
static inline void pbuf_clear(void);
+bool pbuf_has_data(void);
#if defined(PROTOCOL_CHIBIOS)
void ps2_interrupt_service_routine(void);
@@ -309,7 +309,7 @@ static inline uint8_t pbuf_dequeue(void) {
return val;
}
-static inline bool pbuf_has_data(void) {
+bool pbuf_has_data(void) {
#if defined(__AVR__)
uint8_t sreg = SREG;
cli();
diff --git a/drivers/ps2/ps2_mouse.c b/drivers/ps2/ps2_mouse.c
index ccb0a929ae..66b48bb3c3 100644
--- a/drivers/ps2/ps2_mouse.c
+++ b/drivers/ps2/ps2_mouse.c
@@ -53,6 +53,7 @@ void ps2_mouse_init(void) {
ps2_mouse_set_remote_mode();
#else
ps2_mouse_enable_data_reporting();
+ ps2_mouse_set_stream_mode();
#endif
#ifdef PS2_MOUSE_ENABLE_SCROLLING
@@ -75,19 +76,33 @@ void ps2_mouse_task(void) {
extern int tp_buttons;
/* receives packet from mouse */
+#ifdef PS2_MOUSE_USE_REMOTE_MODE
uint8_t rcv;
rcv = ps2_host_send(PS2_MOUSE_READ_DATA);
if (rcv == PS2_ACK) {
mouse_report.buttons = ps2_host_recv_response() | tp_buttons;
mouse_report.x = ps2_host_recv_response() * PS2_MOUSE_X_MULTIPLIER;
mouse_report.y = ps2_host_recv_response() * PS2_MOUSE_Y_MULTIPLIER;
-#ifdef PS2_MOUSE_ENABLE_SCROLLING
+# ifdef PS2_MOUSE_ENABLE_SCROLLING
mouse_report.v = -(ps2_host_recv_response() & PS2_MOUSE_SCROLL_MASK) * PS2_MOUSE_V_MULTIPLIER;
-#endif
+# endif
+ } else {
+ if (debug_mouse) print("ps2_mouse: fail to get mouse packet\n");
+ return;
+ }
+#else
+ if (pbuf_has_data()) {
+ mouse_report.buttons = ps2_host_recv_response() | tp_buttons;
+ mouse_report.x = ps2_host_recv_response() * PS2_MOUSE_X_MULTIPLIER;
+ mouse_report.y = ps2_host_recv_response() * PS2_MOUSE_Y_MULTIPLIER;
+# ifdef PS2_MOUSE_ENABLE_SCROLLING
+ mouse_report.v = -(ps2_host_recv_response() & PS2_MOUSE_SCROLL_MASK) * PS2_MOUSE_V_MULTIPLIER;
+# endif
} else {
if (debug_mouse) print("ps2_mouse: fail to get mouse packet\n");
return;
}
+#endif
/* if mouse moves or buttons state changes */
if (mouse_report.x || mouse_report.y || mouse_report.v || ((mouse_report.buttons ^ buttons_prev) & PS2_MOUSE_BTN_MASK)) {
diff --git a/drivers/sensors/pimoroni_trackball.c b/drivers/sensors/pimoroni_trackball.c
index 333e017a06..88a351316b 100644
--- a/drivers/sensors/pimoroni_trackball.c
+++ b/drivers/sensors/pimoroni_trackball.c
@@ -95,16 +95,3 @@ int16_t pimoroni_trackball_get_offsets(uint8_t negative_dir, uint8_t positive_di
uint16_t magnitude = (scale * offset * offset * precision) >> 7;
return isnegative ? -(int16_t)(magnitude) : (int16_t)(magnitude);
}
-
-void pimoroni_trackball_adapt_values(int8_t* mouse, int16_t* offset) {
- if (*offset > 127) {
- *mouse = 127;
- *offset -= 127;
- } else if (*offset < -127) {
- *mouse = -127;
- *offset += 127;
- } else {
- *mouse = *offset;
- *offset = 0;
- }
-}
diff --git a/drivers/sensors/pimoroni_trackball.h b/drivers/sensors/pimoroni_trackball.h
index e20ee748a7..749f381bbd 100644
--- a/drivers/sensors/pimoroni_trackball.h
+++ b/drivers/sensors/pimoroni_trackball.h
@@ -52,7 +52,6 @@ typedef struct {
void 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);
-void pimoroni_trackball_adapt_values(int8_t* mouse, int16_t* offset);
uint16_t pimoroni_trackball_get_cpi(void);
void pimoroni_trackball_set_cpi(uint16_t cpi);
i2c_status_t read_pimoroni_trackball(pimoroni_data_t* data);
diff --git a/drivers/serial.h b/drivers/serial.h
index 0cfdbd9959..fb91b136e7 100644
--- a/drivers/serial.h
+++ b/drivers/serial.h
@@ -27,3 +27,13 @@ void soft_serial_initiator_init(void);
void soft_serial_target_init(void);
bool soft_serial_transaction(int sstd_index);
+
+#ifdef SERIAL_DEBUG
+# include <debug.h>
+# include <print.h>
+# define serial_dprintf(...) dprintf(__VA_ARGS__)
+#else
+# define serial_dprintf(...) \
+ do { \
+ } while (0)
+#endif