Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers/ws281x: improve timing for ESP32x #19422

Merged
merged 1 commit into from
Mar 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions drivers/ws281x/esp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,23 @@ void ws281x_write_buffer(ws281x_t *dev, const void *buf, size_t size)
on_wait = zero_on;
off_wait = zero_off;
}
data <<= 1;
while (cpu_hal_get_cycle_count() < current_wait) { }
/* end of LOW phase and start of HIGH phase */
start = cpu_hal_get_cycle_count();
gpio_set(dev->params.pin);
current_wait = start + on_wait;
while (cpu_hal_get_cycle_count() < current_wait) { }
gpio_clear(dev->params.pin);
/* end of HIGH phase and start of HIGH phase */
start = cpu_hal_get_cycle_count();
gpio_clear(dev->params.pin);
current_wait = start + off_wait;
while (cpu_hal_get_cycle_count() < current_wait) { }
data <<= 1;
}
pos++;
}
/* final LOW phase */
current_wait = cpu_hal_get_cycle_count();
/* end of final LOW phase */
}

int ws281x_init(ws281x_t *dev, const ws281x_params_t *params)
Expand Down