mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
risc-v/esp_<rmt|ws2812>: Implement the RMT peripheral for ESP32 RVs
This commit implements the RMT peripheral for all the supported Espressif's RISC-V devices. It also implements the support for the WS2812 addressable RGB LED using the RMT peripheral.
This commit is contained in:
committed by
Xiang Xiao
parent
c5358d6365
commit
e49684d781
@@ -130,6 +130,7 @@ endif
|
||||
|
||||
VPATH += chip
|
||||
VPATH += common
|
||||
VPATH += common/espressif
|
||||
VPATH += $(SBI_DIR)
|
||||
VPATH += $(ARCH_SUBDIR)
|
||||
VPATH += $(CHIP_DIR)
|
||||
|
||||
@@ -298,6 +298,16 @@ config ESPRESSIF_BROWNOUT_DET
|
||||
than a specific value. If this happens, it will reset the chip in
|
||||
order to prevent unintended behaviour.
|
||||
|
||||
config ESP_RMT
|
||||
bool "Remote Control Module (RMT)"
|
||||
default n
|
||||
depends on RMT
|
||||
---help---
|
||||
The RMT (Remote Control Transceiver) peripheral was designed to act as
|
||||
an infrared transceiver. However, due to the flexibility of its data
|
||||
format, RMT can be extended to a versatile and general-purpose
|
||||
transceiver, transmitting or receiving many other types of signals.
|
||||
|
||||
endmenu # Peripheral Support
|
||||
|
||||
menu "UART Configuration"
|
||||
|
||||
@@ -73,6 +73,13 @@ ifeq ($(CONFIG_ESPRESSIF_USBSERIAL),y)
|
||||
CHIP_CSRCS += esp_usbserial.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP_RMT),y)
|
||||
CHIP_CSRCS += esp_rmt.c
|
||||
ifeq ($(CONFIG_WS2812_NON_SPI_DRIVER),y)
|
||||
CHIP_CSRCS += esp_ws2812.c
|
||||
endif
|
||||
endif
|
||||
|
||||
#############################################################################
|
||||
# Espressif HAL for 3rd Party Platforms
|
||||
#############################################################################
|
||||
|
||||
@@ -98,6 +98,24 @@
|
||||
#define ONLOW 0x04
|
||||
#define ONHIGH 0x05
|
||||
|
||||
/* Check whether it is a valid GPIO number */
|
||||
|
||||
#define GPIO_IS_VALID_GPIO(gpio_num) ((gpio_num >= 0) && \
|
||||
(((1ULL << (gpio_num)) & \
|
||||
SOC_GPIO_VALID_GPIO_MASK) != 0))
|
||||
|
||||
/* Check whether it can be a valid GPIO number of output mode */
|
||||
|
||||
#define GPIO_IS_VALID_OUTPUT_GPIO(gpio_num) \
|
||||
((gpio_num >= 0) && \
|
||||
(((1ULL << (gpio_num)) & SOC_GPIO_VALID_OUTPUT_GPIO_MASK) != 0))
|
||||
|
||||
/* Check whether it can be a valid digital I/O pad */
|
||||
|
||||
#define GPIO_IS_VALID_DIGITAL_IO_PAD(gpio_num) \
|
||||
((gpio_num >= 0) && \
|
||||
(((1ULL << (gpio_num)) & SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK) != 0))
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,109 @@
|
||||
/****************************************************************************
|
||||
* arch/risc-v/src/common/espressif/esp_rmt.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_RISC_V_SRC_COMMON_ESPRESSIF_ESP_RMT_H
|
||||
#define __ARCH_RISC_V_SRC_COMMON_ESPRESSIF_ESP_RMT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <semaphore.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define RMT_MEM_ITEM_NUM SOC_RMT_MEM_WORDS_PER_CHANNEL
|
||||
|
||||
#define RMT_DEFAULT_CLK_DIV 1
|
||||
|
||||
/* Channel can work during APB clock scaling */
|
||||
|
||||
#define RMT_CHANNEL_FLAGS_AWARE_DFS (1 << 0)
|
||||
|
||||
/* Invert RMT signal */
|
||||
|
||||
#define RMT_CHANNEL_FLAGS_INVERT_SIG (1 << 1)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_ESP_RMT)
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp_rmt_tx_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize the selected RMT device in TX mode
|
||||
*
|
||||
* Input Parameters:
|
||||
* ch - the RMT's channel that will be used
|
||||
* pin - The pin used for the TX channel
|
||||
*
|
||||
* Returned Value:
|
||||
* Valid RMT device structure reference on success; NULL, otherwise.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct rmt_dev_s *esp_rmt_tx_init(int ch, int pin);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp_rmt_rx_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize the selected RMT device in RC mode
|
||||
*
|
||||
* Input Parameters:
|
||||
* ch - the RMT's channel that will be used
|
||||
* pin - The pin used for the RX channel
|
||||
*
|
||||
* Returned Value:
|
||||
* Valid RMT device structure reference on success; NULL, otherwise.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct rmt_dev_s *esp_rmt_rx_init(int ch, int pin);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
#endif /* __ARCH_RISC_V_SRC_COMMON_ESPRESSIF_ESP_RMT_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,100 @@
|
||||
/****************************************************************************
|
||||
* arch/risc-v/src/common/espressif/esp_ws2812.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_RISC_V_SRC_COMMON_ESPRESSIF_ESP_WS2812_H
|
||||
#define __ARCH_RISC_V_SRC_COMMON_ESPRESSIF_ESP_WS2812_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <debug.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_WS2812
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp_ws2812_setup
|
||||
*
|
||||
* Description:
|
||||
* This function sets up a WS2812 device instance. It allocates memory for
|
||||
* the device structures, initializes the device with the provided
|
||||
* parameters, and registers the device with the system.
|
||||
*
|
||||
* Input Parameters:
|
||||
* path - The device path.
|
||||
* rmt - Pointer to the RMT device structure.
|
||||
* pixel_count - The number of pixels in the WS2812 strip.
|
||||
* has_white - Flag indicating if the WS2812 strip includes a white LED.
|
||||
*
|
||||
* Returned Value:
|
||||
* Returns a pointer to the WS2812 device structure on successful setup;
|
||||
* NULL is returned on any failure, with errno set appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct ws2812_dev_s *esp_ws2812_setup(const char *path,
|
||||
struct rmt_dev_s *rmt,
|
||||
uint16_t pixel_count,
|
||||
bool has_white);
|
||||
/****************************************************************************
|
||||
* Name: esp_ws2812_release
|
||||
*
|
||||
* Description:
|
||||
* This function releases a previously opened WS2812 device instance. It
|
||||
* checks if the device is currently open, and if not, it frees the private
|
||||
* data structure and sets the private field of the device to NULL. If the
|
||||
* device is still open, it returns an error.
|
||||
*
|
||||
* Input Parameters:
|
||||
* driver - Pointer to the instance of the WS2812 device driver to be
|
||||
* released.
|
||||
*
|
||||
* Returned Value:
|
||||
* Returns OK on successful release of the device; a negated errno value
|
||||
* is returned on any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int esp_ws2812_release(void * driver);
|
||||
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __ARCH_RISC_V_SRC_COMMON_ESPRESSIF_ESP_WS2812_H */
|
||||
@@ -105,6 +105,7 @@ CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/timer_hal_iram.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/cache_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/mpu_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/mmu_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/rmt_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/uart_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/uart_hal_iram.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/wdt_hal_iram.c
|
||||
@@ -115,6 +116,7 @@ CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/log/log_noos.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/riscv/interrupt.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/soc/$(CHIP_SERIES)/gpio_periph.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/soc/$(CHIP_SERIES)/ledc_periph.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/soc/$(CHIP_SERIES)/rmt_periph.c
|
||||
|
||||
ifeq ($(CONFIG_ESPRESSIF_SIMPLE_BOOT),y)
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/nuttx/src/bootloader_banner_wrap.c
|
||||
|
||||
@@ -97,6 +97,7 @@ CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/gpio_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/ledc_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/ledc_hal_iram.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/lp_timer_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/rmt_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/timer_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/timer_hal_iram.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/uart_hal.c
|
||||
@@ -109,3 +110,4 @@ CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/log/log_noos.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/riscv/interrupt.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/soc/$(CHIP_SERIES)/gpio_periph.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/soc/$(CHIP_SERIES)/ledc_periph.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/soc/$(CHIP_SERIES)/rmt_periph.c
|
||||
|
||||
@@ -96,6 +96,7 @@ CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/gpio_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/ledc_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/ledc_hal_iram.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/lp_timer_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/rmt_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/timer_hal.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/timer_hal_iram.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/hal/uart_hal.c
|
||||
@@ -108,3 +109,4 @@ CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/log/log_noos.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/riscv/interrupt.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/soc/$(CHIP_SERIES)/gpio_periph.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/soc/$(CHIP_SERIES)/ledc_periph.c
|
||||
CHIP_CSRCS += chip/$(ESP_HAL_3RDPARTY_REPO)/components/soc/$(CHIP_SERIES)/rmt_periph.c
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/****************************************************************************
|
||||
* boards/risc-v/esp32c3/common/include/esp_board_rmt.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __BOARDS_RISC_V_ESP32C3_COMMON_INCLUDE_ESP_BOARD_RMT_H
|
||||
#define __BOARDS_RISC_V_ESP32C3_COMMON_INCLUDE_ESP_BOARD_RMT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP_RMT
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_rmt_rxinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the RMT peripheral and register a RX device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ch - the RMT's channel that will be used
|
||||
* pin - The pin used for the RX channel
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_rmt_rxinitialize(int ch, int pin);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_rmt_txinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the RMT peripheral and register a TX device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ch - the RMT's channel that will be used
|
||||
* pin - The pin used for the TX channel
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_rmt_txinitialize(int ch, int pin);
|
||||
|
||||
#endif /* CONFIG_ESP_RMT */
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_RISC_V_ESP32C3_COMMON_INCLUDE_ESP_BOARD_RMT_H */
|
||||
@@ -24,6 +24,10 @@ ifeq ($(CONFIG_ESPRESSIF_LEDC),y)
|
||||
CSRCS += esp_board_ledc.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP_RMT),y)
|
||||
CSRCS += esp_board_rmt.c
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path src
|
||||
VPATH += :src
|
||||
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
/****************************************************************************
|
||||
* boards/risc-v/esp32c3/common/src/esp_board_rmt.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/rmt/rmtchar.h>
|
||||
#ifdef CONFIG_WS2812_NON_SPI_DRIVER
|
||||
#include <nuttx/leds/ws2812.h>
|
||||
|
||||
#include "espressif/esp_ws2812.h"
|
||||
#endif
|
||||
|
||||
#include "espressif/esp_rmt.h"
|
||||
|
||||
#ifdef CONFIG_ESP_RMT
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_rmt_rxinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the RMT peripheral and register a RX device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ch - the RMT's channel that will be used
|
||||
* pin - The pin used for the RX channel
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_rmt_rxinitialize(int ch, int pin)
|
||||
{
|
||||
int ret;
|
||||
|
||||
struct rmt_dev_s *rmt = esp_rmt_rx_init(ch, pin);
|
||||
|
||||
ret = rmtchar_register(rmt);
|
||||
if (ret < 0)
|
||||
{
|
||||
rmterr("ERROR: rmtchar_register failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_rmt_txinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the RMT peripheral and register a TX device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ch - the RMT's channel that will be used
|
||||
* pin - The pin used for the TX channel
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_rmt_txinitialize(int ch, int pin)
|
||||
{
|
||||
int ret;
|
||||
struct rmt_dev_s *rmt;
|
||||
#ifdef CONFIG_WS2812_NON_SPI_DRIVER
|
||||
struct ws2812_dev_s *led;
|
||||
#endif
|
||||
|
||||
rmt = esp_rmt_tx_init(ch, pin);
|
||||
if (rmt == NULL)
|
||||
{
|
||||
rmterr("ERROR: esp_rmt_tx_init failed\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = rmtchar_register(rmt);
|
||||
if (ret < 0)
|
||||
{
|
||||
rmterr("ERROR: rmtchar_register failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_WS2812_NON_SPI_DRIVER
|
||||
led = esp_ws2812_setup("/dev/leds0", rmt, CONFIG_WS2812_LED_COUNT, false);
|
||||
if (led == NULL)
|
||||
{
|
||||
rmterr("ERROR: esp_ws2812_setup failed\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_NDEBUG is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
CONFIG_ARCH="risc-v"
|
||||
CONFIG_ARCH_BOARD="esp32c3-generic"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32C3_GENERIC=y
|
||||
CONFIG_ARCH_CHIP="esp32c3"
|
||||
CONFIG_ARCH_CHIP_ESP32C3_GENERIC=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=1536
|
||||
CONFIG_ARCH_RISCV=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=15000
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEV_ZERO=y
|
||||
CONFIG_ESP_RMT=y
|
||||
CONFIG_EXAMPLES_RMTCHAR=y
|
||||
CONFIG_EXAMPLES_RMTCHAR_RX=y
|
||||
CONFIG_EXAMPLES_RMTCHAR_RX_DEVPATH="/dev/rmt2"
|
||||
CONFIG_EXAMPLES_RMTCHAR_TX=y
|
||||
CONFIG_EXAMPLES_WS2812=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=2048
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_PERROR_STDOUT=y
|
||||
CONFIG_LIBC_STRERROR=y
|
||||
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NSH_STRERROR=y
|
||||
CONFIG_PREALLOC_TIMERS=0
|
||||
CONFIG_RMT=y
|
||||
CONFIG_RMTCHAR=y
|
||||
CONFIG_RMT_DEFAULT_RX_BUFFER_SIZE=512
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_BACKTRACE=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=29
|
||||
CONFIG_START_MONTH=11
|
||||
CONFIG_START_YEAR=2019
|
||||
CONFIG_SYSTEM_DUMPSTACK=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_TESTING_GETPRIME=y
|
||||
CONFIG_TESTING_OSTEST=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
CONFIG_WS2812=y
|
||||
CONFIG_WS2812_LED_COUNT=100
|
||||
CONFIG_WS2812_NON_SPI_DRIVER=y
|
||||
@@ -31,6 +31,19 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* RMT gpio */
|
||||
|
||||
#define RMT_RXCHANNEL 2
|
||||
#define RMT_TXCHANNEL 0
|
||||
|
||||
#ifdef CONFIG_RMT_LOOP_TEST_MODE
|
||||
# define RMT_INPUT_PIN 0
|
||||
# define RMT_OUTPUT_PIN 0
|
||||
#else
|
||||
# define RMT_INPUT_PIN 2
|
||||
# define RMT_OUTPUT_PIN 8
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
@@ -60,6 +60,10 @@
|
||||
# include <nuttx/input/buttons.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP_RMT
|
||||
# include "esp_board_rmt.h"
|
||||
#endif
|
||||
|
||||
#include "esp32c3-generic.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -147,6 +151,20 @@ int esp_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP_RMT
|
||||
ret = board_rmt_txinitialize(RMT_TXCHANNEL, RMT_OUTPUT_PIN);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: board_rmt_txinitialize() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = board_rmt_rxinitialize(RMT_RXCHANNEL, RMT_INPUT_PIN);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: board_rmt_txinitialize() failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RTC_DRIVER
|
||||
/* Initialize the RTC driver */
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/****************************************************************************
|
||||
* boards/risc-v/esp32c6/common/include/esp_board_rmt.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __BOARDS_RISC_V_ESP32C6_COMMON_INCLUDE_ESP_BOARD_RMT_H
|
||||
#define __BOARDS_RISC_V_ESP32C6_COMMON_INCLUDE_ESP_BOARD_RMT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP_RMT
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_rmt_rxinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the RMT peripheral and register a RX device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ch - the RMT's channel that will be used
|
||||
* pin - The pin used for the RX channel
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_rmt_rxinitialize(int ch, int pin);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_rmt_txinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the RMT peripheral and register a TX device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ch - the RMT's channel that will be used
|
||||
* pin - The pin used for the TX channel
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_rmt_txinitialize(int ch, int pin);
|
||||
|
||||
#endif /* CONFIG_ESP_RMT */
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_RISC_V_ESP32C6_COMMON_INCLUDE_ESP_BOARD_RMT_H */
|
||||
@@ -24,6 +24,10 @@ ifeq ($(CONFIG_ESPRESSIF_LEDC),y)
|
||||
CSRCS += esp_board_ledc.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP_RMT),y)
|
||||
CSRCS += esp_board_rmt.c
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path src
|
||||
VPATH += :src
|
||||
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
/****************************************************************************
|
||||
* boards/risc-v/esp32c6/common/src/esp_board_rmt.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/rmt/rmtchar.h>
|
||||
#ifdef CONFIG_WS2812_NON_SPI_DRIVER
|
||||
#include <nuttx/leds/ws2812.h>
|
||||
|
||||
#include "espressif/esp_ws2812.h"
|
||||
#endif
|
||||
|
||||
#include "espressif/esp_rmt.h"
|
||||
|
||||
#ifdef CONFIG_ESP_RMT
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_rmt_rxinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the RMT peripheral and register a RX device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ch - the RMT's channel that will be used
|
||||
* pin - The pin used for the RX channel
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_rmt_rxinitialize(int ch, int pin)
|
||||
{
|
||||
int ret;
|
||||
|
||||
struct rmt_dev_s *rmt = esp_rmt_rx_init(ch, pin);
|
||||
|
||||
ret = rmtchar_register(rmt);
|
||||
if (ret < 0)
|
||||
{
|
||||
rmterr("ERROR: rmtchar_register failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_rmt_txinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the RMT peripheral and register a TX device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ch - the RMT's channel that will be used
|
||||
* pin - The pin used for the TX channel
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_rmt_txinitialize(int ch, int pin)
|
||||
{
|
||||
int ret;
|
||||
struct rmt_dev_s *rmt;
|
||||
#ifdef CONFIG_WS2812_NON_SPI_DRIVER
|
||||
struct ws2812_dev_s *led;
|
||||
#endif
|
||||
|
||||
rmt = esp_rmt_tx_init(ch, pin);
|
||||
if (rmt == NULL)
|
||||
{
|
||||
rmterr("ERROR: esp_rmt_tx_init failed\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = rmtchar_register(rmt);
|
||||
if (ret < 0)
|
||||
{
|
||||
rmterr("ERROR: rmtchar_register failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_WS2812_NON_SPI_DRIVER
|
||||
led = esp_ws2812_setup("/dev/leds0", rmt, CONFIG_WS2812_LED_COUNT, false);
|
||||
if (led == NULL)
|
||||
{
|
||||
rmterr("ERROR: esp_ws2812_setup failed\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
CONFIG_ARCH="risc-v"
|
||||
CONFIG_ARCH_BOARD="esp32c6-devkit"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32C6_DEVKIT=y
|
||||
CONFIG_ARCH_CHIP="esp32c6"
|
||||
CONFIG_ARCH_CHIP_ESP32C6=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_RISCV=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=15000
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEV_ZERO=y
|
||||
CONFIG_ESPRESSIF_ESP32C6=y
|
||||
CONFIG_ESP_RMT=y
|
||||
CONFIG_EXAMPLES_RMTCHAR=y
|
||||
CONFIG_EXAMPLES_RMTCHAR_RX=y
|
||||
CONFIG_EXAMPLES_RMTCHAR_RX_DEVPATH="/dev/rmt2"
|
||||
CONFIG_EXAMPLES_RMTCHAR_TX=y
|
||||
CONFIG_EXAMPLES_WS2812=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=2048
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_PERROR_STDOUT=y
|
||||
CONFIG_LIBC_STRERROR=y
|
||||
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NSH_STRERROR=y
|
||||
CONFIG_PREALLOC_TIMERS=0
|
||||
CONFIG_RMT=y
|
||||
CONFIG_RMTCHAR=y
|
||||
CONFIG_RMT_DEFAULT_RX_BUFFER_SIZE=512
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_BACKTRACE=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=29
|
||||
CONFIG_START_MONTH=11
|
||||
CONFIG_START_YEAR=2019
|
||||
CONFIG_SYSTEM_DUMPSTACK=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_TESTING_GETPRIME=y
|
||||
CONFIG_TESTING_OSTEST=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
CONFIG_WS2812=y
|
||||
CONFIG_WS2812_LED_COUNT=100
|
||||
CONFIG_WS2812_NON_SPI_DRIVER=y
|
||||
@@ -31,6 +31,19 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* RMT gpio */
|
||||
|
||||
#define RMT_RXCHANNEL 2
|
||||
#define RMT_TXCHANNEL 0
|
||||
|
||||
#ifdef CONFIG_RMT_LOOP_TEST_MODE
|
||||
# define RMT_INPUT_PIN 0
|
||||
# define RMT_OUTPUT_PIN 0
|
||||
#else
|
||||
# define RMT_INPUT_PIN 2
|
||||
# define RMT_OUTPUT_PIN 8
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
@@ -60,6 +60,10 @@
|
||||
# include <nuttx/input/buttons.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP_RMT
|
||||
# include "esp_board_rmt.h"
|
||||
#endif
|
||||
|
||||
#include "esp32c6-devkit.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -147,6 +151,20 @@ int esp_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP_RMT
|
||||
ret = board_rmt_txinitialize(RMT_TXCHANNEL, RMT_OUTPUT_PIN);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: board_rmt_txinitialize() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = board_rmt_rxinitialize(RMT_RXCHANNEL, RMT_INPUT_PIN);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: board_rmt_txinitialize() failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RTC_DRIVER
|
||||
/* Initialize the RTC driver */
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/****************************************************************************
|
||||
* boards/risc-v/esp32h2/common/include/esp_board_rmt.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __BOARDS_RISC_V_ESP32H2_COMMON_INCLUDE_ESP_BOARD_RMT_H
|
||||
#define __BOARDS_RISC_V_ESP32H2_COMMON_INCLUDE_ESP_BOARD_RMT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP_RMT
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_rmt_rxinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the RMT peripheral and register a RX device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ch - the RMT's channel that will be used
|
||||
* pin - The pin used for the RX channel
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_rmt_rxinitialize(int ch, int pin);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_rmt_txinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the RMT peripheral and register a TX device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ch - the RMT's channel that will be used
|
||||
* pin - The pin used for the TX channel
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_rmt_txinitialize(int ch, int pin);
|
||||
|
||||
#endif /* CONFIG_ESP_RMT */
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_RISC_V_ESP32H2_COMMON_INCLUDE_ESP_BOARD_RMT_H */
|
||||
@@ -24,6 +24,10 @@ ifeq ($(CONFIG_ESPRESSIF_LEDC),y)
|
||||
CSRCS += esp_board_ledc.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP_RMT),y)
|
||||
CSRCS += esp_board_rmt.c
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path src
|
||||
VPATH += :src
|
||||
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
/****************************************************************************
|
||||
* boards/risc-v/esp32h2/common/src/esp_board_rmt.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/rmt/rmtchar.h>
|
||||
#ifdef CONFIG_WS2812_NON_SPI_DRIVER
|
||||
#include <nuttx/leds/ws2812.h>
|
||||
|
||||
#include "espressif/esp_ws2812.h"
|
||||
#endif
|
||||
|
||||
#include "espressif/esp_rmt.h"
|
||||
|
||||
#ifdef CONFIG_ESP_RMT
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_rmt_rxinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the RMT peripheral and register a RX device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ch - the RMT's channel that will be used
|
||||
* pin - The pin used for the RX channel
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_rmt_rxinitialize(int ch, int pin)
|
||||
{
|
||||
int ret;
|
||||
|
||||
struct rmt_dev_s *rmt = esp_rmt_rx_init(ch, pin);
|
||||
|
||||
ret = rmtchar_register(rmt);
|
||||
if (ret < 0)
|
||||
{
|
||||
rmterr("ERROR: rmtchar_register failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_rmt_txinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the RMT peripheral and register a TX device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ch - the RMT's channel that will be used
|
||||
* pin - The pin used for the TX channel
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_rmt_txinitialize(int ch, int pin)
|
||||
{
|
||||
int ret;
|
||||
struct rmt_dev_s *rmt;
|
||||
#ifdef CONFIG_WS2812_NON_SPI_DRIVER
|
||||
struct ws2812_dev_s *led;
|
||||
#endif
|
||||
|
||||
rmt = esp_rmt_tx_init(ch, pin);
|
||||
if (rmt == NULL)
|
||||
{
|
||||
rmterr("ERROR: esp_rmt_tx_init failed\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = rmtchar_register(rmt);
|
||||
if (ret < 0)
|
||||
{
|
||||
rmterr("ERROR: rmtchar_register failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_WS2812_NON_SPI_DRIVER
|
||||
led = esp_ws2812_setup("/dev/leds0", rmt, CONFIG_WS2812_LED_COUNT, false);
|
||||
if (led == NULL)
|
||||
{
|
||||
rmterr("ERROR: esp_ws2812_setup failed\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
CONFIG_ARCH="risc-v"
|
||||
CONFIG_ARCH_BOARD="esp32h2-devkit"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32H2_DEVKIT=y
|
||||
CONFIG_ARCH_CHIP="esp32h2"
|
||||
CONFIG_ARCH_CHIP_ESP32H2=y
|
||||
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||
CONFIG_ARCH_RISCV=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=15000
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEV_ZERO=y
|
||||
CONFIG_ESPRESSIF_ESP32H2=y
|
||||
CONFIG_ESP_RMT=y
|
||||
CONFIG_EXAMPLES_RMTCHAR=y
|
||||
CONFIG_EXAMPLES_RMTCHAR_RX=y
|
||||
CONFIG_EXAMPLES_RMTCHAR_RX_DEVPATH="/dev/rmt2"
|
||||
CONFIG_EXAMPLES_RMTCHAR_TX=y
|
||||
CONFIG_EXAMPLES_WS2812=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=2048
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBC_PERROR_STDOUT=y
|
||||
CONFIG_LIBC_STRERROR=y
|
||||
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NSH_STRERROR=y
|
||||
CONFIG_PREALLOC_TIMERS=0
|
||||
CONFIG_RMT=y
|
||||
CONFIG_RMTCHAR=y
|
||||
CONFIG_RMT_DEFAULT_RX_BUFFER_SIZE=512
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_BACKTRACE=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=29
|
||||
CONFIG_START_MONTH=11
|
||||
CONFIG_START_YEAR=2019
|
||||
CONFIG_SYSTEM_DUMPSTACK=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_TESTING_GETPRIME=y
|
||||
CONFIG_TESTING_OSTEST=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
CONFIG_WS2812=y
|
||||
CONFIG_WS2812_LED_COUNT=100
|
||||
CONFIG_WS2812_NON_SPI_DRIVER=y
|
||||
@@ -31,6 +31,19 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* RMT gpio */
|
||||
|
||||
#define RMT_RXCHANNEL 2
|
||||
#define RMT_TXCHANNEL 0
|
||||
|
||||
#ifdef CONFIG_RMT_LOOP_TEST_MODE
|
||||
# define RMT_INPUT_PIN 0
|
||||
# define RMT_OUTPUT_PIN 0
|
||||
#else
|
||||
# define RMT_INPUT_PIN 2
|
||||
# define RMT_OUTPUT_PIN 8
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
@@ -60,6 +60,10 @@
|
||||
# include <nuttx/input/buttons.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP_RMT
|
||||
# include "esp_board_rmt.h"
|
||||
#endif
|
||||
|
||||
#include "esp32h2-devkit.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -147,6 +151,20 @@ int esp_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP_RMT
|
||||
ret = board_rmt_txinitialize(RMT_TXCHANNEL, RMT_OUTPUT_PIN);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: board_rmt_txinitialize() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
ret = board_rmt_rxinitialize(RMT_RXCHANNEL, RMT_INPUT_PIN);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: board_rmt_txinitialize() failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RTC_DRIVER
|
||||
/* Initialize the RTC driver */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user