-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
7 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
* @{ | ||
* | ||
* @file | ||
* @brief Implementation of `ws281x_write_buffer()` for the ESP32 CPU | ||
* @brief Implementation of `ws281x_write_buffer()` for the ESP32x CPU | ||
* | ||
* @author Christian Friedrich Coors <[email protected]> | ||
* | ||
|
@@ -27,19 +27,14 @@ | |
#include "ws281x_params.h" | ||
#include "ws281x_constants.h" | ||
#include "periph_cpu.h" | ||
|
||
#include "esp_private/esp_clk.h" | ||
#include "xtensa/core-macros.h" | ||
#include "hal/cpu_hal.h" | ||
#include "soc/rtc.h" | ||
|
||
#define ENABLE_DEBUG 0 | ||
#include "debug.h" | ||
|
||
static inline __attribute__((always_inline)) uint32_t get_cycle_count(void) { | ||
uint32_t ccount; | ||
__asm__ __volatile__("rsr %0,ccount":"=a" (ccount)); | ||
return ccount; | ||
} | ||
|
||
void ws281x_write_buffer(ws281x_t *dev, const void *buf, size_t size) | ||
{ | ||
assert(dev); | ||
|
@@ -74,14 +69,14 @@ void ws281x_write_buffer(ws281x_t *dev, const void *buf, size_t size) | |
on_wait = zero_on; | ||
off_wait = zero_off; | ||
} | ||
start = get_cycle_count(); | ||
start = cpu_hal_get_cycle_count(); | ||
gpio_set(dev->params.pin); | ||
current_wait = start + on_wait; | ||
while (get_cycle_count() < current_wait) { } | ||
while (cpu_hal_get_cycle_count() < current_wait) { } | ||
gpio_clear(dev->params.pin); | ||
start = get_cycle_count(); | ||
start = cpu_hal_get_cycle_count(); | ||
current_wait = start + off_wait; | ||
while (get_cycle_count() < current_wait) { } | ||
while (cpu_hal_get_cycle_count() < current_wait) { } | ||
data <<= 1; | ||
} | ||
pos++; | ||
|