mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 05:55:46 +08:00
esp32/rmt: Remove outdated RMT driver
The new common RMT driver - already available for ESP32-S2 and ESP32-S3 - will be implemented in another commit for ESP32.
This commit is contained in:
committed by
Xiang Xiao
parent
573e1a255f
commit
4b3b22cbeb
@@ -1,282 +0,0 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32/common/src/esp32_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 "xtensa.h"
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include "esp32_rmt.h"
|
||||
|
||||
#ifdef CONFIG_ESP32_RMT
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define APB_PERIOD (12.5)
|
||||
|
||||
#define T0H ((uint16_t)(350 / APB_PERIOD)) // ns
|
||||
#define T0L ((uint16_t)(900 / APB_PERIOD)) // ns
|
||||
#define T1H ((uint16_t)(900 / APB_PERIOD)) // ns
|
||||
#define T1L ((uint16_t)(350 / APB_PERIOD)) // ns
|
||||
#define RES ((uint16_t)(60000 / APB_PERIOD)) // ns
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
static int rmt_open(struct file *filep)
|
||||
{
|
||||
struct inode *inode = filep->f_inode;
|
||||
struct rmt_dev_channel_s *dev_data = inode->i_private;
|
||||
|
||||
struct rmt_dev_s *parent_dev =
|
||||
(struct rmt_dev_s *)dev_data->parent_dev;
|
||||
int ret;
|
||||
irqstate_t flags;
|
||||
DEBUGASSERT(parent_dev);
|
||||
|
||||
nxsem_wait(&dev_data->tx_sem);
|
||||
|
||||
flags = spin_lock_irqsave(&parent_dev->lock);
|
||||
|
||||
if (dev_data->open_count == 0)
|
||||
{
|
||||
int ch_idx = dev_data->ch_idx;
|
||||
|
||||
uint32_t reg0_addr = RMT_CHNCONF0_REG(ch_idx);
|
||||
uint32_t reg1_addr = RMT_CHNCONF1_REG(ch_idx);
|
||||
uint32_t reg_val = 0x00;
|
||||
|
||||
/* a single memory block with double buffering is enough */
|
||||
|
||||
uint32_t mem_blocks = 1;
|
||||
dev_data->available_words = RMT_DATA_MEMORY_BLOCK_WORDS*mem_blocks;
|
||||
dev_data->reload_thresh = dev_data->available_words / 2;
|
||||
uint32_t start_addr_chn = RMT_DATA_BASE_ADDR +
|
||||
RMT_DATA_MEMORY_BLOCK_WORDS * 4 * ch_idx;
|
||||
|
||||
dev_data->start_address = start_addr_chn;
|
||||
|
||||
reg_val = (mem_blocks) << 24;
|
||||
uint32_t clock_divider = 1;
|
||||
reg_val |= (clock_divider);
|
||||
putreg32(reg_val, reg0_addr);
|
||||
reg_val = 0;
|
||||
|
||||
/* use APB clock */
|
||||
|
||||
reg_val |= RMT_REF_ALWAYS_ON_CHN;
|
||||
|
||||
/* memory block in transmission mode */
|
||||
|
||||
reg_val &= ~RMT_MEM_OWNER_CHN;
|
||||
putreg32(reg_val, reg1_addr);
|
||||
|
||||
/* set when the buffer swapping IRQ must be generated */
|
||||
|
||||
uint32_t reload_addr = RMT_CHN_TX_LIM_REG(ch_idx);
|
||||
rmtinfo("Setting thr limit at %08X to %d",
|
||||
reload_addr, dev_data->reload_thresh);
|
||||
putreg32(dev_data->reload_thresh, reload_addr);
|
||||
|
||||
/* allow direct access to RMT's memory */
|
||||
|
||||
modifyreg32(RMT_APB_CONF_REG, 0, BIT(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
rmtwarn("Be careful on opening this channel multiple times");
|
||||
}
|
||||
|
||||
dev_data->open_count += 1;
|
||||
|
||||
ret = OK;
|
||||
|
||||
spin_unlock_irqrestore(&parent_dev->lock, flags);
|
||||
nxsem_post(&dev_data->tx_sem);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rmt_close(struct file *filep)
|
||||
{
|
||||
struct inode *inode = filep->f_inode;
|
||||
struct rmt_dev_channel_s *dev_data = inode->i_private;
|
||||
|
||||
struct rmt_dev_s *parent_dev =
|
||||
(struct rmt_dev_s *)dev_data->parent_dev;
|
||||
|
||||
int ret;
|
||||
irqstate_t flags;
|
||||
DEBUGASSERT(parent_dev);
|
||||
nxsem_wait(&dev_data->tx_sem);
|
||||
flags = spin_lock_irqsave(&parent_dev->lock);
|
||||
|
||||
dev_data->open_count -= 1;
|
||||
|
||||
ret = OK;
|
||||
|
||||
spin_unlock_irqrestore(&parent_dev->lock, flags);
|
||||
nxsem_post(&dev_data->tx_sem);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t rmt_write(struct file *filep,
|
||||
const char *data,
|
||||
size_t len)
|
||||
{
|
||||
struct inode *inode = filep->f_inode;
|
||||
struct rmt_dev_channel_s *dev_data = inode->i_private;
|
||||
|
||||
struct rmt_dev_s *parent_dev =
|
||||
(struct rmt_dev_s *)dev_data->parent_dev;
|
||||
|
||||
irqstate_t flags;
|
||||
size_t len_in_words = len / 4;
|
||||
|
||||
DEBUGASSERT(parent_dev);
|
||||
|
||||
if (data == NULL || (len_in_words == 0) || (len % 4))
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
flags = spin_lock_irqsave(&parent_dev->lock);
|
||||
|
||||
/* set RMT's memory as writable */
|
||||
|
||||
uint32_t reg1_addr = RMT_CHNCONF1_REG(dev_data->ch_idx);
|
||||
modifyreg32(reg1_addr, 0, RMT_MEM_RD_RST_CHN);
|
||||
modifyreg32(reg1_addr, RMT_MEM_RD_RST_CHN, 0);
|
||||
|
||||
dev_data->src = (uint32_t *)data;
|
||||
dev_data->src_offset = 0;
|
||||
dev_data->words_to_send = len_in_words;
|
||||
|
||||
/* enable IRQs for buffer refill and End-of-Transmition (EOT) */
|
||||
|
||||
modifyreg32(
|
||||
RMT_INT_ENA_REG,
|
||||
0,
|
||||
RMT_CHN_TX_THR_EVENT_INT_ENA(dev_data->ch_idx) |
|
||||
RMT_CHN_TX_END_INT_ENA(dev_data->ch_idx));
|
||||
|
||||
rmt_load_tx_buffer(dev_data);
|
||||
|
||||
/* tell RMT to start the transmition */
|
||||
|
||||
modifyreg32(reg1_addr, 0, RMT_TX_START_CHN(dev_data->ch_idx));
|
||||
|
||||
spin_unlock_irqrestore(&parent_dev->lock, flags);
|
||||
|
||||
/* wait for the transmition to finish */
|
||||
|
||||
nxsem_wait(&dev_data->tx_sem);
|
||||
nxsem_post(&dev_data->tx_sem);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_rmt_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize and register the RMT driver
|
||||
*
|
||||
* Input Parameters:
|
||||
* devno - The device number, used to build the device path as /dev/rmtN
|
||||
* rmt_dev - Pointer to the RMT device that will be used
|
||||
* nleds - number of LEDs
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static const struct file_operations g_rmt_channel_fops =
|
||||
{
|
||||
rmt_open, /* open */
|
||||
rmt_close, /* close */
|
||||
NULL, /* read */
|
||||
rmt_write, /* write */
|
||||
NULL, /* seek */
|
||||
NULL, /* ioctl */
|
||||
};
|
||||
|
||||
int board_rmt_initialize(int channel, int output_pin)
|
||||
{
|
||||
struct rmt_dev_s *rmt_dev = esp32_rmtinitialize();
|
||||
DEBUGASSERT(rmt_dev);
|
||||
|
||||
char devpath[13];
|
||||
int ret;
|
||||
|
||||
rmt_attach_pin_to_channel(rmt_dev, channel, output_pin);
|
||||
|
||||
struct rmt_dev_channel_s *channel_data = &(rmt_dev->channels[channel]);
|
||||
|
||||
/* Register the RMT driver at the specified location. */
|
||||
|
||||
snprintf(devpath, sizeof(devpath), "/dev/rmt%d", channel);
|
||||
|
||||
/* Register the character driver */
|
||||
|
||||
ret = register_driver(devpath, &g_rmt_channel_fops, 0666, channel_data);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
rmterr("ERROR: board_rmt_initialize(%s) failed: %d\n",
|
||||
devpath, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
@@ -1,49 +0,0 @@
|
||||
#
|
||||
# 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_ARCH_LEDS is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
CONFIG_ARCH="xtensa"
|
||||
CONFIG_ARCH_BOARD="esp32-devkitc"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32_DEVKITC=y
|
||||
CONFIG_ARCH_CHIP="esp32"
|
||||
CONFIG_ARCH_CHIP_ESP32=y
|
||||
CONFIG_ARCH_CHIP_ESP32WROVER=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_XTENSA=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_ESP32_RMT=y
|
||||
CONFIG_ESP32_UART0=y
|
||||
CONFIG_EXAMPLES_WS2812_ESP32_RMT=y
|
||||
CONFIG_EXPERIMENTAL=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_INIT_STACKSIZE=3072
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_MM_REGIONS=3
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_SYSLOG_BUFFER=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
@@ -161,10 +161,6 @@
|
||||
# include "esp32_max6675.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32_RMT
|
||||
# include "esp32_rmt.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DAC
|
||||
# include "esp32_board_dac.h"
|
||||
#endif
|
||||
@@ -649,14 +645,6 @@ int esp32_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32_RMT
|
||||
ret = board_rmt_initialize(RMT_CHANNEL, RMT_OUTPUT_PIN);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: board_rmt_initialize() failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DAC
|
||||
ret = board_dac_initialize(CONFIG_ESP32_DAC_DEVPATH);
|
||||
if (ret < 0)
|
||||
|
||||
Reference in New Issue
Block a user