mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
docs/rc: document RC/LIRC drivers and remove empty drivers/rmt files
Add documentation for the RC/LIRC character driver subsystem covering device registration, the LIRC interface, and usage from user space. Remove placeholder empty files under drivers/rmt that were left over from the rmtchar era and are no longer referenced. Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
This commit is contained in:
committed by
Alan C. Assis
parent
7b590f9c43
commit
140f2c1c78
@@ -1,3 +1,139 @@
|
|||||||
======================
|
======================
|
||||||
Remote Control Devices
|
Remote Control Devices
|
||||||
======================
|
======================
|
||||||
|
|
||||||
|
NuttX provides a Remote Control (RC) framework for infrared style input and
|
||||||
|
output devices. The userspace interface follows the LIRC model and exposes
|
||||||
|
each device as a character node such as ``/dev/lirc0``.
|
||||||
|
|
||||||
|
Like many NuttX drivers, the RC subsystem is split into two parts:
|
||||||
|
|
||||||
|
#. a generic upper half in ``drivers/rc/lirc_dev.c``, and
|
||||||
|
#. a lower half supplied by platform or device specific code.
|
||||||
|
|
||||||
|
The upper half handles the character driver registration, per-open buffering,
|
||||||
|
``poll()`` support, and the common ``ioctl()`` interface. The lower half is
|
||||||
|
responsible for the hardware specific work such as receiving pulse timings,
|
||||||
|
transmitting IR data, or reporting decoded scancodes.
|
||||||
|
|
||||||
|
Files related to the RC framework are located in:
|
||||||
|
|
||||||
|
- ``include/nuttx/lirc.h``
|
||||||
|
- ``include/nuttx/rc/lirc_dev.h``
|
||||||
|
- ``drivers/rc/lirc_dev.c``
|
||||||
|
|
||||||
|
Application Programming Interface
|
||||||
|
=================================
|
||||||
|
|
||||||
|
Applications should include the following header files:
|
||||||
|
|
||||||
|
.. code-block:: c
|
||||||
|
|
||||||
|
#include <nuttx/lirc.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
|
Each RC device is registered as a POSIX character device in ``/dev``.
|
||||||
|
Applications open the device with the standard ``open()`` call and then use
|
||||||
|
``read()``, ``write()``, ``poll()``, and ``ioctl()`` just like other character
|
||||||
|
drivers.
|
||||||
|
|
||||||
|
The RC framework supports three kinds of lower-half devices:
|
||||||
|
|
||||||
|
- ``LIRC_DRIVER_SCANCODE`` for devices that report decoded scancodes
|
||||||
|
- ``LIRC_DRIVER_IR_RAW`` for devices that report raw pulse/space timings
|
||||||
|
- ``LIRC_DRIVER_IR_RAW_TX`` for transmit-only raw devices
|
||||||
|
|
||||||
|
Raw Pulse/Space Format
|
||||||
|
======================
|
||||||
|
|
||||||
|
Raw IR timing is transferred in the LIRC ``mode2`` format. Each sample is a
|
||||||
|
32-bit ``unsigned int`` value. The upper 8 bits describe the sample type and
|
||||||
|
the lower 24 bits carry the payload, usually a duration in microseconds.
|
||||||
|
|
||||||
|
The helpers in ``include/nuttx/lirc.h`` are intended to build and inspect
|
||||||
|
these values:
|
||||||
|
|
||||||
|
- ``LIRC_PULSE(usec)``
|
||||||
|
- ``LIRC_SPACE(usec)``
|
||||||
|
- ``LIRC_FREQUENCY(value)``
|
||||||
|
- ``LIRC_TIMEOUT(usec)``
|
||||||
|
- ``LIRC_IS_PULSE(sample)``
|
||||||
|
- ``LIRC_IS_SPACE(sample)``
|
||||||
|
- ``LIRC_VALUE(sample)``
|
||||||
|
|
||||||
|
Typical raw transmit data looks like this:
|
||||||
|
|
||||||
|
.. code-block:: c
|
||||||
|
|
||||||
|
unsigned int txbuf[] =
|
||||||
|
{
|
||||||
|
LIRC_PULSE(9000),
|
||||||
|
LIRC_SPACE(4500),
|
||||||
|
LIRC_PULSE(560),
|
||||||
|
LIRC_SPACE(560),
|
||||||
|
LIRC_PULSE(560),
|
||||||
|
};
|
||||||
|
|
||||||
|
For raw transmit, ``write()`` expects an odd number of ``unsigned int``
|
||||||
|
samples. The upper half forwards the pulse/space sequence to the lower-half
|
||||||
|
``tx_ir()`` callback.
|
||||||
|
|
||||||
|
IOCTL Commands
|
||||||
|
==============
|
||||||
|
|
||||||
|
The RC upper half supports the standard LIRC ``ioctl()`` commands defined in
|
||||||
|
``include/nuttx/lirc.h``. Commonly used commands include:
|
||||||
|
|
||||||
|
- ``LIRC_GET_FEATURES``
|
||||||
|
- ``LIRC_GET_SEND_MODE``
|
||||||
|
- ``LIRC_GET_REC_MODE``
|
||||||
|
- ``LIRC_SET_SEND_MODE``
|
||||||
|
- ``LIRC_SET_REC_MODE``
|
||||||
|
- ``LIRC_GET_REC_RESOLUTION``
|
||||||
|
- ``LIRC_SET_SEND_CARRIER``
|
||||||
|
- ``LIRC_SET_SEND_DUTY_CYCLE``
|
||||||
|
- ``LIRC_SET_REC_TIMEOUT``
|
||||||
|
|
||||||
|
Support for a specific command depends on the lower-half capabilities. In
|
||||||
|
practice, applications usually start by querying ``LIRC_GET_FEATURES`` and
|
||||||
|
then only use the operations that the device advertises.
|
||||||
|
|
||||||
|
Lower-Half Registration
|
||||||
|
=======================
|
||||||
|
|
||||||
|
Platform code registers an RC lower half by filling ``struct lirc_lowerhalf_s``
|
||||||
|
and calling ``lirc_register()``.
|
||||||
|
|
||||||
|
.. code-block:: c
|
||||||
|
|
||||||
|
int ret = lirc_register(lower, devno);
|
||||||
|
|
||||||
|
The lower half provides a ``struct lirc_ops_s`` callback table. Depending on
|
||||||
|
the hardware, it may implement open/close callbacks, raw transmit via
|
||||||
|
``tx_ir()``, scancode transmit via ``tx_scancode()``, carrier and duty-cycle
|
||||||
|
configuration, or receive timeout handling.
|
||||||
|
|
||||||
|
Testing
|
||||||
|
-------
|
||||||
|
|
||||||
|
The ``irtest`` application in ``nuttx-apps/system/irtest`` can be used to
|
||||||
|
exercise RC devices from NSH. A typical validation sequence is:
|
||||||
|
|
||||||
|
#. open ``/dev/lircN``
|
||||||
|
#. query ``LIRC_GET_FEATURES``
|
||||||
|
#. query or set send / receive mode
|
||||||
|
#. write raw mode2 samples on transmit-capable devices
|
||||||
|
#. read back mode2 samples from receive-capable devices
|
||||||
|
|
||||||
|
Espressif RMT LIRC Adapter
|
||||||
|
==========================
|
||||||
|
|
||||||
|
Espressif targets may provide an arch-local LIRC adapter built on top of the
|
||||||
|
RMT peripheral:
|
||||||
|
|
||||||
|
- ``arch/xtensa/src/common/espressif/esp_lirc.c``
|
||||||
|
- ``arch/risc-v/src/common/espressif/esp_lirc.c``
|
||||||
|
|
||||||
|
These adapters expose the RMT peripheral through the RC framework as
|
||||||
|
``/dev/lircN`` devices while keeping the hardware specific RMT implementation
|
||||||
|
in the Espressif lower-half driver.
|
||||||
|
|||||||
@@ -1288,7 +1288,6 @@ config ESPRESSIF_BROWNOUT_DET
|
|||||||
config ESP_RMT
|
config ESP_RMT
|
||||||
bool "Remote Control Module (RMT)"
|
bool "Remote Control Module (RMT)"
|
||||||
default n
|
default n
|
||||||
select DRIVERS_RC
|
|
||||||
---help---
|
---help---
|
||||||
The RMT (Remote Control Transceiver) peripheral was designed to act as
|
The RMT (Remote Control Transceiver) peripheral was designed to act as
|
||||||
an infrared transceiver. However, due to the flexibility of its data
|
an infrared transceiver. However, due to the flexibility of its data
|
||||||
|
|||||||
@@ -23,10 +23,18 @@
|
|||||||
#ifndef __ARCH_RISC_V_SRC_COMMON_ESPRESSIF_ESP_LIRC_H
|
#ifndef __ARCH_RISC_V_SRC_COMMON_ESPRESSIF_ESP_LIRC_H
|
||||||
#define __ARCH_RISC_V_SRC_COMMON_ESPRESSIF_ESP_LIRC_H
|
#define __ARCH_RISC_V_SRC_COMMON_ESPRESSIF_ESP_LIRC_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include "esp_rmt.h"
|
#include "esp_rmt.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ endmenu # Interrupt Configuration
|
|||||||
config ESP_RMT
|
config ESP_RMT
|
||||||
bool "Remote Control Module (RMT)"
|
bool "Remote Control Module (RMT)"
|
||||||
default n
|
default n
|
||||||
select DRIVERS_RC
|
|
||||||
---help---
|
---help---
|
||||||
The RMT (Remote Control Transceiver) peripheral was designed to act as
|
The RMT (Remote Control Transceiver) peripheral was designed to act as
|
||||||
an infrared transceiver. However, due to the flexibility of its data
|
an infrared transceiver. However, due to the flexibility of its data
|
||||||
|
|||||||
@@ -26,11 +26,7 @@ CONFIG_BUILTIN=y
|
|||||||
CONFIG_DEV_GPIO=y
|
CONFIG_DEV_GPIO=y
|
||||||
CONFIG_ESP32_UART0=y
|
CONFIG_ESP32_UART0=y
|
||||||
CONFIG_ESPRESSIF_GPIO_IRQ=y
|
CONFIG_ESPRESSIF_GPIO_IRQ=y
|
||||||
CONFIG_ESP_RMT=y
|
|
||||||
CONFIG_EXAMPLES_GPIO=y
|
CONFIG_EXAMPLES_GPIO=y
|
||||||
CONFIG_EXAMPLES_RMTCHAR=y
|
|
||||||
CONFIG_EXAMPLES_RMTCHAR_RX=y
|
|
||||||
CONFIG_EXAMPLES_RMTCHAR_TX=y
|
|
||||||
CONFIG_EXAMPLES_WS2812=y
|
CONFIG_EXAMPLES_WS2812=y
|
||||||
CONFIG_FS_PROCFS=y
|
CONFIG_FS_PROCFS=y
|
||||||
CONFIG_GAMES_MATCH4=y
|
CONFIG_GAMES_MATCH4=y
|
||||||
@@ -50,9 +46,6 @@ CONFIG_NSH_READLINE=y
|
|||||||
CONFIG_PREALLOC_TIMERS=4
|
CONFIG_PREALLOC_TIMERS=4
|
||||||
CONFIG_RAM_SIZE=114688
|
CONFIG_RAM_SIZE=114688
|
||||||
CONFIG_RAM_START=0x20000000
|
CONFIG_RAM_START=0x20000000
|
||||||
CONFIG_RMT=y
|
|
||||||
CONFIG_RMTCHAR=y
|
|
||||||
CONFIG_RMT_DEFAULT_RX_BUFFER_SIZE=256
|
|
||||||
CONFIG_RR_INTERVAL=200
|
CONFIG_RR_INTERVAL=200
|
||||||
CONFIG_SCHED_LPWORK=y
|
CONFIG_SCHED_LPWORK=y
|
||||||
CONFIG_SCHED_WAITPID=y
|
CONFIG_SCHED_WAITPID=y
|
||||||
|
|||||||
@@ -28,9 +28,6 @@ CONFIG_ESP32_UART0=y
|
|||||||
CONFIG_ESPRESSIF_GPIO_IRQ=y
|
CONFIG_ESPRESSIF_GPIO_IRQ=y
|
||||||
CONFIG_ESP_RMT=y
|
CONFIG_ESP_RMT=y
|
||||||
CONFIG_EXAMPLES_GPIO=y
|
CONFIG_EXAMPLES_GPIO=y
|
||||||
CONFIG_EXAMPLES_RMTCHAR=y
|
|
||||||
CONFIG_EXAMPLES_RMTCHAR_RX=y
|
|
||||||
CONFIG_EXAMPLES_RMTCHAR_TX=y
|
|
||||||
CONFIG_EXAMPLES_WS2812=y
|
CONFIG_EXAMPLES_WS2812=y
|
||||||
CONFIG_FS_PROCFS=y
|
CONFIG_FS_PROCFS=y
|
||||||
CONFIG_GAMES_SNAKE=y
|
CONFIG_GAMES_SNAKE=y
|
||||||
@@ -50,9 +47,6 @@ CONFIG_NSH_READLINE=y
|
|||||||
CONFIG_PREALLOC_TIMERS=4
|
CONFIG_PREALLOC_TIMERS=4
|
||||||
CONFIG_RAM_SIZE=114688
|
CONFIG_RAM_SIZE=114688
|
||||||
CONFIG_RAM_START=0x20000000
|
CONFIG_RAM_START=0x20000000
|
||||||
CONFIG_RMT=y
|
|
||||||
CONFIG_RMTCHAR=y
|
|
||||||
CONFIG_RMT_DEFAULT_RX_BUFFER_SIZE=256
|
|
||||||
CONFIG_RR_INTERVAL=200
|
CONFIG_RR_INTERVAL=200
|
||||||
CONFIG_SCHED_LPWORK=y
|
CONFIG_SCHED_LPWORK=y
|
||||||
CONFIG_SCHED_WAITPID=y
|
CONFIG_SCHED_WAITPID=y
|
||||||
|
|||||||
@@ -91,8 +91,6 @@ CONFIG_PSEUDOFS_SOFTLINKS=y
|
|||||||
CONFIG_PTHREAD_MUTEX_TYPES=y
|
CONFIG_PTHREAD_MUTEX_TYPES=y
|
||||||
CONFIG_RAM_SIZE=114688
|
CONFIG_RAM_SIZE=114688
|
||||||
CONFIG_RAM_START=0x20000000
|
CONFIG_RAM_START=0x20000000
|
||||||
CONFIG_RMT=y
|
|
||||||
CONFIG_RMTCHAR=y
|
|
||||||
CONFIG_RR_INTERVAL=200
|
CONFIG_RR_INTERVAL=200
|
||||||
CONFIG_RTC=y
|
CONFIG_RTC=y
|
||||||
CONFIG_RTC_DRIVER=y
|
CONFIG_RTC_DRIVER=y
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ include pinctrl/Make.defs
|
|||||||
include pipes/Make.defs
|
include pipes/Make.defs
|
||||||
include power/Make.defs
|
include power/Make.defs
|
||||||
include regmap/Make.defs
|
include regmap/Make.defs
|
||||||
include rmt/Make.defs
|
|
||||||
include rpmsg/Make.defs
|
include rpmsg/Make.defs
|
||||||
include rptun/Make.defs
|
include rptun/Make.defs
|
||||||
include sensors/Make.defs
|
include sensors/Make.defs
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
# ##############################################################################
|
|
||||||
# drivers/rmt/CMakeLists.txt
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
# ##############################################################################
|
|
||||||
|
|
||||||
# RMT character driver removed; RMT upper-half is now arch/espressif/esp_lirc.c
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#
|
|
||||||
# For a description of the syntax of this configuration file,
|
|
||||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
|
||||||
#
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
############################################################################
|
|
||||||
# drivers/rmt/Make.defs
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
############################################################################
|
|
||||||
Reference in New Issue
Block a user