1
0
Fork 0

Migrate rgblight.pin and RGB_DI_PIN to ws2812.pin (#20303)

This commit is contained in:
Ryan 2023-04-06 18:00:54 +10:00 committed by GitHub
parent 71c22a12db
commit 47966dc2a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2600 changed files with 4027 additions and 1909 deletions

View file

@ -38,10 +38,10 @@
static inline void ws2812_sendarray_mask(uint8_t *data, uint16_t datlen, uint8_t masklo, uint8_t maskhi);
void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds) {
DDRx_ADDRESS(RGB_DI_PIN) |= pinmask(RGB_DI_PIN);
DDRx_ADDRESS(WS2812_DI_PIN) |= pinmask(WS2812_DI_PIN);
uint8_t masklo = ~(pinmask(RGB_DI_PIN)) & PORTx_ADDRESS(RGB_DI_PIN);
uint8_t maskhi = pinmask(RGB_DI_PIN) | PORTx_ADDRESS(RGB_DI_PIN);
uint8_t masklo = ~(pinmask(WS2812_DI_PIN)) & PORTx_ADDRESS(WS2812_DI_PIN);
uint8_t maskhi = pinmask(WS2812_DI_PIN) | PORTx_ADDRESS(WS2812_DI_PIN);
ws2812_sendarray_mask((uint8_t *)ledarray, number_of_leds * sizeof(LED_TYPE), masklo, maskhi);
@ -165,7 +165,7 @@ static inline void ws2812_sendarray_mask(uint8_t *data, uint16_t datlen, uint8_t
" dec %0 \n\t" // '1' [+2] '0' [+2]
" brne loop%=\n\t" // '1' [+3] '0' [+4]
: "=&d"(ctr)
: "r"(curbyte), "I"(_SFR_IO_ADDR(PORTx_ADDRESS(RGB_DI_PIN))), "r"(maskhi), "r"(masklo));
: "r"(curbyte), "I"(_SFR_IO_ADDR(PORTx_ADDRESS(WS2812_DI_PIN))), "r"(maskhi), "r"(masklo));
}
SREG = sreg_prev;

View file

@ -67,8 +67,8 @@
// WS2812-style LED control on pin A10
#ifdef WS2812_DRIVER_PWM
# ifndef RGB_DI_PIN
# define RGB_DI_PIN PAL_LINE(GPIOA, 10)
# ifndef WS2812_DI_PIN
# define WS2812_DI_PIN PAL_LINE(GPIOA, 10)
# endif
# ifndef WS2812_PWM_DRIVER
# define WS2812_PWM_DRIVER PWMD1

View file

@ -185,7 +185,7 @@ bool ws2812_init(void) {
(pio_idx == 0 ? PAL_MODE_ALTERNATE_PIO0 : PAL_MODE_ALTERNATE_PIO1);
// clang-format on
palSetLineMode(RGB_DI_PIN, rgb_pin_mode);
palSetLineMode(WS2812_DI_PIN, rgb_pin_mode);
STATE_MACHINE = pio_claim_unused_sm(pio, true);
if (STATE_MACHINE < 0) {
@ -195,11 +195,11 @@ bool ws2812_init(void) {
uint offset = pio_add_program(pio, &ws2812_program);
pio_sm_set_consecutive_pindirs(pio, STATE_MACHINE, RGB_DI_PIN, 1, true);
pio_sm_set_consecutive_pindirs(pio, STATE_MACHINE, WS2812_DI_PIN, 1, true);
pio_sm_config config = pio_get_default_sm_config();
sm_config_set_wrap(&config, offset + WS2812_WRAP_TARGET, offset + WS2812_WRAP);
sm_config_set_sideset_pins(&config, RGB_DI_PIN);
sm_config_set_sideset_pins(&config, WS2812_DI_PIN);
sm_config_set_fifo_join(&config, PIO_FIFO_JOIN_TX);
#if defined(WS2812_EXTERNAL_PULLUP)

View file

@ -53,22 +53,22 @@ void sendByte(uint8_t byte) {
// using something like wait_ns(is_one ? T1L : T0L) here throws off timings
if (is_one) {
// 1
writePinHigh(RGB_DI_PIN);
writePinHigh(WS2812_DI_PIN);
wait_ns(WS2812_T1H);
writePinLow(RGB_DI_PIN);
writePinLow(WS2812_DI_PIN);
wait_ns(WS2812_T1L);
} else {
// 0
writePinHigh(RGB_DI_PIN);
writePinHigh(WS2812_DI_PIN);
wait_ns(WS2812_T0H);
writePinLow(RGB_DI_PIN);
writePinLow(WS2812_DI_PIN);
wait_ns(WS2812_T0L);
}
}
}
void ws2812_init(void) {
palSetLineMode(RGB_DI_PIN, WS2812_OUTPUT_MODE);
palSetLineMode(WS2812_DI_PIN, WS2812_OUTPUT_MODE);
}
// Setleds for standard RGB

View file

@ -308,7 +308,7 @@ void ws2812_init(void) {
for (i = 0; i < WS2812_RESET_BIT_N; i++)
ws2812_frame_buffer[i + WS2812_COLOR_BIT_N] = 0; // All reset bits are zero
palSetLineMode(RGB_DI_PIN, WS2812_OUTPUT_MODE);
palSetLineMode(WS2812_DI_PIN, WS2812_OUTPUT_MODE);
// PWM Configuration
//#pragma GCC diagnostic ignored "-Woverride-init" // Turn off override-init warning for this struct. We use the overriding ability to set a "default" channel config

View file

@ -136,7 +136,7 @@ static void set_led_color_rgb(LED_TYPE color, int pos) {
}
void ws2812_init(void) {
palSetLineMode(RGB_DI_PIN, WS2812_MOSI_OUTPUT_MODE);
palSetLineMode(WS2812_DI_PIN, WS2812_MOSI_OUTPUT_MODE);
#ifdef WS2812_SPI_SCK_PIN
palSetLineMode(WS2812_SPI_SCK_PIN, WS2812_SCK_OUTPUT_MODE);
@ -150,8 +150,8 @@ void ws2812_init(void) {
WS2812_SPI_BUFFER_MODE,
# endif
NULL, // end_cb
PAL_PORT(RGB_DI_PIN),
PAL_PAD(RGB_DI_PIN),
PAL_PORT(WS2812_DI_PIN),
PAL_PAD(WS2812_DI_PIN),
# if defined(WB32F3G71xx) || defined(WB32FQ95xx)
0,
0,
@ -170,8 +170,8 @@ void ws2812_init(void) {
# endif
NULL, // data_cb
NULL, // error_cb
PAL_PORT(RGB_DI_PIN),
PAL_PAD(RGB_DI_PIN),
PAL_PORT(WS2812_DI_PIN),
PAL_PAD(WS2812_DI_PIN),
WS2812_SPI_DIVISOR_CR1_BR_X,
0
#endif