From 6c22fb9861252e43e7dea68086f6eda9b9674d5b Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Sun, 22 Sep 2024 13:51:42 +0300 Subject: [PATCH] sn32 rgb driver: prefix update `SN32_` -> `SN32F2XX_` --- docs/drivers/sn32f2xx.md | 28 +-- drivers/led/sn32f2xx.c | 366 +++++++++++++++++++-------------------- drivers/led/sn32f2xx.h | 52 +++--- 3 files changed, 223 insertions(+), 223 deletions(-) diff --git a/docs/drivers/sn32f2xx.md b/docs/drivers/sn32f2xx.md index 4742ae7d1dac..6985e99222d9 100644 --- a/docs/drivers/sn32f2xx.md +++ b/docs/drivers/sn32f2xx.md @@ -61,20 +61,20 @@ You can then call the SN32F2XX API by including `sn32f2xx.h` in your code. Add the following to your `config.h`: -|Define |Default |Description | -|-------------------------------|------------------------------|----------------------------------------------------------------------------------------------------| -|`SN32_RGB_MATRIX_ROW_PINS` |*Not defined* |The GPIO pins connected to the RGB sink triplets on every row of the LEDs in the matrix1 | -|`SN32_RGB_MATRIX_COL_PINS` |`MATRIX_COL_PINS` |The GPIO pins connected to the LED columns on every column of the LEDs in the matrix2 | -|`SN32_RGB_MATRIX_COLS` |`MATRIX_COLS` |Number of LED columns in the LED matrix | -|`SN32_RGB_MATRIX_ROWS` |`MATRIX_ROWS` |Number of LED rows in the LED matrix | -|`SN32_RGB_MATRIX_ROW_CHANNELS` |`3` |The number of available color channels for each LED | -|`SN32_PWM_OUTPUT_ACTIVE_LEVEL` |`SN32_PWM_OUTPUT_ACTIVE_LOW` |The logic level that enables PWM output. Depends on transistor controlling PWM | -|`SN32_RGB_OUTPUT_ACTIVE_LEVEL` |`SN32_RGB_OUTPUT_ACTIVE_HIGH` |The logic level that enables RGB output. Depends on transistor controlling RGB sinks | -|`SN32_PWM_DIRECTION` |`DIODE_DIRECTION` |The scanning logic direction for the LED matrix | -|`SN32_PWM_CONTROL` |`HARDWARE_PWM` |Toggles hardware or software control for the PWM | -|`SN32_LED_OUTPUT_LUMINOSITY_R` |`1` |Luminosity correction factor for the Red channel | -|`SN32_LED_OUTPUT_LUMINOSITY_G` |`1` |Luminosity correction factor for the Green channel | -|`SN32_LED_OUTPUT_LUMINOSITY_B` |`1` |Luminosity correction factor for the Blue channel | +|Define |Default |Description | +|-----------------------------------|----------------------------------|----------------------------------------------------------------------------------------------------| +|`SN32F2XX_RGB_MATRIX_ROW_PINS` |*Not defined* |The GPIO pins connected to the RGB sink triplets on every row of the LEDs in the matrix1 | +|`SN32F2XX_RGB_MATRIX_COL_PINS` |`MATRIX_COL_PINS` |The GPIO pins connected to the LED columns on every column of the LEDs in the matrix2 | +|`SN32F2XX_RGB_MATRIX_COLS` |`MATRIX_COLS` |Number of LED columns in the LED matrix | +|`SN32F2XX_RGB_MATRIX_ROWS` |`MATRIX_ROWS` |Number of LED rows in the LED matrix | +|`SN32F2XX_RGB_MATRIX_ROW_CHANNELS` |`3` |The number of available color channels for each LED | +|`SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL` |`SN32F2XX_PWM_OUTPUT_ACTIVE_LOW` |The logic level that enables PWM output. Depends on transistor controlling PWM | +|`SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL` |`SN32F2XX_RGB_OUTPUT_ACTIVE_HIGH` |The logic level that enables RGB output. Depends on transistor controlling RGB sinks | +|`SN32F2XX_PWM_DIRECTION` |`DIODE_DIRECTION` |The scanning logic direction for the LED matrix | +|`SN32F2XX_PWM_CONTROL` |`HARDWARE_PWM` |Toggles hardware or software control for the PWM | +|`SN32F2XX_LED_OUTPUT_LUMINOSITY_R` |`1` |Luminosity correction factor for the Red channel | +|`SN32F2XX_LED_OUTPUT_LUMINOSITY_G` |`1` |Luminosity correction factor for the Green channel | +|`SN32F2XX_LED_OUTPUT_LUMINOSITY_B` |`1` |Luminosity correction factor for the Blue channel | Notes: diff --git a/drivers/led/sn32f2xx.c b/drivers/led/sn32f2xx.c index a0b1150e9101..d7dca504c27f 100644 --- a/drivers/led/sn32f2xx.c +++ b/drivers/led/sn32f2xx.c @@ -25,11 +25,11 @@ # define MATRIX_IO_DELAY 30 #endif -#define SN32_PWM_OUTPUT_ACTIVE_HIGH PWM_OUTPUT_ACTIVE_HIGH -#define SN32_PWM_OUTPUT_ACTIVE_LOW PWM_OUTPUT_ACTIVE_LOW +#define SN32F2XX_PWM_OUTPUT_ACTIVE_HIGH PWM_OUTPUT_ACTIVE_HIGH +#define SN32F2XX_PWM_OUTPUT_ACTIVE_LOW PWM_OUTPUT_ACTIVE_LOW -#define SN32_RGB_OUTPUT_ACTIVE_HIGH PWM_OUTPUT_ACTIVE_HIGH -#define SN32_RGB_OUTPUT_ACTIVE_LOW PWM_OUTPUT_ACTIVE_LOW +#define SN32F2XX_RGB_OUTPUT_ACTIVE_HIGH PWM_OUTPUT_ACTIVE_HIGH +#define SN32F2XX_RGB_OUTPUT_ACTIVE_LOW PWM_OUTPUT_ACTIVE_LOW #define HARDWARE_PWM 0 #define SOFTWARE_PWM 1 @@ -68,20 +68,20 @@ (B) (E) GPIO GND */ -#if (SN32_PWM_DIRECTION == COL2ROW) -static uint8_t chan_col_order[SN32_RGB_MATRIX_COLS] = {0}; // track the channel col order +#if (SN32F2XX_PWM_DIRECTION == COL2ROW) +static uint8_t chan_col_order[SN32F2XX_RGB_MATRIX_COLS] = {0}; // track the channel col order static uint8_t current_row = 0; // LED row scan counter static uint8_t current_key_row = 0; // key row scan counter -# if (SN32_PWM_CONTROL == SOFTWARE_PWM) -static uint8_t led_duty_cycle[SN32_RGB_MATRIX_COLS] = {0}; // track the channel duty cycle +# if (SN32F2XX_PWM_CONTROL == SOFTWARE_PWM) +static uint8_t led_duty_cycle[SN32F2XX_RGB_MATRIX_COLS] = {0}; // track the channel duty cycle # endif -#elif (SN32_PWM_DIRECTION == ROW2COL) +#elif (SN32F2XX_PWM_DIRECTION == ROW2COL) /* make sure to `#define MATRIX_UNSELECT_DRIVE_HIGH` in this configuration*/ -static uint8_t chan_row_order[SN32_RGB_MATRIX_ROWS_HW] = {0}; // track the channel row order +static uint8_t chan_row_order[SN32F2XX_RGB_MATRIX_ROWS_HW] = {0}; // track the channel row order static uint8_t current_key_col = 0; // key col scan counter static uint8_t last_key_col = 0; // key col scan counter -# if (SN32_PWM_CONTROL == SOFTWARE_PWM) -static uint8_t led_duty_cycle[SN32_RGB_MATRIX_ROWS_HW] = {0}; // track the channel duty cycle +# if (SN32F2XX_PWM_CONTROL == SOFTWARE_PWM) +static uint8_t led_duty_cycle[SN32F2XX_RGB_MATRIX_ROWS_HW] = {0}; // track the channel duty cycle # endif #endif #if (DIODE_DIRECTION == ROW2COL) @@ -96,8 +96,8 @@ static volatile bool matrix_scanned = false; #endif // SHARED MATRIX static const uint32_t periodticks = RGB_MATRIX_MAXIMUM_BRIGHTNESS; static const uint32_t freq = (RGB_MATRIX_HUE_STEP * RGB_MATRIX_SAT_STEP * RGB_MATRIX_VAL_STEP * RGB_MATRIX_SPD_STEP * RGB_MATRIX_LED_PROCESS_LIMIT); -static const pin_t led_row_pins[SN32_RGB_MATRIX_ROWS_HW] = SN32_RGB_MATRIX_ROW_PINS; // We expect a R,B,G order here -static const pin_t led_col_pins[SN32_RGB_MATRIX_COLS] = SN32_RGB_MATRIX_COL_PINS; +static const pin_t led_row_pins[SN32F2XX_RGB_MATRIX_ROWS_HW] = SN32F2XX_RGB_MATRIX_ROW_PINS; // We expect a R,B,G order here +static const pin_t led_col_pins[SN32F2XX_RGB_MATRIX_COLS] = SN32F2XX_RGB_MATRIX_COL_PINS; static RGB led_state[SN32F2XX_LED_COUNT]; // led state buffer static RGB led_state_buf[SN32F2XX_LED_COUNT]; // led state buffer bool led_state_buf_update_required = false; @@ -137,12 +137,12 @@ static PWMConfig pwmcfg = { static void rgb_ch_ctrl(PWMConfig *cfg) { /* Enable PWM function, IOs and select the PWM modes for the LED pins */ -#if (SN32_PWM_DIRECTION == COL2ROW) - for (uint8_t i = 0; i < SN32_RGB_MATRIX_COLS; i++) { -# if (SN32_PWM_CONTROL == HARDWARE_PWM) +#if (SN32F2XX_PWM_DIRECTION == COL2ROW) + for (uint8_t i = 0; i < SN32F2XX_RGB_MATRIX_COLS; i++) { +# if (SN32F2XX_PWM_CONTROL == HARDWARE_PWM) // Only P0.0 to P2.15 can be used as pwm output if (led_col_pins[i] > C15) continue; -# endif // SN32_PWM_CONTROL +# endif // SN32F2XX_PWM_CONTROL /* We use a trick here, according to pfpa table of sn32f240b datasheet, pwm channel and pfpa of pin Px.y can be calculated as below: channel = (x*16+y)%24 @@ -151,12 +151,12 @@ static void rgb_ch_ctrl(PWMConfig *cfg) { uint8_t pio_value = ((uint32_t)(PAL_PORT(led_col_pins[i])) - (uint32_t)(PAL_PORT(A0))) / ((uint32_t)(PAL_PORT(B0)) - (uint32_t)(PAL_PORT(A0))) * PAL_IOPORTS_WIDTH + PAL_PAD(led_col_pins[i]); uint8_t ch_idx = pio_value % PWM_CHANNELS; chan_col_order[i] = ch_idx; -#elif (SN32_PWM_DIRECTION == ROW2COL) - for (uint8_t i = 0; i < SN32_RGB_MATRIX_ROWS_HW; i++) { -# if (SN32_PWM_CONTROL == HARDWARE_PWM) +#elif (SN32F2XX_PWM_DIRECTION == ROW2COL) + for (uint8_t i = 0; i < SN32F2XX_RGB_MATRIX_ROWS_HW; i++) { +# if (SN32F2XX_PWM_CONTROL == HARDWARE_PWM) // Only P0.0 to P2.15 can be used as pwm output if (led_row_pins[i] > C15) continue; -# endif // SN32_PWM_CONTROL +# endif // SN32F2XX_PWM_CONTROL /* We use a trick here, according to pfpa table of sn32f240b datasheet, pwm channel and pfpa of pin Px.y can be calculated as below: channel = (x*16+y)%24 @@ -165,11 +165,11 @@ static void rgb_ch_ctrl(PWMConfig *cfg) { uint8_t pio_value = ((uint32_t)(PAL_PORT(led_row_pins[i])) - (uint32_t)(PAL_PORT(A0))) / ((uint32_t)(PAL_PORT(B0)) - (uint32_t)(PAL_PORT(A0))) * PAL_IOPORTS_WIDTH + PAL_PAD(led_row_pins[i]); uint8_t ch_idx = pio_value % PWM_CHANNELS; chan_row_order[i] = ch_idx; -#endif // SN32_PWM_DIRECTION -#if (SN32_PWM_CONTROL == HARDWARE_PWM) +#endif // SN32F2XX_PWM_DIRECTION +#if (SN32F2XX_PWM_CONTROL == HARDWARE_PWM) cfg->channels[ch_idx].pfpamsk = pio_value > (PWM_CHANNELS -1); - cfg->channels[ch_idx].mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL; -#endif // SN32_PWM_CONTROL + cfg->channels[ch_idx].mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL; +#endif // SN32F2XX_PWM_CONTROL } } #elif defined(SN32F260) @@ -183,87 +183,87 @@ static const PWMConfig pwmcfg = { /* Default all channels to disabled */ [0 ... PWM_CHANNELS-1] = {.mode = PWM_OUTPUT_DISABLED}, /* Enable selected channels */ -# if defined(SN32_ACTIVATE_PWM_CHAN_0) - [0] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_0 -# if defined(SN32_ACTIVATE_PWM_CHAN_1) - [1] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_1 -# if defined(SN32_ACTIVATE_PWM_CHAN_2) - [2] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_2 -# if defined(SN32_ACTIVATE_PWM_CHAN_3) - [3] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_3 -# if defined(SN32_ACTIVATE_PWM_CHAN_4) - [4] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_4 -# if defined(SN32_ACTIVATE_PWM_CHAN_5) - [5] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_5 -# if defined(SN32_ACTIVATE_PWM_CHAN_6) - [6] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_6 -# if defined(SN32_ACTIVATE_PWM_CHAN_7) - [7] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_7 -# if defined(SN32_ACTIVATE_PWM_CHAN_8) - [8] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_8 -# if defined(SN32_ACTIVATE_PWM_CHAN_9) - [9] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_9 -# if defined(SN32_ACTIVATE_PWM_CHAN_10) - [10] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_10 -# if defined(SN32_ACTIVATE_PWM_CHAN_11) - [11] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_11 -# if defined(SN32_ACTIVATE_PWM_CHAN_12) - [12] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_12 -# if defined(SN32_ACTIVATE_PWM_CHAN_13) - [13] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_13 -# if defined(SN32_ACTIVATE_PWM_CHAN_14) - [14] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_14 -# if defined(SN32_ACTIVATE_PWM_CHAN_15) - [15] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_15 -# if defined(SN32_ACTIVATE_PWM_CHAN_16) - [16] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_16 -# if defined(SN32_ACTIVATE_PWM_CHAN_17) - [17] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_17 -# if defined(SN32_ACTIVATE_PWM_CHAN_18) - [18] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_18 -# if defined(SN32_ACTIVATE_PWM_CHAN_19) - [19] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_19 -# if defined(SN32_ACTIVATE_PWM_CHAN_20) - [20] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_20 -# if defined(SN32_ACTIVATE_PWM_CHAN_21) - [21] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_21 -# if defined(SN32_ACTIVATE_PWM_CHAN_22) - [22] = {.mode = SN32_PWM_OUTPUT_ACTIVE_LEVEL}, -# endif // SN32_ACTIVATE_PWM_CHAN_22 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_0) + [0] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_0 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_1) + [1] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_1 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_2) + [2] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_2 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_3) + [3] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_3 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_4) + [4] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_4 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_5) + [5] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_5 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_6) + [6] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_6 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_7) + [7] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_7 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_8) + [8] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_8 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_9) + [9] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_9 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_10) + [10] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_10 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_11) + [11] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_11 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_12) + [12] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_12 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_13) + [13] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_13 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_14) + [14] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_14 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_15) + [15] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_15 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_16) + [16] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_16 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_17) + [17] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_17 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_18) + [18] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_18 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_19) + [19] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_19 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_20) + [20] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_20 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_21) + [21] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_21 +# if defined(SN32F2XX_ACTIVATE_PWM_CHAN_22) + [22] = {.mode = SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL}, +# endif // SN32F2XX_ACTIVATE_PWM_CHAN_22 }, 0 /* HW dependent part.*/ }; static void rgb_ch_ctrl(void) { /* Enable PWM function, IOs and select the PWM modes for the LED pins */ -#if (SN32_PWM_DIRECTION == COL2ROW) - for (uint8_t i = 0; i < SN32_RGB_MATRIX_COLS; i++) { -# if (SN32_PWM_CONTROL == HARDWARE_PWM) +#if (SN32F2XX_PWM_DIRECTION == COL2ROW) + for (uint8_t i = 0; i < SN32F2XX_RGB_MATRIX_COLS; i++) { +# if (SN32F2XX_PWM_CONTROL == HARDWARE_PWM) // Only P0.0 to P0.15 and P3.0 to P3.8 can be used as pwm output if (led_col_pins[i] > A15 && led_col_pins[i] < D0) continue; -# endif // SN32_PWM_CONTROL +# endif // SN32F2XX_PWM_CONTROL /* We use a trick here, according to pfpa table of sn32f260 datasheet, pwm channel and pfpa of pin Px.y can be calculated as below: channel = (x*16+y)%23 @@ -271,12 +271,12 @@ static void rgb_ch_ctrl(void) { uint8_t pio_value = ((uint32_t)(PAL_PORT(led_col_pins[i])) - (uint32_t)(PAL_PORT(A0))) / ((uint32_t)(PAL_PORT(D0)) - (uint32_t)(PAL_PORT(A0))) * PAL_IOPORTS_WIDTH + PAL_PAD(led_col_pins[i]); uint8_t ch_idx = pio_value % PWM_CHANNELS; chan_col_order[i] = ch_idx; -#elif (SN32_PWM_DIRECTION == ROW2COL) - for (uint8_t i = 0; i < SN32_RGB_MATRIX_ROWS_HW; i++) { -# if (SN32_PWM_CONTROL == HARDWARE_PWM) +#elif (SN32F2XX_PWM_DIRECTION == ROW2COL) + for (uint8_t i = 0; i < SN32F2XX_RGB_MATRIX_ROWS_HW; i++) { +# if (SN32F2XX_PWM_CONTROL == HARDWARE_PWM) // Only P0.0 to P0.15 and P3.0 to P3.8 can be used as pwm output if (led_row_pins[i] > A15 && led_row_pins[i] < D0) continue; -# endif // SN32_PWM_CONTROL +# endif // SN32F2XX_PWM_CONTROL /* We use a trick here, according to pfpa table of sn32f260 datasheet, pwm channel and pfpa of pin Px.y can be calculated as below: channel = (x*16+y)%23 @@ -284,7 +284,7 @@ static void rgb_ch_ctrl(void) { uint8_t pio_value = ((uint32_t)(PAL_PORT(led_row_pins[i])) - (uint32_t)(PAL_PORT(A0))) / ((uint32_t)(PAL_PORT(D0)) - (uint32_t)(PAL_PORT(A0))) * PAL_IOPORTS_WIDTH + PAL_PAD(led_row_pins[i]); uint8_t ch_idx = pio_value % PWM_CHANNELS; chan_row_order[i] = ch_idx; -#endif // SN32_PWM_DIRECTION +#endif // SN32F2XX_PWM_DIRECTION } } #else @@ -313,7 +313,7 @@ static void shared_matrix_scan_keys(matrix_row_t current_matrix[], uint8_t curre } if (matrix_locked) { #if (DIODE_DIRECTION == COL2ROW) -# if (SN32_PWM_DIRECTION == DIODE_DIRECTION) +# if (SN32F2XX_PWM_DIRECTION == DIODE_DIRECTION) matrix_read_cols_on_row(current_matrix, current_key); # else // For each row... @@ -321,9 +321,9 @@ static void shared_matrix_scan_keys(matrix_row_t current_matrix[], uint8_t curre matrix_read_cols_on_row(current_matrix, row_index); } -# endif // DIODE_DIRECTION == SN32_PWM_DIRECTION +# endif // DIODE_DIRECTION == SN32F2XX_PWM_DIRECTION #elif (DIODE_DIRECTION == ROW2COL) -# if (SN32_PWM_DIRECTION == DIODE_DIRECTION) +# if (SN32F2XX_PWM_DIRECTION == DIODE_DIRECTION) matrix_read_rows_on_col(current_matrix, current_key, row_shifter); # else // For each col... @@ -331,7 +331,7 @@ static void shared_matrix_scan_keys(matrix_row_t current_matrix[], uint8_t curre for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++, row_shifter <<= 1) { matrix_read_rows_on_col(current_matrix, current_key, row_shifter); } -# endif // SN32_PWM_DIRECTION +# endif // SN32F2XX_PWM_DIRECTION #endif // DIODE_DIRECTION matrix_scanned = true; } @@ -339,24 +339,24 @@ static void shared_matrix_scan_keys(matrix_row_t current_matrix[], uint8_t curre } #endif // SHARED_MATRIX -#if (SN32_PWM_DIRECTION == COL2ROW) +#if (SN32F2XX_PWM_DIRECTION == COL2ROW) static void shared_matrix_rgb_disable_output(void) { // Disable PWM outputs on column pins - for (uint8_t y = 0; y < SN32_RGB_MATRIX_COLS; y++) { -# if (SN32_PWM_CONTROL == HARDWARE_PWM) + for (uint8_t y = 0; y < SN32F2XX_RGB_MATRIX_COLS; y++) { +# if (SN32F2XX_PWM_CONTROL == HARDWARE_PWM) pwmDisableChannel(&PWMD1, chan_col_order[y]); -# elif (SN32_PWM_CONTROL == SOFTWARE_PWM) +# elif (SN32F2XX_PWM_CONTROL == SOFTWARE_PWM) gpio_set_pin_input(led_col_pins[y]); -# endif // SN32_PWM_CONTROL +# endif // SN32F2XX_PWM_CONTROL } // Disable LED outputs on RGB channel pins - for (uint8_t x = 0; x < SN32_RGB_MATRIX_ROWS_HW; x++) { -# if (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH) + for (uint8_t x = 0; x < SN32F2XX_RGB_MATRIX_ROWS_HW; x++) { +# if (SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL == SN32F2XX_RGB_OUTPUT_ACTIVE_HIGH) gpio_write_pin_low(led_row_pins[x]); -# elif (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_LOW) +# elif (SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL == SN32F2XX_RGB_OUTPUT_ACTIVE_LOW) gpio_write_pin_high(led_row_pins[x]); -# endif // SN32_RGB_OUTPUT_ACTIVE_LEVEL +# endif // SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL } } @@ -364,18 +364,18 @@ static void update_pwm_channels(PWMDriver *pwmp) { // Advance to the next LED RGB channels current_row++; /* Check if counter has wrapped around, reset before the next pass */ - if (current_row == SN32_RGB_MATRIX_ROWS_HW) current_row = 0; + if (current_row == SN32F2XX_RGB_MATRIX_ROWS_HW) current_row = 0; # if defined(SHARED_MATRIX) uint8_t last_key_row = current_key_row; # endif // SHARED_MATRIX // Advance to the next key matrix row -# if (SN32_PWM_CONTROL == HARDWARE_PWM) - if (current_row % SN32_RGB_MATRIX_ROW_CHANNELS == 2) current_key_row++; -# elif (SN32_PWM_CONTROL == SOFTWARE_PWM) - if (current_row % SN32_RGB_MATRIX_ROW_CHANNELS == 0) current_key_row++; -# endif // SN32_PWM_CONTROL +# if (SN32F2XX_PWM_CONTROL == HARDWARE_PWM) + if (current_row % SN32F2XX_RGB_MATRIX_ROW_CHANNELS == 2) current_key_row++; +# elif (SN32F2XX_PWM_CONTROL == SOFTWARE_PWM) + if (current_row % SN32F2XX_RGB_MATRIX_ROW_CHANNELS == 0) current_key_row++; +# endif // SN32F2XX_PWM_CONTROL /* Check if counter has wrapped around, reset before the next pass */ - if (current_key_row == SN32_RGB_MATRIX_ROWS) current_key_row = 0; + if (current_key_row == SN32F2XX_RGB_MATRIX_ROWS) current_key_row = 0; // Disable LED output before scanning the key matrix if (current_key_row < ROWS_PER_HAND) { shared_matrix_rgb_disable_output(); @@ -384,18 +384,18 @@ static void update_pwm_channels(PWMDriver *pwmp) { # endif // SHARED_MATRIX } bool enable_pwm_output = false; - for (uint8_t current_key_col = 0; current_key_col < SN32_RGB_MATRIX_COLS; current_key_col++) { + for (uint8_t current_key_col = 0; current_key_col < SN32F2XX_RGB_MATRIX_COLS; current_key_col++) { uint8_t led_index = g_led_config.matrix_co[current_key_row][current_key_col]; -# if (SN32_PWM_CONTROL == SOFTWARE_PWM) +# if (SN32F2XX_PWM_CONTROL == SOFTWARE_PWM) if (led_index >= SN32F2XX_LED_COUNT) continue; -# endif // SN32_PWM_CONTROL +# endif // SN32F2XX_PWM_CONTROL // Check if we need to enable RGB output if (led_state[led_index].b > 0) enable_pwm_output |= true; if (led_state[led_index].g > 0) enable_pwm_output |= true; if (led_state[led_index].r > 0) enable_pwm_output |= true; // Update matching RGB channel PWM configuration -# if (SN32_PWM_CONTROL == HARDWARE_PWM) - switch (current_row % SN32_RGB_MATRIX_ROW_CHANNELS) { +# if (SN32F2XX_PWM_CONTROL == HARDWARE_PWM) + switch (current_row % SN32F2XX_RGB_MATRIX_ROW_CHANNELS) { case 0: pwmEnableChannel(pwmp, chan_col_order[current_key_col], led_state[led_index].b); break; @@ -407,8 +407,8 @@ static void update_pwm_channels(PWMDriver *pwmp) { break; default:; } -# elif (SN32_PWM_CONTROL == SOFTWARE_PWM) - switch (current_row % SN32_RGB_MATRIX_ROW_CHANNELS) { +# elif (SN32F2XX_PWM_CONTROL == SOFTWARE_PWM) + switch (current_row % SN32F2XX_RGB_MATRIX_ROW_CHANNELS) { case 0: led_duty_cycle[current_key_col] = led_state[led_index].r; break; @@ -424,41 +424,41 @@ static void update_pwm_channels(PWMDriver *pwmp) { } // Enable RGB output if (enable_pwm_output) { -# if (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH) +# if (SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL == SN32F2XX_RGB_OUTPUT_ACTIVE_HIGH) gpio_write_pin_high(led_row_pins[current_row]); -# elif (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_LOW) +# elif (SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL == SN32F2XX_RGB_OUTPUT_ACTIVE_LOW) gpio_write_pin_low(led_row_pins[current_row]); # endif } } -#elif (SN32_PWM_DIRECTION == ROW2COL) +#elif (SN32F2XX_PWM_DIRECTION == ROW2COL) static void shared_matrix_rgb_disable_output(void) { // Disable LED outputs on RGB channel pins - for (uint8_t x = 0; x < SN32_RGB_MATRIX_COLS; x++) { -# if (DIODE_DIRECTION != SN32_PWM_DIRECTION) + for (uint8_t x = 0; x < SN32F2XX_RGB_MATRIX_COLS; x++) { +# if (DIODE_DIRECTION != SN32F2XX_PWM_DIRECTION) gpio_set_pin_input(led_col_pins[x]); -# endif // DIODE_DIRECTION != SN32_PWM_DIRECTION +# endif // DIODE_DIRECTION != SN32F2XX_PWM_DIRECTION // Unselect all columns before scanning the key matrix -# if (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_LOW) +# if (SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL == SN32F2XX_RGB_OUTPUT_ACTIVE_LOW) gpio_write_pin_high(led_col_pins[x]); -# elif (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH) +# elif (SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL == SN32F2XX_RGB_OUTPUT_ACTIVE_HIGH) gpio_write_pin_low(led_col_pins[x]); # endif } -# if (DIODE_DIRECTION != SN32_PWM_DIRECTION) +# if (DIODE_DIRECTION != SN32F2XX_PWM_DIRECTION) // Disable PWM outputs on row pins - for (uint8_t x = 0; x < SN32_RGB_MATRIX_ROWS_HW; x++) { -# if (SN32_PWM_CONTROL == HARDWARE_PWM) + for (uint8_t x = 0; x < SN32F2XX_RGB_MATRIX_ROWS_HW; x++) { +# if (SN32F2XX_PWM_CONTROL == HARDWARE_PWM) pwmDisableChannel(&PWMD1, chan_row_order[x]); -# endif // SN32_PWM_CONTROL -# if (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_HIGH) +# endif // SN32F2XX_PWM_CONTROL +# if (SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL == SN32F2XX_PWM_OUTPUT_ACTIVE_HIGH) gpio_write_pin_low(led_row_pins[x]); -# elif (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_LOW) +# elif (SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL == SN32F2XX_PWM_OUTPUT_ACTIVE_LOW) gpio_write_pin_high(led_row_pins[x]); -# endif // SN32_RGB_OUTPUT_ACTIVE_LEVEL +# endif // SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL } -# endif // DIODE_DIRECTION != SN32_PWM_DIRECTION +# endif // DIODE_DIRECTION != SN32F2XX_PWM_DIRECTION } static void update_pwm_channels(PWMDriver *pwmp) { @@ -470,7 +470,7 @@ static void update_pwm_channels(PWMDriver *pwmp) { if (current_key_col < MATRIX_COLS) row_shifter <<= 1; if (current_key_col == MATRIX_COLS) row_shifter = MATRIX_ROW_SHIFTER; # endif // DIODE_DIRECTION == ROW2COL - if (current_key_col == SN32_RGB_MATRIX_COLS) current_key_col = 0; + if (current_key_col == SN32F2XX_RGB_MATRIX_COLS) current_key_col = 0; // Disable LED output before scanning the key matrix if (current_key_col < MATRIX_COLS) { shared_matrix_rgb_disable_output(); @@ -482,16 +482,16 @@ static void update_pwm_channels(PWMDriver *pwmp) { bool enable_pwm_output = false; for (uint8_t current_key_row = 0; current_key_row < MATRIX_ROWS; current_key_row++) { uint8_t led_index = g_led_config.matrix_co[current_key_row][current_key_col]; -# if (SN32_PWM_CONTROL == SOFTWARE_PWM) +# if (SN32F2XX_PWM_CONTROL == SOFTWARE_PWM) if (led_index >= SN32F2XX_LED_COUNT) continue; # endif - uint8_t led_row_id = (current_key_row * SN32_RGB_MATRIX_ROW_CHANNELS); + uint8_t led_row_id = (current_key_row * SN32F2XX_RGB_MATRIX_ROW_CHANNELS); // Check if we need to enable RGB output if (led_state[led_index].b > 0) enable_pwm_output |= true; if (led_state[led_index].g > 0) enable_pwm_output |= true; if (led_state[led_index].r > 0) enable_pwm_output |= true; // Update matching RGB channel PWM configuration -# if (SN32_PWM_CONTROL == HARDWARE_PWM) +# if (SN32F2XX_PWM_CONTROL == HARDWARE_PWM) pwmEnableChannelI(pwmp, chan_row_order[(led_row_id + 0)], led_state[led_index].r); pwmEnableChannelI(pwmp, chan_row_order[(led_row_id + 1)], led_state[led_index].b); pwmEnableChannelI(pwmp, chan_row_order[(led_row_id + 2)], led_state[led_index].g); @@ -499,13 +499,13 @@ static void update_pwm_channels(PWMDriver *pwmp) { // Enable RGB output if (enable_pwm_output) { gpio_set_pin_output_push_pull(led_col_pins[last_key_col]); -# if (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH) +# if (SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL == SN32F2XX_RGB_OUTPUT_ACTIVE_HIGH) gpio_write_pin_high(led_col_pins[last_key_col]); -# elif (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_LOW) +# elif (SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL == SN32F2XX_RGB_OUTPUT_ACTIVE_LOW) gpio_write_pin_low(led_col_pins[last_key_col]); -# endif // SN32_RGB_OUTPUT_ACTIVE_LEVEL +# endif // SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL } -# elif (SN32_PWM_CONTROL == SOFTWARE_PWM) +# elif (SN32F2XX_PWM_CONTROL == SOFTWARE_PWM) led_duty_cycle[(led_row_id + 0)] = led_state[led_index].r; led_duty_cycle[(led_row_id + 1)] = led_state[led_index].b; led_duty_cycle[(led_row_id + 2)] = led_state[led_index].g; @@ -513,52 +513,52 @@ static void update_pwm_channels(PWMDriver *pwmp) { // Enable RGB output if (enable_pwm_output) { gpio_set_pin_output_push_pull(led_col_pins[last_key_col]); -# if (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH) +# if (SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL == SN32F2XX_RGB_OUTPUT_ACTIVE_HIGH) gpio_write_pin_high(led_col_pins[current_key_col]); -# elif (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_LOW) +# elif (SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL == SN32F2XX_RGB_OUTPUT_ACTIVE_LOW) gpio_write_pin_low(led_col_pins[current_key_col]); -# endif // SN32_RGB_OUTPUT_ACTIVE_LEVEL +# endif // SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL } -# endif // SN32_PWM_CONTROL +# endif // SN32F2XX_PWM_CONTROL } -#endif // SN32_PWM_DIRECTION == ROW2COL +#endif // SN32F2XX_PWM_DIRECTION == ROW2COL static void rgb_callback(PWMDriver *pwmp) { // Disable the interrupt pwmDisablePeriodicNotification(pwmp); -#if ((SN32_PWM_CONTROL == SOFTWARE_PWM) && (SN32_PWM_DIRECTION == COL2ROW)) - for (uint8_t pwm_cnt = 0; pwm_cnt < (SN32_RGB_MATRIX_COLS * RGB_MATRIX_HUE_STEP); pwm_cnt++) { - uint8_t pwm_index = (pwm_cnt % SN32_RGB_MATRIX_COLS); +#if ((SN32F2XX_PWM_CONTROL == SOFTWARE_PWM) && (SN32F2XX_PWM_DIRECTION == COL2ROW)) + for (uint8_t pwm_cnt = 0; pwm_cnt < (SN32F2XX_RGB_MATRIX_COLS * RGB_MATRIX_HUE_STEP); pwm_cnt++) { + uint8_t pwm_index = (pwm_cnt % SN32F2XX_RGB_MATRIX_COLS); if (((uint16_t)(pwmp->ct->TC) < ((uint16_t)(led_duty_cycle[pwm_index] + periodticks))) && (led_duty_cycle[pwm_index] > 0)) { gpio_set_pin_output_push_pull(led_col_pins[pwm_index]); -# if (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_LOW) +# if (SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL == SN32F2XX_PWM_OUTPUT_ACTIVE_LOW) gpio_write_pin_low(led_col_pins[pwm_index]); } else { gpio_set_pin_input_high(led_col_pins[pwm_index]); -# elif (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_HIGH) +# elif (SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL == SN32F2XX_PWM_OUTPUT_ACTIVE_HIGH) gpio_write_pin_high(led_col_pins[pwm_index]); } else { gpio_set_pin_input_low(led_col_pins[pwm_index]); -# endif // SN32_PWM_OUTPUT_ACTIVE_LEVEL +# endif // SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL } } -#elif ((SN32_PWM_CONTROL == SOFTWARE_PWM) && (SN32_PWM_DIRECTION == ROW2COL)) - for (uint8_t pwm_cnt = 0; pwm_cnt < (SN32_RGB_MATRIX_ROWS_HW * RGB_MATRIX_HUE_STEP); pwm_cnt++) { - uint8_t pwm_index = (pwm_cnt % SN32_RGB_MATRIX_ROWS_HW); +#elif ((SN32F2XX_PWM_CONTROL == SOFTWARE_PWM) && (SN32F2XX_PWM_DIRECTION == ROW2COL)) + for (uint8_t pwm_cnt = 0; pwm_cnt < (SN32F2XX_RGB_MATRIX_ROWS_HW * RGB_MATRIX_HUE_STEP); pwm_cnt++) { + uint8_t pwm_index = (pwm_cnt % SN32F2XX_RGB_MATRIX_ROWS_HW); if (((uint16_t)(pwmp->ct->TC) < ((uint16_t)(led_duty_cycle[pwm_index] + periodticks))) && (led_duty_cycle[pwm_index] > 0)) { -# if (DIODE_DIRECTION != SN32_PWM_DIRECTION) +# if (DIODE_DIRECTION != SN32F2XX_PWM_DIRECTION) gpio_set_pin_output_push_pull(led_row_pins[pwm_index]); -# endif // DIODE_DIRECTION != SN32_PWM_DIRECTION +# endif // DIODE_DIRECTION != SN32F2XX_PWM_DIRECTION -# if (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_LOW) +# if (SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL == SN32F2XX_PWM_OUTPUT_ACTIVE_LOW) gpio_write_pin_low(led_row_pins[pwm_index]); } else { gpio_write_pin_high(led_row_pins[pwm_index]); -# elif (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_HIGH) +# elif (SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL == SN32F2XX_PWM_OUTPUT_ACTIVE_HIGH) gpio_write_pin_high(led_row_pins[pwm_index]); } else { gpio_write_pin_low(led_row_pins[pwm_index]); -# endif // SN32_PWM_OUTPUT_ACTIVE_LEVEL +# endif // SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL } } #endif @@ -573,15 +573,15 @@ static void rgb_callback(PWMDriver *pwmp) { } void sn32f2xx_init(void) { - for (uint8_t x = 0; x < SN32_RGB_MATRIX_ROWS_HW; x++) { + for (uint8_t x = 0; x < SN32F2XX_RGB_MATRIX_ROWS_HW; x++) { gpio_set_pin_output_push_pull(led_row_pins[x]); -# if ((SN32_PWM_DIRECTION == COL2ROW) && (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_HIGH) || \ - (SN32_PWM_DIRECTION == ROW2COL) && (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_HIGH)) +# if ((SN32F2XX_PWM_DIRECTION == COL2ROW) && (SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL == SN32F2XX_RGB_OUTPUT_ACTIVE_HIGH) || \ + (SN32F2XX_PWM_DIRECTION == ROW2COL) && (SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL == SN32F2XX_PWM_OUTPUT_ACTIVE_HIGH)) gpio_write_pin_low(led_row_pins[x]); -# elif ((SN32_PWM_DIRECTION == COL2ROW) && (SN32_RGB_OUTPUT_ACTIVE_LEVEL == SN32_RGB_OUTPUT_ACTIVE_LOW) || \ - (SN32_PWM_DIRECTION == ROW2COL) && (SN32_PWM_OUTPUT_ACTIVE_LEVEL == SN32_PWM_OUTPUT_ACTIVE_LOW)) +# elif ((SN32F2XX_PWM_DIRECTION == COL2ROW) && (SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL == SN32F2XX_RGB_OUTPUT_ACTIVE_LOW) || \ + (SN32F2XX_PWM_DIRECTION == ROW2COL) && (SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL == SN32F2XX_PWM_OUTPUT_ACTIVE_LOW)) gpio_write_pin_high(led_row_pins[x]); -# endif // SN32_RGB_OUTPUT_ACTIVE_LEVEL +# endif // SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL } // Determine which PWM channels we need to control @@ -610,9 +610,9 @@ void sn32f2xx_flush(void) { } void sn32f2xx_set_color(int index, uint8_t r, uint8_t g, uint8_t b) { - uint8_t color_r = r * SN32_LED_OUTPUT_LUMINOSITY_R; - uint8_t color_g = g * SN32_LED_OUTPUT_LUMINOSITY_G; - uint8_t color_b = b * SN32_LED_OUTPUT_LUMINOSITY_B; + uint8_t color_r = r * SN32F2XX_LED_OUTPUT_LUMINOSITY_R; + uint8_t color_g = g * SN32F2XX_LED_OUTPUT_LUMINOSITY_G; + uint8_t color_b = b * SN32F2XX_LED_OUTPUT_LUMINOSITY_B; #ifdef UNDERGLOW_RBG bool flip_gb = false; diff --git a/drivers/led/sn32f2xx.h b/drivers/led/sn32f2xx.h index e07c086efa7f..5b541a1bc385 100644 --- a/drivers/led/sn32f2xx.h +++ b/drivers/led/sn32f2xx.h @@ -19,59 +19,59 @@ #include #include -#if !defined(SN32_LED_OUTPUT_LUMINOSITY_R) -# define SN32_LED_OUTPUT_LUMINOSITY_R 1 +#if !defined(SN32F2XX_LED_OUTPUT_LUMINOSITY_R) +# define SN32F2XX_LED_OUTPUT_LUMINOSITY_R 1 #endif -#if !defined(SN32_LED_OUTPUT_LUMINOSITY_G) -# define SN32_LED_OUTPUT_LUMINOSITY_G 1 +#if !defined(SN32F2XX_LED_OUTPUT_LUMINOSITY_G) +# define SN32F2XX_LED_OUTPUT_LUMINOSITY_G 1 #endif -#if !defined(SN32_LED_OUTPUT_LUMINOSITY_B) -# define SN32_LED_OUTPUT_LUMINOSITY_B 1 +#if !defined(SN32F2XX_LED_OUTPUT_LUMINOSITY_B) +# define SN32F2XX_LED_OUTPUT_LUMINOSITY_B 1 #endif #if defined(RGB_MATRIX_SN32F2XX) # define SN32F2XX_LED_COUNT RGB_MATRIX_LED_COUNT #endif -#if !defined(SN32_PWM_OUTPUT_ACTIVE_LEVEL) -# define SN32_PWM_OUTPUT_ACTIVE_LEVEL SN32_PWM_OUTPUT_ACTIVE_LOW +#if !defined(SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL) +# define SN32F2XX_PWM_OUTPUT_ACTIVE_LEVEL SN32F2XX_PWM_OUTPUT_ACTIVE_LOW #endif -#if !defined(SN32_RGB_OUTPUT_ACTIVE_LEVEL) -# define SN32_RGB_OUTPUT_ACTIVE_LEVEL SN32_RGB_OUTPUT_ACTIVE_HIGH +#if !defined(SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL) +# define SN32F2XX_RGB_OUTPUT_ACTIVE_LEVEL SN32F2XX_RGB_OUTPUT_ACTIVE_HIGH #endif -#if !defined(SN32_PWM_CONTROL) -# define SN32_PWM_CONTROL HARDWARE_PWM +#if !defined(SN32F2XX_PWM_CONTROL) +# define SN32F2XX_PWM_CONTROL HARDWARE_PWM #endif -#if !defined(SN32_PWM_DIRECTION) -# define SN32_PWM_DIRECTION DIODE_DIRECTION +#if !defined(SN32F2XX_PWM_DIRECTION) +# define SN32F2XX_PWM_DIRECTION DIODE_DIRECTION #endif -#if !defined(SN32_RGB_MATRIX_ROW_CHANNELS) -# define SN32_RGB_MATRIX_ROW_CHANNELS 3 +#if !defined(SN32F2XX_RGB_MATRIX_ROW_CHANNELS) +# define SN32F2XX_RGB_MATRIX_ROW_CHANNELS 3 #endif -#if !defined(SN32_RGB_MATRIX_ROWS) -# define SN32_RGB_MATRIX_ROWS MATRIX_ROWS +#if !defined(SN32F2XX_RGB_MATRIX_ROWS) +# define SN32F2XX_RGB_MATRIX_ROWS MATRIX_ROWS #endif -#if !defined(SN32_RGB_MATRIX_COLS) -# define SN32_RGB_MATRIX_COLS MATRIX_COLS +#if !defined(SN32F2XX_RGB_MATRIX_COLS) +# define SN32F2XX_RGB_MATRIX_COLS MATRIX_COLS #endif -#if !defined(SN32_RGB_MATRIX_ROW_PINS) -# error Missing definition for SN32_RGB_MATRIX_ROW_PINS +#if !defined(SN32F2XX_RGB_MATRIX_ROW_PINS) +# error Missing definition for SN32F2XX_RGB_MATRIX_ROW_PINS #endif -#if !defined(SN32_RGB_MATRIX_COL_PINS) +#if !defined(SN32F2XX_RGB_MATRIX_COL_PINS) # define SHARED_MATRIX -# define SN32_RGB_MATRIX_COL_PINS MATRIX_COL_PINS +# define SN32F2XX_RGB_MATRIX_COL_PINS MATRIX_COL_PINS #endif -#if !defined(SN32_RGB_MATRIX_ROWS_HW) -# define SN32_RGB_MATRIX_ROWS_HW (SN32_RGB_MATRIX_ROWS * SN32_RGB_MATRIX_ROW_CHANNELS) +#if !defined(SN32F2XX_RGB_MATRIX_ROWS_HW) +# define SN32F2XX_RGB_MATRIX_ROWS_HW (SN32F2XX_RGB_MATRIX_ROWS * SN32F2XX_RGB_MATRIX_ROW_CHANNELS) #endif void sn32f2xx_init(void);