commit 76daf29ef0820438902eb64027c403cc3e37b892
parent f9ed1e3ebc66b568a20848ae0f07052fbef5e4a8
Author: Ryan <fauxpark@gmail.com>
Date: Thu, 14 Sep 2023 17:02:40 +1000
Add and use PWM frequency defines for ISSI LED drivers (#22009)
Diffstat:
18 files changed, 58 insertions(+), 12 deletions(-)
diff --git a/drivers/led/issi/is31fl3733-simple.c b/drivers/led/issi/is31fl3733-simple.c
@@ -60,7 +60,7 @@
#endif
#ifndef IS31FL3733_PWM_FREQUENCY
-# define IS31FL3733_PWM_FREQUENCY 0b000 // PFS - IS31FL3733B only
+# define IS31FL3733_PWM_FREQUENCY IS31FL3733_PWM_FREQUENCY_8K4_HZ // PFS - IS31FL3733B only
#endif
#ifndef IS31FL3733_SWPULLUP
diff --git a/drivers/led/issi/is31fl3733-simple.h b/drivers/led/issi/is31fl3733-simple.h
@@ -87,6 +87,12 @@ void is31fl3733_update_led_control_registers(uint8_t addr, uint8_t index);
#define IS31FL3733_PUR_16KR 0x06 // 16k Ohm resistor on all the time
#define IS31FL3733_PUR_32KR 0x07 // 32k Ohm resistor in t_NOL
+#define IS31FL3733_PWM_FREQUENCY_8K4_HZ 0b000
+#define IS31FL3733_PWM_FREQUENCY_4K2_HZ 0b001
+#define IS31FL3733_PWM_FREQUENCY_26K7_HZ 0b010
+#define IS31FL3733_PWM_FREQUENCY_2K1_HZ 0b011
+#define IS31FL3733_PWM_FREQUENCY_1K05_HZ 0b100
+
#define A_1 0x00
#define A_2 0x01
#define A_3 0x02
diff --git a/drivers/led/issi/is31fl3733.c b/drivers/led/issi/is31fl3733.c
@@ -59,7 +59,7 @@
#endif
#ifndef IS31FL3733_PWM_FREQUENCY
-# define IS31FL3733_PWM_FREQUENCY 0b000 // PFS - IS31FL3733B only
+# define IS31FL3733_PWM_FREQUENCY IS31FL3733_PWM_FREQUENCY_8K4_HZ // PFS - IS31FL3733B only
#endif
#ifndef IS31FL3733_SWPULLUP
diff --git a/drivers/led/issi/is31fl3733.h b/drivers/led/issi/is31fl3733.h
@@ -88,6 +88,12 @@ void is31fl3733_update_led_control_registers(uint8_t addr, uint8_t index);
#define IS31FL3733_PUR_16KR 0x06 // 16k Ohm resistor on all the time
#define IS31FL3733_PUR_32KR 0x07 // 32k Ohm resistor in t_NOL
+#define IS31FL3733_PWM_FREQUENCY_8K4_HZ 0b000
+#define IS31FL3733_PWM_FREQUENCY_4K2_HZ 0b001
+#define IS31FL3733_PWM_FREQUENCY_26K7_HZ 0b010
+#define IS31FL3733_PWM_FREQUENCY_2K1_HZ 0b011
+#define IS31FL3733_PWM_FREQUENCY_1K05_HZ 0b100
+
#define A_1 0x00
#define A_2 0x01
#define A_3 0x02
diff --git a/drivers/led/issi/is31fl3736.c b/drivers/led/issi/is31fl3736.c
@@ -48,7 +48,7 @@
#define IS31FL3736_REG_SWPULLUP 0x0F // PG3
#define IS31FL3736_REG_CSPULLUP 0x10 // PG3
-#ifndef IS31FL3736_TIMEOUT
+#ifndef IS31FL3736_I2C_TIMEOUT
# define IS31FL3736_I2C_TIMEOUT 100
#endif
@@ -56,6 +56,10 @@
# define IS31FL3736_I2C_PERSISTENCE 0
#endif
+#ifndef IS31FL3736_PWM_FREQUENCY
+# define IS31FL3736_PWM_FREQUENCY IS31FL3736_PWM_FREQUENCY_8K4_HZ // PFS - IS31FL3736B only
+#endif
+
#ifndef IS31FL3736_SWPULLUP
# define IS31FL3736_SWPULLUP IS31FL3736_PUR_0R
#endif
@@ -159,7 +163,7 @@ void is31fl3736_init(uint8_t addr) {
// Set global current to maximum.
is31fl3736_write_register(addr, IS31FL3736_REG_GLOBALCURRENT, IS31FL3736_GLOBALCURRENT);
// Disable software shutdown.
- is31fl3736_write_register(addr, IS31FL3736_REG_CONFIGURATION, 0x01);
+ is31fl3736_write_register(addr, IS31FL3736_REG_CONFIGURATION, ((IS31FL3736_PWM_FREQUENCY & 0b111) << 3) | 0x01);
// Wait 10ms to ensure the device has woken up.
wait_ms(10);
diff --git a/drivers/led/issi/is31fl3736.h b/drivers/led/issi/is31fl3736.h
@@ -89,6 +89,12 @@ void is31fl3736_update_led_control_registers(uint8_t addr, uint8_t index);
#define IS31FL3736_PUR_16KR 0x06 // 16k Ohm resistor
#define IS31FL3736_PUR_32KR 0x07 // 32k Ohm resistor
+#define IS31FL3736_PWM_FREQUENCY_8K4_HZ 0b000
+#define IS31FL3736_PWM_FREQUENCY_4K2_HZ 0b001
+#define IS31FL3736_PWM_FREQUENCY_26K7_HZ 0b010
+#define IS31FL3736_PWM_FREQUENCY_2K1_HZ 0b011
+#define IS31FL3736_PWM_FREQUENCY_1K05_HZ 0b100
+
#define A_1 0x00
#define A_2 0x02
#define A_3 0x04
diff --git a/drivers/led/issi/is31fl3737.c b/drivers/led/issi/is31fl3737.c
@@ -59,7 +59,7 @@
#endif
#ifndef IS31FL3737_PWM_FREQUENCY
-# define IS31FL3737_PWM_FREQUENCY 0b000 // PFS - IS31FL3737B only
+# define IS31FL3737_PWM_FREQUENCY IS31FL3737_PWM_FREQUENCY_8K4_HZ // PFS - IS31FL3737B only
#endif
#ifndef IS31FL3737_SWPULLUP
diff --git a/drivers/led/issi/is31fl3737.h b/drivers/led/issi/is31fl3737.h
@@ -90,6 +90,12 @@ void is31fl3737_update_led_control_registers(uint8_t addr, uint8_t index);
#define IS31FL3737_PUR_16KR 0x06 // 16k Ohm resistor in t_NOL
#define IS31FL3737_PUR_32KR 0x07 // 32k Ohm resistor in t_NOL
+#define IS31FL3737_PWM_FREQUENCY_8K4_HZ 0b000
+#define IS31FL3737_PWM_FREQUENCY_4K2_HZ 0b001
+#define IS31FL3737_PWM_FREQUENCY_26K7_HZ 0b010
+#define IS31FL3737_PWM_FREQUENCY_2K1_HZ 0b011
+#define IS31FL3737_PWM_FREQUENCY_1K05_HZ 0b100
+
#define A_1 0x00
#define A_2 0x01
#define A_3 0x02
diff --git a/drivers/led/issi/is31fl3741.c b/drivers/led/issi/is31fl3741.c
@@ -49,6 +49,7 @@
#define IS31FL3741_REG_CONFIGURATION 0x00 // PG4
#define IS31FL3741_REG_GLOBALCURRENT 0x01 // PG4
#define IS31FL3741_REG_PULLDOWNUP 0x02 // PG4
+#define IS31FL3741_REG_PWM_FREQUENCY 0x36 // PG4
#define IS31FL3741_REG_RESET 0x3F // PG4
#ifndef IS31FL3741_I2C_TIMEOUT
@@ -63,6 +64,10 @@
# define IS31FL3741_CONFIGURATION 0x01
#endif
+#ifndef IS31FL3741_PWM_FREQUENCY
+# define IS31FL3741_PWM_FREQUENCY IS31FL3741_PWM_FREQUENCY_29K_HZ
+#endif
+
#ifndef IS31FL3741_SWPULLUP
# define IS31FL3741_SWPULLUP IS31FL3741_PUR_32KR
#endif
@@ -170,6 +175,8 @@ void is31fl3741_init(uint8_t addr) {
is31fl3741_write_register(addr, IS31FL3741_REG_GLOBALCURRENT, IS31FL3741_GLOBALCURRENT);
// Set Pull up & Down for SWx CSy
is31fl3741_write_register(addr, IS31FL3741_REG_PULLDOWNUP, ((IS31FL3741_CSPULLUP << 4) | IS31FL3741_SWPULLUP));
+ // Set PWM frequency
+ is31fl3741_write_register(addr, IS31FL3741_REG_PWM_FREQUENCY, (IS31FL3741_PWM_FREQUENCY & 0b1111));
// is31fl3741_update_led_scaling_registers(addr, 0xFF, 0xFF, 0xFF);
diff --git a/drivers/led/issi/is31fl3741.h b/drivers/led/issi/is31fl3741.h
@@ -93,6 +93,11 @@ void is31fl3741_set_pwm_buffer(const is31_led *pled, uint8_t red, uint8_t green,
#define IS31FL3741_PUR_16KR 0x06 // 16k Ohm resistor
#define IS31FL3741_PUR_32KR 0x07 // 32k Ohm resistor
+#define IS31FL3741_PWM_FREQUENCY_29K_HZ 0b0000
+#define IS31FL3741_PWM_FREQUENCY_3K6_HZ 0b0011
+#define IS31FL3741_PWM_FREQUENCY_1K8_HZ 0b0111
+#define IS31FL3741_PWM_FREQUENCY_900_HZ 0b1011
+
#define CS1_SW1 0x00
#define CS2_SW1 0x01
#define CS3_SW1 0x02
diff --git a/keyboards/4pplet/perk60_iso/rev_a/config.h b/keyboards/4pplet/perk60_iso/rev_a/config.h
@@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DRIVER_ADDR_1 0b1010000
#define IS31FL3733_DRIVER_COUNT 1
#define RGB_MATRIX_LED_COUNT 62
-#define IS31FL3733_PWM_FREQUENCY 0b010
+#define IS31FL3733_PWM_FREQUENCY IS31FL3733_PWM_FREQUENCY_26K7_HZ
#define RGB_MATRIX_DEFAULT_VAL 80
#define RGB_MATRIX_KEYPRESSES
diff --git a/keyboards/drop/alt/v2/config.h b/keyboards/drop/alt/v2/config.h
@@ -18,7 +18,7 @@
#define DRIVER_ADDR_2 0b1011111
#define IS31FL3733_DRIVER_COUNT 2
#define RGB_MATRIX_LED_COUNT 111
-#define IS31FL3733_PWM_FREQUENCY 0b010 // 26k
+#define IS31FL3733_PWM_FREQUENCY IS31FL3733_PWM_FREQUENCY_26K7_HZ
#define RGB_DISABLE_WHEN_USB_SUSPENDED
#define RGB_MATRIX_DEFAULT_VAL 100
diff --git a/keyboards/drop/ctrl/v2/config.h b/keyboards/drop/ctrl/v2/config.h
@@ -18,7 +18,7 @@
#define DRIVER_ADDR_2 0b1011111
#define IS31FL3733_DRIVER_COUNT 2
#define RGB_MATRIX_LED_COUNT 119
-#define IS31FL3733_PWM_FREQUENCY 0b010 // 26k
+#define IS31FL3733_PWM_FREQUENCY IS31FL3733_PWM_FREQUENCY_26K7_HZ
#define RGB_DISABLE_WHEN_USB_SUSPENDED
#define RGB_MATRIX_DEFAULT_VAL 100
diff --git a/keyboards/drop/sense75/config.h b/keyboards/drop/sense75/config.h
@@ -13,7 +13,7 @@
#define DRIVER_ADDR_2 0b1011111
#define IS31FL3733_DRIVER_COUNT 2
#define RGB_MATRIX_LED_COUNT 111
-#define IS31FL3733_PWM_FREQUENCY 0b010 // 26k
+#define IS31FL3733_PWM_FREQUENCY IS31FL3733_PWM_FREQUENCY_26K7_HZ
#define RGB_DISABLE_WHEN_USB_SUSPENDED
#define RGB_MATRIX_KEYPRESSES
diff --git a/keyboards/drop/shift/v2/config.h b/keyboards/drop/shift/v2/config.h
@@ -19,7 +19,7 @@
#define DRIVER_ADDR_3 0b1010000
#define IS31FL3733_DRIVER_COUNT 3
#define RGB_MATRIX_LED_COUNT 166
-#define IS31FL3733_PWM_FREQUENCY 0b010 // 26k
+#define IS31FL3733_PWM_FREQUENCY IS31FL3733_PWM_FREQUENCY_26K7_HZ
#define RGB_DISABLE_WHEN_USB_SUSPENDED
#define RGB_MATRIX_DEFAULT_VAL 100
diff --git a/keyboards/frooastboard/walnut/config.h b/keyboards/frooastboard/walnut/config.h
@@ -3,7 +3,7 @@
#pragma once
-#define IS31FL3737_PWM_FREQUENCY 0b010
+#define IS31FL3737_PWM_FREQUENCY IS31FL3737_PWM_FREQUENCY_26K7_HZ
#define IS31FL3737_DRIVER_COUNT 1
#define RGB_MATRIX_LED_COUNT 48
#define DRIVER_ADDR_1 0b1010000
diff --git a/keyboards/input_club/k_type/is31fl3733-dual.c b/keyboards/input_club/k_type/is31fl3733-dual.c
@@ -57,7 +57,7 @@
#endif
#ifndef IS31FL3733_PWM_FREQUENCY
-# define IS31FL3733_PWM_FREQUENCY 0b000 // PFS - IS31FL3733B only
+# define IS31FL3733_PWM_FREQUENCY IS31FL3733_PWM_FREQUENCY_8K4_HZ // PFS - IS31FL3733B only
#endif
#ifndef IS31FL3733_SWPULLUP
diff --git a/keyboards/input_club/k_type/is31fl3733-dual.h b/keyboards/input_club/k_type/is31fl3733-dual.h
@@ -55,6 +55,12 @@ void is31fl3733_update_led_control_registers(uint8_t addr, uint8_t index);
#define IS31FL3733_PUR_16KR 0x06 // 16k Ohm resistor on all the time
#define IS31FL3733_PUR_32KR 0x07 // 32k Ohm resistor in t_NOL
+#define IS31FL3733_PWM_FREQUENCY_8K4_HZ 0x00
+#define IS31FL3733_PWM_FREQUENCY_4K2_HZ 0x01
+#define IS31FL3733_PWM_FREQUENCY_26K7_HZ 0x02
+#define IS31FL3733_PWM_FREQUENCY_2K1_HZ 0x03
+#define IS31FL3733_PWM_FREQUENCY_1K05_HZ 0x04
+
#define A_1 0x00
#define A_2 0x01
#define A_3 0x02