调整日志级别为警告,修改 ws2812_spi 结构体中的 spi_pin 类型为 uint8_t,并优化 GPIO 引脚配置逻辑
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
#include "esp_netif_types.h"
|
#include "esp_netif_types.h"
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
|
|
||||||
#define CONFIG_SYS_LOG_LEVEL SYS_LOG_LEVEL_INF
|
#define CONFIG_SYS_LOG_LEVEL SYS_LOG_LEVEL_WRN
|
||||||
#define SYS_LOG_DOMAIN "WIFI"
|
#define SYS_LOG_DOMAIN "WIFI"
|
||||||
#include "sys_log.h"
|
#include "sys_log.h"
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ static struct
|
|||||||
spi_host_device_t host_id;
|
spi_host_device_t host_id;
|
||||||
spi_device_handle_t spi_hdl;
|
spi_device_handle_t spi_hdl;
|
||||||
os_mutex_t mutex_hdl;
|
os_mutex_t mutex_hdl;
|
||||||
uint16_t spi_pin;
|
uint8_t spi_pin;
|
||||||
int max_transfer_sz;
|
int max_transfer_sz;
|
||||||
} s_cm;
|
} s_cm;
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ void ws2812_spi_led_strip_init(uint8_t host_id, uint16_t max_led_num)
|
|||||||
ESP_ERROR_CHECK(ret);
|
ESP_ERROR_CHECK(ret);
|
||||||
|
|
||||||
s_cm.host_id = host_id;
|
s_cm.host_id = host_id;
|
||||||
s_cm.spi_pin = -1;
|
s_cm.spi_pin = ~0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!os_mutex_is_valid(&s_cm.mutex_hdl))
|
if (!os_mutex_is_valid(&s_cm.mutex_hdl))
|
||||||
@@ -254,12 +254,12 @@ int ws2812_spi_led_strip_refresh(ws2812_spi_led_buf_t *buf, uint32_t leds, uint8
|
|||||||
|
|
||||||
if (s_cm.spi_pin != pin)
|
if (s_cm.spi_pin != pin)
|
||||||
{
|
{
|
||||||
if (s_cm.spi_pin > 0)
|
if (GPIO_USED(s_cm.spi_pin))
|
||||||
{
|
{
|
||||||
drv_gpio_pin_configure(s_cm.spi_pin, _GPIO_DIR_OUT, _GPIO_PUD_PULL_UP);
|
drv_gpio_pin_configure(s_cm.spi_pin, _GPIO_DIR_OUT, _GPIO_PUD_PULL_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pin > 0)
|
if (GPIO_USED(pin))
|
||||||
{
|
{
|
||||||
drv_gpio_pin_configure(pin, _GPIO_DIR_OUT, _GPIO_PUD_PULL_UP);
|
drv_gpio_pin_configure(pin, _GPIO_DIR_OUT, _GPIO_PUD_PULL_UP);
|
||||||
esp_rom_gpio_connect_out_signal(pin, spi_periph_signal[s_cm.host_id].spid_out, true, false);
|
esp_rom_gpio_connect_out_signal(pin, spi_periph_signal[s_cm.host_id].spid_out, true, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user