xtensa/esp/rmt: Add the lower-half implementation of the RMT driver

The lower-half implementation of the RMT character driver based on
Espressif HAL enables using the RMT peripheral of ESP32, ESP32-S2
and ESP32-S3 as a common xtensa-based Espressif driver.

The RMT packages on Espressif SoCs are 4-byte long and are known as
"items". Please check the Techinal Reference Manual of the chip to
obtain more details.
This commit is contained in:
Tiago Medicci Serrano 2023-12-15 10:19:01 -03:00 committed by Xiang Xiao
parent d1326e81bc
commit 69929d4084
7 changed files with 2148 additions and 1 deletions

View File

@ -1729,7 +1729,7 @@ endif # DEBUG_REGMAP
config DEBUG_RMT
bool "RMT Debug Features"
default n
depends on ESP32_RMT
depends on RMT
---help---
Enable RMT debug features.

View File

@ -129,6 +129,7 @@ endif
VPATH += chip
VPATH += common
VPATH += common/espressif
VPATH += $(ARCH_SUBDIR)
VPATH += $(CHIP_DIR)

View File

@ -0,0 +1,7 @@
config ESP_RMT
bool "Remote Control Module (RMT)"
default n
depends on RMT
---help---
Remote Control Module is currently used to control WS2812
RGB LED normally used on LED strips.

View File

@ -0,0 +1,26 @@
############################################################################
# arch/xtensa/src/common/espressif/Make.defs
#
# 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.
#
############################################################################
ifeq ($(CONFIG_ESP_RMT),y)
CHIP_CSRCS += esp_rmt.c
ifeq ($(CONFIG_WS2812_NON_SPI_DRIVER),y)
CHIP_CSRCS += esp_ws2812.c
endif
endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,109 @@
/****************************************************************************
* arch/xtensa/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_XTENSA_SRC_COMMON_ESPRESSIF_ESP_RMT_H
#define __ARCH_XTENSA_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_XTENSA_SRC_COMMON_ESPRESSIF_ESP_RMT_H */

View File

@ -33,4 +33,15 @@ config RMT_DEFAULT_RX_BUFFER_SIZE
The RMT RX default buffer size. This is the expected buffer size
that should be returned on a `read()` operation.
config RMT_LOOP_TEST_MODE
bool "RMT character driver loopback test mode (for testing only)"
depends on EXPERIMENTAL
default n
---help---
This enables a lower-half driver-specific loopback test
mode that attaches the transmitter to the receiver, being
able to test the RMT peripheral without any external
connection. This feature depends on lower-half driver
implementation.
endif # RMT