mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-16 18:13:49 +01:00
Merge pull request #18252 from gschorcht/cpu/esp32/update_ws281x
drivers/ws281x: update ESP32 driver to use ESP-IDF CPU HAL
This commit is contained in:
commit
32a1c22e76
@ -12,7 +12,7 @@
|
|||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
* @file
|
* @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 <me@ccoors.de>
|
* @author Christian Friedrich Coors <me@ccoors.de>
|
||||||
*
|
*
|
||||||
@ -27,19 +27,14 @@
|
|||||||
#include "ws281x_params.h"
|
#include "ws281x_params.h"
|
||||||
#include "ws281x_constants.h"
|
#include "ws281x_constants.h"
|
||||||
#include "periph_cpu.h"
|
#include "periph_cpu.h"
|
||||||
|
|
||||||
#include "esp_private/esp_clk.h"
|
#include "esp_private/esp_clk.h"
|
||||||
#include "xtensa/core-macros.h"
|
#include "hal/cpu_hal.h"
|
||||||
#include "soc/rtc.h"
|
#include "soc/rtc.h"
|
||||||
|
|
||||||
#define ENABLE_DEBUG 0
|
#define ENABLE_DEBUG 0
|
||||||
#include "debug.h"
|
#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)
|
void ws281x_write_buffer(ws281x_t *dev, const void *buf, size_t size)
|
||||||
{
|
{
|
||||||
assert(dev);
|
assert(dev);
|
||||||
@ -74,14 +69,14 @@ void ws281x_write_buffer(ws281x_t *dev, const void *buf, size_t size)
|
|||||||
on_wait = zero_on;
|
on_wait = zero_on;
|
||||||
off_wait = zero_off;
|
off_wait = zero_off;
|
||||||
}
|
}
|
||||||
start = get_cycle_count();
|
start = cpu_hal_get_cycle_count();
|
||||||
gpio_set(dev->params.pin);
|
gpio_set(dev->params.pin);
|
||||||
current_wait = start + on_wait;
|
current_wait = start + on_wait;
|
||||||
while (get_cycle_count() < current_wait) { }
|
while (cpu_hal_get_cycle_count() < current_wait) { }
|
||||||
gpio_clear(dev->params.pin);
|
gpio_clear(dev->params.pin);
|
||||||
start = get_cycle_count();
|
start = cpu_hal_get_cycle_count();
|
||||||
current_wait = start + off_wait;
|
current_wait = start + off_wait;
|
||||||
while (get_cycle_count() < current_wait) { }
|
while (cpu_hal_get_cycle_count() < current_wait) { }
|
||||||
data <<= 1;
|
data <<= 1;
|
||||||
}
|
}
|
||||||
pos++;
|
pos++;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user